diff --git a/dist/chrome/background.js b/dist/chrome/background.js index d1b4465..9a7738d 100644 --- a/dist/chrome/background.js +++ b/dist/chrome/background.js @@ -1,4 +1,4 @@ -(()=>{var lc=Object.defineProperty;var ma=(t,e)=>{for(var r in e)lc(t,r,{get:e[r],enumerable:!0})};var m={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var lc=Object.defineProperty;var ma=(t,e)=>{for(var r in e)lc(t,r,{get:e[r],enumerable:!0})};var m={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5165,7 +5165,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Rg,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...jl,{type:"password",name:"apikey",required:!0}],props:jl},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},RD={type:W+"ChildFrameToRootFrameIdentifier"};var ND=ut()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general";var ir="user_info",qD=ut()||jt()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",Ql=ut()||jt()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",UD=Ql+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",jD=Ql+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",qg=ut()||jt()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Bi=ut()||jt()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",Ug=ut()||jt()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",jg=ut()||jt()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",Kg=ut()||jt()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",KD=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",WD=Ug+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",HD=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Yl=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Xl=jg+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Zl=Kg+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Jl=qg+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true";var eu=pe().TRANSLATE_FILE_URL,GD=eu+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",VD=eu+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var kr=console,Fi=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let r=performance.now(),a=Math.round(r-this.#e),n=Xe.green;a>1e4?n=Xe.red:a>1e3&&(n=Xe.yellow),kr.debug(Xe.dim(nr+" TIMING:"),e,"in",n(a+"ms")),this.#e=r}},ra=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&kr.log(Xe.dim(nr+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&kr.log(Xe.green(nr+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&kr.warn(Xe.yellow(nr+" WARN:"),...e)}error(...e){this.#e<=3&&kr.error(Xe.red(nr+" ERROR:"),...e)}fatal(...e){this.#e<=4&&kr.error(Xe.red(nr+" FATAL:"),...e)}timing(){return this.level===0?new Fi:{reset:()=>{},stop:()=>{}}}},q=new ra;function Kt(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let r=ta.map(n=>n.toLowerCase()),a=r.indexOf(e);if(a===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let n=r.indexOf(e);return n===-1?"auto":ta[n]}else return"auto";else return ta[a]}function zi(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}var Oi="DENO",Xa="CHROME",Za="FIREFOX";function tu(t){let e=Xa;try{let r=navigator?.userAgent||"";/firefox/i.test(r)||typeof InstallTrigger<"u"?e=Za:/deno/i.test(r)&&(e=Oi)}catch{}return t===Xa&&e===Xa||t===Za&&e===Za||t===Oi&&e===Oi}function Mi(){return tu(Xa)}function ru(){return typeof Deno<"u"}function aa(){return tu(Za)}function au(){return Ut()?"monkey":Mi()?"chrome":aa()?"firefox":Ct()?"safari":null}var nu={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},iu={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:nu,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:nu,query:()=>{},sendMessage:()=>{}}};var T;ru()?T=iu:T=globalThis.immersiveTranslateBrowserAPI;var ou=W+"SyncStoreKey_";function Pt(t,e){let r=ou+t;return T.storage.sync.get(r).then(a=>a[r]===void 0?e:a[r])}function Wt(t,e){let r=ou+t;return T.storage.sync.set({[r]:e})}var Wg=W+"StoreKey_";function na(t,e){let r=Wg+t;return T.storage.local.get(r).then(a=>a[r]===void 0?e:a[r])}var or=W+"CacheKey_";function Hg(t,e){let r=or+t;return T.storage.local.get(r).then(a=>a[r]===void 0?e:a[r])}function Gg(){let t=T.storage.local.refresh;t&&t()}function Vg(t,e){let r=or+t;return T.storage.local.get(r).then(a=>{if(a[r]===void 0)return e;let{value:n,expired:i}=a[r];return i&&ia.startsWith(or)).filter(a=>a!==or+ir);if(r.length>0)return T.storage.local.remove(r)}}var ia={get:Hg,set:Qg,getExpired:Vg,setExpired:$g,remove:Yg,clear:Xg,refresh:Gg};function Zg(t,e){let r=t;return e&&Object.keys(e).forEach(a=>{let n=e[a];if(n===void 0)return;let i=Jg(a);if(typeof n=="object"||i){let o=n;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let l=`<${a}>`,s=r.indexOf(l);if(s!==-1){let u=o.tag||"a",c=r.indexOf(``);if(c!==-1){let d=r.substring(s+l.length,c),h=Object.keys(o).filter(b=>b!=="tag").map(b=>`${b}="${o[b]}"`).join(" ");r=r.replace(`${l}${d}`,`<${u} ${h}>${d}`)}}}else if(n){let o=new RegExp("{"+a+"}","gm");r=r.replace(o,n.toString())}}),r}function su(t,e,r){let a=t[e];if(!a)return r;if(!r)return"";let n=r.split("."),i="";do{i+=n.shift();let o=a[i];o!==void 0&&(typeof o=="object"||!n.length)?(a=o,i=""):n.length?i+=".":a=r}while(n.length);return a}function Ri(t,e,r,a,n){if(!t.hasOwnProperty(r))return e;let i=su(t,r,e);return i===e&&r!==a&&(i=su(t,a,e)),Zg(i,n)}function Jg(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function Ht(t,e,r){return Ri(_t,e,t.config.interfaceLanguage,"en",r)}function lu(t,e){let r=new Date(t),a=r.getFullYear().toString(),n=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getDate().toString().padStart(2,"0"),o=r.getHours().toString().padStart(2,"0"),l=r.getMinutes().toString().padStart(2,"0"),s=r.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",a).replace("MM",n).replace("DD",i).replace("HH",o).replace("mm",l).replace("ss",s)}function uu(t){return new Date(t).getTime()}var Gt=class extends Error{status;constructor(e,r){if(e&&r){super(r),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let r=null;if(r=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!r){let a=Ht.bind(null,e),n=this.getErrorMsg();r={type:"error",title:a("networkError"),errMsg:a("error.serveUnavailable",{serverName:a("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+a("errorReason",{message:n}),action:"changeService"}}return r}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let r=Ht.bind(null,e),a=this.message.startsWith("bingAuth"),n=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(a||n)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let r=Ht.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:r("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+r("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let r=Ht.bind(null,e),a="retry",n="network",i=r("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${r("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${r("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${r("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${r("error.gemini.429")}

${o}`:o=`${r("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${r("error.claude.403")}

${o}`:o=`${r("error.403")}

${o}`:this.status===400?o=`${r("error.400")}

${o}`:this.status===502?o=`${r("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${r("error.subscriptionExpired")}

${o}`,a="setting",n="configError",i=r("error.subscriptionExpiredTitle")),{type:n,title:i,errMsg:o,action:a}}handleFetchError(e){let r=Ht.bind(null,e);if(this.status!==-999)return;let a=this.getErrorMsg();return{type:"network",title:"",errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}handleProUser(e){let r=Ht.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:r("upgradeToProErrorTitle"),errMsg:r("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let r=Ht.bind(null,e);this.message=this.message.replace("ProQuota:","");let a=this.message;try{a=JSON.parse(this.message).error}catch{}let n=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:l,subscriptionTo:s}=n;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let d=this.data?.translationService=="deepl"?"OpenAI":"Deepl",h=this.data?.translationService=="deepl"?"Deepl":"OpenAI",b=r("errorReason",{message:a});if(i=="onetime_7day")b+=r("proQuotaExceededError.onetime7day",{anotherService:d,brandId:Se,href:Yl});else{let E="";h=="OpenAI"?E=Xl:E=Zl,o?b+=r("proQuotaExceededError.trial",{anotherService:d,brandId:Se,href:Jl}):b+=r("proQuotaExceededError.nonTrial",{anotherService:d,brandId:Se,href:E,translationService:h}),!o&&(n.cancelAtPeriodEnd==="false"||uu(s)>l)&&(b+=r("proQuotaExceededError.resetTime",{resetTime:lu(l,"YYYY-MM-DD HH:mm:ss")}))}return b}}};async function Ja(t){let e;if(t&&t.retry&&t.retry>0)try{e=await vn(cu.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(r){throw r&&r.name==="RetryError"&&r.cause?r.cause:r}else e=await cu(t);return e}async function cu(t){t.body;let{url:e,responseType:r,...a}=t;r||(r="json"),a={mode:"cors",...a};let n=!0;t.fetchPolyfill&&(n=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),n){let s=new AbortController,u=s.signal;setTimeout(()=>{s.abort()},o),a.signal=u}let l;try{l=await i(e,a)}catch(s){q.debug("fetch error",e,s);let u=s.message||"Unknown Error";throw new Gt("fetchError",u).initNetWork(-999).initStack(s.stack)}if(l.ok&&l.status>=200&&l.status<400){if(r==="json")return await l.json();if(r==="text")return await l.text();if(r==="raw"){let s=await l.text(),u=Object.fromEntries([...l.headers.entries()]),c=l.url;return c||(l.headers.get("X-Final-URL")?c=l.headers.get("X-Final-URL"):c=e),{body:s,headers:u,status:l.status,statusText:l.statusText,url:c}}else if(r==="stream"){let s="",u;if(l.body&&l.body instanceof ReadableStream)for await(let c of eh(l.body)){let d=new TextDecoder().decode(c);s+=d;let h;for(;(h=s.indexOf(` -`))>=0;){let b=s.slice(0,h).trim();if(s=s.slice(h+1),b.startsWith("event:")||b==="")continue;let E="";if(b.startsWith("data:")&&(E=b.slice(5).trim()),E==="[DONE]")break;let ne;try{ne=JSON.parse(E??"")}catch(V){q.debug("json error",V);continue}u=ne}}return u}}else{let s;try{s=await l.text()}catch(b){q.error("parse response failed",b)}s&&q.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,h=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),h&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new Gt("fetchError",c).initNetWork(l.status)}}async function*eh(t){let e=t.getReader();try{for(;;){let{done:r,value:a}=await e.read();if(r)return;yield a}}finally{e.releaseLock()}}var th=new Map;function du(t){let e=rh(64),r=new CustomEvent(Hl,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((a,n)=>{th.set(e,(i,o)=>{i?n(i):a(o)})})}function rh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var nh="";function Er(){return nh||pu.version}function mu(){try{let t=[pe().EBOOK_BUILDER_URL,pe().EBOOK_VIEWER_URL,pe().SUBTITLE_BUILDER_URL,pe().HTML_VIEWER_URL,pe().PDF_VIEWER_URL].filter(n=>!!n),e=["app.immersivetranslate.com"];ut()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(n=>{let i=new URL(n);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var oa=new Map,sr=class{fromType;logger;constructor(e,r=!1){this.logger=new ra,r&&this.logger.setLevel("debug"),this.fromType=e,oa.has(e)||(oa.set(e,new Map),T.runtime.onMessage.addListener((a,n,i)=>{let o=a.from,l=a.to,s,u,c;n.tab&&n.tab.id&&(s=n.tab.id,o=`${o}:${s}`,u=n.tab.url,c=n.tab.active),this.logger.debug(`${a.to} received message [${a.payload.method}] from ${a.from}`,a.payload.data?a.payload.data:" ");let d=qi(l),{type:h,name:b}=d;if(h!==e)return!1;let E=qi(o),V=oa.get(h).get(b);if(!V)return this.logger.debug(`no message handler for ${h}:${l}, but it's ok`),!1;let{messageHandler:f,sync:me}=V,z={type:e,name:E.name,id:s,url:u,active:c};if(me){try{let J=f(a.payload,z);i({ok:!0,data:J})}catch(J){i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.details,errorStatus:J.status})}return!1}else return f(a.payload,z).then(J=>{i({ok:!0,data:J})}).catch(J=>{i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.message,errorStatus:J.status})}),!0}))}getConnection(e,r,a){let n=!1;a&&a.sync&&(n=!0);let i=this.fromType,o=oa.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Ni(`${i}:${e}`,this.logger);return oa.get(i).set(e,{messageHandler:r,sync:n,connectionInstance:l}),l}}},Ni=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let a=qi(e),{type:n,id:i}=a;if(n!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await T.runtime.sendMessage(o);return gu(o,l,this.logger)}catch(l){if(n==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await T.tabs.sendMessage(i,o);return gu(o,l,this.logger)}}};function gu(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new Gt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new Gt("noResponse","Unknown error")}function qi(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let a=parseInt(e[2]);if(!isNaN(a))r.id=a;else throw new Error("tab id not a valid number")}return r}var ih="";function Ui(){return ih||globalThis.navigator.userAgent}function hu(){return Ui().includes("ImtFxiOS")}function oh(){return Ui().includes("ImtFxAndroid")}function ji(){let t=Ui();if(hu()||oh()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),a=r[0];return r[2]&&(a+="_"+r[2]),{name:a,version:r[1]}}}return null}var en;function sh(){return en||(en=new sr("content_script",!1).getConnection("pure_main",()=>{}),en)}var fu="G-MKMD9LWFTR";async function Tu(t){try{let e=pe(),r=e.INSTALL_FROM==="firefox_store";if(ji()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let n=Ut(),i=mu(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Pt("fakeUserId","");s||(s=await na("fakeUserId",""),s&&await Wt("fakeUserId",s));let u=Er(),c=new Date,d=await Pt("installedAt","");d||(d=await na("installedAt",""),d&&await Wt("installedAt",d)),s?d||(d=new Date(0).toISOString(),await Wt("installedAt",d)):(s=lh(32),await Wt("fakeUserId",s)),d||(d=c.toISOString(),await Wt("installedAt",d));let h=new Date(d),b=bu(h),E=bu(c),ne=b===E,V=c.getTime()-h.getTime()<7*24*60*60*1e3,f=`https://www.google-analytics.com/mp/collect?measurement_id=${fu}&api_secret=${l}`;o||(f=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${fu}&api_secret=${l}`);let me="";typeof navigator<"u"&&(me=window.navigator.userAgent);let z=ya.parse(me),J=t.map(C=>{let g=C.params||{};if(z.os&&(g.os_name=z.os.name||"unknown",g.os_version=z.os.version||"unknown",g.os_version_name=z.os.versionName||"unknown"),z.browser){g.browser_name=z.browser.name||"unknown",g.browser_version=z.browser.version||"unknown";let S=ji();S&&(g.browser_name=S.name,g.browser_version=S.version)}return z.platform&&(g.platform_type=z.platform.type||"unknown"),z.engine&&(g.engine_name=z.engine.name||"unknown",g.engine_version=z.engine.version||"unknown"),u&&(g.version=u),e.INSTALL_FROM&&(g.install_from=e.INSTALL_FROM),b&&(g.install_day=uh(h)),g.userscript=n.toString(),ne?g.is_new_user_today="1":g.is_new_user_today="0",V?g.is_new_user_this_week="1":g.is_new_user_this_week="0",i?g.main_frame=0:g.main_frame=1,{...C,params:g}}),ue=await dh({responseType:"text",url:f,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:J})})}catch{}}function lh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let b=s.slice(0,h).trim();if(s=s.slice(h+1),b.startsWith("event:")||b==="")continue;let E="";if(b.startsWith("data:")&&(E=b.slice(5).trim()),E==="[DONE]")break;let ne;try{ne=JSON.parse(E??"")}catch(V){q.debug("json error",V);continue}u=ne}}return u}}else{let s;try{s=await l.text()}catch(b){q.error("parse response failed",b)}s&&q.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,h=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),h&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new Gt("fetchError",c).initNetWork(l.status)}}async function*eh(t){let e=t.getReader();try{for(;;){let{done:r,value:a}=await e.read();if(r)return;yield a}}finally{e.releaseLock()}}var th=new Map;function du(t){let e=rh(64),r=new CustomEvent(Hl,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((a,n)=>{th.set(e,(i,o)=>{i?n(i):a(o)})})}function rh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var nh="";function Er(){return nh||pu.version}function mu(){try{let t=[pe().EBOOK_BUILDER_URL,pe().EBOOK_VIEWER_URL,pe().SUBTITLE_BUILDER_URL,pe().HTML_VIEWER_URL,pe().PDF_VIEWER_URL].filter(n=>!!n),e=["app.immersivetranslate.com"];ut()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(n=>{let i=new URL(n);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var oa=new Map,sr=class{fromType;logger;constructor(e,r=!1){this.logger=new ra,r&&this.logger.setLevel("debug"),this.fromType=e,oa.has(e)||(oa.set(e,new Map),T.runtime.onMessage.addListener((a,n,i)=>{let o=a.from,l=a.to,s,u,c;n.tab&&n.tab.id&&(s=n.tab.id,o=`${o}:${s}`,u=n.tab.url,c=n.tab.active),this.logger.debug(`${a.to} received message [${a.payload.method}] from ${a.from}`,a.payload.data?a.payload.data:" ");let d=qi(l),{type:h,name:b}=d;if(h!==e)return!1;let E=qi(o),V=oa.get(h).get(b);if(!V)return this.logger.debug(`no message handler for ${h}:${l}, but it's ok`),!1;let{messageHandler:f,sync:me}=V,z={type:e,name:E.name,id:s,url:u,active:c};if(me){try{let J=f(a.payload,z);i({ok:!0,data:J})}catch(J){i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.details,errorStatus:J.status})}return!1}else return f(a.payload,z).then(J=>{i({ok:!0,data:J})}).catch(J=>{i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.message,errorStatus:J.status})}),!0}))}getConnection(e,r,a){let n=!1;a&&a.sync&&(n=!0);let i=this.fromType,o=oa.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Ni(`${i}:${e}`,this.logger);return oa.get(i).set(e,{messageHandler:r,sync:n,connectionInstance:l}),l}}},Ni=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let a=qi(e),{type:n,id:i}=a;if(n!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await T.runtime.sendMessage(o);return gu(o,l,this.logger)}catch(l){if(n==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await T.tabs.sendMessage(i,o);return gu(o,l,this.logger)}}};function gu(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new Gt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new Gt("noResponse","Unknown error")}function qi(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let a=parseInt(e[2]);if(!isNaN(a))r.id=a;else throw new Error("tab id not a valid number")}return r}var ih="";function Ui(){return ih||globalThis.navigator.userAgent}function hu(){return Ui().includes("ImtFxiOS")}function oh(){return Ui().includes("ImtFxAndroid")}function ji(){let t=Ui();if(hu()||oh()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),a=r[0];return r[2]&&(a+="_"+r[2]),{name:a,version:r[1]}}}return null}var en;function sh(){return en||(en=new sr("content_script",!1).getConnection("pure_main",()=>{}),en)}var fu="G-MKMD9LWFTR";async function Tu(t){try{let e=pe(),r=e.INSTALL_FROM==="firefox_store";if(ji()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let n=Ut(),i=mu(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Pt("fakeUserId","");s||(s=await na("fakeUserId",""),s&&await Wt("fakeUserId",s));let u=Er(),c=new Date,d=await Pt("installedAt","");d||(d=await na("installedAt",""),d&&await Wt("installedAt",d)),s?d||(d=new Date(0).toISOString(),await Wt("installedAt",d)):(s=lh(32),await Wt("fakeUserId",s)),d||(d=c.toISOString(),await Wt("installedAt",d));let h=new Date(d),b=bu(h),E=bu(c),ne=b===E,V=c.getTime()-h.getTime()<7*24*60*60*1e3,f=`https://www.google-analytics.com/mp/collect?measurement_id=${fu}&api_secret=${l}`;o||(f=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${fu}&api_secret=${l}`);let me="";typeof navigator<"u"&&(me=window.navigator.userAgent);let z=ya.parse(me),J=t.map(C=>{let g=C.params||{};if(z.os&&(g.os_name=z.os.name||"unknown",g.os_version=z.os.version||"unknown",g.os_version_name=z.os.versionName||"unknown"),z.browser){g.browser_name=z.browser.name||"unknown",g.browser_version=z.browser.version||"unknown";let S=ji();S&&(g.browser_name=S.name,g.browser_version=S.version)}return z.platform&&(g.platform_type=z.platform.type||"unknown"),z.engine&&(g.engine_name=z.engine.name||"unknown",g.engine_version=z.engine.version||"unknown"),u&&(g.version=u),e.INSTALL_FROM&&(g.install_from=e.INSTALL_FROM),b&&(g.install_day=uh(h)),g.userscript=n.toString(),ne?g.is_new_user_today="1":g.is_new_user_today="0",V?g.is_new_user_this_week="1":g.is_new_user_this_week="0",i?g.main_frame=0:g.main_frame=1,{...C,params:g}}),ue=await dh({responseType:"text",url:f,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:J})})}catch{}}function lh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 diff --git a/dist/chrome/content_script.js b/dist/chrome/content_script.js index 91d9d90..f990db6 100644 --- a/dist/chrome/content_script.js +++ b/dist/chrome/content_script.js @@ -1,4 +1,4 @@ -(()=>{var e6=Object.create;var gd=Object.defineProperty;var t6=Object.getOwnPropertyDescriptor;var n6=Object.getOwnPropertyNames;var r6=Object.getPrototypeOf,a6=Object.prototype.hasOwnProperty;var i6=(t,e)=>()=>(t&&(e=t(t=0)),e);var o6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},s6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n6(e))!a6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=t6(e,a))||r.enumerable});return t};var u6=(t,e,n)=>(n=t!=null?e6(r6(t)):{},s6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=i6(()=>{x={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var e6=Object.create;var gd=Object.defineProperty;var t6=Object.getOwnPropertyDescriptor;var n6=Object.getOwnPropertyNames;var r6=Object.getPrototypeOf,a6=Object.prototype.hasOwnProperty;var i6=(t,e)=>()=>(t&&(e=t(t=0)),e);var o6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},s6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n6(e))!a6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=t6(e,a))||r.enumerable});return t};var u6=(t,e,n)=>(n=t!=null?e6(r6(t)):{},s6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=i6(()=>{x={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5262,7 +5262,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Xo,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...W4,{type:"password",name:"apikey",required:!0}],props:W4},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},Zu={type:me+"ChildFrameToRootFrameIdentifier"},W0=["youtube","netflix","webvtt","khanacademy","bilibili","udemy","hulu","text_track","text_track_dynamic","general","live","ebutt","disneyplus","fmp4.xml","multi_attach_vtt","twitter","subsrt","xml","av"],es=["Ctrl","Shift","Alt","Auto","Off","OtherCustom","Other"],hb=["ctrl","alt","shift","cmd","command","option","control"];var ez=Qt()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general",K0="user_from_plugin",Ft="user_info",ts=Qt()||Rn()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",bb=Qt()||Rn()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",Tb=bb+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",yb=bb+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Xu=Qt()||Rn()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Ai=Qt()||Rn()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",ew=Qt()||Rn()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",tw=Qt()||Rn()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",nw=Qt()||Rn()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",tz=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",nz=ew+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",vb=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",el=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Sb=tw+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",xb=nw+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Eb=Xu+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true",Cb="https://immersivetranslate.com/docs/usage/";var wb=Me().TRANSLATE_FILE_URL,rz=wb+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",Db=wb+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var ki=console,G0=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=On.green;r>1e4?a=On.red:r>1e3&&(a=On.yellow),ki.debug(On.dim(Ua+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ns=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&ki.log(On.dim(Ua+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&ki.log(On.green(Ua+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&ki.warn(On.yellow(Ua+" WARN:"),...e)}error(...e){this.#e<=3&&ki.error(On.red(Ua+" ERROR:"),...e)}fatal(...e){this.#e<=4&&ki.error(On.red(Ua+" FATAL:"),...e)}timing(){return this.level===0?new G0:{reset:()=>{},stop:()=>{}}}},B=new ns;d();d();d();var V0=/iPhone/i,Ab=/iPod/i,kb=/iPad/i,Pb=/\biOS-universal(?:.+)Mac\b/i,$0=/\bAndroid(?:.+)Mobile\b/i,Lb=/Android/i,Pi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,tl=/Silk/i,Br=/Windows Phone/i,_b=/\bWindows(?:.+)ARM\b/i,Fb=/BlackBerry/i,Mb=/BB10/i,Bb=/Opera Mini/i,Ib=/\b(CriOS|Chrome)(?:.+)Mobile/i,Rb=/Mobile(?:.+)Firefox\b/i,Ob=t=>typeof t<"u"&&t.platform==="MacIntel"&&typeof t.maxTouchPoints=="number"&&t.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function rw(t){return e=>e.test(t)}function ut(t){let e={userAgent:"",platform:"",maxTouchPoints:0};!t&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof t=="string"?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0});let n=e.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=rw(n),i={apple:{phone:a(V0)&&!a(Br),ipod:a(Ab),tablet:!a(V0)&&(a(kb)||Ob(e))&&!a(Br),universal:a(Pb),device:(a(V0)||a(Ab)||a(kb)||a(Pb)||Ob(e))&&!a(Br)},amazon:{phone:a(Pi),tablet:!a(Pi)&&a(tl),device:a(Pi)||a(tl)},android:{phone:!a(Br)&&a(Pi)||!a(Br)&&a($0),tablet:!a(Br)&&!a(Pi)&&!a($0)&&(a(tl)||a(Lb)),device:!a(Br)&&(a(Pi)||a(tl)||a($0)||a(Lb))||a(/\bokhttp\b/i)},windows:{phone:a(Br),tablet:a(_b),device:a(Br)||a(_b)},other:{blackberry:a(Fb),blackberry10:a(Mb),opera:a(Bb),firefox:a(Rb),chrome:a(Ib),device:a(Fb)||a(Mb)||a(Bb)||a(Rb)||a(Ib)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var Y0="DENO",nl="CHROME",rl="FIREFOX";function zb(t){let e=nl;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?e=rl:/deno/i.test(n)&&(e=Y0)}catch{}return t===nl&&e===nl||t===rl&&e===rl||t===Y0&&e===Y0}function aw(){return zb(nl)}function Nb(){return typeof Deno<"u"}function Ir(){return zb(rl)}function al(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function rs(t){return!!(t?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function Ub(){return ye()?"monkey":aw()?"chrome":Ir()?"firefox":et()?"safari":null}d();var qb={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},jb={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:qb,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:qb,query:()=>{},sendMessage:()=>{}}};var oe;Nb()?oe=jb:oe=globalThis.immersiveTranslateBrowserAPI;d();d();d();d();d();var Dz=Wb(2),Hb=Wb(3);function Wb(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var iw=/\s+/g,ow=/[\t\n\v\f\r ]+/g;function Kb(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?sw:uw;return String(t).replace(e.style==="html"?ow:iw,e.trim?lw(n):n)}function sw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function uw(){return" "}function lw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var Gb={}.hasOwnProperty;function cw(t){return t==null?"":Kb(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function dw(t){return Hb(" "+cw(t)+" ")}function pw(t){let e=dw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function yw(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function vw(t,e,n,r){e=xw(e,n,r);let a=[],i;if(e)for(i in e)il.call(e,i)&&a.push([i,Sw(t,e[i])]);return a.length===0?J0():a.sort(Ew)}function Sw(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of Mw){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?e3(t)?"zh-TW":"zh-CN":e:"auto"}var n3=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Z0=new Map(n3),Bw=new Map(n3.map(([t,e])=>[e,t]));function r3(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>Bw.get(s));!e&&e!==0&&(e=25);let a=sl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Z0.keys()]},o=Yb(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&m<.95)break;return Z0.get(p)}}let[s,u]=o[0],l=Z0.get(s);if(l&&u>.9)return l}}catch(r){B.error(r)}return"auto"}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=kn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":kn[a]}else return"auto";else return kn[r]}function ht(){return Te(document?.documentElement?.lang||"en")}d();function Jt(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}function a3(t){if(t){let e=new Date(t.createTime),n=Iw(e),r="free",a="unknown";return t.subscription&&t.subscription.subscriptionStatus==="active"&&(r=t.subscription.subscriptionType),t.subscription&&t.subscription.subscriptionId&&(t.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function Iw(t){try{let n=t.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}d();var i3=me+"SyncStoreKey_";function At(t,e){let n=i3+t;return oe.storage.sync.get(n).then(r=>r[n]===void 0?e:r[n])}function Xe(t,e){let n=i3+t;return oe.storage.sync.set({[n]:e})}d();var o3=me+"StoreKey_";function Rr(t,e){let n=o3+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function s3(t,e){let n=o3+t;return oe.storage.local.set({[n]:e})}d();var Ha=me+"CacheKey_";function X0(t,e){let n=Ha+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function Rw(){let t=oe.storage.local.refresh;t&&t()}function ep(t,e){let n=Ha+t;return oe.storage.local.get(n).then(r=>{if(r[n]===void 0)return e;let{value:a,expired:i}=r[n];return i&&ir.startsWith(Ha)).filter(r=>r!==Ha+Ft);if(n.length>0)return oe.storage.local.remove(n)}}var Mt={get:X0,set:np,getExpired:ep,setExpired:tp,remove:rp,clear:u3,refresh:Rw};d();d();d();d();function l3(t,e){return[t,!t||t.endsWith("/")?"":"/",e,".json"].join("")}function ap(t,e){let n=t;return e&&Object.keys(e).forEach(r=>{let a=e[r];if(a===void 0)return;let i=Ow(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let p=n.substring(u+s.length,c),m=Object.keys(o).filter(g=>g!=="tag").map(g=>`${g}="${o[g]}"`).join(" ");n=n.replace(`${s}${p}`,`<${l} ${m}>${p}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function is(t,e,n){let r=t[e];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function mr(t,e,n,r,a){if(!t.hasOwnProperty(n))return e;let i=is(t,n,e);return i===e&&n!==r&&(i=is(t,r,e)),ap(i,a)}function Ow(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function kt(t,e,n){return mr(zt,e,t.config.interfaceLanguage,"en",n)}d();function c3(t,e){let n=new Date(t),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function d3(t){return new Date(t).getTime()}var $=class extends Error{status;constructor(e,n){if(e&&n){super(n),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let n=null;if(n=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!n){let r=kt.bind(null,e),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let n=kt.bind(null,e),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let n=kt.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let n=kt.bind(null,e),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(e){let n=kt.bind(null,e);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(e){let n=kt.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let n=kt.bind(null,e);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let p=this.data?.translationService=="deepl"?"OpenAI":"Deepl",m=this.data?.translationService=="deepl"?"Deepl":"OpenAI",g=n("errorReason",{message:r});if(i=="onetime_7day")g+=n("proQuotaExceededError.onetime7day",{anotherService:p,brandId:Q,href:el});else{let f="";m=="OpenAI"?f=Sb:f=xb,o?g+=n("proQuotaExceededError.trial",{anotherService:p,brandId:Q,href:Eb}):g+=n("proQuotaExceededError.nonTrial",{anotherService:p,brandId:Q,href:f,translationService:m}),!o&&(a.cancelAtPeriodEnd==="false"||d3(u)>s)&&(g+=n("proQuotaExceededError.resetTime",{resetTime:c3(s,"YYYY-MM-DD HH:mm:ss")}))}return g}}};async function Wa(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Sd(p3.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else e=await p3(t);return e}async function p3(t){t.body;let{url:e,responseType:n,...r}=t;n||(n="json"),r={mode:"cors",...r};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(e,r)}catch(u){B.debug("fetch error",e,u);let l=u.message||"Unknown Error";throw new $("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=e),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of zw(s.body)){let p=new TextDecoder().decode(c);u+=p;let m;for(;(m=u.indexOf(` -`))>=0;){let g=u.slice(0,m).trim();if(u=u.slice(m+1),g.startsWith("event:")||g==="")continue;let f="";if(g.startsWith("data:")&&(f=g.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){B.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(g){B.error("parse response failed",g)}u&&B.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,m=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),m&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*zw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Nw=new Map;function ul(t){let e=Uw(64),n=new CustomEvent(Hu,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Nw.set(e,(i,o)=>{i?a(i):r(o)})})}function Uw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var jw="";function Nt(){return jw||ll.version}function ip(){return oe.runtime.getManifest().version}d();function He(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var os=new Map,ea=class{fromType;logger;constructor(e,n=!1){this.logger=new ns,n&&this.logger.setLevel("debug"),this.fromType=e,os.has(e)||(os.set(e,new Map),oe.runtime.onMessage.addListener((r,a,i)=>{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=sp(s),{type:m,name:g}=p;if(m!==e)return!1;let f=sp(o),b=os.get(m).get(g);if(!b)return this.logger.debug(`no message handler for ${m}:${s}, but it's ok`),!1;let{messageHandler:h,sync:E}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(E){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=os.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new op(`${i}:${e}`,this.logger);return os.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},op=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=sp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return g3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return g3(o,s,this.logger)}}};function g3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function sp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var Hw="";function Li(){return Hw||globalThis.navigator.userAgent}function up(){return Li().includes("ImtFxiOS")}function m3(){let e=Li().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function Ww(){return Li().includes("ImtFxAndroid")}function f3(){let t=Li();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function h3(){let e=Li().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function ss(){let t=Li();if(up()||Ww()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var cl;function Kw(){return cl||(cl=new ea("content_script",!1).getConnection("pure_main",()=>{}),cl)}var b3="G-MKMD9LWFTR";async function us(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(ss()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=He(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Rr("fakeUserId",""),u&&await Xe("fakeUserId",u));let l=Nt(),c=new Date,p=await At("installedAt","");p||(p=await Rr("installedAt",""),p&&await Xe("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Xe("installedAt",p)):(u=Gw(32),await Xe("fakeUserId",u)),p||(p=c.toISOString(),await Xe("installedAt",p));let m=new Date(p),g=T3(m),f=T3(c),T=g===f,b=c.getTime()-m.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${b3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${b3}&api_secret=${s}`);let E="";typeof navigator<"u"&&(E=window.navigator.userAgent);let D=mi.parse(E),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let L=ss();L&&(y.browser_name=L.name,y.browser_version=L.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),g&&(y.install_day=Vw(m)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),I=await dl({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Gw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let g=u.slice(0,m).trim();if(u=u.slice(m+1),g.startsWith("event:")||g==="")continue;let f="";if(g.startsWith("data:")&&(f=g.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){B.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(g){B.error("parse response failed",g)}u&&B.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,m=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),m&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*zw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Nw=new Map;function ul(t){let e=Uw(64),n=new CustomEvent(Hu,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Nw.set(e,(i,o)=>{i?a(i):r(o)})})}function Uw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var jw="";function Nt(){return jw||ll.version}function ip(){return oe.runtime.getManifest().version}d();function He(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var os=new Map,ea=class{fromType;logger;constructor(e,n=!1){this.logger=new ns,n&&this.logger.setLevel("debug"),this.fromType=e,os.has(e)||(os.set(e,new Map),oe.runtime.onMessage.addListener((r,a,i)=>{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=sp(s),{type:m,name:g}=p;if(m!==e)return!1;let f=sp(o),b=os.get(m).get(g);if(!b)return this.logger.debug(`no message handler for ${m}:${s}, but it's ok`),!1;let{messageHandler:h,sync:E}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(E){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=os.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new op(`${i}:${e}`,this.logger);return os.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},op=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=sp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return g3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return g3(o,s,this.logger)}}};function g3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function sp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var Hw="";function Li(){return Hw||globalThis.navigator.userAgent}function up(){return Li().includes("ImtFxiOS")}function m3(){let e=Li().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function Ww(){return Li().includes("ImtFxAndroid")}function f3(){let t=Li();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function h3(){let e=Li().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function ss(){let t=Li();if(up()||Ww()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var cl;function Kw(){return cl||(cl=new ea("content_script",!1).getConnection("pure_main",()=>{}),cl)}var b3="G-MKMD9LWFTR";async function us(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(ss()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=He(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Rr("fakeUserId",""),u&&await Xe("fakeUserId",u));let l=Nt(),c=new Date,p=await At("installedAt","");p||(p=await Rr("installedAt",""),p&&await Xe("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Xe("installedAt",p)):(u=Gw(32),await Xe("fakeUserId",u)),p||(p=c.toISOString(),await Xe("installedAt",p));let m=new Date(p),g=T3(m),f=T3(c),T=g===f,b=c.getTime()-m.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${b3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${b3}&api_secret=${s}`);let E="";typeof navigator<"u"&&(E=window.navigator.userAgent);let D=mi.parse(E),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let L=ss();L&&(y.browser_name=L.name,y.browser_version=L.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),g&&(y.install_day=Vw(m)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),I=await dl({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Gw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5421,7 +5421,7 @@ Translate the content to {{to}} Language: `,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};d();d();function pl(t){if(t.beta)return!1;if(et()&&t.spVersion)return ls(ip(),t.spVersion);if(f3()&&t.gspVersion){let e=h3();if(e)return ls(e,t.gspVersion)}if(up()&&t.ispVersion){let e=m3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function lp(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function gl(t){return Array.isArray(t)?t:t?[t]:[]}function ml(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function fl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function hl(t,e){let n={...t};return x3(n,e),Qw(n,e),n}function S3(t,e,n){let r={...e};return Ka({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ka({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function Qw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;x3(t,a)}function Ka({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Jw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=gl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!y3(s))return;c=cp(l,u)}else if(o=="remove_v"){if(!y3(s))return;c=v3(l,u)}else o==="add"?c=cp(l,u):o=="remove"&&(c=v3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=cp(l,u):c=u,r(i,c)})}function x3(t,e){return Ka({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function cp(t,e){let n;if(Array.isArray(t)){let r=gl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Jw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function y3(t){let e=Nt();return t&&ls(e,t)}function v3(t,e){if(Array.isArray(t)){let n=gl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}function E3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Zt(){let t=await oe.storage.local.get(Qo);if(t[Qo]){let e=t[Qo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Xt(i),i}else return{}}async function Xt(t){await oe.storage.local.set({[Qo]:t})}async function C3(t){await oe.storage.local.set({[Xr]:t})}async function w3(){let t=await oe.storage.local.get(Xr),n={...await dp(),..._i,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Xr]){let r=t[Xr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Pn(){let t=await oe.storage.local.get(Xr),e={..._i,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Xr]){let C=t[Xr];if(C&&C.buildinConfigUpdatedAt){let P=new Date(C.buildinConfigUpdatedAt),U=new Date(e.buildinConfigUpdatedAt);P>U&&(e=C)}}let n=await eD(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let C=await oe.commands.getAll();for(let P of C)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await dp(),o=E3(),s=await Or(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Zt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let C=await Zw();p.interfaceLanguage=C}let m=p.interfaceLanguage==="en",g=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!m&&!g&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,E=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(E=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(E.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,I=await At("installedAt",""),S=Number(await Rr("translage_page_daily",0)),y=Number(await At(Xn,0)),L;y>0&&(Date.now()-y0&&(Date.now()-S0){let C=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(C.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],U=Array.isArray(P)?P:[P],H=Array.from(new Set(U.concat(C.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let _=Object.assign(i,e);Ka({rule:e,valueIsArray:C=>Array.isArray(i[C]),getMergedValue:C=>i[C],onMergedResult:(C,P)=>{C!="generalRule"&&(_[C]=P)}});let k=Jt(r),N={};p.translationServices&&p.translationServices.deepl&&(N=p.translationServices.deepl);let z={};p.translationServices&&p.translationServices.openai&&(z=p.translationServices.openai),!k&&N.authKey&&!N.provider?(_.translationServices.deepl||(_.translationServices.deepl={}),_.translationServices.deepl.provider="custom"):N&&N.provider||(_.translationServices.deepl||(_.translationServices.deepl={}),_.translationServices.deepl.provider="pro"),!k&&z.APIKEY&&!z.provider?(_.translationServices.openai||(_.translationServices.openai={}),_.translationServices.openai.provider="custom"):z&&z.provider||(_.translationServices.openai||(_.translationServices.openai={}),_.translationServices.openai.provider="pro");let q=Object.keys(_),F=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let C of q){let P=C;if(P==="generalRule")typeof p[P]=="object"&&(_[P]=hl(i[P],p[P]));else if(P==="translationServices")tD(p,_);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&F.includes(P))p[P]&&(_[P]=Object.assign(_[P],p[P])),P==="shortcuts"&&(ye()||et()?_[P]={..._[P],...a}:_[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let U=_.rules||[],H={};for(let W of U)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?S3(e.generalRule,H[W.id],W):W);_[P]=[...j,..._[P]]}if(we.PROD==="0"&&we.DEV_RULES){let U=JSON.parse(we.DEV_RULES);_[P]=[...U,..._[P]]}}else p[P]!==void 0&&(_[P]=p[P])}return _.donateUrl=e.donateUrl,_.minVersion=e.minVersion,_.feedbackUrl=e.feedbackUrl,_.rawUserConfig=s,_}async function Or(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function cs(t){await oe.storage.sync.set({userConfig:t})}async function ds(t,e){await oe.storage.local.set({[t]:e})}async function bl(t){return(await oe.storage.local.get(t))[t]||""}var Zw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){B.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>zt[r]);return n||"en"},dp=async()=>{let t={..._i,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:pr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Xw(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function eD(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return pr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ka({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ka({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}d();d();function ta(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function nD(t,e){return t<>>32-e}function yl(t,e,n,r,a,i){return ta(nD(ta(ta(e,t),ta(r,i)),a),n)}function en(t,e,n,r,a,i,o){return yl(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return yl(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return yl(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return yl(n^(e|~r),t,e,a,i,o)}function Tl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function pp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Tl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Tl(a.concat(pp(e)),512+e.length*8),D3(Tl(i.concat(o),512+128))}function A3(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function gp(t){return unescape(encodeURIComponent(t))}function k3(t){return rD(gp(t))}function iD(t){return A3(k3(t))}function P3(t,e){return aD(gp(t),gp(e))}function oD(t,e){return A3(P3(t,e))}function Ln(t,e,n){return e?n?P3(e,t):oD(e,t):n?k3(t):iD(t)}d();function L3(t,e,n){let r=sD(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function sD(t,e){let n=[],r=[];for(let a=0;a0?Te){let E=[];mp(b,e,E);for(let D=0;D0&&T{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&mp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?g.push(T):m.push(T))});let f=g.concat(m).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:g,explicitProps:m}}var ps=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Jt(s),l=Object.keys(gr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=gr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&et())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let m=!!p.canary,g=!!p.alpha,f=!!p.beta;return c===t[e]||m&&i||g&&(r||i)||f&&(a||r||i)?!0:!g&&!f&&!m}).map(c=>vl(e,c,t))};function gs(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function _3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}var Fi=[];async function Sl(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function F3(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await cD(e,t)}async function M3(t){let e=Ln(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await lD(n,e)}async function lD(t,e){let n=await Sl(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function cD(t,e){let n=await Sl(t);return(await pD()).includes(t)||await dD(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function dD(t){let e="cache_list",n=await Sl(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Fi.push(t)},a.onerror=i=>{n.close()}}async function pD(){if(Fi&&Fi.length>0)return Fi;let t=await Sl(Q+"-cacheList","cache_list");return Fi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Fi}d();d();var fp="Original";function Qe(){return fp}function gn(t){fp=t,B3(fp)}d();var R3="auto",xl="auto",I3="auto";function O3(t){R3=t}function qn(t){xl=t}function vt(){return xl!=="auto"?xl:I3!=="auto"?I3:R3}function El(){return xl}d();function Ga(t){return t?.id?.endsWith("pdfWebPage")||!1}function ra(t){try{if(!t||!Ga(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Je={},aa=async function(t,e){let{method:n,data:r}=t,a=await Je.updateGlobalContext(),i=Date.now();if(B.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Je.translateTheWholePage(r),Xe(Xn,i);else if(n==="translateTheMainPage")await Je.translateTheMainPage(r),Xe(Xn,i);else if(n==="translateToThePageEndImmediately")await Je.translateToThePageEndImmediately(r),Xe(Xn,i);else if(n==="toggleTranslatePage")await Je.toggleTranslatePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheWholePage")await Je.toggleTranslateTheWholePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheMainPage")await Je.toggleTranslateTheMainPage(r),Xe(Xn,i);else if(n==="toggleOnlyTransation")await Je.ensureSwitchTranslationMode(r),Xe(Xn,i);else if(n==="translatePage")await Je.translatePage(a,r),Xe(Xn,i);else if(n==="toggleTranslationMask")await Je.toggleTranslationMask(r);else if(n==="restorePage")Je.restorePage();else if(n==="retryFailedParagraphs")Je.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Je.switchTranslationMode(r.mode),await Je.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Je.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Ku,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Je.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Yo,{detail:r}));else if(n==="translateWithOpenAI")await Je.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Je.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Je.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Je.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Je.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Je.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Je.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")He()||await Je.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!He())return JSON.stringify(a)}};function z3(t){Object.assign(Je,t)}function N3(t){Object.assign(Je,t)}function U3(t){Object.assign(Je,t)}var gD=function(t,e){let{method:n,data:r}=t;if(B.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Qe();if(n==="getCurrentPageLanguage"){let a=vt();return Je.detectCurrentPageLanguage().catch(i=>{B.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return qn(r),vt();if(n==="getContextString"){let a=Je.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Je.getPureGlobalContext();return ra(a?.rule)}}},Cl,wl;function q3(){let t=Dl();He()||mD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Dl(){return Cl||(Cl=new ea("content_script",!1).getConnection("main",aa),Cl)}function mD(){return wl||(wl=new ea("content_script",!1).getConnection("main_sync",gD,{sync:!0}),wl)}d();var hp=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Al="https://transmart.qq.com/api/imt",zr=class t{static langMapReverse=new Map(hp.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await ce({url:Al,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function fD(t,e){return Math.floor(Math.random()*(e-t+1))+t}var hD=30,bp="RATE_LIMITER_TICKS",Mi=class t{static strictTicks={};static clearStrictTicks(){ds(bp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await bl(bp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){B.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await ds(bp,JSON.stringify(this.strictTicks))}catch(a){B.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=fD(4,hD);await vr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function St(t){return await Dl().sendMessage("background:main",t)}function ce(t){return au()?ul({method:"request",data:t}):ye()||ru()?(t.fetchPolyfill=globalThis.GM_fetch,Wa(t)):St({method:"fetch",data:t})}function an(){return ye()?Pn():St({method:"getConfig"})}function mn(t){return ye()?cs(t):St({method:"setUserConfig",data:t})}function fn(){return ye()?Or():St({method:"getUserConfig"})}function ms(){return ye()?Zt():St({method:"getLocalConfig"})}function kl(t){return ye()?Xt(t):St({method:"setLocalConfig",data:t})}function j3(t){return ye()?C3(t):St({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=sl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||et()){if(t.translateService&&!Ju.includes(t.translateService))return Promise.resolve("auto");let r=r3(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await St({method:"detectLanguage",data:t});return Promise.resolve(e)}function H3(){return St({method:"detectTabLanguage"})}async function Pl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||et()){let n=t.substring(0,200);e=await zr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function B3(t){let e=new CustomEvent(ja,{detail:t});if(document.dispatchEvent(e),ye())return;Dl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function W3(t){return ye()?M3(t):St({method:"queryParagraphCache",data:t})}async function K3(t){if(ye()){await F3(t);return}return St({method:"setParagraphCache",data:t})}async function G3(){if(ye())return Promise.resolve();await St({method:"mockRequest"})}function Bi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):St({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function Ii(t=""){return ye()||et()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function V3(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Ll(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):St({method:"openAboutPage"})}function Ri(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):St({method:"openInTab",data:t})}function $3(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):St({method:"openEbookViewerPage"})}function Y3(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):St({method:"openEbookBuilderPage"})}function _l(t){et()}function Oi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):St({method:"openPdfViewerPage",data:{url:e}})}function Q3(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):St({method:"openSubtitleBuilderPage"})}function zi(t){return ye()?Promise.resolve():St({method:"setBadge",data:{text:t}})}function J3(){return ye()?(B.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):St({method:"autoSyncLatestConfig"})}function Fl(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function Z3(t,e){return ye()?Mi.getDelay(t,e):St({method:"getDelay",data:{key:t,options:e}})}var X3="G-MKMD9LWFTR";async function it(t,e,n){try{let r=ss(),a=Me(),i=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(i=!1);let o=ye(),s=He(),u=a.PROD==="1",l=`report_${t}`,c=t.endsWith("_daily");if(c){if(s)return;let A=await Rr(l,0),v=Ml(new Date(A)),O=Date.now(),_=Ml(new Date(O));if(v===_)return;await s3(l,O)}else if(!n.config.telemetry)return;let p="sitc4WmvShWYwfU0dANM3Q",m=await At("fakeUserId","");m||(m=await Rr("fakeUserId",""),m&&await Xe("fakeUserId",m));let g=Nt(),f=new Date,T=await At("installedAt","");T||(T=await Rr("installedAt",""),T&&await Xe("installedAt",T)),m?T||(T=new Date(0).toISOString(),await Xe("installedAt",T)):(m=bD(32),await Xe("fakeUserId",m)),T||(T=f.toISOString(),await Xe("installedAt",T));let b=new Date(T),h=Ml(b),E=Ml(f),D=h===E,M=f.getTime()-b.getTime()<7*24*60*60*1e3,I=`https://www.google-analytics.com/mp/collect?measurement_id=${X3}&api_secret=${p}`;u||(I=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${X3}&api_secret=${p}`);let S=mi.parse(window.navigator.userAgent),y=e.map(A=>{let v=A.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser&&(v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown",r&&(v.browser_name=r.name,v.browser_version=r.version)),S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),n.translationService&&(v.translation_service||(v.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(v.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?v.openai_is_official="1":v.openai_is_official="0":v.openai_is_official="1"))),n.targetLanguage&&(v.target_language=n.targetLanguage),n.config.interfaceLanguage&&(v.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?v.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":v.enable_default_always_translated_urls="0",g&&(v.version=g),n.config.enableInputTranslation?v.enable_input_translation=n.config.enableInputTranslation?"1":"0":v.enable_input_translation="0",n.config.translationTheme&&(v.translation_theme=n.config.translationTheme),n.config.alpha&&(v.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?v.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):v.always_translate_languages="none",a.INSTALL_FROM&&(v.install_from=a.INSTALL_FROM),n.config.beta&&(v.beta=n.config.alpha.toString()),n.config.translationArea&&(v.translation_area=n.config.translationArea),h&&(v.install_day=TD(b)),n.user){let _=a3(n.user);_&&Object.keys(_).forEach(k=>{v[k]=_[k]})}else v.user_type="anonymous";n.config.translationMode&&(v.translation_mode=n.config.translationMode),v.userscript=o.toString(),D?v.is_new_user_today="1":v.is_new_user_today="0",M?v.is_new_user_this_week="1":v.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?v.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():v.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),v.page_type=O,s?v.main_frame=0:v.main_frame=1,!c){let _=n.url;try{let k=new URL(_);v.site_host=k.hostname}catch{v.site_host="unknown"}n.sourceLanguage&&(v.source_language=n.sourceLanguage)}return{...A,params:v}});if(i)return;let L=await ce({responseType:"text",url:I,method:"POST",body:JSON.stringify({client_id:m,user_id:m,events:y})})}catch{}}function bD(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;ae.removeEventListener("message",n)),t.length=0}function xD(t,e,n,r){return new Promise(a=>{let i=o=>{let s=o.data;vD(e,n,s)&&s.id===r&&(t.removeEventListener("message",i),a(s.response))};t.addEventListener("message",i)})}function ED(t,e,n,r){let a=i=>{let o=i.data;a1(e,"tell",n,o)&&r(o.body)};return t.addEventListener("message",a),[t,a]}function e1(t,e,n,r,a,i){let o=async s=>{let u=s.data;if(a1(n,"ask",r,u)){let l=await i(u.body);e=s.source,e.postMessage(yD(n,r,u.id,l),s.origin)}};return t.addEventListener("message",o),[t,o]}function CD(t,e,n,r,a){let i=Math.random().toString();return t.postMessage(r1(e,"tell",n,i,r),a)}async function t1(t,e,n,r,a,i,o){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let p=setTimeout(()=>c(new Error(`Failed to get response within ${o}ms`)),o),m=await xD(t,n,r,s);clearTimeout(p),l(m)});return e.postMessage(r1(n,"ask",r,s,a),i),u}var oa=class t{constructor(e,n,r=window,a="*"){this.protocol=e;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;e1(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(e,n=10,r=500){for(let a=0;a<=n;a++)try{return await e.ping({timeout:r}),e}catch{continue}throw new Error(`Could not connect on protocol ${e.protocol.type} after ${n*r}ms`)}static parent(e,n,r="*",a=window){let i=n.contentWindow;if(ia(i))return new t(e,i,a,r);throw new Error("iframe.contentWindow was null")}static iframe(e,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new t(e,a,r,n)}static rootIframe(e,n="*",{thisWindow:r=window}={}){return new t(e,null,r,n)}getSystemProtocol(e){return{type:`system|${e}`}}listeners=[];async ping({timeout:e=1e4}){await t1(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,e)}handleTell(e,n){this.listeners.push(ED(this.thisWindow,this.protocol,e,n))}tell(e,n){CD(this.targetWindow,this.protocol,e,n,this.targetOrigin)}handleAsk(e,n){this.listeners.push(e1(this.thisWindow,this.targetWindow,this.protocol,e,this.targetOrigin,n))}ask(e,n,r=1e4){if(this.targetWindow)return t1(this.thisWindow,this.targetWindow,this.protocol,e,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){SD(this.listeners)}};var i1;async function o1(){if(He()){let e=globalThis;for(;e.top!=e.self;)e=e.top;let n=oa.iframe(Zu,"*",{targetWindow:e});i1=n,await oa.connect(n).catch(r=>{B.error("connect with parent frame error",r)})}}function s1(){return i1}d();function u1(t,e){let n=e.matches||[],r=e.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(t)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(t))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(t)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(t))return!0}return!1}d();d();d();d();d();d();function l1(t){return t.replace(//g,">")}d();var Bl=!1,wD=ye();function c1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function DD(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&d1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(sa(i,$u)){if(a===!0)return!0;continue}if(fs(i.nodeName,e.inlineTags))return!0;if(!Tp(i,e))return!1}}return!0}function yp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(fs(t.nodeName,n)||Tp(t,e)){if(sa(t,ob)||fs(t.nodeName,["BR"]))return!1;if(sa(t,$u))return!0;if(Tp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return DD(t,e)}else return sa(t,$u);return!1}function d1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&sa(t,ib,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&sa(t,J4))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||fs(t.nodeName,i))}function Ni(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!g1(r)&&r.length>=n}function p1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(g1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function g1(t){for(let e=0;e127)return!1;return!0}function m1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function f1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function h1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function b1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function T1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function sa(t,e,n=!1){return vp(t,e,"1",n)}function vp(t,e,n,r=!1){return Bl&&!r?t[xn]?!!(t[xn]&&t[xn][e]===n):!1:t.dataset[e]===n}function Ui(t){return(t.innerText||t.textContent||"").trim()}function Sp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Il(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function lt(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(Bl&&!r?(t[xn]||(t[xn]={}),t[xn][e]||(t[xn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Rl(t,e,n=!1){if(Bl&&!n){if(!t[xn]||!t[xn][e])return;delete t[xn][e]}else delete t.dataset[e]}function qi(t,e,n=!1){return Bl&&!n?!t[xn]||!t[xn][e]?void 0:t[xn][e]:t.dataset[e]}function Tp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!fs(t.nodeName,n)}function Ee(){if(!globalThis||!globalThis.location)return"https://example.com";if(!He())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function En(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){B.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else B.warn("injectCSS failed, rootDocument does not have head node",t)}function ji(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(wD){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function fs(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function y1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function v1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||d1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return B.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function S1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();d();d();var ql,Fe,D1,AD,hs,x1,A1,zl={},k1=[],kD=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function ua(t,e){for(var n in e)t[n]=e[n];return t}function P1(t){var e=t.parentNode;e&&e.removeChild(t)}function Ep(t,e,n){var r,a,i,o={};for(i in e)i=="key"?r=e[i]:i=="ref"?a=e[i]:o[i]=e[i];if(arguments.length>2&&(o.children=arguments.length>3?ql.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)o[i]===void 0&&(o[i]=t.defaultProps[i]);return Ol(t,o,r,a,null)}function Ol(t,e,n,r,a){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:a??++D1};return a==null&&Fe.vnode!=null&&Fe.vnode(i),i}function qt(t){return t.children}function Hi(t,e){this.props=t,this.context=e}function Wi(t,e){if(e==null)return t.__?Wi(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e0?Ol(g.type,g.props,g.key,g.ref?g.ref:null,g.__v):g)!=null){if(g.__=n,g.__b=n.__b+1,(m=h[c])===null||m&&g.key==m.key&&g.type===m.type)h[c]=void 0;else for(p=0;p=n.__.length&&n.__.push({__V:jl}),n.__[t]}function se(t){return bs=1,FD(G1,t)}function FD(t,e,n){var r=Wl(Ts++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):G1(void 0,e),function(i){var o=r.__N?r.__N[0]:r.__[0],s=r.t(o,i);o!==s&&(r.__N=[s,r.__[1]],r.__c.setState({}))}],r.__c=wt,!wt.u)){wt.u=!0;var a=wt.shouldComponentUpdate;wt.shouldComponentUpdate=function(i,o,s){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return c.__c});if(u.every(function(c){return!c.__N}))return!a||a.call(this,i,o,s);var l=!1;return u.forEach(function(c){if(c.__N){var p=c.__[0];c.__=c.__N,c.__N=void 0,p!==c.__[0]&&(l=!0)}}),!!l&&(!a||a.call(this,i,o,s))}}return r.__N||r.__}function Ae(t,e){var n=Wl(Ts++,3);!Fe.__s&&K1(n.__H,e)&&(n.__=t,n.i=e,wt.__H.__h.push(n))}function Ve(t){return bs=5,Ue(function(){return{current:t}},[])}function Ue(t,e){var n=Wl(Ts++,7);return K1(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function $e(t,e){return bs=8,Ue(function(){return t},e)}function Kl(t){var e=wt.context[t.__c],n=Wl(Ts++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(wt)),e.props.value):t.__}function MD(){for(var t;t=W1.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Hl),t.__H.__h.forEach(Dp),t.__H.__h=[]}catch(e){t.__H.__h=[],Fe.__e(e,t.__v)}}Fe.__b=function(t){typeof t.type!="function"||t.o||t.type===qt?t.o||(t.o=t.__&&t.__.o?t.__.o:""):t.o=(t.__&&t.__.o?t.__.o:"")+(t.__&&t.__.__k?t.__.__k.indexOf(t):0),wt=null,z1&&z1(t)},Fe.__r=function(t){N1&&N1(t),Ts=0;var e=(wt=t.__c).__H;e&&(wp===wt?(e.__h=[],wt.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=jl,n.__N=n.i=void 0})):(e.__h.forEach(Hl),e.__h.forEach(Dp),e.__h=[])),wp=wt},Fe.diffed=function(t){U1&&U1(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(W1.push(e)!==1&&O1===Fe.requestAnimationFrame||((O1=Fe.requestAnimationFrame)||BD)(MD)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==jl&&(n.__=n.__V),n.i=void 0,n.__V=jl})),wp=wt=null},Fe.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Hl),n.__h=n.__h.filter(function(r){return!r.__||Dp(r)})}catch(r){e.some(function(a){a.__h&&(a.__h=[])}),e=[],Fe.__e(r,n.__v)}}),q1&&q1(t,e)},Fe.unmount=function(t){j1&&j1(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Hl(r)}catch(a){e=a}}),n.__H=void 0,e&&Fe.__e(e,n.__v))};var H1=typeof requestAnimationFrame=="function";function BD(t){var e,n=function(){clearTimeout(r),H1&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);H1&&(e=requestAnimationFrame(n))}function Hl(t){var e=wt,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),wt=e}function Dp(t){var e=wt;t.__c=t.__(),wt=e}function K1(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function G1(t,e){return typeof e=="function"?e(t):e}d();var V1=["*://*/*","*","*://*"],Y1="immersive-translate-wildcard-placeholder.com";function Ap(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>V1.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(V1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return RD(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,Y1),m;try{m=new URL(p)}catch{return B.debug("invalid match pattern",p,"raw match value:",c),!1}let g=m.host,f=m.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=ID(l+":",$1(g),$1(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function $1(t){return t.replaceAll(Y1,"*")}function ID(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function dt(t,e){return Ap(t,e)!==null}function RD(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}var OD=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function Cn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(Cn(t,i))return!1;if(Cn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!Cn(t,o)),c;function p(){return n&&n.display?!!OD.includes(n.display):Cn(t,r)}}var Kt=Cn;function $a(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function ys(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function fr(t,e=!1){let n=Xo;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Va(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return fr(n,e)}function Vi(t,e){return na(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function kp(t){let{rule:e}=t,n=zD(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function zD(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function vs(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",yt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),lt(r,rb,e.toString());let a=kp(t);return r.append(Ye.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function $i(t,e){return t.querySelector(`[${q0}='${e}']`)}function Q1(){document.querySelectorAll(`[${q0}]`).forEach(e=>{e.remove()})}function J1(){document.querySelectorAll(`.${yt}-error`).forEach(e=>{e.remove()})}function Z1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{ji(n)&&e.push(n)}),e}function Pp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},m=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),g=new RegExp(a.replace("{word}",m.map(f=>f.k).join("|")),"g");l=l.replace(g,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let m=new RegExp(p,"gi");l=l.replace(m,(g,f)=>{let T=c++;return e[`${T}`]=l1(f),o.length>2?g.replace(f,`<${o[2]}${T}>`):g.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){B.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function Ss(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||T1(s)||m1(s)||b1(s)||f1(s)||h1(s)||UD(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ni(i,n,r)}function Nr(t){return t.nodeType===Node.ELEMENT_NODE}function X1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Lp(){return await At("fakeUserId","")}async function ND(){return await At("installedAt","")}async function Gl(t){let n=Me().INSTALL_FROM,r=Nt(),a=await ND(),i=await Lp(),o=await Pn(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Jt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function e2(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await Fp(t,e);r(a)})()},[t,e,r]),n}async function Fp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!et()&&ye()||ut().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>dt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>dt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}d();function Mp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(lb),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${H0}-theme-${t}`):a.push(`${j0}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(H0):a.push(j0),a}function Bp(t){let e=["notranslate",Qu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function a2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Va(n,!0),m="afterend",g=p[0],f=p[1],T=`${g}(\\d+)${f}`,b=new RegExp(T,"g"),h=Ye.sanitize(u);o.length>0&&(h=h.replace(b,I=>{let S=h.indexOf(I),y=h[S-1]===" ",L=h[S+I.length]===" ",v=I.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),O=Number(v);if(isNaN(O))return I;let _=o[O];if(_&&_.type==="element"){let k=_.value.outerHTML;return y||(k=" "+k),L||(k=k+" "),k}else B.error("variable type not supported",_,I);return I}));let E=Mp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&E.push(ub);let D=Bp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${E.join(" ")}" ${dr}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${dr}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${dr}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:m}}function Vl(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";m&&(T=ca(Ip(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let E=Rp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",I=ys(E+D+M),S=I[0]+h+I[1];if(E===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=ys(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Rp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);m&&(b=ca(Ip(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",E=ys(T+b+h),D=E[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+E[1];if(T===" ")D=D.trimStart();else{let M=ys(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Rp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Ip(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(m=s[c-1].text),c/g,">"))}t.targetText=Ye.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` +`)}n.push(...g)}for(let a=0;a{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&mp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?g.push(T):m.push(T))});let f=g.concat(m).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:g,explicitProps:m}}var ps=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Jt(s),l=Object.keys(gr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=gr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&et())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let m=!!p.canary,g=!!p.alpha,f=!!p.beta;return c===t[e]||m&&i||g&&(r||i)||f&&(a||r||i)?!0:!g&&!f&&!m}).map(c=>vl(e,c,t))};function gs(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function _3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}var Fi=[];async function Sl(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function F3(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await cD(e,t)}async function M3(t){let e=Ln(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await lD(n,e)}async function lD(t,e){let n=await Sl(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function cD(t,e){let n=await Sl(t);return(await pD()).includes(t)||await dD(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function dD(t){let e="cache_list",n=await Sl(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Fi.push(t)},a.onerror=i=>{n.close()}}async function pD(){if(Fi&&Fi.length>0)return Fi;let t=await Sl(Q+"-cacheList","cache_list");return Fi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Fi}d();d();var fp="Original";function Qe(){return fp}function gn(t){fp=t,B3(fp)}d();var R3="auto",xl="auto",I3="auto";function O3(t){R3=t}function qn(t){xl=t}function vt(){return xl!=="auto"?xl:I3!=="auto"?I3:R3}function El(){return xl}d();function Ga(t){return t?.id?.endsWith("pdfWebPage")||!1}function ra(t){try{if(!t||!Ga(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Je={},aa=async function(t,e){let{method:n,data:r}=t,a=await Je.updateGlobalContext(),i=Date.now();if(B.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Je.translateTheWholePage(r),Xe(Xn,i);else if(n==="translateTheMainPage")await Je.translateTheMainPage(r),Xe(Xn,i);else if(n==="translateToThePageEndImmediately")await Je.translateToThePageEndImmediately(r),Xe(Xn,i);else if(n==="toggleTranslatePage")await Je.toggleTranslatePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheWholePage")await Je.toggleTranslateTheWholePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheMainPage")await Je.toggleTranslateTheMainPage(r),Xe(Xn,i);else if(n==="toggleOnlyTransation")await Je.ensureSwitchTranslationMode(r),Xe(Xn,i);else if(n==="translatePage")await Je.translatePage(a,r),Xe(Xn,i);else if(n==="toggleTranslationMask")await Je.toggleTranslationMask(r);else if(n==="restorePage")Je.restorePage();else if(n==="retryFailedParagraphs")Je.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Je.switchTranslationMode(r.mode),await Je.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Je.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Ku,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Je.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Yo,{detail:r}));else if(n==="translateWithOpenAI")await Je.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Je.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Je.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Je.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Je.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Je.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Je.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")He()||await Je.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!He())return JSON.stringify(a)}};function z3(t){Object.assign(Je,t)}function N3(t){Object.assign(Je,t)}function U3(t){Object.assign(Je,t)}var gD=function(t,e){let{method:n,data:r}=t;if(B.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Qe();if(n==="getCurrentPageLanguage"){let a=vt();return Je.detectCurrentPageLanguage().catch(i=>{B.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return qn(r),vt();if(n==="getContextString"){let a=Je.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Je.getPureGlobalContext();return ra(a?.rule)}}},Cl,wl;function q3(){let t=Dl();He()||mD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Dl(){return Cl||(Cl=new ea("content_script",!1).getConnection("main",aa),Cl)}function mD(){return wl||(wl=new ea("content_script",!1).getConnection("main_sync",gD,{sync:!0}),wl)}d();var hp=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Al="https://transmart.qq.com/api/imt",zr=class t{static langMapReverse=new Map(hp.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await ce({url:Al,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function fD(t,e){return Math.floor(Math.random()*(e-t+1))+t}var hD=30,bp="RATE_LIMITER_TICKS",Mi=class t{static strictTicks={};static clearStrictTicks(){ds(bp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await bl(bp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){B.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await ds(bp,JSON.stringify(this.strictTicks))}catch(a){B.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=fD(4,hD);await vr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function St(t){return await Dl().sendMessage("background:main",t)}function ce(t){return au()?ul({method:"request",data:t}):ye()||ru()?(t.fetchPolyfill=globalThis.GM_fetch,Wa(t)):St({method:"fetch",data:t})}function an(){return ye()?Pn():St({method:"getConfig"})}function mn(t){return ye()?cs(t):St({method:"setUserConfig",data:t})}function fn(){return ye()?Or():St({method:"getUserConfig"})}function ms(){return ye()?Zt():St({method:"getLocalConfig"})}function kl(t){return ye()?Xt(t):St({method:"setLocalConfig",data:t})}function j3(t){return ye()?C3(t):St({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=sl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||et()){if(t.translateService&&!Ju.includes(t.translateService))return Promise.resolve("auto");let r=r3(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await St({method:"detectLanguage",data:t});return Promise.resolve(e)}function H3(){return St({method:"detectTabLanguage"})}async function Pl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||et()){let n=t.substring(0,200);e=await zr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function B3(t){let e=new CustomEvent(ja,{detail:t});if(document.dispatchEvent(e),ye())return;Dl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function W3(t){return ye()?M3(t):St({method:"queryParagraphCache",data:t})}async function K3(t){if(ye()){await F3(t);return}return St({method:"setParagraphCache",data:t})}async function G3(){if(ye())return Promise.resolve();await St({method:"mockRequest"})}function Bi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):St({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function Ii(t=""){return ye()||et()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function V3(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Ll(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):St({method:"openAboutPage"})}function Ri(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):St({method:"openInTab",data:t})}function $3(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):St({method:"openEbookViewerPage"})}function Y3(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):St({method:"openEbookBuilderPage"})}function _l(t){et()}function Oi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):St({method:"openPdfViewerPage",data:{url:e}})}function Q3(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):St({method:"openSubtitleBuilderPage"})}function zi(t){return ye()?Promise.resolve():St({method:"setBadge",data:{text:t}})}function J3(){return ye()?(B.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):St({method:"autoSyncLatestConfig"})}function Fl(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function Z3(t,e){return ye()?Mi.getDelay(t,e):St({method:"getDelay",data:{key:t,options:e}})}var X3="G-MKMD9LWFTR";async function it(t,e,n){try{let r=ss(),a=Me(),i=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(i=!1);let o=ye(),s=He(),u=a.PROD==="1",l=`report_${t}`,c=t.endsWith("_daily");if(c){if(s)return;let A=await Rr(l,0),v=Ml(new Date(A)),O=Date.now(),_=Ml(new Date(O));if(v===_)return;await s3(l,O)}else if(!n.config.telemetry)return;let p="sitc4WmvShWYwfU0dANM3Q",m=await At("fakeUserId","");m||(m=await Rr("fakeUserId",""),m&&await Xe("fakeUserId",m));let g=Nt(),f=new Date,T=await At("installedAt","");T||(T=await Rr("installedAt",""),T&&await Xe("installedAt",T)),m?T||(T=new Date(0).toISOString(),await Xe("installedAt",T)):(m=bD(32),await Xe("fakeUserId",m)),T||(T=f.toISOString(),await Xe("installedAt",T));let b=new Date(T),h=Ml(b),E=Ml(f),D=h===E,M=f.getTime()-b.getTime()<7*24*60*60*1e3,I=`https://www.google-analytics.com/mp/collect?measurement_id=${X3}&api_secret=${p}`;u||(I=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${X3}&api_secret=${p}`);let S=mi.parse(window.navigator.userAgent),y=e.map(A=>{let v=A.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser&&(v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown",r&&(v.browser_name=r.name,v.browser_version=r.version)),S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),n.translationService&&(v.translation_service||(v.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(v.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?v.openai_is_official="1":v.openai_is_official="0":v.openai_is_official="1"))),n.targetLanguage&&(v.target_language=n.targetLanguage),n.config.interfaceLanguage&&(v.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?v.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":v.enable_default_always_translated_urls="0",g&&(v.version=g),n.config.enableInputTranslation?v.enable_input_translation=n.config.enableInputTranslation?"1":"0":v.enable_input_translation="0",n.config.translationTheme&&(v.translation_theme=n.config.translationTheme),n.config.alpha&&(v.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?v.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):v.always_translate_languages="none",a.INSTALL_FROM&&(v.install_from=a.INSTALL_FROM),n.config.beta&&(v.beta=n.config.alpha.toString()),n.config.translationArea&&(v.translation_area=n.config.translationArea),h&&(v.install_day=TD(b)),n.user){let _=a3(n.user);_&&Object.keys(_).forEach(k=>{v[k]=_[k]})}else v.user_type="anonymous";n.config.translationMode&&(v.translation_mode=n.config.translationMode),v.userscript=o.toString(),D?v.is_new_user_today="1":v.is_new_user_today="0",M?v.is_new_user_this_week="1":v.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?v.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():v.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),v.page_type=O,s?v.main_frame=0:v.main_frame=1,!c){let _=n.url;try{let k=new URL(_);v.site_host=k.hostname}catch{v.site_host="unknown"}n.sourceLanguage&&(v.source_language=n.sourceLanguage)}return{...A,params:v}});if(i)return;let L=await ce({responseType:"text",url:I,method:"POST",body:JSON.stringify({client_id:m,user_id:m,events:y})})}catch{}}function bD(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;ae.removeEventListener("message",n)),t.length=0}function xD(t,e,n,r){return new Promise(a=>{let i=o=>{let s=o.data;vD(e,n,s)&&s.id===r&&(t.removeEventListener("message",i),a(s.response))};t.addEventListener("message",i)})}function ED(t,e,n,r){let a=i=>{let o=i.data;a1(e,"tell",n,o)&&r(o.body)};return t.addEventListener("message",a),[t,a]}function e1(t,e,n,r,a,i){let o=async s=>{let u=s.data;if(a1(n,"ask",r,u)){let l=await i(u.body);e=s.source,e.postMessage(yD(n,r,u.id,l),s.origin)}};return t.addEventListener("message",o),[t,o]}function CD(t,e,n,r,a){let i=Math.random().toString();return t.postMessage(r1(e,"tell",n,i,r),a)}async function t1(t,e,n,r,a,i,o){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let p=setTimeout(()=>c(new Error(`Failed to get response within ${o}ms`)),o),m=await xD(t,n,r,s);clearTimeout(p),l(m)});return e.postMessage(r1(n,"ask",r,s,a),i),u}var oa=class t{constructor(e,n,r=window,a="*"){this.protocol=e;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;e1(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(e,n=10,r=500){for(let a=0;a<=n;a++)try{return await e.ping({timeout:r}),e}catch{continue}throw new Error(`Could not connect on protocol ${e.protocol.type} after ${n*r}ms`)}static parent(e,n,r="*",a=window){let i=n.contentWindow;if(ia(i))return new t(e,i,a,r);throw new Error("iframe.contentWindow was null")}static iframe(e,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new t(e,a,r,n)}static rootIframe(e,n="*",{thisWindow:r=window}={}){return new t(e,null,r,n)}getSystemProtocol(e){return{type:`system|${e}`}}listeners=[];async ping({timeout:e=1e4}){await t1(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,e)}handleTell(e,n){this.listeners.push(ED(this.thisWindow,this.protocol,e,n))}tell(e,n){CD(this.targetWindow,this.protocol,e,n,this.targetOrigin)}handleAsk(e,n){this.listeners.push(e1(this.thisWindow,this.targetWindow,this.protocol,e,this.targetOrigin,n))}ask(e,n,r=1e4){if(this.targetWindow)return t1(this.thisWindow,this.targetWindow,this.protocol,e,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){SD(this.listeners)}};var i1;async function o1(){if(He()){let e=globalThis;for(;e.top!=e.self;)e=e.top;let n=oa.iframe(Zu,"*",{targetWindow:e});i1=n,await oa.connect(n).catch(r=>{B.error("connect with parent frame error",r)})}}function s1(){return i1}d();function u1(t,e){let n=e.matches||[],r=e.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(t)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(t))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(t)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(t))return!0}return!1}d();d();d();d();d();d();function l1(t){return t.replace(//g,">")}d();var Bl=!1,wD=ye();function c1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function DD(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&d1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(sa(i,$u)){if(a===!0)return!0;continue}if(fs(i.nodeName,e.inlineTags))return!0;if(!Tp(i,e))return!1}}return!0}function yp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(fs(t.nodeName,n)||Tp(t,e)){if(sa(t,ob)||fs(t.nodeName,["BR"]))return!1;if(sa(t,$u))return!0;if(Tp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return DD(t,e)}else return sa(t,$u);return!1}function d1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&sa(t,ib,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&sa(t,J4))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||fs(t.nodeName,i))}function Ni(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!g1(r)&&r.length>=n}function p1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(g1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function g1(t){for(let e=0;e127)return!1;return!0}function m1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function f1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function h1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function b1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function T1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function sa(t,e,n=!1){return vp(t,e,"1",n)}function vp(t,e,n,r=!1){return Bl&&!r?t[xn]?!!(t[xn]&&t[xn][e]===n):!1:t.dataset[e]===n}function Ui(t){return(t.innerText||t.textContent||"").trim()}function Sp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Il(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function lt(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(Bl&&!r?(t[xn]||(t[xn]={}),t[xn][e]||(t[xn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Rl(t,e,n=!1){if(Bl&&!n){if(!t[xn]||!t[xn][e])return;delete t[xn][e]}else delete t.dataset[e]}function qi(t,e,n=!1){return Bl&&!n?!t[xn]||!t[xn][e]?void 0:t[xn][e]:t.dataset[e]}function Tp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!fs(t.nodeName,n)}function Ee(){if(!globalThis||!globalThis.location)return"https://example.com";if(!He())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function En(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){B.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else B.warn("injectCSS failed, rootDocument does not have head node",t)}function ji(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(wD){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function fs(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function y1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function v1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||d1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return B.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function S1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();d();d();var ql,Fe,D1,AD,hs,x1,A1,zl={},k1=[],kD=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function ua(t,e){for(var n in e)t[n]=e[n];return t}function P1(t){var e=t.parentNode;e&&e.removeChild(t)}function Ep(t,e,n){var r,a,i,o={};for(i in e)i=="key"?r=e[i]:i=="ref"?a=e[i]:o[i]=e[i];if(arguments.length>2&&(o.children=arguments.length>3?ql.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)o[i]===void 0&&(o[i]=t.defaultProps[i]);return Ol(t,o,r,a,null)}function Ol(t,e,n,r,a){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:a??++D1};return a==null&&Fe.vnode!=null&&Fe.vnode(i),i}function qt(t){return t.children}function Hi(t,e){this.props=t,this.context=e}function Wi(t,e){if(e==null)return t.__?Wi(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e0?Ol(g.type,g.props,g.key,g.ref?g.ref:null,g.__v):g)!=null){if(g.__=n,g.__b=n.__b+1,(m=h[c])===null||m&&g.key==m.key&&g.type===m.type)h[c]=void 0;else for(p=0;p=n.__.length&&n.__.push({__V:jl}),n.__[t]}function se(t){return bs=1,FD(G1,t)}function FD(t,e,n){var r=Wl(Ts++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):G1(void 0,e),function(i){var o=r.__N?r.__N[0]:r.__[0],s=r.t(o,i);o!==s&&(r.__N=[s,r.__[1]],r.__c.setState({}))}],r.__c=wt,!wt.u)){wt.u=!0;var a=wt.shouldComponentUpdate;wt.shouldComponentUpdate=function(i,o,s){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return c.__c});if(u.every(function(c){return!c.__N}))return!a||a.call(this,i,o,s);var l=!1;return u.forEach(function(c){if(c.__N){var p=c.__[0];c.__=c.__N,c.__N=void 0,p!==c.__[0]&&(l=!0)}}),!!l&&(!a||a.call(this,i,o,s))}}return r.__N||r.__}function Ae(t,e){var n=Wl(Ts++,3);!Fe.__s&&K1(n.__H,e)&&(n.__=t,n.i=e,wt.__H.__h.push(n))}function Ve(t){return bs=5,Ue(function(){return{current:t}},[])}function Ue(t,e){var n=Wl(Ts++,7);return K1(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function $e(t,e){return bs=8,Ue(function(){return t},e)}function Kl(t){var e=wt.context[t.__c],n=Wl(Ts++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(wt)),e.props.value):t.__}function MD(){for(var t;t=W1.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Hl),t.__H.__h.forEach(Dp),t.__H.__h=[]}catch(e){t.__H.__h=[],Fe.__e(e,t.__v)}}Fe.__b=function(t){typeof t.type!="function"||t.o||t.type===qt?t.o||(t.o=t.__&&t.__.o?t.__.o:""):t.o=(t.__&&t.__.o?t.__.o:"")+(t.__&&t.__.__k?t.__.__k.indexOf(t):0),wt=null,z1&&z1(t)},Fe.__r=function(t){N1&&N1(t),Ts=0;var e=(wt=t.__c).__H;e&&(wp===wt?(e.__h=[],wt.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=jl,n.__N=n.i=void 0})):(e.__h.forEach(Hl),e.__h.forEach(Dp),e.__h=[])),wp=wt},Fe.diffed=function(t){U1&&U1(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(W1.push(e)!==1&&O1===Fe.requestAnimationFrame||((O1=Fe.requestAnimationFrame)||BD)(MD)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==jl&&(n.__=n.__V),n.i=void 0,n.__V=jl})),wp=wt=null},Fe.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Hl),n.__h=n.__h.filter(function(r){return!r.__||Dp(r)})}catch(r){e.some(function(a){a.__h&&(a.__h=[])}),e=[],Fe.__e(r,n.__v)}}),q1&&q1(t,e)},Fe.unmount=function(t){j1&&j1(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Hl(r)}catch(a){e=a}}),n.__H=void 0,e&&Fe.__e(e,n.__v))};var H1=typeof requestAnimationFrame=="function";function BD(t){var e,n=function(){clearTimeout(r),H1&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);H1&&(e=requestAnimationFrame(n))}function Hl(t){var e=wt,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),wt=e}function Dp(t){var e=wt;t.__c=t.__(),wt=e}function K1(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function G1(t,e){return typeof e=="function"?e(t):e}d();var V1=["*://*/*","*","*://*"],Y1="immersive-translate-wildcard-placeholder.com";function Ap(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>V1.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(V1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return RD(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,Y1),m;try{m=new URL(p)}catch{return B.debug("invalid match pattern",p,"raw match value:",c),!1}let g=m.host,f=m.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=ID(l+":",$1(g),$1(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function $1(t){return t.replaceAll(Y1,"*")}function ID(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function dt(t,e){return Ap(t,e)!==null}function RD(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}var OD=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function Cn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(Cn(t,i))return!1;if(Cn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!Cn(t,o)),c;function p(){return n&&n.display?!!OD.includes(n.display):Cn(t,r)}}var Kt=Cn;function $a(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function ys(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function fr(t,e=!1){let n=Xo;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Va(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return fr(n,e)}function Vi(t,e){return na(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function kp(t){let{rule:e}=t,n=zD(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function zD(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function vs(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",yt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),lt(r,rb,e.toString());let a=kp(t);return r.append(Ye.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function $i(t,e){return t.querySelector(`[${q0}='${e}']`)}function Q1(){document.querySelectorAll(`[${q0}]`).forEach(e=>{e.remove()})}function J1(){document.querySelectorAll(`.${yt}-error`).forEach(e=>{e.remove()})}function Z1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{ji(n)&&e.push(n)}),e}function Pp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},m=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),g=new RegExp(a.replace("{word}",m.map(f=>f.k).join("|")),"g");l=l.replace(g,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let m=new RegExp(p,"gi");l=l.replace(m,(g,f)=>{let T=c++;return e[`${T}`]=l1(f),o.length>2?g.replace(f,`<${o[2]}${T}>`):g.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){B.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function Ss(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||T1(s)||m1(s)||b1(s)||f1(s)||h1(s)||UD(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ni(i,n,r)}function Nr(t){return t.nodeType===Node.ELEMENT_NODE}function X1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Lp(){return await At("fakeUserId","")}async function ND(){return await At("installedAt","")}async function Gl(t){let n=Me().INSTALL_FROM,r=Nt(),a=await ND(),i=await Lp(),o=await Pn(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Jt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function e2(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await Fp(t,e);r(a)})()},[t,e,r]),n}async function Fp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!et()&&ye()||ut().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>dt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>dt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}d();function Mp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(lb),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${H0}-theme-${t}`):a.push(`${j0}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(H0):a.push(j0),a}function Bp(t){let e=["notranslate",Qu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function a2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Va(n,!0),m="afterend",g=p[0],f=p[1],T=`${g}(\\d+)${f}`,b=new RegExp(T,"g"),h=Ye.sanitize(u);o.length>0&&(h=h.replace(b,I=>{let S=h.indexOf(I),y=h[S-1]===" ",L=h[S+I.length]===" ",v=I.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),O=Number(v);if(isNaN(O))return I;let _=o[O];if(_&&_.type==="element"){let k=_.value.outerHTML;return y||(k=" "+k),L||(k=k+" "),k}else B.error("variable type not supported",_,I);return I}));let E=Mp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&E.push(ub);let D=Bp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${E.join(" ")}" ${dr}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${dr}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${dr}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:m}}function Vl(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";m&&(T=ca(Ip(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let E=Rp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",I=ys(E+D+M),S=I[0]+h+I[1];if(E===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=ys(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Rp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);m&&(b=ca(Ip(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",E=ys(T+b+h),D=E[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+E[1];if(T===" ")D=D.trimStart();else{let M=ys(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Rp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Ip(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(m=s[c-1].text),c/g,">"))}t.targetText=Ye.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` `).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(t.id),elements:[],isVertical:!1,rootFrame:t.commonAncestorContainer,text:t.text,variables:r,inline:a,preWhitespace:t.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Va(e);if(l.length>2){let c=l[2];return qD({delimiterTag:c,targetText:t.targetText,inline:a,preWhitespace:t.isPreWhitespace||!1,wrapperPrefix:e.rule.wrapperPrefix,wrapperSuffix:e.rule.wrapperSuffix,targetWrapperTag:e.rule.targetWrapperTag,translationTheme:e.state.translationTheme,translationBlockStyle:e.rule.translationBlockStyle,translationClasses:e.rule.translationClasses,variables:r}).html}else{let c=a2(u,{id:Number(t.id),url:"https://google.com",text:t.targetText,from:"auto",to:"auto",fromByClient:"auto"},e);return c.html}}function Ip(t){return(t?.innerText||t.textContent||"").replace(/\s+/g," ")||""}function qD(t){let{delimiterTag:e,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=t;o=o||[];let p=t.targetText;p=Ye.sanitize(p);let m=p,g=new RegExp(`<${e}(\\d+)>(.*?)`,"g"),f=new RegExp(`<${e}(\\d+)>`);o.length>0&&(m=m.replace(g,E=>{let D=m.indexOf(E),M=m[D-1]===" ",I=m[D+E.length]===" ",S=E.match(f);if(!S)return E;let y=S[1],L=Number(y);if(isNaN(L))return E;let A=o[Number(L)];if(A&&A.type==="element"){let v=A.value.outerHTML;return M||(v=" "+v),I||(v=v+" "),v}else if(A&&A.type==="text"){let v=A.value;return M||(v=" "+v),I||(v=v+" "),v}else B.error("variable type not supported",A,E);return E}));let T=Mp(l,n,r||[],s),b=Bp(l),h="";return c&&(h=`style="${c}"`),m=`<${a} ${h} class="${T.join(" ")}" ${dr}="1"><${a} class="${b.join(" ")}" ${dr}="1">${m}`,n||(i==="smart"?m=`
${m}`:m=`${i}${m}`),n&&(i!=="smart"?m=`${i}${m}`:m=`<${a} class="notranslate" ${dr}="1"> ${m}`),u==="smart"?m=`${m}`:m=`${m}${u}`,{html:m,position:"afterend"}}function Rp(t){let e=t[t.length-1];return e?e.text:""}function Op(t){let{text:e,delimiters:n,variables:r}=t,a=e;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=e;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let p=c.match(s);if(!p)return c;let m=p[1],g=Number(m);if(isNaN(g))return c;let f=r[m];return f||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}var De=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(e,n,r){this.serviceConfig=e,this.generalConfig=n,this.translationOptions=r,e?.retry&&(this.retry=e.retry),e?.requestTimeout&&(this.requestTimeout=Number(e.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let e=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(e.limit=Number(n.limit)),n?.interval&&(e.interval=Number(n.interval)),e}formatRateLimit(e){return e.limit<1&&(e.interval=Math.round(1e3/e.limit),e.limit=1),e}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(e){throw new Error("Not implemented")}translateList(e){throw new Error("Not implemented")}async multipleTranslate(e,n,r){if(e.sentences.length===0)return{sentences:[]};let{sentences:a}=e,i=!1,o=!1,s=[],u=null,l=new Set;for(let b of a)b.from&&b.from!=="auto"&&l.add(b.from),b.refresh&&(i=!0),b.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let p=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(p=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(p=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=L3(a,c,p)}catch(b){if(r)for(let h=0;hb));let m=[],g=[],f=(b,h,E)=>{let D="";if(h.translatedTexts&&h.translatedTexts[0]&&(D=h.translatedTexts[0]),g[b]||(g[b]=h,g[b].translatedTexts=Array(h.sentenceTotalParts).fill(null)),g[b].hasError)return;if(E){let S=E instanceof $?new $(E.name,E.message).initNetWork(E.status).initData(E.data):E;g[b].hasError=!0,h.callback&&h.callback(S,null,h.sentence);return}g[b].translatedTexts[h.partIndex]=D;let M=g[b],I=0;for(let S=0;S{let I=h.from;if(h.fromByClient&&h.fromByClient!=="auto"&&(I=h.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:h.tempSentences.map(y=>y.text),forces:h.tempSentences.map(y=>y.force),xpaths:h.tempSentences.map(y=>y.xpath||""),from:I,to:h.to,url:E,options:n,refresh:i,debug:o}),sourceTempSentences:h.tempSentences};{let S=sb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(S=this.serviceConfig.translationTextSeparator);let y=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(y=this.serviceConfig.newlinePlaceholderDelimiters);let L=[],A=fr(this.serviceConfig);if(h.tempSentences.forEach((q,F)=>{let C=Pp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:A,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:h.to});q.force!==!0&&(C&&C.text&&C.text.trim().lengthF.text);return Promise.resolve({sourceTempSentences:h.tempSentences,text:q,from:I,to:h.to})}let v="";y&&y.length>=2?v=L.map((q,F)=>{let{item:C}=q;return F===L.length-1?C.text:C.text+y[0]+(F+1)+y[1]}).join(""):v=L.map(({item:q})=>q.text).join(S);let O=await this.translate({text:v,from:I,to:h.to,url:E,options:{...n,rawTextArrayLength:L.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:_}=O,k=[];if(y&&y.length>=2){let q=`${y[0]}\\d+${y[1]}`;y&&y.length>=3&&(q=y[2]);let F=new RegExp(q,"g");k=_.split(F)}else k=_.split(S);let N=[];if(k.length>L.length){for(let q=0;qq.text);return A=fr(this.serviceConfig,!0),N.forEach((q,F)=>{let C=L[F],P=C.index,U=C.variables||{};Object.keys(U).length>0&&(q=Op({text:q,delimiters:A,variables:U})),z[P]=q}),{sourceTempSentences:h.tempSentences,text:z,from:O.from,to:O.to}}};m.push(M().then(I=>{let{text:S,sourceTempSentences:y}=I;for(let L=0;L{if(I instanceof $&&I.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let S=0;S{let h=b.sentence.text;return b.translatedTexts&&b.translatedTexts.length>0&&(h=b.translatedTexts.join("")),{...b.sentence,text:h}})}}async formatAndTranslateList(e){let n={...e},{forces:r}=e,a=[],i=fr(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=e;if(l.forEach((p,m)=>{let g=Pp({text:p,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:e.to});r&&r[m]!==!0&&(g&&g.text&&g.text.trim().lengthp.text),n.xpaths=a.map(p=>p.xpath)}catch(l){B.debug("formatAndTranslateList error",e,l)}let o=await this.translateList(n),{text:s}=o,u=e.text.map(l=>l);return i=fr(this.serviceConfig,!0),s.forEach((l,c)=>{let p=a[c];if(p){let m=p.index,g=p.variables,f=Object.keys(g);u[m]=l,f.length>0&&(u[m]=Op({text:l,delimiters:i,variables:g}))}}),{...o,text:u}}detectLanguageLocally(e){return Ie({text:e,minLength:18,pageLangs:[vt(),"en"]})}detectLanguageRemotely(e){return Promise.resolve("auto")}detectLanguage(e){return e.length>=50?this.detectLanguageLocally(e):this.detectLanguageRemotely(e)}};d();d();var Qi="input is invalid type",zp=typeof window=="object",da=zp?window:{};da.JS_SHA256_NO_WINDOW&&(zp=!1);var jD=!zp&&typeof self=="object",HD=!da.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;HD?da=global:jD&&(da=self);var jH=!da.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,HH=typeof define=="function"&&define.amd,xs=!da.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),WD=[-2147483648,8388608,32768,128],er=[24,16,8,0],$l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Yl=["hex","array","digest","arrayBuffer"],jt=[];(da.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});xs&&(da.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var o2=function(t,e){return function(n){return new Ht(e,!0).update(n)[t]()}},u2=function(t){var e=o2("hex",t);e.create=function(){return new Ht(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Ht.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=WD[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};Ht.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,m,g,f,T,b,h,E,D;for(l=16;l<64;++l)g=u[l-15],c=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=u[l-2],p=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,g=u[0]-1413257819,s=g-150054599<<0,r=g+24177077<<0):(b=704751109,g=u[0]-210244248,s=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,m=b^t&n^D,T=a&i^~a&o,g=s+p+T+$l[l]+u[l],f=c+m,s=r+g<<0,r=g+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,m=h^r&e^b,T=s&a^~s&i,g=o+p+T+$l[l+1]+u[l+1],f=c+m,o=n+g<<0,n=g+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),E=n&r,m=E^n&t^h,T=o&s^~o&a,g=i+p+T+$l[l+2]+u[l+2],f=c+m,i=e+g<<0,e=g+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,m=D^e&r^E,T=i&o^~i&s,g=a+p+T+$l[l+3]+u[l+3],f=c+m,a=t+g<<0,t=g+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};Ht.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};Ht.prototype.toString=Ht.prototype.hex;Ht.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};Ht.prototype.array=Ht.prototype.digest;Ht.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Ql(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Qi);if(xs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!xs||!ArrayBuffer.isView(t)))throw new Error(Qi)}else throw new Error(Qi);t.length>64&&(t=new Ht(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}Ht.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Ql.prototype=new Ht;Ql.prototype.finalize=function(){if(Ht.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();Ht.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Ht.prototype.finalize.call(this)}};var Ji=u2();Ji.sha256=Ji;Ji.sha224=u2(!0);Ji.sha256.hmac=l2();Ji.sha224.hmac=l2(!0);var c2=Ji;var d2=c2.sha256;function tr(t){return Promise.resolve(d2(t))}function Jl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function pa(t,e){let n=d2.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function p2(t,e){let n=await pa(t,e);return Jl(n)}async function Zl(t,e){let n=KD(e),r=await pa(t,n);return Jl(r)}function KD(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}var g2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Es=class t extends De{static langMap=new Map(g2);maxTextGroupLength=50;static langMapReverse=new Map(g2.map(([e,n])=>[n,e]));static getUTCDate(e){let n=e.getUTCFullYear(),r=`${e.getUTCMonth()+1}`.padStart(2,"0"),a=`${e.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(e,n,r){if(super(e,n,r),!e||!e.secretId||!e.secretKey)throw new $("secretId and secretKey are required");this.secretId=e.secretId?.trim(),this.secretKey=e.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceText:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async translateList(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceTextList:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:e,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await tr(a)].join(` `),p=t.getUTCDate(u),m=["TC3-HMAC-SHA256",l,`${p}/${i}/tc3_request`,await tr(c)].join(` `),g=await p2(p,`TC3${n}`),f=await Zl(i,g),T=await Zl("tc3_request",f),b=await Zl(m,T),h=await ce({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${e}/${p}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${b}`},body:a,timeout:this.requestTimeout});if(h instanceof Error)throw h;if(h.Response&&h.Response.Error&&h.Response.Error.Message)throw new $(h.Response.Error.Message);return h}};d();var m2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],GD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Cs=class t extends De{static langMap=new Map(m2);static langMapReverse=new Map(m2.map(([e,n])=>[n,e]));isSupportList=!1;constructor(e,n,r){super(e,n,r)}async translate(e){let{text:n,from:r,to:a}=e,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await ce({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:GD,timeout:this.requestTimeout});return{text:o.targetText,from:t.langMapReverse.get(o.source)||r,to:t.langMapReverse.get(o.target)||a}}};d();var f2=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Ya=class t extends De{static langMap=new Map(f2);static langMapReverse=new Map(f2.map(([e,n])=>[n,e]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(e,n,r){super(e,n,r),e?.apiUrl&&(this.apiUrl=Ut(this.apiUrl,e.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(e,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}).toString();return{data:await ce({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(e,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}),i=this.apiUrl+"?"+a.toString();return{data:await ce({retry:this.retry,url:i,timeout:this.requestTimeout})}}};d();d();d();function VD(t,e){return e?t+(e-t%e):t}function $D(t,e){return t.split(e).length-1}function Np(t){let e=Date.now(),n=1;for(let r of t)n+=$D(r,"i");return VD(e,n)}function YD(t,e){return Math.floor(Math.random()*(e-t+1))+t}function Up(){return YD(1e6,1e8)}d();d();d();var qp="https://www2.deepl.com/jsonrpc",jp="auto",h2=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];d();function QD(t=h2){return t.reduce((e,n)=>(e[n.code.toLowerCase()]=n.code,e[n.language.toLowerCase()]=n.code,e),{})}function Hp(t){return QD()[t.toLowerCase()]}var JD={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function ZD(t){return JSON.stringify(t).replace('"method":"',()=>{let e=t;return(e.id+3)%13===0||(e.id+5)%29===0?'"method" : "':'"method": "'})}function XD(t,e){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:t,target_lang:e}}}}async function eA(t,e,n,r,a,i,o){let s=Up(),u=XD(r,n),l=[];e.forEach(m=>{l.push({text:m,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Np(e);let c=await ce({retry:2,method:"POST",url:t,body:ZD(u),headers:JD}),p={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(m=>{p.text.push(m.text)}),p}async function b2(t,e,n,r=jp,a,i,o){return e?e&&e.length===1&&e[0]===""?{text:[""],from:r,to:n}:eA(t,e,Hp(n),Hp(r)??"auto",a,i,o):{text:[],from:r,to:n}}var T2=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Zi=class t extends De{static langMap=new Map(T2);static langMapReverse=new Map(T2.map(([e,n])=>[n,e]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=qp;constructor(e,n,r){super(e,n,r),e&&e.apiUrl&&(this.API_URL=Ut(qp,e.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(e){let{text:n,to:r,from:a}=e,i=await b2(this.API_URL,n,t.langMap.get(r)||r,t.langMap.get(a)||"auto");return{text:i.text,from:t.langMapReverse.get(i.from),to:t.langMapReverse.get(i.to)}}};d();var ws=class t extends De{static langMap=new Map(hp);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(e,n,r){super(e,n,r),this.clientKey=zr.getClientKey()}async translate(e){let{text:n,to:r}=e,a=await this.detectLanguage(n),i=t.langMap.get(a)||a,o=t.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Me(),u=e.url;s.INSTALL_FROM==="firefox_store"&&(u=y2());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),p=await ce({url:Al,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(p.header.ret_code!=="succ")throw new $(p.message||p.header.ret_code);return{text:p.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(e){let{from:n,text:r,to:a}=e,i=Me(),o=e.url;if(i.INSTALL_FROM==="firefox_store"&&(o=y2()),r.length===1){let g=await this.translate({from:n,text:r[0],to:a,url:o,options:e.options});return{text:[g.text],from:g.from,to:g.to}}let u=await this.detectLanguage(r.join(` diff --git a/dist/chrome/content_start.js b/dist/chrome/content_start.js index a2b1350..46aaf2b 100644 --- a/dist/chrome/content_start.js +++ b/dist/chrome/content_start.js @@ -1,4 +1,4 @@ -(()=>{var nu=Object.defineProperty;var qn=(t,e)=>{for(var r in e)nu(t,r,{get:e[r],enumerable:!0})};var b={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var nu=Object.defineProperty;var qn=(t,e)=>{for(var r in e)nu(t,r,{get:e[r],enumerable:!0})};var b={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5162,7 +5162,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Us,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...Rs,{type:"password",name:"apikey",required:!0}],props:Rs},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},TD={type:V+"ChildFrameToRootFrameIdentifier"};var vD=Je()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general";var Ft="user_info",yD=Je()||St()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",js=Je()||St()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",SD=js+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",xD=js+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Fm=Je()||St()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Ha=Je()||St()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",Bm=Je()||St()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",Im=Je()||St()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",zm=Je()||St()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",wD=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",AD=Bm+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",DD=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Ws=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Ks=Im+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Gs=zm+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Vs=Fm+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true";var $s=Oe().TRANSLATE_FILE_URL,ED=$s+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",_D=$s+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var cr=console,ja=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let r=performance.now(),n=Math.round(r-this.#e),a=Ye.green;n>1e4?a=Ye.red:n>1e3&&(a=Ye.yellow),cr.debug(Ye.dim(Vt+" TIMING:"),e,"in",a(n+"ms")),this.#e=r}},Hr=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&cr.log(Ye.dim(Vt+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&cr.log(Ye.green(Vt+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&cr.warn(Ye.yellow(Vt+" WARN:"),...e)}error(...e){this.#e<=3&&cr.error(Ye.red(Vt+" ERROR:"),...e)}fatal(...e){this.#e<=4&&cr.error(Ye.red(Vt+" FATAL:"),...e)}timing(){return this.level===0?new ja:{reset:()=>{},stop:()=>{}}}},$e=new Hr;function Sn(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let r=yn.map(a=>a.toLowerCase()),n=r.indexOf(e);if(n===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=r.indexOf(e);return a===-1?"auto":yn[a]}else return"auto";else return yn[n]}function dr(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}var Qs=V+"SyncStoreKey_";function Bt(t,e){let r=Qs+t;return se.storage.sync.get(r).then(n=>n[r]===void 0?e:n[r])}function pr(t,e){let r=Qs+t;return se.storage.sync.set({[r]:e})}var Mm=V+"StoreKey_";function jr(t,e){let r=Mm+t;return se.storage.local.get(r).then(n=>n[r]===void 0?e:n[r])}var Qt=V+"CacheKey_";function Om(t,e){let r=Qt+t;return se.storage.local.get(r).then(n=>n[r]===void 0?e:n[r])}function Rm(){let t=se.storage.local.refresh;t&&t()}function Nm(t,e){let r=Qt+t;return se.storage.local.get(r).then(n=>{if(n[r]===void 0)return e;let{value:a,expired:i}=n[r];return i&&in.startsWith(Qt)).filter(n=>n!==Qt+Ft);if(r.length>0)return se.storage.local.remove(r)}}var mr={get:Om,set:Um,getExpired:Nm,setExpired:qm,remove:Hm,clear:jm,refresh:Rm};function Wm(t,e){let r=t;return e&&Object.keys(e).forEach(n=>{let a=e[n];if(a===void 0)return;let i=Gm(n);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let l=`<${n}>`,s=r.indexOf(l);if(s!==-1){let u=o.tag||"a",c=r.indexOf(``);if(c!==-1){let d=r.substring(s+l.length,c),g=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");r=r.replace(`${l}${d}`,`<${u} ${g}>${d}`)}}}else if(a){let o=new RegExp("{"+n+"}","gm");r=r.replace(o,a.toString())}}),r}function Ys(t,e,r){let n=t[e];if(!n)return r;if(!r)return"";let a=r.split("."),i="";do{i+=a.shift();let o=n[i];o!==void 0&&(typeof o=="object"||!a.length)?(n=o,i=""):a.length?i+=".":n=r}while(a.length);return n}function Km(t,e,r,n,a){if(!t.hasOwnProperty(r))return e;let i=Ys(t,r,e);return i===e&&r!==n&&(i=Ys(t,n,e)),Wm(i,a)}function Gm(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function It(t,e,r){return Km(qr,e,t.config.interfaceLanguage,"en",r)}function Xs(t,e){let r=new Date(t),n=r.getFullYear().toString(),a=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getDate().toString().padStart(2,"0"),o=r.getHours().toString().padStart(2,"0"),l=r.getMinutes().toString().padStart(2,"0"),s=r.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",n).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",l).replace("ss",s)}function Zs(t){return new Date(t).getTime()}var zt=class extends Error{status;constructor(e,r){if(e&&r){super(r),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let r=null;if(r=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!r){let n=It.bind(null,e),a=this.getErrorMsg();r={type:"error",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:a}),action:"changeService"}}return r}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let r=It.bind(null,e),n=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(n||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let r=It.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:r("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+r("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let r=It.bind(null,e),n="retry",a="network",i=r("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${r("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${r("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${r("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${r("error.gemini.429")}

${o}`:o=`${r("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${r("error.claude.403")}

${o}`:o=`${r("error.403")}

${o}`:this.status===400?o=`${r("error.400")}

${o}`:this.status===502?o=`${r("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${r("error.subscriptionExpired")}

${o}`,n="setting",a="configError",i=r("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:n}}handleFetchError(e){let r=It.bind(null,e);if(this.status!==-999)return;let n=this.getErrorMsg();return{type:"network",title:"",errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:n}),action:"changeService"}}handleProUser(e){let r=It.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:r("upgradeToProErrorTitle"),errMsg:r("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let r=It.bind(null,e);this.message=this.message.replace("ProQuota:","");let n=this.message;try{n=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:l,subscriptionTo:s}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let d=this.data?.translationService=="deepl"?"OpenAI":"Deepl",g=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=r("errorReason",{message:n});if(i=="onetime_7day")m+=r("proQuotaExceededError.onetime7day",{anotherService:d,brandId:ke,href:Ws});else{let T="";g=="OpenAI"?T=Ks:T=Gs,o?m+=r("proQuotaExceededError.trial",{anotherService:d,brandId:ke,href:Vs}):m+=r("proQuotaExceededError.nonTrial",{anotherService:d,brandId:ke,href:T,translationService:g}),!o&&(a.cancelAtPeriodEnd==="false"||Zs(s)>l)&&(m+=r("proQuotaExceededError.resetTime",{resetTime:Xs(l,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function el(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Kn(Js.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(r){throw r&&r.name==="RetryError"&&r.cause?r.cause:r}else e=await Js(t);return e}async function Js(t){t.body;let{url:e,responseType:r,...n}=t;r||(r="json"),n={mode:"cors",...n};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let s=new AbortController,u=s.signal;setTimeout(()=>{s.abort()},o),n.signal=u}let l;try{l=await i(e,n)}catch(s){$e.debug("fetch error",e,s);let u=s.message||"Unknown Error";throw new zt("fetchError",u).initNetWork(-999).initStack(s.stack)}if(l.ok&&l.status>=200&&l.status<400){if(r==="json")return await l.json();if(r==="text")return await l.text();if(r==="raw"){let s=await l.text(),u=Object.fromEntries([...l.headers.entries()]),c=l.url;return c||(l.headers.get("X-Final-URL")?c=l.headers.get("X-Final-URL"):c=e),{body:s,headers:u,status:l.status,statusText:l.statusText,url:c}}else if(r==="stream"){let s="",u;if(l.body&&l.body instanceof ReadableStream)for await(let c of Vm(l.body)){let d=new TextDecoder().decode(c);s+=d;let g;for(;(g=s.indexOf(` -`))>=0;){let m=s.slice(0,g).trim();if(s=s.slice(g+1),m.startsWith("event:")||m==="")continue;let T="";if(m.startsWith("data:")&&(T=m.slice(5).trim()),T==="[DONE]")break;let j;try{j=JSON.parse(T??"")}catch(k){$e.debug("json error",k);continue}u=j}}return u}}else{let s;try{s=await l.text()}catch(m){$e.error("parse response failed",m)}s&&$e.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),g&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new zt("fetchError",c).initNetWork(l.status)}}async function*Vm(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}var $m=new Map;function tl(t){let e=Qm(64),r=new CustomEvent(Ns,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((n,a)=>{$m.set(e,(i,o)=>{i?a(i):n(o)})})}function Qm(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var Xm="";function Wr(){return Xm||rl.version}function xn(){try{let t=[Oe().EBOOK_BUILDER_URL,Oe().EBOOK_VIEWER_URL,Oe().SUBTITLE_BUILDER_URL,Oe().HTML_VIEWER_URL,Oe().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Je()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var Kr=new Map,Gr=class{fromType;logger;constructor(e,r=!1){this.logger=new Hr,r&&this.logger.setLevel("debug"),this.fromType=e,Kr.has(e)||(Kr.set(e,new Map),se.runtime.onMessage.addListener((n,a,i)=>{let o=n.from,l=n.to,s,u,c;a.tab&&a.tab.id&&(s=a.tab.id,o=`${o}:${s}`,u=a.tab.url,c=a.tab.active),this.logger.debug(`${n.to} received message [${n.payload.method}] from ${n.from}`,n.payload.data?n.payload.data:" ");let d=Ka(l),{type:g,name:m}=d;if(g!==e)return!1;let T=Ka(o),k=Kr.get(g).get(m);if(!k)return this.logger.debug(`no message handler for ${g}:${l}, but it's ok`),!1;let{messageHandler:h,sync:Q}=k,P={type:e,name:T.name,id:s,url:u,active:c};if(Q){try{let $=h(n.payload,P);i({ok:!0,data:$})}catch($){i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.details,errorStatus:$.status})}return!1}else return h(n.payload,P).then($=>{i({ok:!0,data:$})}).catch($=>{i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.message,errorStatus:$.status})}),!0}))}getConnection(e,r,n){let a=!1;n&&n.sync&&(a=!0);let i=this.fromType,o=Kr.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Wa(`${i}:${e}`,this.logger);return Kr.get(i).set(e,{messageHandler:r,sync:a,connectionInstance:l}),l}}},Wa=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let n=Ka(e),{type:a,id:i}=n;if(a!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await se.runtime.sendMessage(o);return nl(o,l,this.logger)}catch(l){if(a==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await se.tabs.sendMessage(i,o);return nl(o,l,this.logger)}}};function nl(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new zt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new zt("noResponse","Unknown error")}function Ka(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let n=parseInt(e[2]);if(!isNaN(n))r.id=n;else throw new Error("tab id not a valid number")}return r}var Zm="";function Ga(){return Zm||globalThis.navigator.userAgent}function al(){return Ga().includes("ImtFxiOS")}function Jm(){return Ga().includes("ImtFxAndroid")}function Va(){let t=Ga();if(al()||Jm()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),n=r[0];return r[2]&&(n+="_"+r[2]),{name:n,version:r[1]}}}return null}var wn;function $a(){return wn||(wn=new Gr("content_script",!1).getConnection("pure_main",()=>{}),wn)}var il="G-MKMD9LWFTR";async function sl(t){try{let e=Oe(),r=e.INSTALL_FROM==="firefox_store";if(Va()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let a=Ge(),i=xn(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Bt("fakeUserId","");s||(s=await jr("fakeUserId",""),s&&await pr("fakeUserId",s));let u=Wr(),c=new Date,d=await Bt("installedAt","");d||(d=await jr("installedAt",""),d&&await pr("installedAt",d)),s?d||(d=new Date(0).toISOString(),await pr("installedAt",d)):(s=eg(32),await pr("fakeUserId",s)),d||(d=c.toISOString(),await pr("installedAt",d));let g=new Date(d),m=ol(g),T=ol(c),j=m===T,k=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${il}&api_secret=${l}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${il}&api_secret=${l}`);let Q="";typeof navigator<"u"&&(Q=window.navigator.userAgent);let P=nn.parse(Q),$=t.map(A=>{let f=A.params||{};if(P.os&&(f.os_name=P.os.name||"unknown",f.os_version=P.os.version||"unknown",f.os_version_name=P.os.versionName||"unknown"),P.browser){f.browser_name=P.browser.name||"unknown",f.browser_version=P.browser.version||"unknown";let y=Va();y&&(f.browser_name=y.name,f.browser_version=y.version)}return P.platform&&(f.platform_type=P.platform.type||"unknown"),P.engine&&(f.engine_name=P.engine.name||"unknown",f.engine_version=P.engine.version||"unknown"),u&&(f.version=u),e.INSTALL_FROM&&(f.install_from=e.INSTALL_FROM),m&&(f.install_day=tg(g)),f.userscript=a.toString(),j?f.is_new_user_today="1":f.is_new_user_today="0",k?f.is_new_user_this_week="1":f.is_new_user_this_week="0",i?f.main_frame=0:f.main_frame=1,{...A,params:f}}),oe=await ng({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:$})})}catch{}}function eg(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=s.slice(0,g).trim();if(s=s.slice(g+1),m.startsWith("event:")||m==="")continue;let T="";if(m.startsWith("data:")&&(T=m.slice(5).trim()),T==="[DONE]")break;let j;try{j=JSON.parse(T??"")}catch(k){$e.debug("json error",k);continue}u=j}}return u}}else{let s;try{s=await l.text()}catch(m){$e.error("parse response failed",m)}s&&$e.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),g&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new zt("fetchError",c).initNetWork(l.status)}}async function*Vm(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}var $m=new Map;function tl(t){let e=Qm(64),r=new CustomEvent(Ns,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((n,a)=>{$m.set(e,(i,o)=>{i?a(i):n(o)})})}function Qm(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var Xm="";function Wr(){return Xm||rl.version}function xn(){try{let t=[Oe().EBOOK_BUILDER_URL,Oe().EBOOK_VIEWER_URL,Oe().SUBTITLE_BUILDER_URL,Oe().HTML_VIEWER_URL,Oe().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Je()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var Kr=new Map,Gr=class{fromType;logger;constructor(e,r=!1){this.logger=new Hr,r&&this.logger.setLevel("debug"),this.fromType=e,Kr.has(e)||(Kr.set(e,new Map),se.runtime.onMessage.addListener((n,a,i)=>{let o=n.from,l=n.to,s,u,c;a.tab&&a.tab.id&&(s=a.tab.id,o=`${o}:${s}`,u=a.tab.url,c=a.tab.active),this.logger.debug(`${n.to} received message [${n.payload.method}] from ${n.from}`,n.payload.data?n.payload.data:" ");let d=Ka(l),{type:g,name:m}=d;if(g!==e)return!1;let T=Ka(o),k=Kr.get(g).get(m);if(!k)return this.logger.debug(`no message handler for ${g}:${l}, but it's ok`),!1;let{messageHandler:h,sync:Q}=k,P={type:e,name:T.name,id:s,url:u,active:c};if(Q){try{let $=h(n.payload,P);i({ok:!0,data:$})}catch($){i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.details,errorStatus:$.status})}return!1}else return h(n.payload,P).then($=>{i({ok:!0,data:$})}).catch($=>{i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.message,errorStatus:$.status})}),!0}))}getConnection(e,r,n){let a=!1;n&&n.sync&&(a=!0);let i=this.fromType,o=Kr.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Wa(`${i}:${e}`,this.logger);return Kr.get(i).set(e,{messageHandler:r,sync:a,connectionInstance:l}),l}}},Wa=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let n=Ka(e),{type:a,id:i}=n;if(a!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await se.runtime.sendMessage(o);return nl(o,l,this.logger)}catch(l){if(a==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await se.tabs.sendMessage(i,o);return nl(o,l,this.logger)}}};function nl(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new zt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new zt("noResponse","Unknown error")}function Ka(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let n=parseInt(e[2]);if(!isNaN(n))r.id=n;else throw new Error("tab id not a valid number")}return r}var Zm="";function Ga(){return Zm||globalThis.navigator.userAgent}function al(){return Ga().includes("ImtFxiOS")}function Jm(){return Ga().includes("ImtFxAndroid")}function Va(){let t=Ga();if(al()||Jm()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),n=r[0];return r[2]&&(n+="_"+r[2]),{name:n,version:r[1]}}}return null}var wn;function $a(){return wn||(wn=new Gr("content_script",!1).getConnection("pure_main",()=>{}),wn)}var il="G-MKMD9LWFTR";async function sl(t){try{let e=Oe(),r=e.INSTALL_FROM==="firefox_store";if(Va()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let a=Ge(),i=xn(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Bt("fakeUserId","");s||(s=await jr("fakeUserId",""),s&&await pr("fakeUserId",s));let u=Wr(),c=new Date,d=await Bt("installedAt","");d||(d=await jr("installedAt",""),d&&await pr("installedAt",d)),s?d||(d=new Date(0).toISOString(),await pr("installedAt",d)):(s=eg(32),await pr("fakeUserId",s)),d||(d=c.toISOString(),await pr("installedAt",d));let g=new Date(d),m=ol(g),T=ol(c),j=m===T,k=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${il}&api_secret=${l}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${il}&api_secret=${l}`);let Q="";typeof navigator<"u"&&(Q=window.navigator.userAgent);let P=nn.parse(Q),$=t.map(A=>{let f=A.params||{};if(P.os&&(f.os_name=P.os.name||"unknown",f.os_version=P.os.version||"unknown",f.os_version_name=P.os.versionName||"unknown"),P.browser){f.browser_name=P.browser.name||"unknown",f.browser_version=P.browser.version||"unknown";let y=Va();y&&(f.browser_name=y.name,f.browser_version=y.version)}return P.platform&&(f.platform_type=P.platform.type||"unknown"),P.engine&&(f.engine_name=P.engine.name||"unknown",f.engine_version=P.engine.version||"unknown"),u&&(f.version=u),e.INSTALL_FROM&&(f.install_from=e.INSTALL_FROM),m&&(f.install_day=tg(g)),f.userscript=a.toString(),j?f.is_new_user_today="1":f.is_new_user_today="0",k?f.is_new_user_this_week="1":f.is_new_user_this_week="0",i?f.main_frame=0:f.main_frame=1,{...A,params:f}}),oe=await ng({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:$})})}catch{}}function eg(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 diff --git a/dist/chrome/manifest.json b/dist/chrome/manifest.json index c418343..a679f03 100644 --- a/dist/chrome/manifest.json +++ b/dist/chrome/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "__MSG_brandName__", "description": "__MSG_brandDescription__", - "version": "1.4.3", + "version": "1.4.4", "default_locale": "en", "background": { "service_worker": "background.js" diff --git a/dist/chrome/options.js b/dist/chrome/options.js index d037b73..50283c0 100644 --- a/dist/chrome/options.js +++ b/dist/chrome/options.js @@ -1,4 +1,4 @@ -(()=>{var GS=Object.create;var yd=Object.defineProperty;var VS=Object.getOwnPropertyDescriptor;var $S=Object.getOwnPropertyNames;var YS=Object.getPrototypeOf,QS=Object.prototype.hasOwnProperty;var ZS=(e,t)=>()=>(e&&(t=e(e=0)),t);var JS=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ol=(e,t)=>{for(var n in t)yd(e,n,{get:t[n],enumerable:!0})},XS=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $S(t))!QS.call(e,a)&&a!==n&&yd(e,a,{get:()=>t[a],enumerable:!(r=VS(t,a))||r.enumerable});return e};var eC=(e,t,n)=>(n=e!=null?GS(YS(e)):{},XS(t||!e||!e.__esModule?yd(n,"default",{value:e,enumerable:!0}):n,e));var E,p=ZS(()=>{E={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var GS=Object.create;var yd=Object.defineProperty;var VS=Object.getOwnPropertyDescriptor;var $S=Object.getOwnPropertyNames;var YS=Object.getPrototypeOf,QS=Object.prototype.hasOwnProperty;var ZS=(e,t)=>()=>(e&&(t=e(e=0)),t);var JS=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ol=(e,t)=>{for(var n in t)yd(e,n,{get:t[n],enumerable:!0})},XS=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $S(t))!QS.call(e,a)&&a!==n&&yd(e,a,{get:()=>t[a],enumerable:!(r=VS(t,a))||r.enumerable});return e};var eC=(e,t,n)=>(n=e!=null?GS(YS(e)):{},XS(t||!e||!e.__esModule?yd(n,"default",{value:e,enumerable:!0}):n,e));var E,p=ZS(()=>{E={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5176,13 +5176,13 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {env.imt_trans_field}: tradu\xE7\xE3o`,"subtitle.quickButton.green":"verde","subtitle.quickButton.magenta":"Magenta","translationServices.claude":"Claude","subtitle.quickButton.white":"branco","subtitle.quickButton.translationTextColor":"Cor da fonte da tradu\xE7\xE3o","subtitle.quickButton.backgroundOpacity":"opacidade de fundo","subtitle.quickButton.sourceFontSize":"Tamanho original da fonte","subtitle.quickButton.backgroundColor":"cor de fundo","subtitle.quickButton.setting":"configura\xE7\xE3o","subtitle.quickButton.blue":"azul","subtitle.quickButton.translationPositionBottom":"\u539F\u6587\u4E0B\u65B9","subtitle.quickButton.yellow":"Amarelo","subtitle.quickButton.translationPositionTop":"Acima do texto original","subtitle.quickButton.sourceTextColor":"Cor original da fonte","subtitle.quickButton.red":"vermelho","subtitle.quickButton.translationPosition":"Posi\xE7\xE3o de tradu\xE7\xE3o","subtitle.quickButton.cyan":"Azul","subtitle.quickButton.black":"preto","subtitle.quickButton.translationFontSize":"Tamanho da fonte do texto traduzido",attachSubtitleTranslating:"Usando {service} para traduzir...","error.claude.403":"Sem permiss\xE3o para acessar o servi\xE7o, pode estar relacionado com as restri\xE7\xF5es de \xE1rea de Claude, voc\xEA pode tentar alterar o seu endere\xE7o IP, ou usar outros servi\xE7os de tradu\xE7\xE3o.","browser.brandDescriptionForSafari":"\u3010Tradu\xE7\xE3o imersiva\u3011Um plugin de tradu\xE7\xE3o de p\xE1ginas da web bilingue (original/tradu\xE7\xE3o) gratuito, que suporta a tradu\xE7\xE3o de PDF e EPUB e mant\xE9m a formata\xE7\xE3o original do documento, a tradu\xE7\xE3o de legendas bilingues de v\xEDdeos online como Youtube/Netflix, e suporta servi\xE7os de tradu\xE7\xE3o mainstream como Deepl/Google;","browser.PdfProFile":"AI impulsionado pela tradu\xE7\xE3o do PDF Pro","browser.textTranslate":"Tradu\xE7\xE3o de texto"};var Lb=[{code:"zh-CN",messages:hb},{code:"zh-TW",messages:bb},{code:"en",messages:yb},{code:"ja",messages:Tb},{code:"ar",messages:vb},{code:"de",messages:Sb},{code:"es",messages:Cb},{code:"fa",messages:xb},{code:"fr",messages:Eb},{code:"hi",messages:wb},{code:"it",messages:Db},{code:"ru",messages:Ab},{code:"ko",messages:kb},{code:"pt",messages:Pb}];var Mb="immersiveTranslateDeeplGlobalState",hp="immersiveTranslateBingGlobalState",bp="immersiveTranslateYandexGlobalState",nn={};for(let e of Lb)nn[e.code]=e.messages;var Di="Immersive Translate",ee="immersive-translate";var be="immersiveTranslate",sc="759003177173-mfm15s5nd77vfmo6e7lanof1emnanf0e.apps.googleusercontent.com",_a=be+"GoogleAccessToken",tu=be+"AuthFlow",uc="immersive-translate-config-latest.json",yp=be+"AuthState",lc=be+"IframeMessage",bj=be+"WaitForRateLimit",Fb=be+"DocumentMessageAsk",Yt=be+"DocumentMessageTellThirdParty",Ai=be+"showError",Bb=be+"DocumentMessageThirdPartyTell",Ib=be+"DocumentMessageEventUpload",Q8=be+"DocumentMessageHandler",cc=`${be}Share`,nu=`${be}ToggleMouseHoverTranslateDirectly`,Rb=`${be}ReqDraft`,Ob=`${be}ResDraft`,Z8=`${be}Container`,zb=`${be}SpecifiedContainer`,ia="buildinConfig",Ao="localConfig",ru="openOptionsPage",Tp="openAboutPage",Nb="translateLocalPdfFile";var au="openEbookViewer",iu="openEbookBuilder";var ki=`${be}PageTranslatedStatus`,yj=`${be}PageUrlChanged`,oa=`${be}ReceiveCommand`,Ub=be+"LastUseMouseHoverTime",dc=be+"LastUseInputTime",yr=be+"LastUseManualTranslatePageTime",Tj=`${be}PopupReceiveMessage`,J8="immersivetranslate.com",X8="config.immersivetranslate.com",vj=`https://${J8}/`,Ma=`https://${X8}/default_config.json`,Sj=`${be}Mark`,In=`${be}Root`,qb=`${be}Walked`,Cj=`data-${ee}-walked`,jb=`${be}Paragraph`,Hb=`data-${ee}-paragraph`,Fr=`data-${ee}-translation-element-mark`,Wb=`${be}TranslationElementMark`,xj=`${be}TranslatedMark`,Kb=`${be}LoadingId`,vp=`data-${ee}-loading-id`,Gb=`${be}ErrorId`,gc=`data-${ee}-error-id`,e7=`${be}AtomicBlockMark`,Vb=`${be}ExcludeMark`,Ej=`data-${ee}-exclude-mark`,t7=`${be}StayOriginalMark`,wj=`${be}PreWhitespaceMark`,pc=`${be}InlineMark`,$b=`${be}BlockMark`,Dj=`${be}Left`,Aj=`${be}Right`,kj=`${be}Width`,Pj=`${be}Height`,Lj=`${be}Top`,_j=`${be}FontSize`,Yb="lastRunTime",Mj=`${be}GlobalStyleMark`,ou=["@","#"],mc=" --- ",Qb=` `,Lt=`${ee}-target-wrapper`,Fj=`${ee}-pdf-target-container`,fc=`${ee}-target-inner`,Bj=`${ee}-source-wrapper`,Sp=`${ee}-target-translation-block-wrapper`,Ij=`${ee}-root-translation-theme`,ko=`${be}RootTranslationTheme`,Zb=`${ee}-target-translation-vertical-block-wrapper`,Rj=`${ee}-target-translation-pdf-block-wrapper`,Jb=`${ee}-target-translation-pre-whitespace`,Cp=`${ee}-target-translation-inline-wrapper`,xp=["none","dashed","underline","dashedBorder","solidBorder","mask","opacity","dotted","dividingLine","highlight","marker","marker2","blockquote","weakening","grey","paper","italic","bold","thinDashed","wavy","nativeDotted","nativeDashed","nativeUnderline"],su={underline:[{name:"borderColor",required:!1,type:"color"}],nativeUnderline:[{name:"borderColor",required:!1,type:"color"}],nativeDashed:[{name:"borderColor",required:!1,type:"color"}],nativeDotted:[{name:"borderColor",required:!1,type:"color"}],dotted:[{name:"borderColor",required:!1,type:"color"}],dividingLine:[{name:"borderColor",required:!1,type:"color"}],highlight:[{name:"backgroundColor",required:!1,type:"color"}],marker:[{name:"backgroundColor",required:!1,type:"color"}],dashed:[{name:"borderColor",required:!1,type:"color"}],blockquote:[{name:"borderColor",required:!1,type:"color"}],thinDashed:[{name:"borderColor",required:!1,type:"color"}],dashedBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],solidBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],marker2:[{name:"backgroundColor",required:!1,type:"color"}],wavy:[{name:"borderColor",required:!1,type:"color"}],opacity:[{name:"opacity",required:!1,type:"number",default:10}]},Rn=["auto","zh-CN","zh-TW","en","ja","ko","es","de","fr","pt","pt-br","ru","ar","it","ms","id","vi","af","th","ur","yue","zh-CN-NE","bo","wyw","am","az","be","bg","bn","bs","ca","ceb","co","cs","cy","da","el","eo","et","eu","fa","fi","fil","fj","fy","ga","gd","gl","gu","ha","haw","he","hi","hmn","hr","ht","hu","hy","ig","is","jw","ka","kk","km","kn","ku","ky","la","lb","lo","lt","lv","mg","mi","mk","ml","mn","mr","mt","mww","my","ne","nl","no","ny","otq","pa","pl","ps","ro","sa","sd","si","sk","sl","sm","sn","so","sq","sr","sr-Cyrl","sr-Latn","st","su","sv","sw","ta","te","tg","tlh","tlh-Qaak","to","tr","ty","ug","uk","uz","xh","yi","yo","yua","zu"],Xb={af:"Afrikaans",am:"Amharic",ar:"Arabic",auto:"Auto Detect",az:"Azerbaijani",be:"Belarusian",bg:"Bulgarian",tn:"Zana",bn:"Bengali",bs:"Bosnian",bo:"Tibetan",ca:"Catalan",ceb:"Cebuano",co:"Corsican",cs:"Czech",cy:"Welsh",da:"Danish",de:"German",el:"Greek",en:"English",eo:"Esperanto",es:"Spanish",et:"Estonian",eu:"Basque",sa:"Sanskrit",fa:"Persian",fi:"Finnish",fil:"Filipino",fj:"Fijian",fr:"French",fy:"Frisian",ga:"Irish",gd:"Scottish Gaelic",gl:"Galician",gu:"Gujarati",ha:"Hausa",haw:"Hawaiian",he:"Hebrew",hi:"Hindi",hmn:"Hmong",hr:"Croatian",ht:"Haitian Creole",hu:"Hungarian",hy:"Armenian",id:"Indonesian",ig:"Igbo",is:"Icelandic",it:"Italian",ja:"Japanese",jw:"Javanese",ka:"Georgian",kk:"Kazakh",km:"Khmer",kn:"Kannada",ko:"Korean",ku:"Kurdish",ky:"Kyrgyz",la:"Latin",lb:"Luxembourgish",lo:"Lao",lt:"Lithuanian",lv:"Latvian",mg:"Malagasy",mi:"Maori",mk:"Macedonian",ml:"Malayalam",mn:"Mongolian",mr:"Marathi",ms:"Malay",mt:"Maltese",mww:"Hmong Daw",my:"Burmese",ne:"Nepali",nl:"Dutch",no:"Norwegian",ny:"Chichewa",otq:"Quer\xE9taro Otomi",pa:"Punjabi",pl:"Polish",ps:"Pashto",pt:"Portuguese","pt-br":"Portuguese (Brazil)",ro:"Romanian",ru:"Russian",sd:"Sindhi",si:"Sinhala",sk:"Slovak",sl:"Slovenian",sm:"Samoan",sn:"Shona",so:"Somali",sq:"Albanian",sr:"Serbian","sr-Cyrl":"Serbian (Cyrillic)","sr-Latn":"Serbian (Latin)",st:"Sesotho",su:"Sundanese",sv:"Swedish",sw:"Swahili",ta:"Tamil",te:"Telugu",tg:"Tajik",th:"Thai",tlh:"Klingon","tlh-Qaak":"Klingon (piqaD)",to:"Tongan",tr:"Turkish",ty:"Tahitian",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",vi:"Vietnamese",wyw:"Classical Chinese",xh:"Xhosa",placeholder:"Please Select",yi:"Yiddish",yo:"Yoruba",yua:"Yucatec Maya",yue:"Cantonese (Traditional)","zh-CN":"Simplified Chinese","zh-TW":"Traditional Chinese","zh-CN-NE":"Northeastern Chinese",zu:"Zulu","":"All Languages"},e1={placeholder:"\u8BF7\u9009\u62E9",af:"\u5357\u975E\u8377\u5170\u8BED",am:"\u963F\u59C6\u54C8\u62C9\u8BED",ar:"\u963F\u62C9\u4F2F\u8BED",auto:"\u81EA\u52A8\u68C0\u6D4B",az:"\u963F\u585E\u62DC\u7586\u8BED",be:"\u767D\u4FC4\u7F57\u65AF\u8BED",bg:"\u4FDD\u52A0\u5229\u4E9A\u8BED",tn:"\u8D5E\u7EB3\u8BED",bn:"\u5B5F\u52A0\u62C9\u8BED",bs:"\u6CE2\u65AF\u5C3C\u4E9A\u8BED",bo:"\u85CF\u8BED",ca:"\u52A0\u6CF0\u7F57\u5C3C\u4E9A\u8BED",ceb:"\u5BBF\u52A1\u8BED",co:"\u79D1\u897F\u5609\u8BED",cs:"\u6377\u514B\u8BED",cy:"\u5A01\u5C14\u58EB\u8BED",da:"\u4E39\u9EA6\u8BED",de:"\u5FB7\u8BED",el:"\u5E0C\u814A\u8BED",en:"\u82F1\u8BED",eo:"\u4E16\u754C\u8BED",es:"\u897F\u73ED\u7259\u8BED",et:"\u7231\u6C99\u5C3C\u4E9A\u8BED",eu:"\u5DF4\u65AF\u514B\u8BED",sa:"\u68B5\u8BED",fa:"\u6CE2\u65AF\u8BED",fi:"\u82AC\u5170\u8BED",fil:"\u83F2\u5F8B\u5BBE\u8BED",fj:"\u6590\u6D4E\u8BED",fr:"\u6CD5\u8BED",fy:"\u5F17\u91CC\u65AF\u5170\u8BED",ga:"\u7231\u5C14\u5170\u8BED",gd:"\u82CF\u683C\u5170\u76D6\u5C14\u8BED",gl:"\u52A0\u5229\u897F\u4E9A\u8BED",gu:"\u53E4\u5409\u62C9\u7279\u8BED",ha:"\u8C6A\u8428\u8BED",haw:"\u590F\u5A01\u5937\u8BED",he:"\u5E0C\u4F2F\u6765\u8BED",hi:"\u5370\u5730\u8BED",hmn:"\u82D7\u8BED",hr:"\u514B\u7F57\u5730\u4E9A\u8BED",ht:"\u6D77\u5730\u514B\u91CC\u5965\u5C14\u8BED",hu:"\u5308\u7259\u5229\u8BED",hy:"\u4E9A\u7F8E\u5C3C\u4E9A\u8BED",id:"\u5370\u5EA6\u5C3C\u897F\u4E9A\u8BED",ig:"\u4F0A\u535A\u8BED",is:"\u51B0\u5C9B\u8BED",it:"\u610F\u5927\u5229\u8BED",ja:"\u65E5\u672C\u8BED",jw:"\u722A\u54C7\u8BED",ka:"\u683C\u9C81\u5409\u4E9A\u8BED",kk:"\u54C8\u8428\u514B\u8BED",km:"\u9AD8\u68C9\u8BED",kn:"\u5361\u7EB3\u8FBE\u8BED",ko:"\u97E9\u8BED",ku:"\u5E93\u5C14\u5FB7\u8BED",ky:"\u5409\u5C14\u5409\u65AF\u8BED",la:"\u62C9\u4E01\u8BED",lb:"\u5362\u68EE\u5821\u8BED",lo:"\u8001\u631D\u8BED",lt:"\u7ACB\u9676\u5B9B\u8BED",lv:"\u62C9\u8131\u7EF4\u4E9A\u8BED",mg:"\u9A6C\u62C9\u52A0\u65AF\u8BED",mi:"\u6BDB\u5229\u8BED",mk:"\u9A6C\u5176\u987F\u8BED",ml:"\u9A6C\u62C9\u96C5\u62C9\u59C6\u8BED",mn:"\u8499\u53E4\u8BED",mr:"\u9A6C\u62C9\u5730\u8BED",ms:"\u9A6C\u6765\u8BED",mt:"\u9A6C\u8033\u4ED6\u8BED",mww:"\u767D\u82D7\u8BED",my:"\u7F05\u7538\u8BED",ne:"\u5C3C\u6CCA\u5C14\u8BED",nl:"\u8377\u5170\u8BED",no:"\u632A\u5A01\u8BED",ny:"\u9F50\u5207\u74E6\u8BED\uFF08\u5C3C\u626C\u8D3E\u8BED\uFF09",otq:"\u514B\u96F7\u5854\u7F57\u5965\u6258\u7C73\u8BED",pa:"\u65C1\u906E\u666E\u8BED",pl:"\u6CE2\u5170\u8BED",ps:"\u666E\u4EC0\u56FE\u8BED",pt:"\u8461\u8404\u7259\u8BED","pt-br":"\u8461\u8404\u7259\u8BED\uFF08\u5DF4\u897F\uFF09",ro:"\u7F57\u9A6C\u5C3C\u4E9A\u8BED",ru:"\u4FC4\u8BED",sd:"\u4FE1\u5FB7\u8BED",si:"\u50E7\u4F3D\u7F57\u8BED",sk:"\u65AF\u6D1B\u4F10\u514B\u8BED",sl:"\u65AF\u6D1B\u6587\u5C3C\u4E9A\u8BED",sm:"\u8428\u6469\u4E9A\u8BED",sn:"\u4FEE\u7EB3\u8BED",so:"\u7D22\u9A6C\u91CC\u8BED",sq:"\u963F\u5C14\u5DF4\u5C3C\u4E9A\u8BED",sr:"\u585E\u5C14\u7EF4\u4E9A\u8BED","sr-Cyrl":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u897F\u91CC\u5C14\u6587\uFF09","sr-Latn":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u62C9\u4E01\u6587\uFF09",st:"\u585E\u7D22\u6258\u8BED",su:"\u5DFD\u4ED6\u8BED",sv:"\u745E\u5178\u8BED",sw:"\u65AF\u74E6\u5E0C\u91CC\u8BED",ta:"\u6CF0\u7C73\u5C14\u8BED",te:"\u6CF0\u5362\u56FA\u8BED",tg:"\u5854\u5409\u514B\u8BED",th:"\u6CF0\u8BED",tlh:"\u514B\u6797\u8D21\u8BED","tlh-Qaak":"\u514B\u6797\u8D21\u8BED\uFF08piqaD\uFF09",to:"\u6C64\u52A0\u8BED",tr:"\u571F\u8033\u5176\u8BED",ty:"\u5854\u5E0C\u63D0\u8BED",ug:"\u7EF4\u543E\u5C14\u8BED",uk:"\u4E4C\u514B\u5170\u8BED",ur:"\u4E4C\u5C14\u90FD\u8BED",uz:"\u4E4C\u5179\u522B\u514B\u8BED",vi:"\u8D8A\u5357\u8BED",wyw:"\u6587\u8A00\u6587",xh:"\u73ED\u56FE\u8BED",yi:"\u610F\u7B2C\u7EEA\u8BED",yo:"\u7EA6\u9C81\u5DF4\u8BED",yua:"\u5C24\u5361\u5766\u739B\u96C5\u8BED",yue:"\u7CA4\u8BED","zh-CN":"\u7B80\u4F53\u4E2D\u6587","zh-TW":"\u7E41\u4F53\u4E2D\u6587","zh-CN-NE":"\u4E1C\u5317\u8BDD",zu:"\u7956\u9C81\u8BED","":"\u6240\u6709\u8BED\u8A00"},t1={placeholder:"\u8ACB\u9078\u64C7",af:"\u963F\u975E\u5229\u5361\u8A9E",am:"\u963F\u59C6\u54C8\u62C9\u8A9E",ar:"\u963F\u62C9\u4F2F\u8A9E",auto:"\u81EA\u52D5\u6AA2\u6E2C",az:"\u963F\u585E\u62DC\u7586\u8A9E",be:"\u767D\u4FC4\u7F85\u65AF\u8A9E",bg:"\u4FDD\u52A0\u5229\u4E9E\u8A9E",tn:"\u8D0A\u7D0D\u8A9E",bn:"\u5B5F\u52A0\u62C9\u8A9E",bs:"\u6CE2\u65AF\u5C3C\u4E9E\u8A9E",bo:"\u85CF\u8A9E",ca:"\u52A0\u6CF0\u862D\u8A9E",ceb:"\u5BBF\u9727\u8A9E",co:"\u79D1\u897F\u5609\u8A9E",cs:"\u6377\u514B\u8A9E",cy:"\u5A01\u723E\u65AF\u8A9E",da:"\u4E39\u9EA5\u8A9E",de:"\u5FB7\u8A9E",el:"\u5E0C\u81D8\u8A9E",en:"\u82F1\u8A9E",eo:"\u4E16\u754C\u8A9E",es:"\u897F\u73ED\u7259\u8A9E",et:"\u611B\u6C99\u5C3C\u4E9E\u8A9E",eu:"\u5DF4\u65AF\u514B\u8A9E",sa:"\u68B5\u8A9E",fa:"\u6CE2\u65AF\u8A9E",fi:"\u82AC\u862D\u8A9E",fil:"\u83F2\u5F8B\u8CD3\u8A9E",fj:"\u6590\u6FDF\u8A9E",fr:"\u6CD5\u8A9E",fy:"\u5F17\u91CC\u897F\u8A9E",ga:"\u611B\u723E\u862D\u8A9E",gd:"\u8607\u683C\u862D\u84CB\u723E\u8A9E",gl:"\u52A0\u5229\u897F\u4E9E\u8A9E",gu:"\u53E4\u5409\u62C9\u7279\u8A9E",ha:"\u8C6A\u6492\u8A9E",haw:"\u590F\u5A01\u5937\u8A9E",he:"\u5E0C\u4F2F\u4F86\u8A9E",hi:"\u5370\u5730\u8A9E",hmn:"\u82D7\u8A9E",hr:"\u514B\u7F85\u5730\u4E9E\u8A9E",ht:"\u6D77\u5730\u514B\u91CC\u5967\u723E\u8A9E",hu:"\u5308\u7259\u5229\u8A9E",hy:"\u4E9E\u7F8E\u5C3C\u4E9E\u8A9E",id:"\u5370\u5C3C\u8A9E",ig:"\u4F0A\u535A\u8A9E",is:"\u51B0\u5CF6\u8A9E",it:"\u610F\u5927\u5229\u8A9E",ja:"\u65E5\u8A9E",jw:"\u722A\u54C7\u8A9E",ka:"\u55AC\u6CBB\u4E9E\u8A9E",kk:"\u54C8\u85A9\u514B\u8A9E",km:"\u9AD8\u68C9\u8A9E",kn:"\u574E\u7D0D\u9054\u8A9E",ko:"\u97D3\u8A9E",ku:"\u5EAB\u723E\u5FB7\u8A9E",ky:"\u5409\u723E\u5409\u65AF\u8A9E",la:"\u62C9\u4E01\u8A9E",lb:"\u76E7\u68EE\u5821\u8A9E",lo:"\u8001\u64BE\u8A9E",lt:"\u7ACB\u9676\u5B9B\u8A9E",lv:"\u62C9\u812B\u7DAD\u4E9E\u8A9E",mg:"\u99AC\u62C9\u52A0\u65AF\u8A9E",mi:"\u6BDB\u5229\u8A9E",mk:"\u99AC\u5176\u9813\u8A9E",ml:"\u99AC\u62C9\u96C5\u62C9\u59C6\u8A9E",mn:"\u8499\u53E4\u8A9E",mr:"\u99AC\u62C9\u5730\u8A9E",ms:"\u99AC\u4F86\u8A9E",mt:"\u99AC\u723E\u4ED6\u8A9E",mww:"\u767D\u82D7\u8A9E",my:"\u7DEC\u7538\u8A9E",ne:"\u5C3C\u6CCA\u723E\u8A9E",nl:"\u8377\u862D\u8A9E",no:"\u632A\u5A01\u8A9E",ny:"\u9F4A\u5207\u74E6\u8A9E",otq:"\u594E\u96F7\u5854\u7F85\u5967\u6258\u7C73\u8A9E",pa:"\u65C1\u906E\u666E\u8A9E",pl:"\u6CE2\u862D\u8A9E",ps:"\u666E\u4EC0\u5716\u8A9E",pt:"\u8461\u8404\u7259\u8A9E","pt-br":"\u8461\u8404\u7259\u8A9E\uFF08\u5DF4\u897F\uFF09",ro:"\u7F85\u99AC\u5C3C\u4E9E\u8A9E",ru:"\u4FC4\u8A9E",sd:"\u4FE1\u5FB7\u8A9E",si:"\u50E7\u4F3D\u7F85\u8A9E",sk:"\u65AF\u6D1B\u4F10\u514B\u8A9E",sl:"\u65AF\u6D1B\u7DAD\u5C3C\u4E9E\u8A9E",sm:"\u85A9\u6469\u4E9E\u8A9E",sn:"\u7D39\u7D0D\u8A9E",so:"\u7D22\u99AC\u91CC\u8A9E",sq:"\u963F\u723E\u5DF4\u5C3C\u4E9E\u8A9E",sr:"\u585E\u723E\u7DAD\u4E9E\u8A9E","sr-Cyrl":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u897F\u91CC\u723E\u6587)","sr-Latn":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u62C9\u4E01\u6587)",st:"\u585E\u7D22\u6258\u8A9E",su:"\u5DFD\u4ED6\u8A9E",sv:"\u745E\u5178\u8A9E",sw:"\u65AF\u74E6\u5E0C\u91CC\u8A9E",ta:"\u6CF0\u7C73\u723E\u8A9E",te:"\u6CF0\u76E7\u56FA\u8A9E",tg:"\u5854\u5409\u514B\u8A9E",th:"\u6CF0\u8A9E",tlh:"\u514B\u6797\u8CA2\u8A9E","tlh-Qaak":"\u514B\u6797\u8CA2\u8A9E (piqaD)",to:"\u6771\u52A0\u8A9E",tr:"\u571F\u8033\u5176\u8A9E",ty:"\u5854\u5E0C\u63D0\u8A9E",ug:"\u7DAD\u543E\u723E\u8A9E",uk:"\u70CF\u514B\u862D\u8A9E",ur:"\u70CF\u723E\u90FD\u8A9E",uz:"\u70CF\u8332\u5225\u514B\u8A9E",vi:"\u8D8A\u5357\u8A9E",wyw:"\u6587\u8A00\u6587",xh:"\u79D1\u85A9\u8A9E",yi:"\u610F\u7B2C\u7DD2\u8A9E",yo:"\u7D04\u9B6F\u5DF4\u8A9E",yua:"\u5C24\u52A0\u6566\u99AC\u96C5\u8A9E",yue:"\u5EE3\u6771\u8A71 (\u50B3\u7D71)","zh-CN":"\u7C21\u9AD4\u4E2D\u6587","zh-TW":"\u7E41\u9AD4\u4E2D\u6587","zh-CN-NE":"\u6771\u5317\u8A71",zu:"\u7956\u9B6F\u8A9E","":"\u6240\u6709\u8A9E\u8A00"};var hc=[{name:"touch",shortcuts:[{command:"touchShortcutsToggleTranslatePage",type:"finger"},{command:"touchShortcutsToggleTranslationMask",type:"finger"},{command:"touchShortcutsToggleTranslatePageOnlyTranslation",type:"finger"},{command:"touchShortcutsToggleTranslateTouchElement",type:"finger"}]},{name:"main",shortcuts:["toggleTranslatePage","shareToDraft","translateInputBox"]},{name:"mouse",shortcuts:[{command:"mouseHoverHoldKey",type:"mouseHoverHoldKey"},"toggleMouseHoverTranslateDirectly"]},{name:"others",shortcuts:["toggleTranslationMask","toggleTranslateToThePageEndImmediately","toggleTranslateTheMainPage","toggleOnlyTransation","toggleTranslateTheWholePage","toggleVideoSubtitlePreTranslation"]},{name:"shortcutsForTranslationServices",shortcuts:["translateWithDeepL","translateWithGoogle","translateWithOpenAI","translateWithBing","translateWithTransmart","translateWithGemini"]}],n1=["https://immersive-translate.owenyoung.com/options/","https://immersive-translate.owenyoung.com/auth-done/","https://dash.immersivetranslate.com/","https://dash.immersivetranslate.com/auth-done/","http://localhost:8000/dist/userscript/options/","http://localhost:8000/auth-done/","http://192.168.50.9:8000/dist/userscript/options/","http://192.168.31.51:8000/dist/userscript/options/","http://192.168.1.72:8000/dist/userscript/options/","https://www.deepl.com/translator","translate.google.com","http://localhost:8000/options/","http://192.168.50.9:8000/options/","http://192.168.31.51:8000/options/","http://192.168.1.72:8000/options/"],Br="zh-CN",bc="https://immersivetranslate.com/docs/communities/",_b=[{type:"select",name:"codename",labelKey:"field.translationEngine",default:"youdao",required:!1,options:[{label:"translationServices.google",value:"google"},{label:"translationServices.deepl",value:"deepl"},{label:"translationServices.youdao",value:"youdao"},{label:"translationServices.tencent",value:"tencent"},{label:"translationServices.aliyun",value:"aliyun"},{label:"translationServices.baidu",value:"baidu"},{label:"translationServices.caiyun",value:"caiyun"},{label:"translationServices.wechat",value:"wechat"},{label:"translationServices.ibm",value:"ibm"},{label:"translationServices.azure",value:"azure"},{label:"translationServices.aws",value:"aws"}]}],yc=["caiyun","cai"],nr={bing:{name:"\u5FAE\u8F6F\u7FFB\u8BD1",homepage:"https://www.bing.com/translator"},google:{name:"Google",homepage:"https://translate.google.com/"},deepl:{name:"DeepL",homepage:"https://www.deepl.com/translator",docUrl:"https://immersivetranslate.com/docs/services/deepL/",providers:[{name:"pro",nameKey:"deepLProName",descriptionKey:"deepLProDescription",descriptionKeyForNormal:"deeplProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"deepLCustomName",descriptionKey:"deepLCustomDescription",descriptionLink1:"https://www.deepl.com/translator",descriptionLink2:"https://immersivetranslate.com/docs/services/deepL/"}],allProps:[{name:"authKey",providers:["custom"],label:"Auth Key",required:!0,type:"password"}]},openai:{name:"Open AI",homepage:"https://openai.com/api/",docUrl:"https://immersivetranslate.com/docs/services/openai/",providers:[{name:"pro",nameKey:"openaiProName",descriptionKey:"openaiProDescription",descriptionKeyForNormal:"openaiProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"openaiCustomName",descriptionKey:"openaiCustomDescription",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/"}],allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",required:!1,type:"model-select",default:"gpt-3.5-turbo-1106",providers:["custom"],options:[{providers:["custom","pro"],label:"gpt-3.5-turbo",value:"gpt-3.5-turbo"},{providers:["custom"],label:"gpt-3.5-turbo-0125",value:"gpt-3.5-turbo-0125"},{providers:["custom","pro"],label:"gpt-3.5-turbo-1106",value:"gpt-3.5-turbo-1106"},{providers:["custom","pro"],label:"gpt-3.5-turbo-0613",value:"gpt-3.5-turbo-0613"},{providers:["custom"],label:"gpt-4-1106-preview",value:"gpt-4-1106-preview"},{providers:["custom"],label:"gpt-4-0125-preview",value:"gpt-4-0125-preview"},{providers:["custom"],label:"gpt-4",value:"gpt-4"}]},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.limitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:10,providers:["custom"]},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.openai.com/v1/chat/completions",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",optional:!0,providers:["custom"]},{name:"systemPrompt",label:"System Prompt",required:!1,descriptionKey:"description.systemPrompt",type:"textarea",optional:!0,default:"You are a translation engine, you can only translate text and cannot interpret it, and do not explain."},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:`Translate the text to {{to}}, please do not explain any sentences, just translate or leave them as they are.: -{{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:ou,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[..._b,{type:"password",name:"apikey",required:!0}],props:_b},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},Tc={type:be+"ChildFrameToRootFrameIdentifier"},Ep=["youtube","netflix","webvtt","khanacademy","bilibili","udemy","hulu","text_track","text_track_dynamic","general","live","ebutt","disneyplus","fmp4.xml","multi_attach_vtt","twitter","subsrt","xml","av"],sa=["Ctrl","Shift","Alt","Auto","Off","OtherCustom","Other"],r1=["ctrl","alt","shift","cmd","command","option","control"],vc=[{key:"/"},{key:"="},{key:";"},{key:","},{key:"."},{key:":"},{key:"space",labelKey:"spaceKey",skipForStarting:!0},{key:"none",labelKey:"noneKey",skipForTrailing:!0}],Oj=pn()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general",uu="user_from_plugin",ht="user_info",Pi=pn()||tr()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",Sc=pn()||tr()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",a1=Sc+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",i1=Sc+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Li=pn()||tr()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Fa=pn()||tr()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",n7=pn()||tr()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",r7=pn()||tr()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",a7=pn()||tr()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",zj=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",o1=n7+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",s1=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Cc=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",u1=r7+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",l1=a7+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",c1=Li+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true",xc="https://immersivetranslate.com/docs/usage/",d1="https://immersivetranslate.com/docs/communities/",g1=Le().TRANSLATE_FILE_URL,p1=g1+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",m1=g1+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var Po=console,wp=class{#e=performance.now();reset(){this.#e=performance.now()}stop(t){let n=performance.now(),r=Math.round(n-this.#e),a=Zn.green;r>1e4?a=Zn.red:r>1e3&&(a=Zn.yellow),Po.debug(Zn.dim(Di+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},lu=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&Po.log(Zn.dim(Di+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&Po.log(Zn.green(Di+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&Po.warn(Zn.yellow(Di+" WARN:"),...t)}error(...t){this.#e<=3&&Po.error(Zn.red(Di+" ERROR:"),...t)}fatal(...t){this.#e<=4&&Po.error(Zn.red(Di+" FATAL:"),...t)}timing(){return this.level===0?new wp:{reset:()=>{},stop:()=>{}}}},R=new lu;p();function ot(){try{let e=[Le().EBOOK_BUILDER_URL,Le().EBOOK_VIEWER_URL,Le().SUBTITLE_BUILDER_URL,Le().HTML_VIEWER_URL,Le().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];pn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&t.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}p();p();var Ec={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.3",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};p();p();p();var Dp=/iPhone/i,f1=/iPod/i,h1=/iPad/i,b1=/\biOS-universal(?:.+)Mac\b/i,Ap=/\bAndroid(?:.+)Mobile\b/i,y1=/Android/i,Lo=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wc=/Silk/i,ua=/Windows Phone/i,T1=/\bWindows(?:.+)ARM\b/i,v1=/BlackBerry/i,S1=/BB10/i,C1=/Opera Mini/i,x1=/\b(CriOS|Chrome)(?:.+)Mobile/i,E1=/Mobile(?:.+)Firefox\b/i,w1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function o7(e){return t=>t.test(e)}function st(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=o7(n),i={apple:{phone:a(Dp)&&!a(ua),ipod:a(f1),tablet:!a(Dp)&&(a(h1)||w1(t))&&!a(ua),universal:a(b1),device:(a(Dp)||a(f1)||a(h1)||a(b1)||w1(t))&&!a(ua)},amazon:{phone:a(Lo),tablet:!a(Lo)&&a(wc),device:a(Lo)||a(wc)},android:{phone:!a(ua)&&a(Lo)||!a(ua)&&a(Ap),tablet:!a(ua)&&!a(Lo)&&!a(Ap)&&(a(wc)||a(y1)),device:!a(ua)&&(a(Lo)||a(wc)||a(Ap)||a(y1))||a(/\bokhttp\b/i)},windows:{phone:a(ua),tablet:a(T1),device:a(ua)||a(T1)},other:{blackberry:a(v1),blackberry10:a(S1),opera:a(C1),firefox:a(E1),chrome:a(x1),device:a(v1)||a(S1)||a(C1)||a(E1)||a(x1)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var kp="DENO",Dc="CHROME",Ac="FIREFOX";function D1(e){let t=Dc;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Ac:/deno/i.test(n)&&(t=kp)}catch{}return e===Dc&&t===Dc||e===Ac&&t===Ac||e===kp&&t===kp}function Pp(){return D1(Dc)}function A1(){return typeof Deno<"u"}function rr(){return D1(Ac)}function Ba(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function k1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function _i(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function P1(){return pe()?"monkey":Pp()?"chrome":rr()?"firefox":Ge()?"safari":null}p();var L1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},_1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:L1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:L1,query:()=>{},sendMessage:()=>{}}};var Z;A1()?Z=_1:Z=globalThis.immersiveTranslateBrowserAPI;var s7="";function On(){return s7||Ec.version}function Ir(){return Z.runtime.getManifest().version}p();function M1(e){return e.replace(//g,">")}p();function Qt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function F1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function B1(e){if(e){let t=new Date(e.createTime),n=u7(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function u7(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}p();p();function ve(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Rn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Rn[a]}else return"auto";else return Rn[r]}function At(){return ve(document?.documentElement?.lang||"en")}function cu(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+o.text.length>t||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function l7(e,t){let n=[],r=[];for(let a=0;a0?y1e4?a=Zn.red:r>1e3&&(a=Zn.yellow),Po.debug(Zn.dim(Di+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},lu=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&Po.log(Zn.dim(Di+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&Po.log(Zn.green(Di+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&Po.warn(Zn.yellow(Di+" WARN:"),...t)}error(...t){this.#e<=3&&Po.error(Zn.red(Di+" ERROR:"),...t)}fatal(...t){this.#e<=4&&Po.error(Zn.red(Di+" FATAL:"),...t)}timing(){return this.level===0?new wp:{reset:()=>{},stop:()=>{}}}},R=new lu;p();function ot(){try{let e=[Le().EBOOK_BUILDER_URL,Le().EBOOK_VIEWER_URL,Le().SUBTITLE_BUILDER_URL,Le().HTML_VIEWER_URL,Le().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];pn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&t.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}p();p();var Ec={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.4",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};p();p();p();var Dp=/iPhone/i,f1=/iPod/i,h1=/iPad/i,b1=/\biOS-universal(?:.+)Mac\b/i,Ap=/\bAndroid(?:.+)Mobile\b/i,y1=/Android/i,Lo=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wc=/Silk/i,ua=/Windows Phone/i,T1=/\bWindows(?:.+)ARM\b/i,v1=/BlackBerry/i,S1=/BB10/i,C1=/Opera Mini/i,x1=/\b(CriOS|Chrome)(?:.+)Mobile/i,E1=/Mobile(?:.+)Firefox\b/i,w1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function o7(e){return t=>t.test(e)}function st(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=o7(n),i={apple:{phone:a(Dp)&&!a(ua),ipod:a(f1),tablet:!a(Dp)&&(a(h1)||w1(t))&&!a(ua),universal:a(b1),device:(a(Dp)||a(f1)||a(h1)||a(b1)||w1(t))&&!a(ua)},amazon:{phone:a(Lo),tablet:!a(Lo)&&a(wc),device:a(Lo)||a(wc)},android:{phone:!a(ua)&&a(Lo)||!a(ua)&&a(Ap),tablet:!a(ua)&&!a(Lo)&&!a(Ap)&&(a(wc)||a(y1)),device:!a(ua)&&(a(Lo)||a(wc)||a(Ap)||a(y1))||a(/\bokhttp\b/i)},windows:{phone:a(ua),tablet:a(T1),device:a(ua)||a(T1)},other:{blackberry:a(v1),blackberry10:a(S1),opera:a(C1),firefox:a(E1),chrome:a(x1),device:a(v1)||a(S1)||a(C1)||a(E1)||a(x1)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var kp="DENO",Dc="CHROME",Ac="FIREFOX";function D1(e){let t=Dc;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Ac:/deno/i.test(n)&&(t=kp)}catch{}return e===Dc&&t===Dc||e===Ac&&t===Ac||e===kp&&t===kp}function Pp(){return D1(Dc)}function A1(){return typeof Deno<"u"}function rr(){return D1(Ac)}function Ba(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function k1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function _i(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function P1(){return pe()?"monkey":Pp()?"chrome":rr()?"firefox":Ge()?"safari":null}p();var L1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},_1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:L1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:L1,query:()=>{},sendMessage:()=>{}}};var Z;A1()?Z=_1:Z=globalThis.immersiveTranslateBrowserAPI;var s7="";function On(){return s7||Ec.version}function Ir(){return Z.runtime.getManifest().version}p();function M1(e){return e.replace(//g,">")}p();function Qt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function F1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function B1(e){if(e){let t=new Date(e.createTime),n=u7(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function u7(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}p();p();function ve(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Rn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Rn[a]}else return"auto";else return Rn[r]}function At(){return ve(document?.documentElement?.lang||"en")}function cu(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+o.text.length>t||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function l7(e,t){let n=[],r=[];for(let a=0;a0?yt){let x=[];Lp(T,t,x);for(let w=0;w0&&y{let s=e.lastIndexOf(o,t);return s>i?s:i},-1);if(a===-1){let i=e.slice(0,t);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),e.length>t&&Lp(e.slice(t),t,n)}else{let i=e.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){g.forEach(y=>{c.length>0&&y.providers&&y.providers.length>0&&!y.providers.includes(l)||(y.optional?m.push(y):f.push(y))});let h=m.concat(f).filter(y=>y.required);if(h.length>0){for(let y of h)if(!i[y.name]){u=!1;break}}}return{...a,id:t,selected:n[e]===t,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:g,optionalProps:m,explicitProps:f}}var Mi=(e,t)=>{let{config:n}=e,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=e.user,u=Qt(s),l=Object.keys(nr);return t!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let g=nr[c];if(c.startsWith("mock"))return o?!0:c===e.config[t];if(c===e.config[t])return!0;if(c==="openai"&&Ge())return e.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let f=!!g.canary,m=!!g.alpha,h=!!g.beta;return c===e[t]||f&&i||m&&(r||i)||h&&(a||r||i)?!0:!m&&!h&&!f}).map(c=>_o(t,c,e))};function du(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function R1(e){return e.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}p();var O1=be+"SyncStoreKey_";function qt(e,t){let n=O1+e;return Z.storage.sync.get(n).then(r=>r[n]===void 0?t:r[n])}function at(e,t){let n=O1+e;return Z.storage.sync.set({[n]:t})}p();var Fi=be+"CacheKey_";function _p(e,t){let n=Fi+e;return Z.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function c7(){let e=Z.storage.local.refresh;e&&e()}function Mp(e,t){let n=Fi+e;return Z.storage.local.get(n).then(r=>{if(r[n]===void 0)return t;let{value:a,expired:i}=r[n];return i&&ir.startsWith(Fi)).filter(r=>r!==Fi+ht);if(n.length>0)return Z.storage.local.remove(n)}}var it={get:_p,set:Bp,getExpired:Mp,setExpired:Fp,remove:Ip,clear:Rp,refresh:c7};p();var z1=["*://*/*","*","*://*"],U1="immersive-translate-wildcard-placeholder.com";function Op(e,t){try{let n=[];if(!t||(t&&!Array.isArray(t)?n=[t]:n=t,n.length===0))return null;if(n.some(s=>z1.includes(s)))return e;let r=new URL(e);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(z1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,g=l.port===o;return l.port?c&&g:c}else return g7(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let T=u.split("://");l=T[0],l==="*"&&T.length>1&&(l="*",u="https://"+T[1])}else l="*",u="https://"+u;let g=u.replace(/\*/g,U1),f;try{f=new URL(g)}catch{return R.debug("invalid match pattern",g,"raw match value:",c),!1}let m=f.host,h=f.pathname;h==="/"&&(c.replace("://","").includes("/")||(h="/*"));let y=d7(l+":",N1(m),N1(h));if(y){let T=new URL(a);return y.test(T.href)}else return!1}});if(s)return s}return null}catch{return null}}function N1(e){return e.replaceAll(U1,"*")}function d7(e,t,n){let r="^";return e==="*:"?r+="(http:|https:|file:)":r+=e,r+="//",t&&(e==="file:"||(t==="*"?r+="[^/]+?":(t.match(/^\*\./)&&(r+="[^/]*?",t=t.substring(1)),r+=t.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function _t(e,t){return Op(e,t)!==null}function g7(e,t){let n=new URL(e),r=new URL(t);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}p();p();var q1=be+"StoreKey_";function la(e,t){let n=q1+e;return Z.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function j1(e,t){let n=q1+e;return Z.storage.local.set({[n]:t})}p();p();p();p();function H1(e,t){return[e,!e||e.endsWith("/")?"":"/",t,".json"].join("")}function zp(e,t){let n=e;return t&&Object.keys(t).forEach(r=>{let a=t[r];if(a===void 0)return;let i=p7(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let g=n.substring(u+s.length,c),f=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");n=n.replace(`${s}${g}`,`<${l} ${f}>${g}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function gu(e,t,n){let r=e[t];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function Rr(e,t,n,r,a){if(!e.hasOwnProperty(n))return t;let i=gu(e,n,t);return i===t&&n!==r&&(i=gu(e,r,t)),zp(i,a)}function p7(e){if(typeof e=="number")return!0;if(e){let t=parseInt(e);return!isNaN(t)}else return!1}function jt(e,t,n){return Rr(nn,t,e.config.interfaceLanguage,"en",n)}p();function W1(e,t){let n=new Date(e),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return t.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function K1(e){return new Date(e).getTime()}var Q=class extends Error{status;constructor(t,n){if(t&&n){super(n),this.name=t;return}super(t)}initNetWork(t){return t&&(this.status=t),this}initStack(t){return t&&(this.stack=t),this}initData(t){return this.data=t,this}data;uiConfig(t){if(!this.message)return{};let n=null;if(n=this.handleProQuota(t)||this.handleUnavailableError(t)||this.handleProUser(t)||this.handleServiceMissingConfig(t)||this.handleNetwork(t)||this.handleFetchError(t),!n){let r=jt.bind(null,t),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(t){let n=jt.bind(null,t),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(t){let n=jt.bind(null,t);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(t){let n=jt.bind(null,t),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(t){let n=jt.bind(null,t);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(t){let n=jt.bind(null,t);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return t.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(t){if(!this.message.startsWith("ProQuota:")||!t.user?.subscription)return;let n=jt.bind(null,t);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=t.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let g=this.data?.translationService=="deepl"?"OpenAI":"Deepl",f=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=n("errorReason",{message:r});if(i=="onetime_7day")m+=n("proQuotaExceededError.onetime7day",{anotherService:g,brandId:ee,href:Cc});else{let h="";f=="OpenAI"?h=u1:h=l1,o?m+=n("proQuotaExceededError.trial",{anotherService:g,brandId:ee,href:c1}):m+=n("proQuotaExceededError.nonTrial",{anotherService:g,brandId:ee,href:h,translationService:f}),!o&&(a.cancelAtPeriodEnd==="false"||K1(u)>s)&&(m+=n("proQuotaExceededError.resetTime",{resetTime:W1(s,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function Tr(e){let t;if(e&&e.retry&&e.retry>0)try{t=await eg(G1.bind(null,e),{multiplier:2,maxAttempts:e.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else t=await G1(e);return t}async function G1(e){e.body;let{url:t,responseType:n,...r}=e;n||(n="json"),r={mode:"cors",...r};let a=!0;e.fetchPolyfill&&(a=!1);let i=e.fetchPolyfill||fetch,o=3e4;if(e.timeout&&(o=e.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(t,r)}catch(u){R.debug("fetch error",t,u);let l=u.message||"Unknown Error";throw new Q("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=t),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of m7(s.body)){let g=new TextDecoder().decode(c);u+=g;let f;for(;(f=u.indexOf(` -`))>=0;){let m=u.slice(0,f).trim();if(u=u.slice(f+1),m.startsWith("event:")||m==="")continue;let h="";if(m.startsWith("data:")&&(h=m.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(T){R.debug("json error",T);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(m){R.error("parse response failed",m)}u&&R.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,f=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),f&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new Q("fetchError",c).initNetWork(s.status)}}async function*m7(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}p();var f7=new Map;function kc(e){let t=h7(64),n=new CustomEvent(Fb,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{f7.set(t,(i,o)=>{i?a(i):r(o)})})}function h7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=Up(s),{type:f,name:m}=g;if(f!==t)return!1;let h=Up(o),T=pu.get(f).get(m);if(!T)return this.logger.debug(`no message handler for ${f}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=T,w={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let L=b(r.payload,w);i({ok:!0,data:L})}catch(L){i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.details,errorStatus:L.status})}return!1}else return b(r.payload,w).then(L=>{i({ok:!0,data:L})}).catch(L=>{i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.message,errorStatus:L.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=pu.get(i);if(o.has(t))return o.get(t).connectionInstance;{let s=new Np(`${i}:${t}`,this.logger);return pu.get(i).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Np=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=Up(t),{type:a,id:i}=r;if(a!=="content_script"){let o={to:t,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await Z.runtime.sendMessage(o);return V1(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:t,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await Z.tabs.sendMessage(i,o);return V1(o,s,this.logger)}}};function V1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new Q(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new Q("noResponse","Unknown error")}function Up(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}p();var b7="";function Mo(){return b7||globalThis.navigator.userAgent}function qp(){return Mo().includes("ImtFxiOS")}function $1(){let t=Mo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function y7(){return Mo().includes("ImtFxAndroid")}function Y1(){let e=Mo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Q1(){let t=Mo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function mu(){let e=Mo();if(qp()||y7()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Pc;function T7(){return Pc||(Pc=new ca("content_script",!1).getConnection("pure_main",()=>{}),Pc)}var Z1="G-MKMD9LWFTR";async function Bi(e){try{let t=Le(),n=t.INSTALL_FROM==="firefox_store";if(mu()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=pe(),i=ot(),o=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await qt("fakeUserId","");u||(u=await la("fakeUserId",""),u&&await at("fakeUserId",u));let l=On(),c=new Date,g=await qt("installedAt","");g||(g=await la("installedAt",""),g&&await at("installedAt",g)),u?g||(g=new Date(0).toISOString(),await at("installedAt",g)):(u=v7(32),await at("fakeUserId",u)),g||(g=c.toISOString(),await at("installedAt",g));let f=new Date(g),m=J1(f),h=J1(c),y=m===h,T=c.getTime()-f.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${Z1}&api_secret=${s}`;o||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Z1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let w=po.parse(x),L=e.map(C=>{let v=C.params||{};if(w.os&&(v.os_name=w.os.name||"unknown",v.os_version=w.os.version||"unknown",v.os_version_name=w.os.versionName||"unknown"),w.browser){v.browser_name=w.browser.name||"unknown",v.browser_version=w.browser.version||"unknown";let A=mu();A&&(v.browser_name=A.name,v.browser_version=A.version)}return w.platform&&(v.platform_type=w.platform.type||"unknown"),w.engine&&(v.engine_name=w.engine.name||"unknown",v.engine_version=w.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),m&&(v.install_day=S7(f)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",T?v.is_new_user_this_week="1":v.is_new_user_this_week="0",i?v.main_frame=0:v.main_frame=1,{...C,params:v}}),M=await Lc({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:L})})}catch{}}function v7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=u.slice(0,f).trim();if(u=u.slice(f+1),m.startsWith("event:")||m==="")continue;let h="";if(m.startsWith("data:")&&(h=m.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(T){R.debug("json error",T);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(m){R.error("parse response failed",m)}u&&R.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,f=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),f&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new Q("fetchError",c).initNetWork(s.status)}}async function*m7(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}p();var f7=new Map;function kc(e){let t=h7(64),n=new CustomEvent(Fb,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{f7.set(t,(i,o)=>{i?a(i):r(o)})})}function h7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=Up(s),{type:f,name:m}=g;if(f!==t)return!1;let h=Up(o),T=pu.get(f).get(m);if(!T)return this.logger.debug(`no message handler for ${f}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=T,w={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let L=b(r.payload,w);i({ok:!0,data:L})}catch(L){i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.details,errorStatus:L.status})}return!1}else return b(r.payload,w).then(L=>{i({ok:!0,data:L})}).catch(L=>{i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.message,errorStatus:L.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=pu.get(i);if(o.has(t))return o.get(t).connectionInstance;{let s=new Np(`${i}:${t}`,this.logger);return pu.get(i).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Np=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=Up(t),{type:a,id:i}=r;if(a!=="content_script"){let o={to:t,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await Z.runtime.sendMessage(o);return V1(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:t,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await Z.tabs.sendMessage(i,o);return V1(o,s,this.logger)}}};function V1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new Q(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new Q("noResponse","Unknown error")}function Up(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}p();var b7="";function Mo(){return b7||globalThis.navigator.userAgent}function qp(){return Mo().includes("ImtFxiOS")}function $1(){let t=Mo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function y7(){return Mo().includes("ImtFxAndroid")}function Y1(){let e=Mo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Q1(){let t=Mo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function mu(){let e=Mo();if(qp()||y7()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Pc;function T7(){return Pc||(Pc=new ca("content_script",!1).getConnection("pure_main",()=>{}),Pc)}var Z1="G-MKMD9LWFTR";async function Bi(e){try{let t=Le(),n=t.INSTALL_FROM==="firefox_store";if(mu()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=pe(),i=ot(),o=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await qt("fakeUserId","");u||(u=await la("fakeUserId",""),u&&await at("fakeUserId",u));let l=On(),c=new Date,g=await qt("installedAt","");g||(g=await la("installedAt",""),g&&await at("installedAt",g)),u?g||(g=new Date(0).toISOString(),await at("installedAt",g)):(u=v7(32),await at("fakeUserId",u)),g||(g=c.toISOString(),await at("installedAt",g));let f=new Date(g),m=J1(f),h=J1(c),y=m===h,T=c.getTime()-f.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${Z1}&api_secret=${s}`;o||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Z1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let w=po.parse(x),L=e.map(C=>{let v=C.params||{};if(w.os&&(v.os_name=w.os.name||"unknown",v.os_version=w.os.version||"unknown",v.os_version_name=w.os.versionName||"unknown"),w.browser){v.browser_name=w.browser.name||"unknown",v.browser_version=w.browser.version||"unknown";let A=mu();A&&(v.browser_name=A.name,v.browser_version=A.version)}return w.platform&&(v.platform_type=w.platform.type||"unknown"),w.engine&&(v.engine_name=w.engine.name||"unknown",v.engine_version=w.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),m&&(v.install_day=S7(f)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",T?v.is_new_user_this_week="1":v.is_new_user_this_week="0",i?v.main_frame=0:v.main_frame=1,{...C,params:v}}),M=await Lc({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:L})})}catch{}}function v7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5353,7 +5353,7 @@ ${s}} `+t.rule.additionalInjectedCss.join(` `):t.rule.additionalInjectedCss&&(s+=` `+t.rule.additionalInjectedCss)),s&&Kn(e,s,"immersive-translate-dynamic-injected-css")}p();p();p();var R7=0;function d(e,t,n,r,a){var i,o,s={};for(o in t)o=="ref"?i=t[o]:s[o]=t[o];var u={type:e,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--R7,__source:a,__self:r};if(typeof e=="function"&&(i=e.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Oe.vnode&&Oe.vnode(u),u}function Jp({value:e,defaultCase:t=null,cases:n}){return e==null?null:d(xe,{children:n[e]!=null?n[e]:t})}p();function Xp(){let[e,t]=K(location.hash);return le(()=>{let n=()=>t(location.hash);return globalThis.addEventListener("hashchange",n,!1),()=>{globalThis.removeEventListener("hashchange",n)}},[]),e}p();p();p();var Dy={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},Ay={...nn,"zh-CN":{...Dy["zh-CN"],...nn["zh-CN"]},"zh-TW":{...Dy["zh-TW"],...nn["zh-TW"]}},Uo=Ay;function ja(e,t,n){return Rr(Ay,e,t,Br,n)}var Nc=()=>Rn.filter(e=>e!=="auto"),Zt=(e,t,n,r)=>{let a=Xb[e]||e,i=e1[e],o=t1[e],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[e]?s[e]:a;if(s[t]){let u=s[t];return r||e==="auto"||e==="placeholder"?u:`${u} (${a})`}else return a};p();p();p();p();p();p();p();p();p();p();var zr=class{accessToken;constructor(t){this.accessToken=t}async listAll(){let t=[],n="";do{let{nextPageToken:r,files:a}=await this.list(n).catch(i=>{throw i});t.push(...a),n=r||""}while(n);return t}async getConfig(t){try{return await(await fetch(`https://www.googleapis.com/drive/v3/files/${t}?alt=media`,{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(n){return R.error("get config error, use default",n),{}}}async delete(t){await fetch(`https://www.googleapis.com/drive/v3/files/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${this.accessToken}`}})}findByName(t){return this.list(void 0,`name = '${t}'`)}uploadConfig(t,n=uc){let r=new Blob([JSON.stringify(t,null,2)],{type:"application/json"});return this.upload({name:n,parents:["appDataFolder"],mimeType:"application/json"},r)}updateConfig(t,n){let r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"});return this.updateContent(t,r)}async upload(t,n){let r=new FormData;r.append("metadata",new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"})),r.append("file",n);let a=await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart",{method:"POST",headers:{Authorization:`Bearer ${this.accessToken}`},body:r});return a.ok?await a.json():Promise.reject(a.text())}async list(t,n){let r=new URL("https://www.googleapis.com/drive/v3/files");t&&r.searchParams.append("pageToken",t),n&&r.searchParams.append("q",n),r.searchParams.append("spaces","appDataFolder"),r.searchParams.append("fields","files(id,name,createdTime,modifiedTime,size)"),r.searchParams.append("pageSize","100"),r.searchParams.append("orderBy","createdTime desc");try{return R.debug("list api:",r.toString(),this.accessToken),await(await fetch(r.toString(),{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(a){throw R.error("fetch google ip error",a),a}}async updateContent(t,n){return await(await fetch(`https://www.googleapis.com/upload/drive/v3/files/${t}?uploadType=media`,{method:"PATCH",headers:{Authorization:`Bearer ${this.accessToken}`},body:n})).text()}};function ky(e,t){let n=["https://www.googleapis.com/auth/drive.appdata"];return`https://accounts.google.com/o/oauth2/v2/auth?client_id=${sc}&response_type=token&redirect_uri=${encodeURIComponent(t)}&scope=${encodeURIComponent(n.join(" "))}&state=${encodeURIComponent(JSON.stringify(e))}`}function Py(e){let t=e.match(/[#?](.*)/);return!t||t.length<1?null:{access_token:new URLSearchParams(t[1].split("#")[0]).get("access_token")}}async function em(e,t,n,r,a,i,o){if(R.debug(`autoSyncStrategy accessToken: ${e}`),t===null){R.debug("autoSyncStrategy settings is null");return}let s=new zr(e);try{let u=(await s.findByName(uc)).files;R.debug("files",u);let l=u[0]?.id,c=null;if(l&&(c=await s.getConfig(l).then(g=>({fileId:l,config:g}))),c){let{config:g,fileId:f}=c,m=g.updatedAt?new Date(g.updatedAt):new Date(0),h=t.updatedAt?new Date(t.updatedAt):new Date(0);if(R.debug("remoteUpdatedAt",m,"localUpdatedAt",h),m>h)R.debug("remote is newer, update local config",g),n(g),i&&i(!0);else if(m.getTime()===h.getTime())R.debug("remote and local are the same, do nothing"),i&&i(!1);else if(m(await e.removeAuthInfo(),eu()&&globalThis.location.reload(),r))}static async getAuthInfo(){let t=await Z.storage.local.get(_a);if(t[_a])return t[_a]}static async removeAuthInfo(){return await Z.storage.local.remove(_a)}static setAuthInfo(t){return Z.storage.local.set({[_a]:t})}async auth(t=!1){let n=await e.getAuthInfo();if(R.debug(this.CLASSNAME,"token from cache:",n),n&&n.access_token&&await Ly(n.access_token).then(i=>!0).catch(i=>!1))return Promise.resolve(n);let r=ky(this._state,this._redirectUrl);return R.debug(this.CLASSNAME,"auth url: "+r),eu()?this.userscriptAuthWorkflow(r,t):this.extensionAuthWorkflow(r).then(a=>(e.setAuthInfo(a),a))}async userscriptAuthWorkflow(t,n){return n&&await Z.storage.local.set({[tu]:!0}),globalThis.open(t,"_self"),Promise.resolve({})}extensionAuthWorkflow(t){let n,r=!1;return new Promise((a,i)=>{let o=()=>{Z.tabs.onUpdated.removeListener(s),Z.tabs.onRemoved.removeListener(u)},s=(f,m,h)=>{if(R.debug(this.CLASSNAME,"create tab onUpdated: "+h.url),n===f){let y=new URL(h.url||""),T=Py(h.url);y.pathname.startsWith("/auth-done")&&T?.access_token&&(R.debug(this.CLASSNAME,"auth done: "+h.url),a({access_token:T.access_token}),r=!0,Z.tabs.remove(f),o())}},u=(f,m)=>{R.debug(this.CLASSNAME,"create tab onRemoved: "+f),(f===n||!r)&&(o(),i(new Error("auth failed")))},l=Math.min(500,screen.availWidth),c=Math.min(650,screen.availHeight),g;Z.windows===void 0?g=Z.tabs.create({url:t}).then(f=>{n=f.id}):g=Z.windows.create({url:t,type:"popup",width:l,height:c,left:Math.round((screen.width-l)/2),top:Math.round((screen.height-c)/2)}).then(f=>{n=f.tabs[0].id}),g.then(()=>{Z.tabs.onUpdated.addListener(s),Z.tabs.onRemoved.addListener(u)}).catch(f=>{R.debug(this.CLASSNAME,"create tab failed: "+f),i(f)})})}};var z7="https://www.googleapis.com/oauth2/v3/tokeninfo",N7=sc,U7=Le().REDIRECT_URL;function Ly(e){if(!e)throw"Authorization failure";let t=`${z7}?access_token=${e}`,n=new Request(t,{method:"GET"});function r(a){return new Promise((i,o)=>{a.status!=200&&o("Token validation error"),a.json().then(s=>{s.aud&&s.aud===N7?i(e):o("Token validation error")})})}return fetch(n).then(r)}function _y(e,t=!1){let n=U7;if(typeof window<"u"&&window.location.protocol.startsWith("http")){let a=window.location.hostname,i=window.location.port;n=`${window.location.protocol}//${a}${i?`:${i}`:""}/auth-done/`}return new Ha(e,n).auth(t)}function tm(e,t=!1){return _y(e,t).then(n=>n.access_token||null)}p();p();p();function Wa(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function q7(e,t){return e<>>32-t}function qc(e,t,n,r,a,i){return Wa(q7(Wa(Wa(t,e),Wa(r,i)),a),n)}function mn(e,t,n,r,a,i,o){return qc(t&n|~t&r,e,t,a,i,o)}function fn(e,t,n,r,a,i,o){return qc(t&r|n&~r,e,t,a,i,o)}function hn(e,t,n,r,a,i,o){return qc(t^n^r,e,t,a,i,o)}function bn(e,t,n,r,a,i,o){return qc(n^(t|~r),e,t,a,i,o)}function Uc(e,t){e[t>>5]|=128<>>9<<4)+14]=t;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>t%32&255);return n}function nm(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(e.charCodeAt(t/8)&255)<16&&(r=Uc(r,e.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Uc(a.concat(nm(t)),512+t.length*8),My(Uc(i.concat(o),512+128))}function Fy(e){var t="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+t.charAt(r&15);return n}function rm(e){return unescape(encodeURIComponent(e))}function By(e){return j7(rm(e))}function W7(e){return Fy(By(e))}function Iy(e,t){return H7(rm(e),rm(t))}function K7(e,t){return Fy(Iy(e,t))}function Gn(e,t,n){return t?n?Iy(t,e):K7(t,e):n?By(e):W7(e)}var qo=[];async function xu(e,t){return await new Promise((n,r)=>{let a=e,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=t||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function am(e){let t=`${ee}-${e.service}@${e.from}->${e.to}`;return await V7(t,e)}async function im(e){let t=Gn(e.originalText),n=`${ee}-${e.service}@${e.from}->${e.to}`;return await G7(n,t)}async function G7(e,t){let n=await xu(e);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(t);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function V7(e,t){let n=await xu(e);return(await om()).includes(e)||await $7(e),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(t);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function $7(e){let t="cache_list",n=await xu(ee+"-cacheList",t),a=n.transaction([t],"readwrite").objectStore(t).put({key:e});a.onsuccess=i=>{n.close(),qo.push(e)},a.onerror=i=>{n.close()}}async function om(){if(qo&&qo.length>0)return qo;let e=await xu(ee+"-cacheList","cache_list");return qo=await new Promise(t=>{let n="cache_list",a=e.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{e.close(),t(a.result)},a.onerror=i=>{e.close(),t([])}}),qo}async function sm(){try{let e=[];(await om()).forEach(r=>{e.push(Y7(r))});let n=await Promise.all(e);return cu(n.reduce((r,a)=>r+a,0))}catch{return cu(0)}}async function Y7(e){let t=await xu(e),r=[...t.objectStoreNames].reduce((o,s)=>{let u=Q7(t,s);return o.push(u),o},[]),a=await Promise.all(r);return t.close(),a.reduce((o,s)=>o+s,0)}async function Q7(e,t){return await new Promise((n,r)=>{if(e==null)return r();let a=0,i=e.transaction([t]).objectStore(t).openCursor();i.onsuccess=o=>{let s=i.result;if(s){let u=s.value,l=JSON.stringify(u);a+=l.length,s.continue()}else n(a)},i.onerror=o=>r("error in "+t+": "+o)})}async function Ry(){try{let t=(await om()).map(r=>Z7(r));return!!(await Promise.all(t)).every(r=>r)}catch{return!1}}async function Z7(e){return await new Promise(t=>{let n=indexedDB.deleteDatabase(e);n.onsuccess=()=>{t(!0)},n.onerror=r=>{t(!1)}})}p();function J7(e,t){return Math.floor(Math.random()*(t-e+1))+e}var X7=30,um="RATE_LIMITER_TICKS",qi=class e{static strictTicks={};static clearStrictTicks(){bu(um,"{}")}static async getStrictTicks(t,n){if(n)return this.strictTicks[t]||[];try{let r=await Fc(um);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){R.debug("Error setting rate limiter ticks",r),this.strictTicks[t]=[]}finally{return this.strictTicks[t]||[]}}static wait(t,n){return new Promise((r,a)=>{e.getDelay(t,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(t,n,r){try{if(this.strictTicks[t]=n,r)return;await bu(um,JSON.stringify(this.strictTicks))}catch(a){R.debug("Error setting rate limiter ticks",a)}}static async getDelay(t,n,r=!1){if(!r){let l=J7(4,X7);await xn(l)}let a=await this.getStrictTicks(t,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(t,a,r),0):(a.push(u),await this.setStrictTicks(t,a,r),u-s)}};var Eu=Pp()?["action"]:["browser_action","page_action"],tD=[{id:"toggleTranslatePage",contexts:["page","frame","selection",...Eu]},{id:ru,contexts:Eu},{id:au,contexts:Eu},{id:iu,contexts:Eu},{id:Nb,contexts:Eu}];async function jc(e){e=e||await bt(),R.debug("update ContextMenu",e);for(let t of tD){let n=!0;e.isShowContextMenu===!1&&t.id==="toggleTranslatePage"&&(n=!1);let r=ja(`browser.${t.id}`,e.interfaceLanguage);Z.contextMenus.update(t.id,{title:r,visible:n})}}p();function Oy(e,t){let n=t;n||(n=Le().IMMERSIVE_TRANSLATE_INJECTED_CSS||"");let a=`${`--immersive-translate-${e}`}: (.+?);`,i=new RegExp(a),o=n.match(i);return o?o[1]:""}p();function jo(e,t,n=[],r){let a=["notranslate"];return r&&a.push(Jb),e&&(a.push(`${ee}-target-translation-theme-${e}`),t?a.push(`${Cp}-theme-${e}`):a.push(`${Sp}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Cp):a.push(Sp),a}function Ho(e){let t=["notranslate",fc];return e&&t.push(`${ee}-target-translation-theme-${e}-inner`),t}function zy(e,t,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=e;o=o||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,g=Ni(n,!0),f="afterend",m=g[0],h=g[1],y=`${m}(\\d+)${h}`,T=new RegExp(y,"g"),b=rt.sanitize(u);o.length>0&&(b=b.replace(T,M=>{let C=b.indexOf(M),v=b[C-1]===" ",A=b[C+M.length]===" ",S=M.replace(new RegExp(g[0],"g"),"").replace(new RegExp(g[1],"g"),""),N=Number(S);if(isNaN(N))return M;let F=o[N];if(F&&F.type==="element"){let P=F.value.outerHTML;return v||(P=" "+P),A||(P=P+" "),P}else R.error("variable type not supported",F,M);return M}));let x=jo(i,e.inline,r.translationClasses||[],e.preWhitespace);s&&x.push(Zb);let w=Ho(i),L="";return r.translationBlockStyle&&(L=`style="${r.translationBlockStyle}"`),b=`<${n.rule.targetWrapperTag} ${L} class="${x.join(" ")}" ${Fr}="1"><${r.targetWrapperTag} class="${w.join(" ")}" ${Fr}="1">${b}`,e.inline||(l==="smart"?b=`
${b}`:b=`${l}${b}`),e.inline&&(l!=="smart"?b=`${l}${b}`:b=`<${r.targetWrapperTag} class="notranslate" ${Fr}="1"> ${b}`),c==="smart"?b=`${b}`:b=`${b}${c}`,{html:b,position:f}}p();function ut(e){fp({type:"success",text:e})}function an(e){fp({type:"error",text:e})}p();p();p();p();var lm={get:(e,t,n)=>{let r=t===void 0?e:{[e]:t};return Z.storage[n].get(r)},set:(e,t,n)=>Z.storage[n].set({[e]:t})};function Hc(e,t,n){let[r]=K(()=>typeof t=="function"?t():t),[a]=K(n),[i,o]=K(r),[s,u]=K(!1),[l,c]=K("");le(()=>{lm.get(e,r,a).then(f=>{f[e]&&o(f[e]),u(!0),c("")}).catch(f=>{u(!1),c(f)})},[e,r,a]);let g=qe(f=>{let m=typeof f=="function"?f(i):f;R.debug("new settings",m),lm.set(e,m,a).then(()=>{o(m),u(!0),c("")}).catch(h=>{o(m),u(!1),c(h)})},[a,e,i]);return[i,g,s,l]}p();function Wc(e,t,n){let r=[];return function(){let[i,o,s,u]=Hc(e,t,n),l=qe(c=>{for(let g of r)g(c)},[]);return le(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function Ny(e,t){return Wc(e,t,"local")}function Uy(e,t){return Wc(e,t,"sync")}var nD="userConfig",rD=null,aD=Uy(nD,rD);function $e(e){let[t,n,r,a]=aD(),i=qe(o=>{let s=typeof o=="function"?o(t):o;s&&(s.updatedAt=new Date().toISOString()),n(s),e&&e(s)},[t]);return[t,i,r,a,n]}p();p();p();p();function Kc(e,t){let n=e.original||e,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=t,s=[],u={};for(let l=0;l2&&(b=`<${i[2]}${T}>`),u[T]=c,s.push({text:b,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let y=c.textContent||"";f&&(y=Na(cm(c))),s.push({text:y,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&ln(c,a)){let T=Object.keys(u).length,b=`${i[0]}${T}${i[1]}`;i.length>2&&(b=`<${i[2]}${T}>`),u[T]=c;let x=dm(s).endsWith(" ")?" ":"",w=Na(c.innerText||c.textContent),L=Na(c.nextSibling).startsWith(" ")?" ":"",M=yu(x+w+L),C=M[0]+b+M[1];if(x===" ")C=C.trimStart();else if(!C.startsWith(" ")){let v=yu(c.previousSibling)[1];v===""&&(v=" "),C=v+C}s.push({text:C,type:"variable"})}else{let y=dm(s).endsWith(" ")?" ":"",T=Na(c.innerText||c.textContent);f&&(T=Na(cm(c)));let b=Na(c.nextSibling).startsWith(" ")?" ":"",x=yu(y+T+b),w=x[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+x[1];if(y===" ")w=w.trimStart();else{let L=yu(c.previousSibling)[1];L===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(L=" "),w=L+w}s.push({text:w,type:"text"})}else{let y=dm(s).endsWith(" ")?" ":"",T="";c.textContent&&(T=Na(cm(c))),y===" "&&(T=T.trimStart()),s.push({text:T,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(f=s[c-1].text),c/g,">"))}e.targetText=rt.sanitize(e.targetText);let a=!1,i=e.text,o=i.split(" ").length,s=i.split(` -`).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ni(t);if(l.length>2){let c=l[2];return iD({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=zy(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function cm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function iD(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;o=o||[];let g=e.targetText;g=rt.sanitize(g);let f=g,m=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);o.length>0&&(f=f.replace(m,x=>{let w=f.indexOf(x),L=f[w-1]===" ",M=f[w+x.length]===" ",C=x.match(h);if(!C)return x;let v=C[1],A=Number(v);if(isNaN(A))return x;let D=o[Number(A)];if(D&&D.type==="element"){let S=D.value.outerHTML;return L||(S=" "+S),M||(S=S+" "),S}else if(D&&D.type==="text"){let S=D.value;return L||(S=" "+S),M||(S=S+" "),S}else R.error("variable type not supported",D,x);return x}));let y=jo(l,n,r||[],s),T=Ho(l),b="";return c&&(b=`style="${c}"`),f=`<${a} ${b} class="${y.join(" ")}" ${Fr}="1"><${a} class="${T.join(" ")}" ${Fr}="1">${f}`,n||(i==="smart"?f=`
${f}`:f=`${i}${f}`),n&&(i!=="smart"?f=`${i}${f}`:f=`<${a} class="notranslate" ${Fr}="1"> ${f}`),u==="smart"?f=`${f}`:f=`${f}${u}`,{html:f,position:"afterend"}}function dm(e){let t=e[e.length-1];return t?t.text:""}function gm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let g=c.match(s);if(!g)return c;let f=g[1],m=Number(f);if(isNaN(m))return c;let h=r[f];return h||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}p();p();p();p();p();p();var H$=Hy(2),jy=Hy(3);function Hy(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-e+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+e);return r}}p();var oD=/\s+/g,sD=/[\t\n\v\f\r ]+/g;function Wy(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?uD:lD;return String(e).replace(t.style==="html"?sD:oD,t.trim?cD(n):n)}function uD(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function lD(){return" "}function cD(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var Ky={}.hasOwnProperty;function dD(e){return e==null?"":Wy(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function gD(e){return jy(" "+dD(e)+" ")}function pD(e){let t=gD(e),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function vD(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function SD(e,t,n,r){t=xD(t,n,r);let a=[],i;if(t)for(i in t)Gc.call(t,i)&&a.push([i,CD(e,t[i])]);return a.length===0?mm():a.sort(ED)}function CD(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharacterso+s.length,0));let i=e.length-r;for(let o of BD){let s=o[1],u=o[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/i>.5?t==="zh-CN"?Xy(e)?"zh-TW":"zh-CN":t:"auto"}var tT=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],fm=new Map(tT),ID=new Map(tT.map(([e,t])=>[t,e]));function nT(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>ID.get(s));!t&&t!==0&&(t=25);let a=$c(e);if(a!=="auto")return a;let i={minLength:t,whitelist:[...fm.keys()]},o=$y(e,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(g=="eng"&&f<.95)break;return fm.get(g)}}let[s,u]=o[0],l=fm.get(s);if(l&&u>.9)return l}}catch(r){R.error(r)}return"auto"}p();p();var hm="Original";function et(){return hm}function An(e){hm=e,rT(hm)}p();var iT="auto",Yc="auto",aT="auto";function oT(e){iT=e}function ar(e){Yc=e}function Mt(){return Yc!=="auto"?Yc:aT!=="auto"?aT:iT}function Qc(){return Yc}p();function ji(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ga(e){try{if(!e||!ji(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";t=o.getAttribute(i)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var tt={},Va=async function(e,t){let{method:n,data:r}=e,a=await tt.updateGlobalContext(),i=Date.now();if(R.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await tt.translateTheWholePage(r),at(yr,i);else if(n==="translateTheMainPage")await tt.translateTheMainPage(r),at(yr,i);else if(n==="translateToThePageEndImmediately")await tt.translateToThePageEndImmediately(r),at(yr,i);else if(n==="toggleTranslatePage")await tt.toggleTranslatePage(r),at(yr,i);else if(n==="toggleTranslateTheWholePage")await tt.toggleTranslateTheWholePage(r),at(yr,i);else if(n==="toggleTranslateTheMainPage")await tt.toggleTranslateTheMainPage(r),at(yr,i);else if(n==="toggleOnlyTransation")await tt.ensureSwitchTranslationMode(r),at(yr,i);else if(n==="translatePage")await tt.translatePage(a,r),at(yr,i);else if(n==="toggleTranslationMask")await tt.toggleTranslationMask(r);else if(n==="restorePage")tt.restorePage();else if(n==="retryFailedParagraphs")tt.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await tt.switchTranslationMode(r.mode),await tt.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")tt.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(cc,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await tt.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(nu,{detail:r}));else if(n==="translateWithOpenAI")await tt.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await tt.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await tt.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await tt.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await tt.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await tt.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await tt.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")ot()||await tt.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!ot())return JSON.stringify(a)}};function sT(e){Object.assign(tt,e)}function uT(e){Object.assign(tt,e)}function lT(e){Object.assign(tt,e)}var RD=function(e,t){let{method:n,data:r}=e;if(R.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return et();if(n==="getCurrentPageLanguage"){let a=Mt();return tt.detectCurrentPageLanguage().catch(i=>{R.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return ar(r),Mt();if(n==="getContextString"){let a=tt.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=tt.getPureGlobalContext();return Ga(a?.rule)}}},Zc,Jc;function cT(){let e=Xc();ot()||OD(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Xc(){return Zc||(Zc=new ca("content_script",!1).getConnection("main",Va),Zc)}function OD(){return Jc||(Jc=new ca("content_script",!1).getConnection("main_sync",RD,{sync:!0}),Jc)}p();var bm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],e0="https://transmart.qq.com/api/imt",pa=class e{static langMapReverse=new Map(bm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:e0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=e.langMapReverse.get(a);return i||a}};async function Ft(e){return await Xc().sendMessage("background:main",e)}function de(e){return oc()?kc({method:"request",data:e}):pe()||ic()?(e.fetchPolyfill=globalThis.GM_fetch,Tr(e)):Ft({method:"fetch",data:e})}function ir(){return pe()?bt():Ft({method:"getConfig"})}function kn(e){return pe()?Oi(e):Ft({method:"setUserConfig",data:e})}function Pn(){return pe()?vr():Ft({method:"getUserConfig"})}function Du(){return pe()?Wt():Ft({method:"getLocalConfig"})}function t0(e){return pe()?Kt(e):Ft({method:"setLocalConfig",data:e})}function dT(e){return pe()?ry(e):Ft({method:"setBuildinConfig",data:e})}async function Ue(e){if(e.text){let n=$c(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(pe()||Ge()){if(e.translateService&&!yc.includes(e.translateService))return Promise.resolve("auto");let r=nT(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Ft({method:"detectLanguage",data:e});return Promise.resolve(t)}function gT(){return Ft({method:"detectTabLanguage"})}async function n0(e){let t=await Ue({text:e,pageLangs:["en"]});try{if(pe()||Ge()){let n=e.substring(0,200);t=await pa.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function rT(e){let t=new CustomEvent(ki,{detail:e});if(document.dispatchEvent(t),pe())return;Xc().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function pT(e){return pe()?im(e):Ft({method:"queryParagraphCache",data:e})}async function mT(e){if(pe()){await am(e);return}return Ft({method:"setParagraphCache",data:e})}async function fT(){if(pe())return Promise.resolve();await Ft({method:"mockRequest"})}function Wo(e=!1,t=""){return pe()?(Z.runtime.openOptionsPage(e,t),Promise.resolve()):Ft({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function r0(e=""){return pe()||Ge()?Le().OPTIONS_URL:Z.runtime.getURL("options.html")}function hT(e=""){return Z&&Z.runtime&&Z.runtime.getURL?Z.runtime.getURL("options.html"):""}function a0(e=!1){return pe()?(Z.extra.openAboutPage(e),Promise.resolve()):Ft({method:"openAboutPage"})}function Ko(e){return pe()?(Z.extra.openInTab(e),Promise.resolve()):Ft({method:"openInTab",data:e})}function bT(e=!1){return pe()?(Z.extra.openEbookViewerPage(e),Promise.resolve()):Ft({method:"openEbookViewerPage"})}function yT(e=!1){return pe()?(Z.extra.openEbookBuilderPage(e),Promise.resolve()):Ft({method:"openEbookBuilderPage"})}function TT(e){Ge()}function Go(e=!1,t){return pe()?(Z.extra.openPdfViewerPage(e),Promise.resolve()):Ft({method:"openPdfViewerPage",data:{url:t}})}function vT(e=!1){return pe()?(Z.extra.openSubtitleBuilderPage(e),Promise.resolve()):Ft({method:"openSubtitleBuilderPage"})}function Vo(e){return pe()?Promise.resolve():Ft({method:"setBadge",data:{text:e}})}function ST(){return pe()?(R.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Ft({method:"autoSyncLatestConfig"})}function i0(e,t=!1){return pe()?Z.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function CT(e,t){return pe()?qi.getDelay(e,t):Ft({method:"getDelay",data:{key:e,options:t}})}var Pe=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,i=!1,o=!1,s=[],u=null,l=new Set;for(let T of a)T.from&&T.from!=="auto"&&l.add(T.from),T.refresh&&(i=!0),T.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=I1(a,c,g)}catch(T){if(r)for(let b=0;bT));let f=[],m=[],h=(T,b,x)=>{let w="";if(b.translatedTexts&&b.translatedTexts[0]&&(w=b.translatedTexts[0]),m[T]||(m[T]=b,m[T].translatedTexts=Array(b.sentenceTotalParts).fill(null)),m[T].hasError)return;if(x){let C=x instanceof Q?new Q(x.name,x.message).initNetWork(x.status).initData(x.data):x;m[T].hasError=!0,b.callback&&b.callback(C,null,b.sentence);return}m[T].translatedTexts[b.partIndex]=w;let L=m[T],M=0;for(let C=0;C{let M=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(M=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:M,to:b.to,url:x,options:n,refresh:i,debug:o}),sourceTempSentences:b.tempSentences};{let C=Qb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(C=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let A=[],D=Or(this.serviceConfig);if(b.tempSentences.forEach((q,I)=>{let k=Kp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});q.force!==!0&&(k&&k.text&&k.text.trim().lengthI.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:q,from:M,to:b.to})}let S="";v&&v.length>=2?S=A.map((q,I)=>{let{item:k}=q;return I===A.length-1?k.text:k.text+v[0]+(I+1)+v[1]}).join(""):S=A.map(({item:q})=>q.text).join(C);let N=await this.translate({text:S,from:M,to:b.to,url:x,options:{...n,rawTextArrayLength:A.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=N,P=[];if(v&&v.length>=2){let q=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(q=v[2]);let I=new RegExp(q,"g");P=F.split(I)}else P=F.split(C);let O=[];if(P.length>A.length){for(let q=0;qq.text);return D=Or(this.serviceConfig,!0),O.forEach((q,I)=>{let k=A[I],_=k.index,B=k.variables||{};Object.keys(B).length>0&&(q=gm({text:q,delimiters:D,variables:B})),z[_]=q}),{sourceTempSentences:b.tempSentences,text:z,from:N.from,to:N.to}}};f.push(L().then(M=>{let{text:C,sourceTempSentences:v}=M;for(let A=0;A{if(M instanceof Q&&M.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let C=0;C{let b=T.sentence.text;return T.translatedTexts&&T.translatedTexts.length>0&&(b=T.translatedTexts.join("")),{...T.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],i=Or(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,f)=>{let m=Kp({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[f]!==!0&&(m&&m.text&&m.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){R.debug("formatAndTranslateList error",t,l)}let o=await this.translateList(n),{text:s}=o,u=t.text.map(l=>l);return i=Or(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let f=g.index,m=g.variables,h=Object.keys(m);u[f]=l,h.length>0&&(u[f]=gm({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(t){return Ue({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};p();p();var $o="input is invalid type",ym=typeof window=="object",$a=ym?window:{};$a.JS_SHA256_NO_WINDOW&&(ym=!1);var zD=!ym&&typeof self=="object",ND=!$a.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;ND?$a=global:zD&&($a=self);var pQ=!$a.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,mQ=typeof define=="function"&&define.amd,Au=!$a.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Te="0123456789abcdef".split(""),UD=[-2147483648,8388608,32768,128],Sr=[24,16,8,0],o0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s0=["hex","array","digest","arrayBuffer"],on=[];($a.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});Au&&($a.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var xT=function(e,t){return function(n){return new sn(t,!0).update(n)[e]()}},wT=function(e){var t=xT("hex",e);t.create=function(){return new sn(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};sn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=UD[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};sn.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,g,f,m,h,y,T,b,x,w;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],g=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(w=t&n,l=0;l<64;l+=4)this.first?(this.is224?(T=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(T=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),T=e&t,f=T^e&n^w,y=a&i^~a&o,m=s+g+y+o0[l]+u[l],h=c+f,s=r+m<<0,r=m+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,f=b^r&t^T,y=s&a^~s&i,m=o+g+y+o0[l+1]+u[l+1],h=c+f,o=n+m<<0,n=m+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=n&r,f=x^n&e^b,y=o&s^~o&a,m=i+g+y+o0[l+2]+u[l+2],h=c+f,i=t+m<<0,t=m+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),w=t&n,f=w^t&r^x,y=i&o^~i&s,m=a+g+y+o0[l+3]+u[l+3],h=c+f,a=e+m<<0,e=m+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};sn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=Te[e>>28&15]+Te[e>>24&15]+Te[e>>20&15]+Te[e>>16&15]+Te[e>>12&15]+Te[e>>8&15]+Te[e>>4&15]+Te[e&15]+Te[t>>28&15]+Te[t>>24&15]+Te[t>>20&15]+Te[t>>16&15]+Te[t>>12&15]+Te[t>>8&15]+Te[t>>4&15]+Te[t&15]+Te[n>>28&15]+Te[n>>24&15]+Te[n>>20&15]+Te[n>>16&15]+Te[n>>12&15]+Te[n>>8&15]+Te[n>>4&15]+Te[n&15]+Te[r>>28&15]+Te[r>>24&15]+Te[r>>20&15]+Te[r>>16&15]+Te[r>>12&15]+Te[r>>8&15]+Te[r>>4&15]+Te[r&15]+Te[a>>28&15]+Te[a>>24&15]+Te[a>>20&15]+Te[a>>16&15]+Te[a>>12&15]+Te[a>>8&15]+Te[a>>4&15]+Te[a&15]+Te[i>>28&15]+Te[i>>24&15]+Te[i>>20&15]+Te[i>>16&15]+Te[i>>12&15]+Te[i>>8&15]+Te[i>>4&15]+Te[i&15]+Te[o>>28&15]+Te[o>>24&15]+Te[o>>20&15]+Te[o>>16&15]+Te[o>>12&15]+Te[o>>8&15]+Te[o>>4&15]+Te[o&15];return this.is224||(u+=Te[s>>28&15]+Te[s>>24&15]+Te[s>>20&15]+Te[s>>16&15]+Te[s>>12&15]+Te[s>>8&15]+Te[s>>4&15]+Te[s&15]),u};sn.prototype.toString=sn.prototype.hex;sn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};sn.prototype.array=sn.prototype.digest;sn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function u0(e,t,n){var r,a=typeof e;if(a==="string"){var i=[],o=e.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);e=i}else if(a==="object"){if(e===null)throw new Error($o);if(Au&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!Au||!ArrayBuffer.isView(e)))throw new Error($o)}else throw new Error($o);e.length>64&&(e=new sn(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}sn.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}u0.prototype=new sn;u0.prototype.finalize=function(){if(sn.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();sn.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),sn.prototype.finalize.call(this)}};var Yo=wT();Yo.sha256=Yo;Yo.sha224=wT(!0);Yo.sha256.hmac=DT();Yo.sha224.hmac=DT(!0);var AT=Yo;var kT=AT.sha256;function Cr(e){return Promise.resolve(kT(e))}function l0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Ya(e,t){let n=kT.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function PT(e,t){let n=await Ya(e,t);return l0(n)}async function c0(e,t){let n=qD(t),r=await Ya(e,n);return l0(r)}function qD(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var LT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ku=class e extends Pe{static langMap=new Map(LT);maxTextGroupLength=50;static langMapReverse=new Map(LT.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new Q("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await Cr(a)].join(` +`).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ni(t);if(l.length>2){let c=l[2];return iD({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=zy(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function cm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function iD(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;o=o||[];let g=e.targetText;g=rt.sanitize(g);let f=g,m=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);o.length>0&&(f=f.replace(m,x=>{let w=f.indexOf(x),L=f[w-1]===" ",M=f[w+x.length]===" ",C=x.match(h);if(!C)return x;let v=C[1],A=Number(v);if(isNaN(A))return x;let D=o[Number(A)];if(D&&D.type==="element"){let S=D.value.outerHTML;return L||(S=" "+S),M||(S=S+" "),S}else if(D&&D.type==="text"){let S=D.value;return L||(S=" "+S),M||(S=S+" "),S}else R.error("variable type not supported",D,x);return x}));let y=jo(l,n,r||[],s),T=Ho(l),b="";return c&&(b=`style="${c}"`),f=`<${a} ${b} class="${y.join(" ")}" ${Fr}="1"><${a} class="${T.join(" ")}" ${Fr}="1">${f}`,n||(i==="smart"?f=`
${f}`:f=`${i}${f}`),n&&(i!=="smart"?f=`${i}${f}`:f=`<${a} class="notranslate" ${Fr}="1"> ${f}`),u==="smart"?f=`${f}`:f=`${f}${u}`,{html:f,position:"afterend"}}function dm(e){let t=e[e.length-1];return t?t.text:""}function gm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let g=c.match(s);if(!g)return c;let f=g[1],m=Number(f);if(isNaN(m))return c;let h=r[f];return h||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}p();p();p();p();p();p();var H$=Hy(2),jy=Hy(3);function Hy(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-e+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+e);return r}}p();var oD=/\s+/g,sD=/[\t\n\v\f\r ]+/g;function Wy(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?uD:lD;return String(e).replace(t.style==="html"?sD:oD,t.trim?cD(n):n)}function uD(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function lD(){return" "}function cD(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var Ky={}.hasOwnProperty;function dD(e){return e==null?"":Wy(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function gD(e){return jy(" "+dD(e)+" ")}function pD(e){let t=gD(e),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function vD(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function SD(e,t,n,r){t=xD(t,n,r);let a=[],i;if(t)for(i in t)Gc.call(t,i)&&a.push([i,CD(e,t[i])]);return a.length===0?mm():a.sort(ED)}function CD(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharacterso+s.length,0));let i=e.length-r;for(let o of BD){let s=o[1],u=o[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/i>.5?t==="zh-CN"?Xy(e)?"zh-TW":"zh-CN":t:"auto"}var tT=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],fm=new Map(tT),ID=new Map(tT.map(([e,t])=>[t,e]));function nT(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>ID.get(s));!t&&t!==0&&(t=25);let a=$c(e);if(a!=="auto")return a;let i={minLength:t,whitelist:[...fm.keys()]},o=$y(e,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(g=="eng"&&f<.95)break;return fm.get(g)}}let[s,u]=o[0],l=fm.get(s);if(l&&u>.9)return l}}catch(r){R.error(r)}return"auto"}p();p();var hm="Original";function et(){return hm}function An(e){hm=e,rT(hm)}p();var iT="auto",Yc="auto",aT="auto";function oT(e){iT=e}function ar(e){Yc=e}function Mt(){return Yc!=="auto"?Yc:aT!=="auto"?aT:iT}function Qc(){return Yc}p();function ji(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ga(e){try{if(!e||!ji(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";t=o.getAttribute(i)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var tt={},Va=async function(e,t){let{method:n,data:r}=e,a=await tt.updateGlobalContext(),i=Date.now();if(R.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await tt.translateTheWholePage(r),at(yr,i);else if(n==="translateTheMainPage")await tt.translateTheMainPage(r),at(yr,i);else if(n==="translateToThePageEndImmediately")await tt.translateToThePageEndImmediately(r),at(yr,i);else if(n==="toggleTranslatePage")await tt.toggleTranslatePage(r),at(yr,i);else if(n==="toggleTranslateTheWholePage")await tt.toggleTranslateTheWholePage(r),at(yr,i);else if(n==="toggleTranslateTheMainPage")await tt.toggleTranslateTheMainPage(r),at(yr,i);else if(n==="toggleOnlyTransation")await tt.ensureSwitchTranslationMode(r),at(yr,i);else if(n==="translatePage")await tt.translatePage(a,r),at(yr,i);else if(n==="toggleTranslationMask")await tt.toggleTranslationMask(r);else if(n==="restorePage")tt.restorePage();else if(n==="retryFailedParagraphs")tt.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await tt.switchTranslationMode(r.mode),await tt.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")tt.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(cc,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await tt.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(nu,{detail:r}));else if(n==="translateWithOpenAI")await tt.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await tt.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await tt.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await tt.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await tt.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await tt.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await tt.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")ot()||await tt.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!ot())return JSON.stringify(a)}};function sT(e){Object.assign(tt,e)}function uT(e){Object.assign(tt,e)}function lT(e){Object.assign(tt,e)}var RD=function(e,t){let{method:n,data:r}=e;if(R.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return et();if(n==="getCurrentPageLanguage"){let a=Mt();return tt.detectCurrentPageLanguage().catch(i=>{R.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return ar(r),Mt();if(n==="getContextString"){let a=tt.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=tt.getPureGlobalContext();return Ga(a?.rule)}}},Zc,Jc;function cT(){let e=Xc();ot()||OD(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Xc(){return Zc||(Zc=new ca("content_script",!1).getConnection("main",Va),Zc)}function OD(){return Jc||(Jc=new ca("content_script",!1).getConnection("main_sync",RD,{sync:!0}),Jc)}p();var bm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],e0="https://transmart.qq.com/api/imt",pa=class e{static langMapReverse=new Map(bm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:e0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=e.langMapReverse.get(a);return i||a}};async function Ft(e){return await Xc().sendMessage("background:main",e)}function de(e){return oc()?kc({method:"request",data:e}):pe()||ic()?(e.fetchPolyfill=globalThis.GM_fetch,Tr(e)):Ft({method:"fetch",data:e})}function ir(){return pe()?bt():Ft({method:"getConfig"})}function kn(e){return pe()?Oi(e):Ft({method:"setUserConfig",data:e})}function Pn(){return pe()?vr():Ft({method:"getUserConfig"})}function Du(){return pe()?Wt():Ft({method:"getLocalConfig"})}function t0(e){return pe()?Kt(e):Ft({method:"setLocalConfig",data:e})}function dT(e){return pe()?ry(e):Ft({method:"setBuildinConfig",data:e})}async function Ue(e){if(e.text){let n=$c(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(pe()||Ge()){if(e.translateService&&!yc.includes(e.translateService))return Promise.resolve("auto");let r=nT(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Ft({method:"detectLanguage",data:e});return Promise.resolve(t)}function gT(){return Ft({method:"detectTabLanguage"})}async function n0(e){let t=await Ue({text:e,pageLangs:["en"]});try{if(pe()||Ge()){let n=e.substring(0,200);t=await pa.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function rT(e){let t=new CustomEvent(ki,{detail:e});if(document.dispatchEvent(t),pe())return;Xc().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function pT(e){return pe()?im(e):Ft({method:"queryParagraphCache",data:e})}async function mT(e){if(pe()){await am(e);return}return Ft({method:"setParagraphCache",data:e})}async function fT(){if(pe())return Promise.resolve();await Ft({method:"mockRequest"})}function Wo(e=!1,t=""){return pe()?(Z.runtime.openOptionsPage(e,t),Promise.resolve()):Ft({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function r0(e=""){return pe()||Ge()?Le().OPTIONS_URL:Z.runtime.getURL("options.html")}function hT(e=""){return Z&&Z.runtime&&Z.runtime.getURL?Z.runtime.getURL("options.html"):""}function a0(e=!1){return pe()?(Z.extra.openAboutPage(e),Promise.resolve()):Ft({method:"openAboutPage"})}function Ko(e){return pe()?(Z.extra.openInTab(e),Promise.resolve()):Ft({method:"openInTab",data:e})}function bT(e=!1){return pe()?(Z.extra.openEbookViewerPage(e),Promise.resolve()):Ft({method:"openEbookViewerPage"})}function yT(e=!1){return pe()?(Z.extra.openEbookBuilderPage(e),Promise.resolve()):Ft({method:"openEbookBuilderPage"})}function TT(e){Ge()}function Go(e=!1,t){return pe()?(Z.extra.openPdfViewerPage(e),Promise.resolve()):Ft({method:"openPdfViewerPage",data:{url:t}})}function vT(e=!1){return pe()?(Z.extra.openSubtitleBuilderPage(e),Promise.resolve()):Ft({method:"openSubtitleBuilderPage"})}function Vo(e){return pe()?Promise.resolve():Ft({method:"setBadge",data:{text:e}})}function ST(){return pe()?(R.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Ft({method:"autoSyncLatestConfig"})}function i0(e,t=!1){return pe()?Z.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function CT(e,t){return pe()?qi.getDelay(e,t):Ft({method:"getDelay",data:{key:e,options:t}})}var Pe=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,i=!1,o=!1,s=[],u=null,l=new Set;for(let T of a)T.from&&T.from!=="auto"&&l.add(T.from),T.refresh&&(i=!0),T.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=I1(a,c,g)}catch(T){if(r)for(let b=0;bT));let f=[],m=[],h=(T,b,x)=>{let w="";if(b.translatedTexts&&b.translatedTexts[0]&&(w=b.translatedTexts[0]),m[T]||(m[T]=b,m[T].translatedTexts=Array(b.sentenceTotalParts).fill(null)),m[T].hasError)return;if(x){let C=x instanceof Q?new Q(x.name,x.message).initNetWork(x.status).initData(x.data):x;m[T].hasError=!0,b.callback&&b.callback(C,null,b.sentence);return}m[T].translatedTexts[b.partIndex]=w;let L=m[T],M=0;for(let C=0;C{let M=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(M=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:M,to:b.to,url:x,options:n,refresh:i,debug:o}),sourceTempSentences:b.tempSentences};{let C=Qb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(C=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let A=[],D=Or(this.serviceConfig);if(b.tempSentences.forEach((q,I)=>{let k=Kp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});q.force!==!0&&(k&&k.text&&k.text.trim().lengthI.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:q,from:M,to:b.to})}let S="";v&&v.length>=2?S=A.map((q,I)=>{let{item:k}=q;return I===A.length-1?k.text:k.text+v[0]+(I+1)+v[1]}).join(""):S=A.map(({item:q})=>q.text).join(C);let N=await this.translate({text:S,from:M,to:b.to,url:x,options:{...n,rawTextArrayLength:A.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=N,P=[];if(v&&v.length>=2){let q=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(q=v[2]);let I=new RegExp(q,"g");P=F.split(I)}else P=F.split(C);let O=[];if(P.length>A.length){for(let q=0;qq.text);return D=Or(this.serviceConfig,!0),O.forEach((q,I)=>{let k=A[I],_=k.index,B=k.variables||{};Object.keys(B).length>0&&(q=gm({text:q,delimiters:D,variables:B})),z[_]=q}),{sourceTempSentences:b.tempSentences,text:z,from:N.from,to:N.to}}};f.push(L().then(M=>{let{text:C,sourceTempSentences:v}=M;for(let A=0;A{if(M instanceof Q&&M.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let C=0;C{let b=T.sentence.text;return T.translatedTexts&&T.translatedTexts.length>0&&(b=T.translatedTexts.join("")),{...T.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],i=Or(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,f)=>{let m=Kp({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[f]!==!0&&(m&&m.text&&m.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){R.debug("formatAndTranslateList error",t,l)}let o=await this.translateList(n),{text:s}=o,u=t.text.map(l=>l);return i=Or(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let f=g.index,m=g.variables,h=Object.keys(m);u[f]=l,h.length>0&&(u[f]=gm({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(t){return Ue({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};p();p();var $o="input is invalid type",ym=typeof window=="object",$a=ym?window:{};$a.JS_SHA256_NO_WINDOW&&(ym=!1);var zD=!ym&&typeof self=="object",ND=!$a.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;ND?$a=global:zD&&($a=self);var pQ=!$a.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,mQ=typeof define=="function"&&define.amd,Au=!$a.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Te="0123456789abcdef".split(""),UD=[-2147483648,8388608,32768,128],Sr=[24,16,8,0],o0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s0=["hex","array","digest","arrayBuffer"],on=[];($a.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});Au&&($a.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var xT=function(e,t){return function(n){return new sn(t,!0).update(n)[e]()}},wT=function(e){var t=xT("hex",e);t.create=function(){return new sn(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};sn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=UD[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};sn.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,g,f,m,h,y,T,b,x,w;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],g=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(w=t&n,l=0;l<64;l+=4)this.first?(this.is224?(T=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(T=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),T=e&t,f=T^e&n^w,y=a&i^~a&o,m=s+g+y+o0[l]+u[l],h=c+f,s=r+m<<0,r=m+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,f=b^r&t^T,y=s&a^~s&i,m=o+g+y+o0[l+1]+u[l+1],h=c+f,o=n+m<<0,n=m+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=n&r,f=x^n&e^b,y=o&s^~o&a,m=i+g+y+o0[l+2]+u[l+2],h=c+f,i=t+m<<0,t=m+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),w=t&n,f=w^t&r^x,y=i&o^~i&s,m=a+g+y+o0[l+3]+u[l+3],h=c+f,a=e+m<<0,e=m+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};sn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=Te[e>>28&15]+Te[e>>24&15]+Te[e>>20&15]+Te[e>>16&15]+Te[e>>12&15]+Te[e>>8&15]+Te[e>>4&15]+Te[e&15]+Te[t>>28&15]+Te[t>>24&15]+Te[t>>20&15]+Te[t>>16&15]+Te[t>>12&15]+Te[t>>8&15]+Te[t>>4&15]+Te[t&15]+Te[n>>28&15]+Te[n>>24&15]+Te[n>>20&15]+Te[n>>16&15]+Te[n>>12&15]+Te[n>>8&15]+Te[n>>4&15]+Te[n&15]+Te[r>>28&15]+Te[r>>24&15]+Te[r>>20&15]+Te[r>>16&15]+Te[r>>12&15]+Te[r>>8&15]+Te[r>>4&15]+Te[r&15]+Te[a>>28&15]+Te[a>>24&15]+Te[a>>20&15]+Te[a>>16&15]+Te[a>>12&15]+Te[a>>8&15]+Te[a>>4&15]+Te[a&15]+Te[i>>28&15]+Te[i>>24&15]+Te[i>>20&15]+Te[i>>16&15]+Te[i>>12&15]+Te[i>>8&15]+Te[i>>4&15]+Te[i&15]+Te[o>>28&15]+Te[o>>24&15]+Te[o>>20&15]+Te[o>>16&15]+Te[o>>12&15]+Te[o>>8&15]+Te[o>>4&15]+Te[o&15];return this.is224||(u+=Te[s>>28&15]+Te[s>>24&15]+Te[s>>20&15]+Te[s>>16&15]+Te[s>>12&15]+Te[s>>8&15]+Te[s>>4&15]+Te[s&15]),u};sn.prototype.toString=sn.prototype.hex;sn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};sn.prototype.array=sn.prototype.digest;sn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function u0(e,t,n){var r,a=typeof e;if(a==="string"){var i=[],o=e.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);e=i}else if(a==="object"){if(e===null)throw new Error($o);if(Au&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!Au||!ArrayBuffer.isView(e)))throw new Error($o)}else throw new Error($o);e.length>64&&(e=new sn(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}sn.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}u0.prototype=new sn;u0.prototype.finalize=function(){if(sn.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();sn.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),sn.prototype.finalize.call(this)}};var Yo=wT();Yo.sha256=Yo;Yo.sha224=wT(!0);Yo.sha256.hmac=DT();Yo.sha224.hmac=DT(!0);var AT=Yo;var kT=AT.sha256;function Cr(e){return Promise.resolve(kT(e))}function l0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Ya(e,t){let n=kT.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function PT(e,t){let n=await Ya(e,t);return l0(n)}async function c0(e,t){let n=qD(t),r=await Ya(e,n);return l0(r)}function qD(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var LT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ku=class e extends Pe{static langMap=new Map(LT);maxTextGroupLength=50;static langMapReverse=new Map(LT.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new Q("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await Cr(a)].join(` `),g=e.getUTCDate(u),f=["TC3-HMAC-SHA256",l,`${g}/${i}/tc3_request`,await Cr(c)].join(` `),m=await PT(g,`TC3${n}`),h=await c0(i,m),y=await c0("tc3_request",h),T=await c0(f,y),b=await de({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${t}/${g}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${T}`},body:a,timeout:this.requestTimeout});if(b instanceof Error)throw b;if(b.Response&&b.Response.Error&&b.Response.Error.Message)throw new Q(b.Response.Error.Message);return b}};p();var _T=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],jD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Pu=class e extends Pe{static langMap=new Map(_T);static langMapReverse=new Map(_T.map(([t,n])=>[n,t]));isSupportList=!1;constructor(t,n,r){super(t,n,r)}async translate(t){let{text:n,from:r,to:a}=t,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await de({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:jD,timeout:this.requestTimeout});return{text:o.targetText,from:e.langMapReverse.get(o.source)||r,to:e.langMapReverse.get(o.target)||a}}};p();var MT=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Hi=class e extends Pe{static langMap=new Map(MT);static langMapReverse=new Map(MT.map(([t,n])=>[n,t]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(t,n,r){super(t,n,r),t?.apiUrl&&(this.apiUrl=rn(this.apiUrl,t.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=e.langMap.get(r)||"auto",o=e.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new Q("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new Q("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=e.langMap.get(r)||"auto",o=e.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new Q("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new Q("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(t,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}).toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(t,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}),i=this.apiUrl+"?"+a.toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}};p();p();p();function HD(e,t){return t?e+(t-e%t):e}function WD(e,t){return e.split(t).length-1}function Tm(e){let t=Date.now(),n=1;for(let r of e)n+=WD(r,"i");return HD(t,n)}function KD(e,t){return Math.floor(Math.random()*(t-e+1))+e}function vm(){return KD(1e6,1e8)}p();p();p();var Sm="https://www2.deepl.com/jsonrpc",Cm="auto",FT=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];p();function GD(e=FT){return e.reduce((t,n)=>(t[n.code.toLowerCase()]=n.code,t[n.language.toLowerCase()]=n.code,t),{})}function xm(e){return GD()[e.toLowerCase()]}var VD={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function $D(e){return JSON.stringify(e).replace('"method":"',()=>{let t=e;return(t.id+3)%13===0||(t.id+5)%29===0?'"method" : "':'"method": "'})}function YD(e,t){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:e,target_lang:t}}}}async function QD(e,t,n,r,a,i,o){let s=vm(),u=YD(r,n),l=[];t.forEach(f=>{l.push({text:f,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Tm(t);let c=await de({retry:2,method:"POST",url:e,body:$D(u),headers:VD}),g={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(f=>{g.text.push(f.text)}),g}async function BT(e,t,n,r=Cm,a,i,o){return t?t&&t.length===1&&t[0]===""?{text:[""],from:r,to:n}:QD(e,t,xm(n),xm(r)??"auto",a,i,o):{text:[],from:r,to:n}}var IT=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Qo=class e extends Pe{static langMap=new Map(IT);static langMapReverse=new Map(IT.map(([t,n])=>[n,t]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Sm;constructor(t,n,r){super(t,n,r),t&&t.apiUrl&&(this.API_URL=rn(Sm,t.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(t){let{text:n,to:r,from:a}=t,i=await BT(this.API_URL,n,e.langMap.get(r)||r,e.langMap.get(a)||"auto");return{text:i.text,from:e.langMapReverse.get(i.from),to:e.langMapReverse.get(i.to)}}};p();var Lu=class e extends Pe{static langMap=new Map(bm);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(t,n,r){super(t,n,r),this.clientKey=pa.getClientKey()}async translate(t){let{text:n,to:r}=t,a=await this.detectLanguage(n),i=e.langMap.get(a)||a,o=e.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Le(),u=t.url;s.INSTALL_FROM==="firefox_store"&&(u=RT());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),g=await de({url:e0,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(g.header.ret_code!=="succ")throw new Q(g.message||g.header.ret_code);return{text:g.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(t){let{from:n,text:r,to:a}=t,i=Le(),o=t.url;if(i.INSTALL_FROM==="firefox_store"&&(o=RT()),r.length===1){let m=await this.translate({from:n,text:r[0],to:a,url:o,options:t.options});return{text:[m.text],from:m.from,to:m.to}}let u=await this.detectLanguage(r.join(` `));if(u===a)return{text:r,from:u,to:a};let l=e.langMap.get(u)||u,c=e.langMap.get(a)||a,g=JSON.stringify({header:{fn:"auto_translation",client_key:this.clientKey},source:{text_list:r,lang:l,orig_url:o},target:{lang:c},type:"plain"}),f=await de({url:e0,body:g,method:"POST"});if(f.header.ret_code!=="succ")throw new Q(f.message||f.header.ret_code);return{text:f.auto_translation,from:u||"auto",to:a}}detectLanguageLocally(t){return this.detectLanguageRemotely(t)}detectLanguageRemotely(t){return pa.detectLanguageRemotelyByTransmart(t)}};function RT(){let e=new Date;return e.setMinutes(e.getMinutes()-e.getMinutes()%5),e.setSeconds(0),e.setMilliseconds(0),`https://google.com/search?q=google&_t=${e.getTime()/1e3}`}p();p();function Em(){return Math.random()>=.1}var Zo=class extends Pe{isSupportList=!1;maxTextLength=1200;maxTextGroupLength=1;async translate(t){let{text:n}=t;if(!Em())throw new Q("404","\u6A21\u62DF\u9519\u8BEF");let r=n.match(/^\s*/)[0].length;return{text:n.slice(0,r)+"\u6A21\u62DF\uFF1A"+n.slice(r,-6),from:t.from,to:t.to}}async translateList(t){let{text:n,from:r,to:a}=t;if(await fT(),!Em())throw new Q("404","\u6A21\u62DF\u9519\u8BEF");return n.length===0?{from:r,to:a,text:[""]}:{from:r,to:a,text:n.map(i=>{let o=i.match(/^\s*/)[0].length;return i.slice(0,o)+"\u6A21\u62DF\uFF1A"+i.slice(o,-6)})}}};p();var zT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh"],["en","en"],["ja","ja"],["de","de"],["fr","fr"],["it","it"],["es","es"],["nl","nl"],["pl","pl"],["pt","pt"],["ru","ru"]],wm=new Map(zT),OT=new Map(zT.map(([e,t])=>[t,e])),Dm=class e extends Pe{static langMap=wm;static DEFAULT_CODENAME="deepl";apikey="";codename=e.DEFAULT_CODENAME;isSupportList=!1;maxTextGroupLength=1;constructor(t,n,r){if(super(t,n,r),!t||!t.apikey)throw new Q("apikey are required");this.apikey=t.apikey?.trim(),t.codename&&(this.codename=t.codename)}async translate(t){let{text:n,from:r,to:a}=t,i=await de({retry:this.retry,url:`https://api.openl.club/services/${this.codename}/translate`,headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify({apikey:this.apikey,text:n,source_lang:wm.get(r)||"auto",target_lang:wm.get(a)||a}),timeout:this.requestTimeout});if(i.status){let o=i;return o.result&&a=="zh-TW",{text:o.result,from:OT.get(o.source_lang),to:OT.get(o.target_lang)}}else throw new Q(i.msg)}},d0=Dm;p();var NT=[["auto",""],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ar","AR"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["pt-br","PT-BR"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],_u=new Map(NT),ZD=new Map(NT.map(([e,t])=>[t,e])),Am=class extends Pe{static langMap=_u;authKey="";maxTextLength=1800;freeApiUrl="https://api-free.deepl.com/v2/translate";proApiUrl="https://api.deepl.com/v2/translate";immersiveTranslateApiUrl="https://deepl.immersivetranslate.com/v2/translate";immersiveTranslateDeeplTokenUrl="https://api.immersivetranslate.com";immersiveTranslateDeeplProApiUrl=pn()||tr()?"https://api2.immersivetranslate.com/deepl/translate":"https://test-api2.immersivetranslate.com/deepl/translate";provider="custom";splitor="";qualityNoSymabol="";qualityMinTextLength;apiKeys=[];static async clearState(){}getRandomKey(){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}constructor(t,n,r){if(super(t,n,r),t=t||{},this.splitor=t.qualityDelimiterBetaV3||"",this.qualityNoSymabol=t.qualityNoSymoblBetaV3||"",this.qualityMinTextLength=t.qualityMinTextLengthV3||0,t.provider==="pro")if(this.provider="pro",r.userToken){if(!r.isPro)throw new Q("Please activate Pro membership first, \u8BF7\u5148\u5F00\u901A Pro \u4F1A\u5458\u3002");this.authKey=r.userToken,this.apiKeys=this.authKey.split(",").map(a=>a.trim())}else throw new Q("Login required, \u767B\u5F55\u540E\u624D\u53EF\u4EE5\u4F7F\u7528\u3002");else if(this.authKey=t.authKey?.trim(),this.apiKeys=this.authKey.split(",").map(a=>a.trim()),!this.authKey)throw new Q("authKey are required");if(!this.authKey)throw new Q("authKey are required");t&&t.freeApiUrl&&(this.freeApiUrl=rn(this.freeApiUrl,t.freeApiUrl)),t&&t.proApiUrl&&(this.proApiUrl=rn(this.proApiUrl,t.proApiUrl)),t&&t.immersiveTranslateApiUrl&&(this.immersiveTranslateApiUrl=rn(this.immersiveTranslateApiUrl,t.immersiveTranslateApiUrl)),t&&t.immersiveTranslateDeeplTokenUrl&&(this.immersiveTranslateDeeplTokenUrl=rn(this.immersiveTranslateDeeplTokenUrl,t.immersiveTranslateDeeplTokenUrl)),t&&t.immersiveTranslateDeeplProApiUrl&&(this.immersiveTranslateDeeplProApiUrl=rn(this.immersiveTranslateDeeplProApiUrl,t.immersiveTranslateDeeplProApiUrl))}async init(){}getRateLimiter(){let t=super.getRateLimiter();if(this.provider==="pro"){if(this.serviceConfig?.immersiveTranslateProLimit){let n=Number(this.serviceConfig.immersiveTranslateProLimit);return isNaN(n)&&(n=15),{limit:n,interval:t?.interval||1050}}return{limit:15,interval:t?.interval||1050}}return super.getRateLimiter()}getDefaultRateLimit(){return{limit:3,interval:1250}}async translateList(t){let{from:n,to:r}=t,a=this.getRandomKey(),{text:i,merged:o}=this.optimizationText(t),s={source_lang:_u.get(n)||"",target_lang:_u.get(r)||r,tag_handling:"html"};this.serviceConfig?.tag_handling&&(this.serviceConfig.tag_handling==="none"?delete s.tag_handling:s.tag_handling=this.serviceConfig.tag_handling);let u=new URLSearchParams(s);i.forEach(T=>{u.append("text",T)});let l=u.toString(),c={text:i,source_lang:_u.get(n)||"auto",target_lang:_u.get(r)||r},g=this.freeApiUrl;a.endsWith(":im")?g=this.immersiveTranslateApiUrl:a.endsWith(":fx")||(g=this.proApiUrl);let f,m={};t.refresh&&(m={"X-Refresh":"True"}),t.debug&&(m={...m,"X-Debug":"True"}),this.provider==="pro"?f=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...m,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):a.startsWith("immersive_")?f=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...m,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):f=await de({retry:2,url:g,method:"POST",body:l,headers:{Authorization:"DeepL-Auth-Key "+a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},extra:{overrideMimeType:"application/json; charset=utf-8"}});let{translations:h}=this.restoreText(f,o,!!t.debug),y=h.map(T=>T.text);if(r==="zh-TW"){let T=this.serviceConfig||{};T&&T.googleApiUrl&&(T.apiUrl=T.googleApiUrl);let x=await new Hi(this.serviceConfig,this.generalConfig,this.translationOptions).translate({from:"zh-CN",to:"zh-TW",text:h.map(w=>w.text).join(` diff --git a/dist/chrome/popup.js b/dist/chrome/popup.js index 36dc786..c25fdff 100644 --- a/dist/chrome/popup.js +++ b/dist/chrome/popup.js @@ -1,4 +1,4 @@ -(()=>{var J9=Object.create;var gd=Object.defineProperty;var X9=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var t6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var r6=(t,e)=>()=>(t&&(e=t(t=0)),e);var a6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},i6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of e6(e))!n6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=X9(e,a))||r.enumerable});return t};var o6=(t,e,n)=>(n=t!=null?J9(t6(t)):{},i6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=r6(()=>{x={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var J9=Object.create;var gd=Object.defineProperty;var X9=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var t6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var r6=(t,e)=>()=>(t&&(e=t(t=0)),e);var a6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},i6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of e6(e))!n6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=X9(e,a))||r.enumerable});return t};var o6=(t,e,n)=>(n=t!=null?J9(t6(t)):{},i6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=r6(()=>{x={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5176,13 +5176,13 @@ Event: ${Ir(t)}`),!0):TC(t,e.denyUrls)?(!1&&Se.warn(`Event dropped due to being Event: ${Ir(t)}. Url: ${ul(t)}`),!0):yC(t,e.allowUrls)?!1:(!1&&Se.warn(`Event dropped due to not being matched by \`allowUrls\` option. Event: ${Ir(t)}. -Url: ${ul(t)}`),!0)}function bC(t,e){return!e||!e.length?!1:vC(t).some(n=>e.some(r=>Gu(n,r)))}function TC(t,e){if(!e||!e.length)return!1;let n=ul(t);return n?e.some(r=>Gu(n,r)):!1}function yC(t,e){if(!e||!e.length)return!0;let n=ul(t);return n?e.some(r=>Gu(n,r)):!0}function vC(t){if(t.message)return[t.message];if(t.exception)try{let{type:e="",value:n=""}=t.exception.values&&t.exception.values[0]||{};return[`${n}`,`${e}: ${n}`]}catch{return!1&&Se.error(`Cannot extract message for event ${Ir(t)}`),[]}return[]}function SC(t){try{return t.exception.values[0].type==="SentryError"}catch{}return!1}function xC(t=[]){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n&&n.filename!==""&&n.filename!=="[native code]")return n.filename||null}return null}function ul(t){try{let e;try{e=t.exception.values[0].stacktrace.frames}catch{}return e?xC(e):null}catch{return!1&&Se.error(`Cannot extract url for event ${Ir(t)}`),null}}d();d();function W0(t,e){let n=K0(t,e),r={type:e&&e.name,value:DC(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function EC(t,e,n,r){let a={exception:{values:[{type:$o(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:`Non-Error ${r?"promise rejection":"exception"} captured with keys: ${Tb(e)}`}]},extra:{__serialized__:P0(e)}};if(n){let i=K0(t,n);i.length&&(a.exception.values[0].stacktrace={frames:i})}return a}function j0(t,e){return{exception:{values:[W0(t,e)]}}}function K0(t,e){let n=e.stacktrace||e.stack||"",r=wC(e);try{return t(n,r)}catch{}return[]}var CC=/Minified React error #\d+;/i;function wC(t){if(t){if(typeof t.framesToPop=="number")return t.framesToPop;if(CC.test(t.message))return 1}return 0}function DC(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function $b(t,e,n,r){let a=n&&n.syntheticException||void 0,i=ll(t,e,a,r);return Xr(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),vn(i)}function Yb(t,e,n="info",r,a){let i=r&&r.syntheticException||void 0,o=H0(t,e,i,a);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),vn(o)}function ll(t,e,n,r,a){let i;if(Wu(e)&&e.error)return j0(t,e.error);if(sb(e)){let o=e;if("stack"in e)i=j0(t,e);else{let s=o.name||"DOMException",u=o.message?`${s}: ${o.message}`:s;i=H0(t,u,n,r),Xo(i,u)}return"code"in o&&(i.tags={...i.tags,"DOMException.code":`${o.code}`}),i}return Hu(e)?j0(t,e):Zn(e)||$o(e)?(i=EC(t,e,n,a),Xr(i,{synthetic:!0}),i):(i=H0(t,e,n,r),Xo(i,`${e}`,void 0),Xr(i,{synthetic:!0}),i)}function H0(t,e,n,r){let a={message:e};if(r&&n){let i=K0(t,n);i.length&&(a.exception={values:[{value:e,stacktrace:{frames:i}}]})}return a}d();var G0="Breadcrumbs",ta=class t{static id=G0;name=t.id;options;constructor(e){this.options={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e}}setupOnce(){this.options.console&&er("console",kC),this.options.dom&&er("dom",AC(this.options.dom)),this.options.xhr&&er("xhr",PC),this.options.fetch&&er("fetch",LC),this.options.history&&er("history",_C)}};function AC(t){function e(n){let r,a=typeof t=="object"?t.serializeAttribute:void 0;typeof a=="string"&&(a=[a]);try{r=n.event.target?Yo(n.event.target,a):Yo(n.event,a)}catch{r=""}r.length!==0&&Le().addBreadcrumb({category:`ui.${n.name}`,message:r},{event:n.event,name:n.name,global:n.global})}return e}function kC(t){let e={category:"console",data:{arguments:t.args,logger:"console"},level:kb(t.level),message:y0(t.args," ")};if(t.level==="assert")if(t.args[0]===!1)e.message=`Assertion failed: ${y0(t.args.slice(1)," ")||"console.assert"}`,e.data.arguments=t.args.slice(1);else return;Le().addBreadcrumb(e,{input:t.args,level:t.level})}function PC(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;let{method:e,url:n,status_code:r,body:a}=t.xhr.__sentry_xhr__||{};Le().addBreadcrumb({category:"xhr",data:{method:e,url:n,status_code:r},type:"http"},{xhr:t.xhr,input:a});return}}function LC(t){t.endTimestamp&&(t.fetchData.url.match(/sentry_key/)&&t.fetchData.method==="POST"||(t.error?Le().addBreadcrumb({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args}):Le().addBreadcrumb({category:"fetch",data:{...t.fetchData,status_code:t.response.status},type:"http"},{input:t.args,response:t.response})))}function _C(t){let e=at(),n=t.from,r=t.to,a=Vu(e.location.href),i=Vu(n),o=Vu(r);i.path||(i=a),a.protocol===o.protocol&&a.host===o.host&&(r=o.relative),a.protocol===i.protocol&&a.host===i.host&&(n=i.relative),Le().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}d();var dl=at(),cl;function V0(){if(cl)return cl;if(Sb(fetch))return cl=fetch.bind(dl);let t=dl.document,e=fetch;if(t&&typeof t.createElement=="function")try{let n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n);let r=n.contentWindow;r&&r.fetch&&(e=r.fetch),t.head.removeChild(n)}catch(n){!1&&Se.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return cl=e.bind(dl)}function Qb(t,e){Object.prototype.toString.call(dl&&navigator)==="[object Navigator]"&&typeof navigator.sendBeacon=="function"?navigator.sendBeacon.bind(navigator)(t,e):vb()&&V0()(t,{body:e,method:"POST",credentials:"omit",keepalive:!0}).then(null,i=>{!1&&Se.error(i)})}var $0=at(),Mi=class extends rs{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:Fi}],version:Fi},super(e),e.sendClientReports&&$0.document&&$0.document.addEventListener("visibilitychange",()=>{$0.document.visibilityState==="hidden"&&this._flushOutcomes()})}eventFromException(e,n){return $b(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Yb(this._options.stackParser,e,n,r,this._options.attachStacktrace)}sendEvent(e,n){let r=this.getIntegrationById(G0);r&&r.options&&r.options.sentry&&Le().addBreadcrumb({category:`sentry.${e.type==="transaction"?"transaction":"event"}`,event_id:e.event_id,level:e.level,message:Ir(e)},{event:e}),super.sendEvent(e,n)}_prepareEvent(e,n,r){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r)}_flushOutcomes(){let e=this._clearOutcomes();if(e.length===0){!1&&Se.log("No outcomes to send");return}if(!this._dsn){!1&&Se.log("No dsn provided, will not send outcomes");return}!1&&Se.log("Sending outcomes:",e);let n=ns(this._dsn,this._options),r=Fb(e,this._options.tunnel&&qa(this._dsn));try{Qb(n,Yu(r))}catch(a){!1&&Se.error(a)}}};d();d();function is(t,e=V0()){function n(r){let a={body:r.body,method:"POST",referrerPolicy:"origin",headers:t.headers,...t.fetchOptions};return e(t.url,a).then(i=>({statusCode:i.status,headers:{"x-sentry-rate-limits":i.headers.get("X-Sentry-Rate-Limits"),"retry-after":i.headers.get("Retry-After")}}))}return as(t,n)}d();var Bi="?",FC=10,MC=20,BC=30,IC=40,RC=50;function os(t,e,n,r){let a={filename:t,function:e,in_app:!0};return n!==void 0&&(a.lineno=n),r!==void 0&&(a.colno=r),a}var OC=/^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zC=/\((\S*)(?::(\d+))(?::(\d+))\)/,NC=t=>{let e=OC.exec(t);if(e){if(e[2]&&e[2].indexOf("eval")===0){let i=zC.exec(e[2]);i&&(e[2]=i[1],e[3]=i[2],e[4]=i[3])}let[r,a]=Xb(e[1]||Bi,e[2]);return os(a,r,e[3]?+e[3]:void 0,e[4]?+e[4]:void 0)}},Y0=[BC,NC],UC=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,qC=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,jC=t=>{let e=UC.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){let i=qC.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],a=e[1]||Bi;return[a,r]=Xb(a,r),os(r,a,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Q0=[RC,jC],HC=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,WC=t=>{let e=HC.exec(t);return e?os(e[2],e[1]||Bi,+e[3],e[4]?+e[4]:void 0):void 0},Z0=[IC,WC],KC=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,GC=t=>{let e=KC.exec(t);return e?os(e[2],e[3]||Bi,+e[1]):void 0},Zb=[FC,GC],VC=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,$C=t=>{let e=VC.exec(t);return e?os(e[5],e[3]||e[4]||Bi,+e[1],+e[2]):void 0},Jb=[MC,$C],J0=[Y0,Q0,Z0],pl=C0(...J0),Xb=(t,e)=>{let n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};d();d();var X0=0;function ep(){return X0>0}function YC(){X0+=1,setTimeout(()=>{X0-=1})}function zr(t,e={},n){if(typeof t!="function")return t;try{let a=t.__sentry_wrapped__;if(a)return a;if(Ai(t))return t}catch{return t}let r=function(){let a=Array.prototype.slice.call(arguments);try{n&&typeof n=="function"&&n.apply(this,arguments);let i=a.map(o=>zr(o,e));return t.apply(this,i)}catch(i){throw YC(),_i(o=>{o.addEventProcessor(s=>(e.mechanism&&(Xo(s,void 0,void 0),Xr(s,e.mechanism)),s.extra={...s.extra,arguments:a},s)),Li(i)}),i}};try{for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}catch{}S0(r,t),Zo(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}var tp={};tu(tp,{Breadcrumbs:()=>ta,Dedupe:()=>ia,GlobalHandlers:()=>fr,HttpContext:()=>aa,LinkedErrors:()=>ra,TryCatch:()=>na});d();d();var fr=class t{static id="GlobalHandlers";name=t.id;_options;_installFunc={onerror:QC,onunhandledrejection:ZC};constructor(e){this._options={onerror:!0,onunhandledrejection:!0,...e}}setupOnce(){let e=this._options;for(let n in e){let r=this._installFunc[n];r&&e[n]&&(ew(n),r(),this._installFunc[n]=void 0)}}};function QC(){er("error",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let{msg:a,url:i,line:o,column:s,error:u}=t;if(ep()||u&&u.__sentry_own_request__)return;let l=u===void 0&&Fr(a)?XC(a,i,o,s):e3(ll(n,u||a,void 0,r,!1),i,o,s);l.level="error",t3(e,u,l,"onerror")})}function ZC(){er("unhandledrejection",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let a=t;try{"reason"in t?a=t.reason:"detail"in t&&"reason"in t.detail&&(a=t.detail.reason)}catch{}if(ep()||a&&a.__sentry_own_request__)return!0;let i=Vo(a)?JC(a):ll(n,a,void 0,r,!0);i.level="error",t3(e,a,i,"onunhandledrejection")})}function JC(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function XC(t,e,n,r){let a=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=Wu(t)?t.message:t,o="Error",s=i.match(a);return s&&(o=s[1],i=s[2]),e3({exception:{values:[{type:o,value:i}]}},e,n,r)}function e3(t,e,n,r){let a=t.exception=t.exception||{},i=a.values=a.values||[],o=i[0]=i[0]||{},s=o.stacktrace=o.stacktrace||{},u=s.frames=s.frames||[],l=isNaN(parseInt(r,10))?void 0:r,c=isNaN(parseInt(n,10))?void 0:n,p=Fr(e)&&e.length>0?e:pb();return u.length===0&&u.push({colno:l,filename:p,function:"?",in_app:!0,lineno:c}),t}function ew(t){!1&&Se.log(`Global Handler attached: ${t}`)}function t3(t,e,n,r){Xr(n,{handled:!1,type:r}),t.captureEvent(n,{originalException:e})}function n3(){let t=Le(),e=t.getClient(),n=e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1};return[t,n.stackParser,n.attachStacktrace]}d();var tw=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],na=class t{static id="TryCatch";name=t.id;_options;constructor(e){this._options={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e}}setupOnce(){let e=at();this._options.setTimeout&&Jn(e,"setTimeout",r3),this._options.setInterval&&Jn(e,"setInterval",r3),this._options.requestAnimationFrame&&Jn(e,"requestAnimationFrame",nw),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&Jn(XMLHttpRequest.prototype,"send",rw);let n=this._options.eventTarget;n&&(Array.isArray(n)?n:tw).forEach(aw)}};function r3(t){return function(...e){let n=e[0];return e[0]=zr(n,{mechanism:{data:{function:Xn(t)},handled:!0,type:"instrument"}}),t.apply(this,e)}}function nw(t){return function(e){return t.apply(this,[zr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Xn(t)},handled:!0,type:"instrument"}})])}}function rw(t){return function(...e){let n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(a=>{a in n&&typeof n[a]=="function"&&Jn(n,a,function(i){let o={mechanism:{data:{function:a,handler:Xn(i)},handled:!0,type:"instrument"}},s=Ai(i);return s&&(o.mechanism.data.handler=Xn(s)),zr(i,o)})}),t.apply(this,e)}}function aw(t){let e=at(),n=e[t]&&e[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Jn(n,"addEventListener",function(r){return function(a,i,o){try{typeof i.handleEvent=="function"&&(i.handleEvent=zr(i.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Xn(i),target:t},handled:!0,type:"instrument"}}))}catch{}let s=zr(i,{mechanism:{data:{function:"addEventListener",handler:Xn(i),target:t},handled:!0,type:"instrument"}}),u=[a,s,o];return r.apply(this,u)}}),Jn(n,"removeEventListener",function(r){return function(a,i,o){let s=i;try{let u=s&&s.__sentry_wrapped__;u&&r.call(this,a,u,o)}catch{}return r.call(this,a,s,o)}}))}d();var iw="cause",ow=5,ra=class t{static id="LinkedErrors";name=t.id;_key;_limit;constructor(e={}){this._key=e.key||iw,this._limit=e.limit||ow}setupOnce(){let e=Le().getClient();e&&mr((n,r)=>{let a=Le().getIntegration(t);return a?sw(e.getOptions().stackParser,a._key,a._limit,n,r):n})}};function sw(t,e,n,r,a){if(!r.exception||!r.exception.values||!a||!dr(a.originalException,Error))return r;let i=a3(t,n,a.originalException,e);return r.exception.values=[...i,...r.exception.values],r}function a3(t,e,n,r,a=[]){if(!dr(n[r],Error)||a.length+1>=e)return a;let i=W0(t,n[r]);return a3(t,e,n[r],r,[i,...a])}d();var i3=at(),aa=class t{static id="HttpContext";name=t.id;setupOnce(){mr(e=>{if(Le().getIntegration(t)){if(!navigator&&!location&&!i3.document)return e;let n=e.request&&e.request.url||location&&location.href,{referrer:r}=i3.document||{},{userAgent:a}=navigator||{},i={...e.request&&e.request.headers,...r&&{Referer:r},...a&&{"User-Agent":a}},o={...n&&{url:n},headers:i};return{...e,request:o}}return e})}};d();var ia=class t{static id="Dedupe";name=t.id;_previousEvent;setupOnce(e,n){let r=a=>{let i=n().getIntegration(t);if(i){try{if(uw(a,i._previousEvent))return!1&&Se.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{return i._previousEvent=a}return i._previousEvent=a}return a};r.id=this.name,e(r)}};function uw(t,e){return e?!!(lw(t,e)||cw(t,e)):!1}function lw(t,e){let n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!l3(t,e)||!u3(t,e))}function cw(t,e){let n=o3(e),r=o3(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!l3(t,e)||!u3(t,e))}function u3(t,e){let n=s3(t),r=s3(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let a=0;a"u"){!1&&Se.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");return}let n=Le();n.captureSession&&(c3(n),er("history",({from:r,to:a})=>{r===void 0||r===a||c3(Le())}))}var y3={},rp=at();rp.Sentry&&rp.Sentry.Integrations&&(y3=rp.Sentry.Integrations);var pw={...y3,...Va,...tp};var gw=Ru.alert;d();var Ii=console,ap=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=In.green;r>1e4?a=In.red:r>1e3&&(a=In.yellow),Ii.debug(In.dim(Ia+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ss=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&Ii.log(In.dim(Ia+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&Ii.log(In.green(Ia+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&Ii.warn(In.yellow(Ia+" WARN:"),...e)}error(...e){this.#e<=3&&Ii.error(In.red(Ia+" ERROR:"),...e)}fatal(...e){this.#e<=4&&Ii.error(In.red(Ia+" FATAL:"),...e)}timing(){return this.level===0?new ap:{reset:()=>{},stop:()=>{}}}},z=new ss;var v3=["*://*/*","*","*://*"],x3="immersive-translate-wildcard-placeholder.com";function ip(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>v3.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(v3.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return fw(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,x3),g;try{g=new URL(p)}catch{return z.debug("invalid match pattern",p,"raw match value:",c),!1}let m=g.host,f=g.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=mw(l+":",S3(m),S3(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function S3(t){return t.replaceAll(x3,"*")}function mw(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function wt(t,e){return ip(t,e)!==null}function fw(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}d();d();var gl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.3",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var bw="";function Sn(){return bw||gl.version}function op(){return oe.runtime.getManifest().version}d();d();var Tw="";function Ri(){return Tw||globalThis.navigator.userAgent}function sp(){return Ri().includes("ImtFxiOS")}function E3(){let e=Ri().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function yw(){return Ri().includes("ImtFxAndroid")}function C3(){let t=Ri();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function w3(){let e=Ri().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function us(){let t=Ri();if(sp()||yw()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}function ml(t){if(t.beta)return!1;if(it()&&t.spVersion)return ls(op(),t.spVersion);if(C3()&&t.gspVersion){let e=w3();if(e)return ls(e,t.gspVersion)}if(sp()&&t.ispVersion){let e=E3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function up(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function fl(t){return Array.isArray(t)?t:t?[t]:[]}function hl(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function bl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function Tl(t,e){let n={...t};return P3(n,e),vw(n,e),n}function k3(t,e,n){let r={...e};return Ya({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ya({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function vw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;P3(t,a)}function Ya({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Sw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=fl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!D3(s))return;c=lp(l,u)}else if(o=="remove_v"){if(!D3(s))return;c=A3(l,u)}else o==="add"?c=lp(l,u):o=="remove"&&(c=A3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=lp(l,u):c=u,r(i,c)})}function P3(t,e){return Ya({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function lp(t,e){let n;if(Array.isArray(t)){let r=fl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Sw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function D3(t){let e=Sn();return t&&ls(e,t)}function A3(t,e){if(Array.isArray(t)){let n=fl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}d();d();var Oi="input is invalid type",cp=typeof window=="object",oa=cp?window:{};oa.JS_SHA256_NO_WINDOW&&(cp=!1);var xw=!cp&&typeof self=="object",Ew=!oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;Ew?oa=global:xw&&(oa=self);var SN=!oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,xN=typeof define=="function"&&define.amd,cs=!oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),Cw=[-2147483648,8388608,32768,128],tr=[24,16,8,0],yl=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],vl=["hex","array","digest","arrayBuffer"],Ut=[];(oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});cs&&(oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var L3=function(t,e){return function(n){return new qt(e,!0).update(n)[t]()}},F3=function(t){var e=L3("hex",t);e.create=function(){return new qt(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};qt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Cw[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};qt.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,g,m,f,T,b,h,C,D;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],p=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(b=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,g=b^t&n^D,T=a&i^~a&o,m=s+p+T+yl[l]+u[l],f=c+g,s=r+m<<0,r=m+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,g=h^r&e^b,T=s&a^~s&i,m=o+p+T+yl[l+1]+u[l+1],f=c+g,o=n+m<<0,n=m+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),C=n&r,g=C^n&t^h,T=o&s^~o&a,m=i+p+T+yl[l+2]+u[l+2],f=c+g,i=e+m<<0,e=m+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,g=D^e&r^C,T=i&o^~i&s,m=a+p+T+yl[l+3]+u[l+3],f=c+g,a=t+m<<0,t=m+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};qt.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};qt.prototype.toString=qt.prototype.hex;qt.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};qt.prototype.array=qt.prototype.digest;qt.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Sl(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Oi);if(cs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cs||!ArrayBuffer.isView(t)))throw new Error(Oi)}else throw new Error(Oi);t.length>64&&(t=new qt(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}qt.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Sl.prototype=new qt;Sl.prototype.finalize=function(){if(qt.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();qt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),qt.prototype.finalize.call(this)}};var zi=F3();zi.sha256=zi;zi.sha224=F3(!0);zi.sha256.hmac=M3();zi.sha224.hmac=M3(!0);var B3=zi;var I3=B3.sha256;function nr(t){return Promise.resolve(I3(t))}function xl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function sa(t,e){let n=I3.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function R3(t,e){let n=await sa(t,e);return xl(n)}async function El(t,e){let n=ww(e),r=await sa(t,n);return xl(r)}function ww(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}d();d();function Je(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();d();function O3(t){return t.replace(//g,">")}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=wn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":wn[a]}else return"auto";else return wn[r]}function ft(){return Te(document?.documentElement?.lang||"en")}function z3(t,e,n){let r=Dw(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function Dw(t,e){let n=[],r=[];for(let a=0;a0?Te.some(r=>Gu(n,r)))}function TC(t,e){if(!e||!e.length)return!1;let n=ul(t);return n?e.some(r=>Gu(n,r)):!1}function yC(t,e){if(!e||!e.length)return!0;let n=ul(t);return n?e.some(r=>Gu(n,r)):!0}function vC(t){if(t.message)return[t.message];if(t.exception)try{let{type:e="",value:n=""}=t.exception.values&&t.exception.values[0]||{};return[`${n}`,`${e}: ${n}`]}catch{return!1&&Se.error(`Cannot extract message for event ${Ir(t)}`),[]}return[]}function SC(t){try{return t.exception.values[0].type==="SentryError"}catch{}return!1}function xC(t=[]){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n&&n.filename!==""&&n.filename!=="[native code]")return n.filename||null}return null}function ul(t){try{let e;try{e=t.exception.values[0].stacktrace.frames}catch{}return e?xC(e):null}catch{return!1&&Se.error(`Cannot extract url for event ${Ir(t)}`),null}}d();d();function W0(t,e){let n=K0(t,e),r={type:e&&e.name,value:DC(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function EC(t,e,n,r){let a={exception:{values:[{type:$o(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:`Non-Error ${r?"promise rejection":"exception"} captured with keys: ${Tb(e)}`}]},extra:{__serialized__:P0(e)}};if(n){let i=K0(t,n);i.length&&(a.exception.values[0].stacktrace={frames:i})}return a}function j0(t,e){return{exception:{values:[W0(t,e)]}}}function K0(t,e){let n=e.stacktrace||e.stack||"",r=wC(e);try{return t(n,r)}catch{}return[]}var CC=/Minified React error #\d+;/i;function wC(t){if(t){if(typeof t.framesToPop=="number")return t.framesToPop;if(CC.test(t.message))return 1}return 0}function DC(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function $b(t,e,n,r){let a=n&&n.syntheticException||void 0,i=ll(t,e,a,r);return Xr(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),vn(i)}function Yb(t,e,n="info",r,a){let i=r&&r.syntheticException||void 0,o=H0(t,e,i,a);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),vn(o)}function ll(t,e,n,r,a){let i;if(Wu(e)&&e.error)return j0(t,e.error);if(sb(e)){let o=e;if("stack"in e)i=j0(t,e);else{let s=o.name||"DOMException",u=o.message?`${s}: ${o.message}`:s;i=H0(t,u,n,r),Xo(i,u)}return"code"in o&&(i.tags={...i.tags,"DOMException.code":`${o.code}`}),i}return Hu(e)?j0(t,e):Zn(e)||$o(e)?(i=EC(t,e,n,a),Xr(i,{synthetic:!0}),i):(i=H0(t,e,n,r),Xo(i,`${e}`,void 0),Xr(i,{synthetic:!0}),i)}function H0(t,e,n,r){let a={message:e};if(r&&n){let i=K0(t,n);i.length&&(a.exception={values:[{value:e,stacktrace:{frames:i}}]})}return a}d();var G0="Breadcrumbs",ta=class t{static id=G0;name=t.id;options;constructor(e){this.options={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e}}setupOnce(){this.options.console&&er("console",kC),this.options.dom&&er("dom",AC(this.options.dom)),this.options.xhr&&er("xhr",PC),this.options.fetch&&er("fetch",LC),this.options.history&&er("history",_C)}};function AC(t){function e(n){let r,a=typeof t=="object"?t.serializeAttribute:void 0;typeof a=="string"&&(a=[a]);try{r=n.event.target?Yo(n.event.target,a):Yo(n.event,a)}catch{r=""}r.length!==0&&Le().addBreadcrumb({category:`ui.${n.name}`,message:r},{event:n.event,name:n.name,global:n.global})}return e}function kC(t){let e={category:"console",data:{arguments:t.args,logger:"console"},level:kb(t.level),message:y0(t.args," ")};if(t.level==="assert")if(t.args[0]===!1)e.message=`Assertion failed: ${y0(t.args.slice(1)," ")||"console.assert"}`,e.data.arguments=t.args.slice(1);else return;Le().addBreadcrumb(e,{input:t.args,level:t.level})}function PC(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;let{method:e,url:n,status_code:r,body:a}=t.xhr.__sentry_xhr__||{};Le().addBreadcrumb({category:"xhr",data:{method:e,url:n,status_code:r},type:"http"},{xhr:t.xhr,input:a});return}}function LC(t){t.endTimestamp&&(t.fetchData.url.match(/sentry_key/)&&t.fetchData.method==="POST"||(t.error?Le().addBreadcrumb({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args}):Le().addBreadcrumb({category:"fetch",data:{...t.fetchData,status_code:t.response.status},type:"http"},{input:t.args,response:t.response})))}function _C(t){let e=at(),n=t.from,r=t.to,a=Vu(e.location.href),i=Vu(n),o=Vu(r);i.path||(i=a),a.protocol===o.protocol&&a.host===o.host&&(r=o.relative),a.protocol===i.protocol&&a.host===i.host&&(n=i.relative),Le().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}d();var dl=at(),cl;function V0(){if(cl)return cl;if(Sb(fetch))return cl=fetch.bind(dl);let t=dl.document,e=fetch;if(t&&typeof t.createElement=="function")try{let n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n);let r=n.contentWindow;r&&r.fetch&&(e=r.fetch),t.head.removeChild(n)}catch(n){!1&&Se.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return cl=e.bind(dl)}function Qb(t,e){Object.prototype.toString.call(dl&&navigator)==="[object Navigator]"&&typeof navigator.sendBeacon=="function"?navigator.sendBeacon.bind(navigator)(t,e):vb()&&V0()(t,{body:e,method:"POST",credentials:"omit",keepalive:!0}).then(null,i=>{!1&&Se.error(i)})}var $0=at(),Mi=class extends rs{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:Fi}],version:Fi},super(e),e.sendClientReports&&$0.document&&$0.document.addEventListener("visibilitychange",()=>{$0.document.visibilityState==="hidden"&&this._flushOutcomes()})}eventFromException(e,n){return $b(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Yb(this._options.stackParser,e,n,r,this._options.attachStacktrace)}sendEvent(e,n){let r=this.getIntegrationById(G0);r&&r.options&&r.options.sentry&&Le().addBreadcrumb({category:`sentry.${e.type==="transaction"?"transaction":"event"}`,event_id:e.event_id,level:e.level,message:Ir(e)},{event:e}),super.sendEvent(e,n)}_prepareEvent(e,n,r){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r)}_flushOutcomes(){let e=this._clearOutcomes();if(e.length===0){!1&&Se.log("No outcomes to send");return}if(!this._dsn){!1&&Se.log("No dsn provided, will not send outcomes");return}!1&&Se.log("Sending outcomes:",e);let n=ns(this._dsn,this._options),r=Fb(e,this._options.tunnel&&qa(this._dsn));try{Qb(n,Yu(r))}catch(a){!1&&Se.error(a)}}};d();d();function is(t,e=V0()){function n(r){let a={body:r.body,method:"POST",referrerPolicy:"origin",headers:t.headers,...t.fetchOptions};return e(t.url,a).then(i=>({statusCode:i.status,headers:{"x-sentry-rate-limits":i.headers.get("X-Sentry-Rate-Limits"),"retry-after":i.headers.get("Retry-After")}}))}return as(t,n)}d();var Bi="?",FC=10,MC=20,BC=30,IC=40,RC=50;function os(t,e,n,r){let a={filename:t,function:e,in_app:!0};return n!==void 0&&(a.lineno=n),r!==void 0&&(a.colno=r),a}var OC=/^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zC=/\((\S*)(?::(\d+))(?::(\d+))\)/,NC=t=>{let e=OC.exec(t);if(e){if(e[2]&&e[2].indexOf("eval")===0){let i=zC.exec(e[2]);i&&(e[2]=i[1],e[3]=i[2],e[4]=i[3])}let[r,a]=Xb(e[1]||Bi,e[2]);return os(a,r,e[3]?+e[3]:void 0,e[4]?+e[4]:void 0)}},Y0=[BC,NC],UC=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,qC=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,jC=t=>{let e=UC.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){let i=qC.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],a=e[1]||Bi;return[a,r]=Xb(a,r),os(r,a,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Q0=[RC,jC],HC=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,WC=t=>{let e=HC.exec(t);return e?os(e[2],e[1]||Bi,+e[3],e[4]?+e[4]:void 0):void 0},Z0=[IC,WC],KC=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,GC=t=>{let e=KC.exec(t);return e?os(e[2],e[3]||Bi,+e[1]):void 0},Zb=[FC,GC],VC=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,$C=t=>{let e=VC.exec(t);return e?os(e[5],e[3]||e[4]||Bi,+e[1],+e[2]):void 0},Jb=[MC,$C],J0=[Y0,Q0,Z0],pl=C0(...J0),Xb=(t,e)=>{let n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};d();d();var X0=0;function ep(){return X0>0}function YC(){X0+=1,setTimeout(()=>{X0-=1})}function zr(t,e={},n){if(typeof t!="function")return t;try{let a=t.__sentry_wrapped__;if(a)return a;if(Ai(t))return t}catch{return t}let r=function(){let a=Array.prototype.slice.call(arguments);try{n&&typeof n=="function"&&n.apply(this,arguments);let i=a.map(o=>zr(o,e));return t.apply(this,i)}catch(i){throw YC(),_i(o=>{o.addEventProcessor(s=>(e.mechanism&&(Xo(s,void 0,void 0),Xr(s,e.mechanism)),s.extra={...s.extra,arguments:a},s)),Li(i)}),i}};try{for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}catch{}S0(r,t),Zo(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}var tp={};tu(tp,{Breadcrumbs:()=>ta,Dedupe:()=>ia,GlobalHandlers:()=>fr,HttpContext:()=>aa,LinkedErrors:()=>ra,TryCatch:()=>na});d();d();var fr=class t{static id="GlobalHandlers";name=t.id;_options;_installFunc={onerror:QC,onunhandledrejection:ZC};constructor(e){this._options={onerror:!0,onunhandledrejection:!0,...e}}setupOnce(){let e=this._options;for(let n in e){let r=this._installFunc[n];r&&e[n]&&(ew(n),r(),this._installFunc[n]=void 0)}}};function QC(){er("error",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let{msg:a,url:i,line:o,column:s,error:u}=t;if(ep()||u&&u.__sentry_own_request__)return;let l=u===void 0&&Fr(a)?XC(a,i,o,s):e3(ll(n,u||a,void 0,r,!1),i,o,s);l.level="error",t3(e,u,l,"onerror")})}function ZC(){er("unhandledrejection",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let a=t;try{"reason"in t?a=t.reason:"detail"in t&&"reason"in t.detail&&(a=t.detail.reason)}catch{}if(ep()||a&&a.__sentry_own_request__)return!0;let i=Vo(a)?JC(a):ll(n,a,void 0,r,!0);i.level="error",t3(e,a,i,"onunhandledrejection")})}function JC(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function XC(t,e,n,r){let a=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=Wu(t)?t.message:t,o="Error",s=i.match(a);return s&&(o=s[1],i=s[2]),e3({exception:{values:[{type:o,value:i}]}},e,n,r)}function e3(t,e,n,r){let a=t.exception=t.exception||{},i=a.values=a.values||[],o=i[0]=i[0]||{},s=o.stacktrace=o.stacktrace||{},u=s.frames=s.frames||[],l=isNaN(parseInt(r,10))?void 0:r,c=isNaN(parseInt(n,10))?void 0:n,p=Fr(e)&&e.length>0?e:pb();return u.length===0&&u.push({colno:l,filename:p,function:"?",in_app:!0,lineno:c}),t}function ew(t){!1&&Se.log(`Global Handler attached: ${t}`)}function t3(t,e,n,r){Xr(n,{handled:!1,type:r}),t.captureEvent(n,{originalException:e})}function n3(){let t=Le(),e=t.getClient(),n=e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1};return[t,n.stackParser,n.attachStacktrace]}d();var tw=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],na=class t{static id="TryCatch";name=t.id;_options;constructor(e){this._options={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e}}setupOnce(){let e=at();this._options.setTimeout&&Jn(e,"setTimeout",r3),this._options.setInterval&&Jn(e,"setInterval",r3),this._options.requestAnimationFrame&&Jn(e,"requestAnimationFrame",nw),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&Jn(XMLHttpRequest.prototype,"send",rw);let n=this._options.eventTarget;n&&(Array.isArray(n)?n:tw).forEach(aw)}};function r3(t){return function(...e){let n=e[0];return e[0]=zr(n,{mechanism:{data:{function:Xn(t)},handled:!0,type:"instrument"}}),t.apply(this,e)}}function nw(t){return function(e){return t.apply(this,[zr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Xn(t)},handled:!0,type:"instrument"}})])}}function rw(t){return function(...e){let n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(a=>{a in n&&typeof n[a]=="function"&&Jn(n,a,function(i){let o={mechanism:{data:{function:a,handler:Xn(i)},handled:!0,type:"instrument"}},s=Ai(i);return s&&(o.mechanism.data.handler=Xn(s)),zr(i,o)})}),t.apply(this,e)}}function aw(t){let e=at(),n=e[t]&&e[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Jn(n,"addEventListener",function(r){return function(a,i,o){try{typeof i.handleEvent=="function"&&(i.handleEvent=zr(i.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Xn(i),target:t},handled:!0,type:"instrument"}}))}catch{}let s=zr(i,{mechanism:{data:{function:"addEventListener",handler:Xn(i),target:t},handled:!0,type:"instrument"}}),u=[a,s,o];return r.apply(this,u)}}),Jn(n,"removeEventListener",function(r){return function(a,i,o){let s=i;try{let u=s&&s.__sentry_wrapped__;u&&r.call(this,a,u,o)}catch{}return r.call(this,a,s,o)}}))}d();var iw="cause",ow=5,ra=class t{static id="LinkedErrors";name=t.id;_key;_limit;constructor(e={}){this._key=e.key||iw,this._limit=e.limit||ow}setupOnce(){let e=Le().getClient();e&&mr((n,r)=>{let a=Le().getIntegration(t);return a?sw(e.getOptions().stackParser,a._key,a._limit,n,r):n})}};function sw(t,e,n,r,a){if(!r.exception||!r.exception.values||!a||!dr(a.originalException,Error))return r;let i=a3(t,n,a.originalException,e);return r.exception.values=[...i,...r.exception.values],r}function a3(t,e,n,r,a=[]){if(!dr(n[r],Error)||a.length+1>=e)return a;let i=W0(t,n[r]);return a3(t,e,n[r],r,[i,...a])}d();var i3=at(),aa=class t{static id="HttpContext";name=t.id;setupOnce(){mr(e=>{if(Le().getIntegration(t)){if(!navigator&&!location&&!i3.document)return e;let n=e.request&&e.request.url||location&&location.href,{referrer:r}=i3.document||{},{userAgent:a}=navigator||{},i={...e.request&&e.request.headers,...r&&{Referer:r},...a&&{"User-Agent":a}},o={...n&&{url:n},headers:i};return{...e,request:o}}return e})}};d();var ia=class t{static id="Dedupe";name=t.id;_previousEvent;setupOnce(e,n){let r=a=>{let i=n().getIntegration(t);if(i){try{if(uw(a,i._previousEvent))return!1&&Se.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{return i._previousEvent=a}return i._previousEvent=a}return a};r.id=this.name,e(r)}};function uw(t,e){return e?!!(lw(t,e)||cw(t,e)):!1}function lw(t,e){let n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!l3(t,e)||!u3(t,e))}function cw(t,e){let n=o3(e),r=o3(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!l3(t,e)||!u3(t,e))}function u3(t,e){let n=s3(t),r=s3(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let a=0;a"u"){!1&&Se.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");return}let n=Le();n.captureSession&&(c3(n),er("history",({from:r,to:a})=>{r===void 0||r===a||c3(Le())}))}var y3={},rp=at();rp.Sentry&&rp.Sentry.Integrations&&(y3=rp.Sentry.Integrations);var pw={...y3,...Va,...tp};var gw=Ru.alert;d();var Ii=console,ap=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=In.green;r>1e4?a=In.red:r>1e3&&(a=In.yellow),Ii.debug(In.dim(Ia+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ss=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&Ii.log(In.dim(Ia+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&Ii.log(In.green(Ia+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&Ii.warn(In.yellow(Ia+" WARN:"),...e)}error(...e){this.#e<=3&&Ii.error(In.red(Ia+" ERROR:"),...e)}fatal(...e){this.#e<=4&&Ii.error(In.red(Ia+" FATAL:"),...e)}timing(){return this.level===0?new ap:{reset:()=>{},stop:()=>{}}}},z=new ss;var v3=["*://*/*","*","*://*"],x3="immersive-translate-wildcard-placeholder.com";function ip(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>v3.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(v3.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return fw(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,x3),g;try{g=new URL(p)}catch{return z.debug("invalid match pattern",p,"raw match value:",c),!1}let m=g.host,f=g.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=mw(l+":",S3(m),S3(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function S3(t){return t.replaceAll(x3,"*")}function mw(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function wt(t,e){return ip(t,e)!==null}function fw(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}d();d();var gl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.4",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var bw="";function Sn(){return bw||gl.version}function op(){return oe.runtime.getManifest().version}d();d();var Tw="";function Ri(){return Tw||globalThis.navigator.userAgent}function sp(){return Ri().includes("ImtFxiOS")}function E3(){let e=Ri().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function yw(){return Ri().includes("ImtFxAndroid")}function C3(){let t=Ri();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function w3(){let e=Ri().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function us(){let t=Ri();if(sp()||yw()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}function ml(t){if(t.beta)return!1;if(it()&&t.spVersion)return ls(op(),t.spVersion);if(C3()&&t.gspVersion){let e=w3();if(e)return ls(e,t.gspVersion)}if(sp()&&t.ispVersion){let e=E3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function up(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function fl(t){return Array.isArray(t)?t:t?[t]:[]}function hl(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function bl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function Tl(t,e){let n={...t};return P3(n,e),vw(n,e),n}function k3(t,e,n){let r={...e};return Ya({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ya({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function vw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;P3(t,a)}function Ya({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Sw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=fl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!D3(s))return;c=lp(l,u)}else if(o=="remove_v"){if(!D3(s))return;c=A3(l,u)}else o==="add"?c=lp(l,u):o=="remove"&&(c=A3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=lp(l,u):c=u,r(i,c)})}function P3(t,e){return Ya({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function lp(t,e){let n;if(Array.isArray(t)){let r=fl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Sw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function D3(t){let e=Sn();return t&&ls(e,t)}function A3(t,e){if(Array.isArray(t)){let n=fl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}d();d();var Oi="input is invalid type",cp=typeof window=="object",oa=cp?window:{};oa.JS_SHA256_NO_WINDOW&&(cp=!1);var xw=!cp&&typeof self=="object",Ew=!oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;Ew?oa=global:xw&&(oa=self);var SN=!oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,xN=typeof define=="function"&&define.amd,cs=!oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),Cw=[-2147483648,8388608,32768,128],tr=[24,16,8,0],yl=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],vl=["hex","array","digest","arrayBuffer"],Ut=[];(oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});cs&&(oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var L3=function(t,e){return function(n){return new qt(e,!0).update(n)[t]()}},F3=function(t){var e=L3("hex",t);e.create=function(){return new qt(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};qt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Cw[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};qt.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,g,m,f,T,b,h,C,D;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],p=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(b=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,g=b^t&n^D,T=a&i^~a&o,m=s+p+T+yl[l]+u[l],f=c+g,s=r+m<<0,r=m+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,g=h^r&e^b,T=s&a^~s&i,m=o+p+T+yl[l+1]+u[l+1],f=c+g,o=n+m<<0,n=m+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),C=n&r,g=C^n&t^h,T=o&s^~o&a,m=i+p+T+yl[l+2]+u[l+2],f=c+g,i=e+m<<0,e=m+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,g=D^e&r^C,T=i&o^~i&s,m=a+p+T+yl[l+3]+u[l+3],f=c+g,a=t+m<<0,t=m+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};qt.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};qt.prototype.toString=qt.prototype.hex;qt.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};qt.prototype.array=qt.prototype.digest;qt.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Sl(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Oi);if(cs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cs||!ArrayBuffer.isView(t)))throw new Error(Oi)}else throw new Error(Oi);t.length>64&&(t=new qt(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}qt.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Sl.prototype=new qt;Sl.prototype.finalize=function(){if(qt.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();qt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),qt.prototype.finalize.call(this)}};var zi=F3();zi.sha256=zi;zi.sha224=F3(!0);zi.sha256.hmac=M3();zi.sha224.hmac=M3(!0);var B3=zi;var I3=B3.sha256;function nr(t){return Promise.resolve(I3(t))}function xl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function sa(t,e){let n=I3.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function R3(t,e){let n=await sa(t,e);return xl(n)}async function El(t,e){let n=ww(e),r=await sa(t,n);return xl(r)}function ww(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}d();d();function Je(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();d();function O3(t){return t.replace(//g,">")}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=wn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":wn[a]}else return"auto";else return wn[r]}function ft(){return Te(document?.documentElement?.lang||"en")}function z3(t,e,n){let r=Dw(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function Dw(t,e){let n=[],r=[];for(let a=0;a0?Te){let C=[];dp(b,e,C);for(let D=0;D0&&T{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&dp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?m.push(T):g.push(T))});let f=m.concat(g).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:m,explicitProps:g}}var ds=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Zt(s),l=Object.keys(cr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=cr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&it())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let g=!!p.canary,m=!!p.alpha,f=!!p.beta;return c===t[e]||g&&i||m&&(r||i)||f&&(a||r||i)?!0:!m&&!f&&!g}).map(c=>Cl(e,c,t))};function ps(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function N3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}d();var U3=me+"SyncStoreKey_";function At(t,e){let n=U3+t;return oe.storage.sync.get(n).then(r=>r[n]===void 0?e:r[n])}function Ze(t,e){let n=U3+t;return oe.storage.sync.set({[n]:e})}d();d();var q3=me+"StoreKey_";function Nr(t,e){let n=q3+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function j3(t,e){let n=q3+t;return oe.storage.local.set({[n]:e})}d();d();d();d();function H3(t,e){return[t,!t||t.endsWith("/")?"":"/",e,".json"].join("")}function pp(t,e){let n=t;return e&&Object.keys(e).forEach(r=>{let a=e[r];if(a===void 0)return;let i=Aw(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let p=n.substring(u+s.length,c),g=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");n=n.replace(`${s}${p}`,`<${l} ${g}>${p}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function gs(t,e,n){let r=t[e];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function hr(t,e,n,r,a){if(!t.hasOwnProperty(n))return e;let i=gs(t,n,e);return i===e&&n!==r&&(i=gs(t,r,e)),pp(i,a)}function Aw(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function kt(t,e,n){return hr(Ot,e,t.config.interfaceLanguage,"en",n)}d();function W3(t,e){let n=new Date(t),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function K3(t){return new Date(t).getTime()}var $=class extends Error{status;constructor(e,n){if(e&&n){super(n),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let n=null;if(n=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!n){let r=kt.bind(null,e),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let n=kt.bind(null,e),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let n=kt.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let n=kt.bind(null,e),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(e){let n=kt.bind(null,e);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(e){let n=kt.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let n=kt.bind(null,e);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let p=this.data?.translationService=="deepl"?"OpenAI":"Deepl",g=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=n("errorReason",{message:r});if(i=="onetime_7day")m+=n("proQuotaExceededError.onetime7day",{anotherService:p,brandId:Q,href:Pu});else{let f="";g=="OpenAI"?f=i4:f=o4,o?m+=n("proQuotaExceededError.trial",{anotherService:p,brandId:Q,href:s4}):m+=n("proQuotaExceededError.nonTrial",{anotherService:p,brandId:Q,href:f,translationService:g}),!o&&(a.cancelAtPeriodEnd==="false"||K3(u)>s)&&(m+=n("proQuotaExceededError.resetTime",{resetTime:W3(s,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function Ur(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Hd(G3.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else e=await G3(t);return e}async function G3(t){t.body;let{url:e,responseType:n,...r}=t;n||(n="json"),r={mode:"cors",...r};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(e,r)}catch(u){z.debug("fetch error",e,u);let l=u.message||"Unknown Error";throw new $("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=e),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of kw(s.body)){let p=new TextDecoder().decode(c);u+=p;let g;for(;(g=u.indexOf(` -`))>=0;){let m=u.slice(0,g).trim();if(u=u.slice(g+1),m.startsWith("event:")||m==="")continue;let f="";if(m.startsWith("data:")&&(f=m.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){z.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(m){z.error("parse response failed",m)}u&&z.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*kw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Pw=new Map;function wl(t){let e=Lw(64),n=new CustomEvent(Ph,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Pw.set(e,(i,o)=>{i?a(i):r(o)})})}function Lw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=mp(s),{type:g,name:m}=p;if(g!==e)return!1;let f=mp(o),b=ms.get(g).get(m);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(C){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=ms.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new gp(`${i}:${e}`,this.logger);return ms.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},gp=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=mp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return V3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return V3(o,s,this.logger)}}};function V3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function mp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}var Dl;function _w(){return Dl||(Dl=new br("content_script",!1).getConnection("pure_main",()=>{}),Dl)}var $3="G-MKMD9LWFTR";async function fs(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(us()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=Je(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Nr("fakeUserId",""),u&&await Ze("fakeUserId",u));let l=Sn(),c=new Date,p=await At("installedAt","");p||(p=await Nr("installedAt",""),p&&await Ze("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Ze("installedAt",p)):(u=Fw(32),await Ze("fakeUserId",u)),p||(p=c.toISOString(),await Ze("installedAt",p));let g=new Date(p),m=Y3(g),f=Y3(c),T=m===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${$3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${$3}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let D=Ei.parse(C),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let _=us();_&&(y.browser_name=_.name,y.browser_version=_.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),m&&(y.install_day=Mw(g)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),B=await Al({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Fw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=u.slice(0,g).trim();if(u=u.slice(g+1),m.startsWith("event:")||m==="")continue;let f="";if(m.startsWith("data:")&&(f=m.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){z.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(m){z.error("parse response failed",m)}u&&z.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*kw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Pw=new Map;function wl(t){let e=Lw(64),n=new CustomEvent(Ph,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Pw.set(e,(i,o)=>{i?a(i):r(o)})})}function Lw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=mp(s),{type:g,name:m}=p;if(g!==e)return!1;let f=mp(o),b=ms.get(g).get(m);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(C){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=ms.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new gp(`${i}:${e}`,this.logger);return ms.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},gp=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=mp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return V3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return V3(o,s,this.logger)}}};function V3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function mp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}var Dl;function _w(){return Dl||(Dl=new br("content_script",!1).getConnection("pure_main",()=>{}),Dl)}var $3="G-MKMD9LWFTR";async function fs(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(us()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=Je(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Nr("fakeUserId",""),u&&await Ze("fakeUserId",u));let l=Sn(),c=new Date,p=await At("installedAt","");p||(p=await Nr("installedAt",""),p&&await Ze("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Ze("installedAt",p)):(u=Fw(32),await Ze("fakeUserId",u)),p||(p=c.toISOString(),await Ze("installedAt",p));let g=new Date(p),m=Y3(g),f=Y3(c),T=m===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${$3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${$3}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let D=Ei.parse(C),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let _=us();_&&(y.browser_name=_.name,y.browser_version=_.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),m&&(y.install_day=Mw(g)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),B=await Al({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Fw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5338,7 +5338,7 @@ Translate the content to {{to}} Language: `,selectors:["h3 a[data-clk]","div.gs_rs","td a.gsc_a_at","td div.gs_gray:last-of-type","div.gsc_oci_value","#gs_opinion"],extraInlineSelectors:["br"],atomicBlockSelectors:["h3 a[data-clk]"]},{id:"googleMail",matches:"mail.google.com",detectParagraphLanguage:!0,selectors:["h2[data-thread-perm-id]","span[data-thread-id]","div[data-message-id] div[class='']",".messageBody","#views"],globalStyles:{"[role='listitem'] > div":"height:auto!important;white-space:unset!important;"}},{id:"googleNews",matches:"news.google.com",blockMinTextCount:26,blockMinWordCount:5,globalStyles:{".MCAGUe":"height: auto;",".To2ZZb.DbQnIe":"height: unset;",".cp7Yvc > h2":"display: block;",".oovtQ":"height: auto;",h4:"-webkit-line-clamp: unset;"},excludeSelectors:[".EyERq",".AOl7G.eejsDc","[aria-label='Home']","[aria-label='For you']","[aria-label='Following']","[aria-label='World']","[aria-label='Local']",".gb_Fc",".wBQf7b",".yPI8Rb",".jKHa4e",".u43Gd",".Zgjpyb","[role='button']","[jsname='rymPhb']",".cbz1ld",".VfPpkd-P5QLlc",".XvhY1d"]},{id:"outlook",matches:"outlook.live.com",excludeSelectors:[".jHAG3.XG5Jd",".OZZZK",".lDdSm"]},{id:"producthunt",matches:"www.producthunt.com",excludeMatches:"https://www.producthunt.com/stories/*",selectors:["h2","div[class^='styles_htmlText__']","[class^='styles_tagline']","a[href^='/discussions/'].fontWeight-600","button[class^='styles_textButton'] > div > span","h5 + p","div[data-test=product-item-name] + div",".noOfLines-1,.noOfLines-2,.noOfLines-3",".fontWeight-600","[class*='styles_dropdown']","[class*='styles_aboutText']"],globalStyles:{"h5 + p":"height:unset;",".noOfLines-1,.noOfLines-2,.noOfLines-3":"-webkit-line-clamp:unset;"},"excludeTags.remove":["PRE"]},{id:"codeforces",matches:"https://codeforces.com/*","stayOriginalTags.add":["[class^='MathJax']"]},{id:"discord",matches:"https://discord.com/channels/*",isTranslateTitle:!1,selectors:["li[id^=chat-messages] div[id^=message-content]","div[class^=headerText]","section[aria-label='Search Results'] div[id^=message-content]"],extraBlockSelectors:["[class^='embedFieldValue']","li[class^='card'] div[class^='message']","[data-list-item-id^='forum-channel-list'] div[class^='headerText']"],globalStyles:{"div[class^=headerText]":"max-height: unset;","div[class^=message]":"max-height: unset;","div[class^=text]":"max-height: unset;","h3[data-text-variant='heading-lg/semibold']":"-webkit-line-clamp: none;"},detectParagraphLanguage:!0,wrapperPrefix:"
",wrapperSuffix:"",paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"telegram",matches:["web.telegram.org/z/*","web.telegram.org/a/*"],isTranslateTitle:!1,selectors:[".text-content",".message",".reply-markup-button-text",".bot-commands-list-element-description"],"extraBlockSelectors.add":[".message.spoilers-container em",".message.spoilers-container strong"],excludeSelectors:[".time",".peer-title",".document-wrapper",".message.spoilers-container custom-emoji-element"],detectParagraphLanguage:!0},{id:"telegramK",matches:["web.telegram.org/k/*","web.telegram.org/k/"],selectors:[".message",".reply-markup-button-text",".bot-commands-list-element-description"],"extraBlockSelectors.add":[".message.spoilers-container em",".message.spoilers-container strong"],excludeSelectors:[".time",".peer-title",".document-wrapper",".message.spoilers-container custom-emoji-element"],detectParagraphLanguage:!0},{id:"githubGist",matches:"gist.github.com",selectors:[".markdown-body",".readme"],detectParagraphLanguage:!0},{id:"lobste",matches:"lobste.rs",excludeMatches:["https://lobste.rs/about","https://lobste.rs/chat"],selectors:[".u-repost-of",".comment_text",".story_text"]},{id:"slack",matches:"*.slack.com",selectors:[".p-rich_text_block",".p-message_pane__foreword",".c-alert__message","[data-qa=message_attachment_text]"],additionalStayOriginalSelectors:["[data-qa=emoji]"],detectParagraphLanguage:!0},{id:"artstationArtwork",matches:"www.artstation.com/artwork/*",excludeSelectors:".project-description a",selectors:[".project-description","div.project-comment-text"],detectParagraphLanguage:!0},{id:"artstationLearning",matches:"www.artstation.com/learning/courses/*",additionalSelectors:["footer.learning-course-description.ng-star-inserted > span"],excludeSelectors:[".learning-card-meta",".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/subtitles/.*\\.(vtt|webvtt)$",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"},videoSelector:"video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:[".vjs-text-track-display {display: none;}",".captions-text: {margin-bottom: 10%;}"]}}},{id:"artstationBlog",matches:["https://www.artstation.com/blogs","https://www.artstation.com/blogs/*"],detectParagraphLanguage:!0,additionalSelectors:[".comment-item-body"],atomicBlockSelectors:[".author-headline",".author-location"],excludeSelectors:["blog-card-thumbnail","blog-card-header",".blog-card-author",".blog-card-meta",".blog-view-header",".blog-grid-title",".post-meta-header"]},{id:"figmaCommunity",matches:"www.figma.com/community/*",normalizeBody:"div.ql-editor[contenteditable='false']",excludeSelectors:["div[class*='metadataRight']","div[class*='commentMetaAndOptions']"],globalStyles:{"div[class*='mini_cardBottomRowSizing']":"height: 3em;"},additionalSelectors:["div[class*='mini_cardBottomRow_Metadata']"],stayOriginalSelectors:["[data-tooltip='tooltip-user-info']"]},{id:"googleIndex",matches:["https://www.google.com/","https://www.google.com.hk/"],excludeSelectors:["#gb","#SIvCob"],inputTutorialsText:"\u8BD5\u8BD5\u8F93\u5165\u4E2D\u6587\u540E\u5FEB\u901F\u8FDE\u51FB 3 \u6B21\u7A7A\u683C\u952E\u7FFB\u8BD1\uFF08\u4EC5\u63D0\u793A\u4E00\u6B21\uFF09",inputTutorialsSelectors:["textarea#APjFqb"],"inputConfig.add":{tutorialsText:"\u8BD5\u8BD5\u8F93\u5165\u4E2D\u6587\u540E\u5FEB\u901F\u8FDE\u51FB 3 \u6B21\u7A7A\u683C\u952E\u7FFB\u8BD1\uFF08\u4EC5\u63D0\u793A\u4E00\u6B21\uFF09",tutorialsSelectors:["textarea#APjFqb"]}},{id:"googleSearch",matches:"www.google.*/search*",blockMinTextCount:32,blockMinWordCount:3,wrapperSuffix:"",detectParagraphLanguage:!0,excludeSelectors:["a h3 + div","div#sfooter","a[role=presentation] > div > div:first-child",".b5ZQcf",".CEMjEf",".MgUUmf.NUnG9d","#result-stats","[role=navigation]","div.sCuL3","div.eFM0qc.BCF2pd","div.WZ8Tjf","div.adDDi","#headerSection","#rateChatDiv","[id=bres]",".title-D5Lgyj","[data-attrid='VisualDigestVideoResult']",".search-enhance-WDIEkP h4",".SPZz6b h2",".CtCigf",".VLkRKc",".EbH0bb",".Wr0c6d",".jleFbf","#searchform",".yg51vc",".CbAZb"],extraBlockSelectors:[".MUFPAc"],"additionalExcludeSelectors.add":["[jscontroller='UsftYd']"],globalStyles:{".V82bz":"-webkit-line-clamp: unset;max-height: unset;margin-bottom:30px",".pe7FNb":"-webkit-line-clamp: unset;",".promotion-3PDMAb":"display: none;",".uAKcGb":"-webkit-line-clamp: unset;max-height: unset;margin-bottom:30px","div[data-content-feature='1'] > div":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:2']":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:3']":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:4']":"-webkit-line-clamp: unset;max-height: unset;",".Pw4Ldf.RsCEN":"height:unset;",".related-question-pair":"overflow:auto;"},ignoreZhCNandZhTW:!0,isTranslateTitle:!1,searchEnhancementConfig:[{id:"google",urlMatch:"https://www\\.google\\..+/search",style:{source:"font-size:12px; margin-bottom: 6px;",enTitle:"margin-top:6px;font-size:14px;",searchTitle:"margin-top:6px;position:relative;padding-right:24px;",more:"color:#1a0dab;margin-top:8px;",enTitleClassName:"immersive-translate-search-enhancement-en-title"},keyword:{value:"[0]$1",matches:[{source:"url",matchRegex:"q=(.+?)&"}]},showCount:5}]},{id:"lowendtalk",matches:"lowendtalk.com",selectors:["[role=heading]","h1",".userContent"]},{id:"linkedinJobs",matches:"www.linkedin.com/jobs/*",selectors:["#job-details > span",".decorated-job-posting__details"]},{id:"linkedinFeed",matches:"https://linkedin.com/feed/*",selectors:["h1",".feed-shared-update-v2__description-wrapper"]},{id:"indiehackers",matches:"www.indiehackers.com",selectors:[".content","h1","h3.story__title",".feed-item__title-link",".article-body",".interview-body"]},{id:"libreddit",matches:"libreddit.de",selectors:["h2.post_title",".comment_body > .md"]},{id:"notionSite",matches:["notion.site","*.notion.site"],normalizeBody:"body",selectors:["div[data-block-id]"]},{id:"notion_so",matches:["www.notion.so"],injectedCss:["[aria-label='Templates'] font br {display:none;}"]},{id:"newyorker",matches:"www.newyorker.com",additionalSelectors:["h1","[data-testid=SummaryItemHed]"],excludeSelectors:["[data-testid=PersistentTop]","[data-testid=StackedNavigationHeader]"],urlChangeDelay:2e3},{id:"startme",matches:"start.me",selectors:[".rss-article__title",".rss-articles-list__article-link",".rss-showcase__title",".rss-showcase__text"]},{id:"scmp",matches:"www.scmp.com",additionalSelectors:[".info__subHeadline",".section-content h2"],globalStyles:{".topic__article-list":"height: unset;",".adverisers__adveriser":"height: unset;",".advertiser__content":"height: unset;",".content-title__link":"display:unset;overflow:unset;-webkit-line-clamp:unset;",".title__text":"max-height:unset; -webkit-line-clamp:unset;",".news-list-item__news-title":"max-height:unset; -webkit-line-clamp:unset;","a[class*='link'] > .link__headline":"max-height:unset; -webkit-line-clamp:unset;"},"bodyRule.add":{bodySelector:"[data-qa='ArticleList-Item']",articleSelector:"[data-qa='GenericArticle-Content']",xpathRule:["datatype:p"]}},{id:"lesswrong",matches:"www.lesswrong.com",extraBlockSelectors:["span.commentOnSelection"]},{id:"mastodon",matches:["mastodon.social","mastodon.online","kolektiva.social","indieweb.social","mastodon.world","infosec.exchange"],isTranslateTitle:!1,selectorMatches:["div#mastodon"],selectors:["div.status__content__text",".about__section__body",".content",".form-container",".account__header__extra"],globalAttributes:{"[class='notranslate app-holder']":{class:"app-holder"}},detectLanguage:!0},{id:"cnbc",matches:"www.cnbc.com",urlChangeDelay:1e3,globalStyles:{"div.Card-titleContainer > div":"-webkit-line-clamp: unset;max-height: unset;"},"excludeSelectors.add":["#GlobalNavigation","#GlobalFooter",".LiveBlogHeader-timestampAndShareBarContainer",".LiveBlogHeader-liveUpdatesPill"]},{id:"dailyDev",matches:"app.daily.dev",selectors:["h1",".typo-body","article h3","[class^=markdown_markdown]"],globalStyles:{".line-clamp-3":"-webkit-line-clamp: unset"}},{id:"pornhub",matches:["*.pornhub.com","pornhub.com"],excludeMatches:["*.pornhub.com/insights/*","pornhub.com/insights/*"],extraBlockSelectors:[".trendingNow",".searchItem",".tagcloud > a"],detectParagraphLanguage:!0,wrapperPrefix:"
",wrapperSuffix:` `,globalStyles:{"span.title":"height:unset; max-height:unset;",".detailedInfo":"max-height:unset;",".pcVideoListItem":"max-height:unset;",".wrap":"height:unset;",".entry-header":"height:unset;",".entry-title > a":"height:unset;-webkit-line-clamp:unset;"}},{id:"yourporn",matches:"https://www.youporn.com/*",extraBlockSelectors:[".button"],globalStyles:{".video-box":"max-height:unset;",".video-box-title":"white-space:unset;"}},{id:"modelhub",matches:"https://www.modelhub.com/*",globalStyles:{".videoTitle":"height:unset;",a:"height:unset;"}},{id:"xvideos",matches:"https://www.xvideos.com/*",globalStyles:{".title":"-webkit-line-clamp:unset;max-height:unset;",".mozaique":"display:flex; flex-wrap:wrap;"},excludeSelectors:[".video-hd-mark"]},{id:"missav",matches:"https://missav.com/*",globalStyles:{".truncate":"white-space:unset;",".overflow-y-hidden":"max-height:unset;overflow-y:unset;"},"subtitleRule.add":{type:"av",avSerial:{type:"url",regexStr:".+/([a-z0-9-]+)$"},videoSelector:".plyr__video-wrapper video",attachRule:{appendSelector:".plyr--video",injectedGlobalCSS:""},quickButtonRule:{appendSelector:".plyr__controls",insertBeforeSelector:'[data-plyr="captions"]'}}},{id:"javbus",matches:"https://www.javbus.com/*",globalStyles:{".photo-info":"height:unset;"},excludeSelectors:[".item-tag","date"]},{id:"spankbang",matches:"https://spankbang.com/*",globalStyles:{".video-item > a":"white-space:unset;"},excludeSelectors:[".stats",".thumb"],extraBlockSelectors:[".searches > a",".tag > a",".extra > a",".positions > li"]},{id:"javdb",matches:"https://javdb*.com/*",globalStyles:{".video-title":"white-space:unset;"},excludeSelectors:[".video-number",".score",".has-addons"]},{id:"jable",matches:"https://jable.tv/*",globalStyles:{".title":"white-space:unset;max-height:unset;",".img-box > a":"position:relative;"}},{id:"netflav.player",matches:["https://netflavns1.com","https://embedrise.com"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"av",avSerial:{type:"url",regexStr:"code=([a-z0-9-]+)"},videoSelector:"#vplayer video",attachRule:{appendSelector:"#vplayer"},quickButtonRule:{appendSelector:"#vplayer .jw-button-container",insertBeforeSelector:"#vplayer .jw-button-container .jw-icon-cc"}}},{id:"netflav",matches:["https://netflav*.com/*"],globalStyles:{".grid_title":"max-height:unset;"},extraBlockSelectors:[".genre_filter_item","button"],"subtitleRule.add":{type:"av",avSerial:{type:"selector",selector:".videodetail_2_field_values",serialAttachIframe:"#iframe-block"}}},{id:"czechvideo",matches:"https://czechvideo.co/*",globalStyles:{".short-story":"height:unset;",".short-title":"height:unset;"},globalAttributes:{header:{translate:"unset;"}}},{id:"weibo",matches:["weibo.com","*.weibo.*"],selectors:["div[class^='detail_wbtext']",".weibo-text"],"stayOriginalSelectors.add":[".expand"]},{id:"medium",matches:["medium.com","*.medium.com"],selectorMatches:["meta[property='al:ios:url'][content^='medium://']"],urlChangeDelay:20,"additionalExcludeSelectors.remove":["i.fa","i[class^=fa-]",".navmenu-container",".google-symbols"],selectors:["h1","h2","h3","article section","[aria-hidden='false'] pre","article p",".postMetaInline","a .u-fontSize24"],excludeSelectors:["[aria-label='Post Preview Reading Time']",".al.b.bl.ag.bp",".al.b.bl.ag.ai",".hx.hy.hz.ia.ib.ab",".qb.ab",".ai.bn.n.mj",".speechify-ignore"],globalStyles:{"h2,h3":"-webkit-line-clamp: unset;max-height:unset;","article p":"-webkit-line-clamp: unset;max-height:unset;"},injectedCss:[".u-lineClamp4,.u-lineClamp3,.u-lineClamp2 {-webkit-line-clamp:unset!important;max-height:unset!important;}"]},{id:"nitter",selectorMatches:["meta[property='og:site_name'][content='Nitter']"],selectors:[".tweet-content",".quote-text"]},{id:"economist",matches:"www.economist.com",extraInlineSelectors:["span[data-caps='initial']"],excludeSelectors:["footer.ds-footer"],injectedCss:["a::before {position:relative!important;}"]},{id:"healthline",matches:"www.healthline.com",excludeSelectors:[".icon-hl-trusted-source-after"]},{id:"ebay",matches:"www.ebay.com",excludeSelectors:["headers","[itemprop=offers]",".dne-itemtile-original-price"],paragraphMinTextCount:4,paragraphMinWordCount:2,globalStyles:{"[itemprop=name]":"-webkit-line-clamp: unset;max-height: unset;",".merch-item-title":"-webkit-line-clamp: unset;max-height: unset;"}},{id:"skinstore",matches:"www.skinstore.com",excludeSelectors:[".responsiveFlyoutMenu_levelOneLink"],paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"tripadvisor",matches:"www.tripadvisor.com",paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"primevideo",matches:["www.primevideo.com","https://*.amazon.co.*/*video*","https://*.amazon.com/*video*"],"excludeSelectors.add":["#dv-web-player"],"mutationExcludeSelectors.add":["#dv-web-player *"],"subtitleRule.add":{type:"ebutt",hookType:"xhr",subtitleUrlRegExp:"\\.ttml2$",loadingContainerSelector:"#dv-web-player"}},{id:"amazon",matches:"www.amazon.com",paragraphMinTextCount:4,paragraphMinWordCount:2,extraBlockSelectors:[".a-size-small.a-link-normal.page-banner-link.a-nowrap"],globalStyles:{".a-carousel-viewport":"height:unset;","[class*='clamp']":"max-height: unset;-webkit-line-clamp: unset;","[data-rows]":"max-height: unset;-webkit-line-clamp: unset;","[data-a-expander-name='review_text_read_more']":" max-height: unset;"},excludeSelectors:["#navFooter","#navbar-main",".s-price-instructions-style","[class*='-star ']","[data-hook='acr-average-stars-rating-text']",".a-color-price"]},{id:"visualstudioMarketplace",matches:"marketplace.visualstudio.com",additionalExcludeSelectors:[".core-info-second-row",".core-info-third-row",".meta-data-list",".item-title",".breadcrumb",".itemDetails-right",".ux-user-name",".ux-updated-date",".ux-item-second-row-wrapper",".stats-and-offer",".header-container"],atomicBlockSelectors:[".core-info-cell > div.name"],globalStyles:{".item-details-control-root.ux-item-shortdesc":"height: unset; overflow: visible; max-height:unset;"}},{id:"bloomberg",matches:"www.bloomberg.com",urlChangeDelay:2e3,excludeSelectors:[".ticker-bar","nav","[aria-label=Banner]","aside","[data-component=ticker-bar]","footer.bb-global-footer",".vjs-text-track-display"],"bodyRule.add":{bodySelector:"main article",articleSelector:".body-content"},"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"webvtt$",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"baiduXueshu",matches:"xueshu.baidu.com",globalStyles:{".abstract_wr":"height: unset; overflow: visible; max-height:unset;"}},{id:"sciencedirect",matches:"www.sciencedirect.com",urlChangeDelay:2e3,stayOriginalSelectors:["span.display","span.math"],extraBlockSelectors:["span.captions","span[id^=cap]"],globalAttributes:{"#abspara0010 br":{style:"display:none;"}}},{id:"thehighestofthemountains",matches:"www.thehighestofthemountains.com",extraBlockSelectors:"div"},{id:"telegraph1",matches:"te.legra.ph",normalizeBody:"div.ql-editor[contenteditable='false']",urlChangeDelay:500},{id:"telegraph2",matches:["telegra.ph"],normalizeBody:"div.ql-editor[contenteditable='false']",wrapperPrefix:` `},{id:"annasArchive",matches:["*.annas-archive.org","annas-archive.org"],selectors:[],globalStyles:{"div[id^='link-index-']":"height: unset; max-height: unset;","main div[class*='h-[125]']":"height:auto"},normalizeBody:"body",extraBlockSelectors:["a.custom-a"]},{id:"explainshell",matches:["explainshell.com"],selectors:["[class='help-box']"]},{id:"apnews",matches:["apnews.com"],urlChangeDelay:2e3},{id:"googlePlay",matches:"play.google.com",excludeSelectors:[".vlGucd",".ubGTjb"],globalStyles:{".Epkrse":"-webkit-line-clamp:unset;"}},{id:"tumblr",matches:["www.tumblr.com"],selectors:["article h1","article > header + div","[data-testid=notes-root] p","div.k31gt","p","article ul","article h2","article h3","article h4","article h5","article h6","article blockquote","article ol"],excludeSelectors:["div.fAAi8","div.wvu3V"],preWhitespaceDetectedTags:["DIV","SPAN","P"]},{id:"tinytask",matches:"https://www.tinytask.net",globalStyles:{"table > tbody > tr > td > center > table > tbody > tr > td > ul > li":"height: 100%"}},{id:"foxnews",matches:"www.foxnews.com",shadowRootSelectors:["[data-spot-im-module-default-area='conversation'] > div"],"excludeTags.add":["TEXT","IMG","SUB","SUP","CODE","TT","ASIDE"],excludeSelectors:[".site-footer",".components-MessageDetails-index__message-details-wrapper","div[class^=SlideDown__container]",".components-MessageActions-index__messageActionsWrapper","span[data-openweb-allow-amp]","div.spcv_typing-users"]},{id:"afreecatv",matches:"www.afreecatv.com",globalStyles:{"a.title":"max-height:unset;-webkit-line-clamp:unset;"}},{id:"opennet",matches:"opennet.ru","excludeTags.add":["LABEL","IMG","SUB","SUP","CODE","TT"],"excludeTags.remove":["LINK","G","MATH","TTS-SENTENCE","AIO-CODE"]},{id:"construct",matches:["www.construct.net"],excludeMatches:["preview.construct.net","editor.construct.net"],additionalSelectors:["aside","div.manualContent"],atomicBlockSelectors:[],stayOriginalSelectors:["a.usernameReference"],additionalInlineSelectors:["a.forumLink"],additionalExcludeSelectors:["div.topNav","div.usernameLink","ul.authorDetails","ul.tagViewer","ul.breadCrumbNav","ul.subForumForums","ul.postTools","li.comment ul.controls","div.forumTopNavWrap","div.downloadWrap","div.articleLeftMenu","div.usernameTextWrap","div.favouriteWrap","div.bannerWrapper","div.viewAddonRightMenu","div.extendedMenu.addonsSubMenu","#BottomLinks.bottomLinks","div#LeftSide.leftSide","div#BottomWrap.bottomWrap","div.courseListWrap div.overview","div.conversationControls","div.contentWrapper h1","div.conversationControls","td.location a#LocationLink","#TopLevelComments .topBar","#TopLevelComments .controls",".tagViewWrap",".changeCount",".otherStats",".FilterMenu",".mobileTopicStats",".forumControlsWrapper",".forumsBottomNavWrap",".breadCrumbNav",".favouriteWrap",".usernameLink",".followWrapper",".blogPostStats",".manualContent dl dt"],globalStyles:{"td.location a#LocationLink":"padding-top: 4px;","div.articleMain .tutCourseWrap":"align-items: flex-start;"}},{id:"getpocket",matches:"getpocket.com",selectors:["h2","div.excerpt p","article","h1"],globalStyles:{"h2.title":"max-height:unset;-webkit-line-clamp:unset;","div.excerpt p":"max-height:unset;-webkit-line-clamp:unset;"}},{id:"fandom",matches:"*.fandom.com",urlChangeDelay:800,normalizeBody:"#mw-content-text",globalStyles:{"#mw-content-text > div > div:nth-child(1)":"height:100%;"},additionalExcludeSelectors:["header.fandom-community-header","div.ph-registration-buttons"]},{id:"huggingface",matches:"huggingface.co",globalStyles:{".line-clamp-2":"-webkit-line-clamp:unset;max-height:unset;"}},{id:"statista",matches:"www.statista.com",globalStyles:{".itemContent__text":"height:unset;max-height:unset;",".itemContent__subline":"height:unset;max-height:unset;"}},{id:"epubReader",matches:"epub-reader.online",globalStyles:{"span.slide-contents-item-label":"overflow:visible;max-height:unset;white-space:normal;"},atomicBlockSelectors:["div.slide-contents-item"]},{id:"you",matches:"https://you.com/search",globalStyles:{h3:"max-height:unset;-webkit-line-clamp:unset;",".caKYaC":"max-height:unset;-webkit-line-clamp:unset;",".dDwDsu":"max-height:unset;-webkit-line-clamp:unset;"},excludeSelectors:["div.hpIWZO"]},{id:"auth0Openai",matches:"auth0.openai.com",excludeSelectors:["form","header > h1"]},{id:"chatOpenai",matches:"chat.openai.com",excludeSelectors:["div.absolute.bottom-0.left-0.w-full","h1","div#headlessui-portal-root","nav","ul[aria-multiselectable]",".markdown *","div[class='flex flex-col items-start']","div[class='flex items-center justify-center gap-1 border-b border-black/10 bg-gray-50 p-3 text-gray-500 dark:border-gray-900/50 dark:bg-gray-700 dark:text-gray-300']"],"excludeTags.remove":["BUTTON"],isTranslateTitle:!1,wrapperPrefix:"",globalStyles:{"[class*='line-clamp']":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},aiRule:{streamingSelector:".result-streaming.markdown",messageWrapperSelector:".markdown",streamingChange:!0,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"poe",matches:["https://poe.com/*"],excludeSelectors:[".Markdown_markdownContainer__Tz3HQ *",".MarkdownLink_linkifiedLink__KxC9G","menu","aside"],aiRule:{streamingSelector:".ChatStopMessageButton_stopButton__LWNj6",messageWrapperSelector:".Markdown_markdownContainer__Tz3HQ",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"glasp",matches:"glasp.co",excludeSelectors:[".home_overview_list_content_wrapper"]},{id:"developerChrome",matches:"developer.chrome.com",excludeSelectors:["web-tabs","ul.code-sections--summary"]},{id:"android",matches:["developer.android.google.cn","developer.android.com"],observeUrlChange:!0,additionalSelectors:["aside","google-codelab-step"]},{id:"ft",matches:"www.ft.com",excludeSelectors:["header","[aria-labelledby=cookie-banner-aria-label]","footer","[aria-label='Primary navigation']"]},{id:"microsoft",matches:"https://apps.microsoft.com/store/detail/*",additionalSelectors:["pre"],globalStyles:{".line-clamp":"-webkit-line-clamp:unset;max-height:unset;"},isTransformPreTagNewLine:!0},{id:"gitlab",matches:"gitlab.com",excludeSelectors:[".tree-content-holder","nav",".home-panel-metadata","div[data-testid=project_topic_list]",".commit"]},{id:"tiktok",matches:"https://www.tiktok.com/*/video/*",selectors:["[data-e2e^=comment-level]","[data-e2e=browse-video-desc] > span"]},{id:"rfcEditor",matches:["www.rfc-editor.org","docs.haproxy.org"],isTransformPreTagNewLine:!0,"excludeTags.add":["IMG","SUB","SUP","CODE","TT","ASIDE","FOOTER"],"excludeTags.remove":["LINK","G","PRE","TTS-SENTENCE","AIO-CODE"]},{id:"steamcommunity",matches:"steamcommunity.com",globalStyles:{".forum_topic,.rightbox_list_option":"height:auto;",".forum_topic_name":"white-space:normal;line-height: 1.25rem; padding: 6px 20px 0 0;",".forum_topic_op":"clear: left; padding: 0 0 6px 2rem;"},excludeSelectors:[".forum_paging",".forum_topic_reply_count",".forum_topic_lastpost",".forum_topic_award_count",".discussion_search_pagingcontrols"]},{id:"steampoweredApp",matches:"store.steampowered.com/app/*",selectors:[".game_description_snippet",".game_area_description","#earlyAccessHeader","[id^='ReviewContent'] .content",".ModalOverlayContent"],excludeSelectors:["#global_actions","#store_controls","#foryou_tab","[class*=persona]","[class*=game_title_area]","a.btn_medium",".persona_name",".hours.ellipsis",".checkcol",".postedDate",".dev_row .summary",".already_in_library",".game_header_image_ctn .grid_content",".ds_flag.ds_wishlist_flag",".early_access_review.tooltip",".communitylink_achievement_images",".user_reviews_summary_row.summary",".review_award_ctn",".add_to_wishlist_area",".next_in_queue_content",".glance_tags.popular_tags",".game_purchase_action",".vote_button_ctn","#VoteUpDownBtnCtn","#footer","#ViewAllReviewssummary"],atomicBlockSelectors:[".game_area_sys_req_leftCol",".game_area_sys_req_rightCol"],extraInlineSelectors:[".pulldown"],additionalSelectors:[".game_page_autocollapse_ctn iframe"],globalStyles:{".game_description_snippet":"max-height:unset; overflow: scroll;",".game_purchase_area_friends_want":"height: auto; padding-bottom: 6px;",".div.early_access_banner":"height: 84px",".franchise_notice > *":"height: 84px"},detectParagraphLanguage:!0},{id:"steampowered",matches:"store.steampowered.com",detectParagraphLanguage:!0},{id:"nature",matches:"https://www.nature.com/articles/*",excludeSelectors:[".c-header",".c-recommendations-header",".c-recommendations-list-container",".c-article-references__links",".c-article-identifiers",".c-article-author-list",".c-article-metrics-bar__wrapper",".c-article__pill-button","#author-information-content","#article-info-section"]},{id:"webofscience",matches:"https://www.webofscience.com/*",globalStyles:{".abstract":"height:auto !important;",".show-more-lines":"height:unset !important;"},excludeSelectors:[".summary-left-panel",".authors","app-full-record-keywords mark"],mutationObserverContainerSelectors:["[data-ta='summary-record-title-link']","#FullRTa-fullRecordtitle-0"],extraBlockSelectors:["app-summary-authors + div","app-full-record-keywords span span"],observeUrlChange:!0,urlChangeDelay:600,mutationChangeDelay:600},{id:"appleinsider",matches:["appleinsider.com"],excludeSelectors:["#topic-nav"]},{id:"jetbrains",matches:"https://www.jetbrains.com/help/*",extraBlockSelectors:["[data-test=prompt]"]},{id:"crates",matches:["https://crates.io/search*"],selectors:["div[class^=_description-box] div[class^=_description]"]},{id:"theverge",matches:"www.theverge.com",shadowRootSelectors:["div#coral_thread > div"]},{id:"simp",matches:"https://beta.simp.red/trans*",mainFrameSelector:".simpread-read-root"},{id:"lookintobitcoin",matches:"https://www.lookintobitcoin.com/charts/*",excludeSelectors:["svg"]},{id:"openaiAccount",matches:"https://platform.openai.com/account/api-keys*",urlChangeDelay:1500},{id:"openaiDocs",matches:"https://platform.openai.com/docs*","excludeSelectors.add":[".pheader"]},{id:"pkgStd",matches:"https://pkg.go.dev/std",selectors:["td.UnitDirectories-desktopSynopsis"]},{id:"pkg",matches:"https://pkg.go.dev/*",selectors:["div.UnitDetails p"]},{id:"explainpaper",matches:["https://www.explainpaper.com/reader*"],isTranslateTitle:!1,selectors:[".leading-relaxed",".chat-messages p",".text-sm"]},{id:"colab",matches:"https://colab.research.google.com/*",excludeSelectors:["code","view-line"]},{id:"gatesnotes",matches:"www.gatesnotes.com",minZIndex:-1},{id:"kakao",matches:"page.kakao.com",shadowRootSelectors:["div[style^='visibility: visible'"]},{id:"coinmarketcap",matches:"coinmarketcap.com",extraBlockSelectors:["div[class='sc-3502f6cd-0 JxHqg']"]},{id:"wandb",matches:"wandb.ai",additionalSelectors:[".report-page-top"],additionalStayOriginalSelectors:["span[data-slate-inline=true]"],extraInlineSelectors:[]},{id:"paulgraham",matches:"paulgraham.com",additionalSelectors:["font[face=verdana]"],extraBlockSelectors:"font[face=verdana]"},{id:"zendesk",matches:"https://*.zendesk.com/agent/*",selectors:["[data-test-id*=subject]",".zd-comment",".title"]},{id:"migadu",matches:"webmail.migadu.com",selectors:[".bodyText"]},{id:"thehackernews",matches:"thehackernews.com",excludeSelectors:["span#blog-pager-older-link","span.h-datetime"],additionalSelectors:[".pop-title"]},{id:"brown",matches:"cs.brown.edu",excludeSelectors:[".SCodeFlow"]},{id:"tass",matches:"tass.ru",globalStyles:{"#__next":"font-size: 19px;line-height:28px;"}},{id:"chatGoogle",matches:"chat.google.com",selectors:["[jsname=bgckF]"]},{id:"fiverr",matches:"https://www.fiverr.com/inbox/*",selectors:[".message-body"]},{id:"fiverr-main",matches:"*.fiverr.com",globalStyles:{"h3 > a":"-webkit-line-clamp:unset;overflow:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",h5:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;",".YLycza2.u9KHmsf":"height:unset;max-height:unset;",".lt2ar2q.EhHcMiw":"height:unset; max-height: unset;"},excludeSelectors:[".popular"]},{id:"jira",matches:["jira.*.com/browse/*","jira.*.com/projects/*"],selectors:["[id=descriptionmodule]","[id=summary-val]","div.action-body","td.stsummary"]},{id:"ahaIo",matches:["*.aha.io"],selectors:["[tabindex='0']","div.user-content","div.comments__body","span.name"]},{id:"thehill",matches:"thehill.com",injectedCss:[".most-popular-item { max-height: unset !important; }",".most-popular-item__link { -webkit-line-clamp: unset !important; }"],excludeSelectors:["div.featured-cards__byline","div.list-item__meta",".tags__item","div.extended-scroll__header",".submitted-by",".site-header--has-alert-banner",".homepage__container__opinion__item__byline",".homepage__container__header",".archive__item__meta"]},{id:"ubuntu",matches:"manpages.ubuntu.com",selectors:["pre"],atomicBlockTags:["pre"]},{id:"spiedigitallibrary",matches:"www.spiedigitallibrary.org","excludeTags.add":["IMG","SUB","SUP","CODE","TT","ASIDE","FOOTER"],"excludeTags.remove":["LINK"]},{id:"promptingguide",matches:"www.promptingguide.ai",selectors:["article","li"]},{id:"ground",matches:"ground.news",globalStyles:{".line-clamp-3":"-webkit-line-clamp: unset !important;"}},{id:"ietf",matches:"*.ietf.org/doc/html/*",additionalSelectors:["pre"],isTransformPreTagNewLine:!0,preWhitespaceDetectedTags:["DIV","SPAN","PRE"]},{id:"newsminimalist",matches:"https://www.newsminimalist.com/",extraBlockSelectors:[".inline-flex"],"excludeTags.remove":["BUTTON"]},{id:"yandexIndex",matches:"https://yandex.com/",selectors:[".tabs__item-text"]},{id:"yandexSearch",matches:"https://yandex.com/search/*",excludeSelectors:[".KeyValue-Row",".EntityFeedbackFooter",".Organic-Subtitle",".SerpFooter-Content",".serp-user",".Pager"],globalStyles:{".ExtendedText-Toggle":"white-space:normal;"}},{id:"yandex",matches:"https://yandex.com/video/*",selectors:[".serp-item__title",".serp-item__text",".Keypoints-ItemTitle",".bes-epmjnzm-idtktyj",".OrganicTitle-LinkText","h1.VideoTitle"],globalStyles:{".serp-item__title":"-webkit-line-clamp: unset;max-height:unset;",".serp-item__text":"-webkit-line-clamp: unset;max-height:unset;",".OrganicTitle-LinkText":"-webkit-line-clamp: unset;max-height:unset;","h1.VideoTitle":"-webkit-line-clamp: unset;max-height:unset;",".link .serp-item__keypoints":"bottom:2px;",".OrganicTitle":"max-height:unset;"}},{id:"perplexity",matches:"https://www.perplexity.ai",globalStyles:{".line-clamp-1":"-webkit-line-clamp: unset !important;",".line-clamp-2":"-webkit-line-clamp: unset !important;"},"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3},additionalStayOriginalSelectors:["a.citation"],selectors:[".prose",".my-md",".line-clamp-2",".line-clamp-1"]},{id:"allmyfaves",matches:"https://allmyfaves.com/",selectors:["p"],paragraphMinTextCount:2,paragraphMinWordCount:1},{id:"man7",matches:"man7.org",isTransformPreTagNewLine:!0,globalStyles:{pre:"white-space: inherit;"}},{id:"kadaza",matches:"https://www.kadaza.com/",selectors:[".header span.title",".custom-content-footer"],containerMinTextCount:2,containerMinWordCount:1,paragraphMinTextCount:2,paragraphMinWordCount:1},{id:"urlChangeDelay",matches:["https://babelnovel.com/books/*","https://www.webnovel.com/book/*","https://platform.openai.com/docs/*","docs.oracle.com","docs-cortex.paloaltonetworks.com","forum.m5stack.com/topic/*","community.m5stack.com/topic/*"],urlChangeDelay:0,_comment:"\u89E3\u51B3url\u53D8\u5316\u91CD\u590D\u7FFB\u8BD1\u95EE\u9898"},{id:"genuine",matches:"blog.genuine.com",excludeSelectors:["div.enlighter"]},{id:"chinadaily",matches:"www.chinadaily.com.cn",injectedCss:["a { height: unset !important; }","li { height: unset !important; }","div { height: unset !important; }",".immersive-translate-target-inner {color:black;}"],excludeSelectors:[".topNav",".topNav2_art > span",".topNav_art2 > .dropdown",".dibu-three",".topBar"]},{id:"braynzarsoft",matches:"www.braynzarsoft.net",selectors:["div#view-question-desc"]},{globalAttributes:{"#stimulus":{translate:"off",class:"stimulus"},"#stem":{translate:"off",class:"stem"}},id:"lawhub",matches:"https://lawhub.lsac.org/question/*"},{id:"yuque",matches:"https://www.yuque.com/*",excludeSelectors:[".lark-virtual-tree"]},{id:"bearblog",matches:"https://bearblog.dev/discover/*",excludeTags:["small"]},{id:"researchgate",matches:"www.researchgate.net",excludeSelectors:[".nova-legacy-v-publication-item__meta-data",".nova-legacy-v-publication-item__person-list",".js-authors-list"]},{id:"theatlantic",matches:["www.theatlantic.com","https://mashable.com/*"],"excludeSelectors.add":["footer:last-of-type","nav","header div.subtitle-2.w-full"],initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},"nav:last-of-type":{translate:"no"},nav:{translate:"no"}}},{id:"youtrackJetbrains",matches:"youtrack.jetbrains.com/articles/*",selectors:["[role=presentation]","[data-test=article-content]"],excludeSelectors:[".toolbar__ee8"]},{id:"dw",matches:"www.dw.com",initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},"nav:last-of-type":{translate:"no"},nav:{translate:"no"}},excludeSelectors:[".focus-menu-shown"]},{id:"sentry",matches:"docs.sentry.io",initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},".navbar":{translate:"no"}},"extraInlineSelectors.add":[".term-wrapper","span.description"]},{id:"openai-blog",matches:"https://openai.com/blog/*","stayOriginalTags.remove":["CODE"]},{id:"urlComment",selectorMatches:["meta[name='generator'][content^='Discourse']"],urlChangeDelay:0,_comment:"\u89E3\u51B3url\u53D8\u5316\u4F46\u662F\u9875\u9762\u4E0D\u53D8\u7684\u95EE\u9898"},{id:"feedly",matches:"feedly.com",globalStyles:{".TitleOnlyLayout":"height:unset !important;",".EntrySummary--u4":"-webkit-line-clamp: unset;max-height:unset;",".EntrySummary--u5":"-webkit-line-clamp: unset;max-height:unset;"},excludeSelectors:[".Leftnav"]},{id:"bardGoogle",matches:"bard.google.com",excludeSelectors:["mat-sidenav","div.capabilities-disclaimer","#cdk-overlay-6","message-actions button",".mdc-button__label .ng-star-inserted",".mdc-list-item__primary-text"],isTranslateTitle:!1,"excludeTags.add":["mat-tooltip-component"],"excludeTags.remove":["BUTTON"]},{id:"whatsapp",matches:"web.whatsapp.com",selectors:[".copyable-text > span"],wrapperPrefix:` -`,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};function Q3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Jt(){let t=await oe.storage.local.get(Fo);if(t[Fo]){let e=t[Fo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Ht(i),i}else return{}}async function Ht(t){await oe.storage.local.set({[Fo]:t})}async function kl(t){await oe.storage.local.set({[Yr]:t})}async function Z3(){let t=await oe.storage.local.get(Yr),n={...await fp(),...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let r=t[Yr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Xt(){let t=await oe.storage.local.get(Yr),e={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let E=t[Yr];if(E&&E.buildinConfigUpdatedAt){let P=new Date(E.buildinConfigUpdatedAt),O=new Date(e.buildinConfigUpdatedAt);P>O&&(e=E)}}let n=await zw(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let E=await oe.commands.getAll();for(let P of E)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await fp(),o=Q3(),s=await qr(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Jt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let E=await Rw();p.interfaceLanguage=E}let g=p.interfaceLanguage==="en",m=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!g&&!m&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,C=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(C=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(C.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,B=await At("installedAt",""),S=Number(await Nr("translage_page_daily",0)),y=Number(await At(Kn,0)),_;y>0&&(Date.now()-y0&&(Date.now()-S0){let E=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(E.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],O=Array.isArray(P)?P:[P],H=Array.from(new Set(O.concat(E.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let F=Object.assign(i,e);Ya({rule:e,valueIsArray:E=>Array.isArray(i[E]),getMergedValue:E=>i[E],onMergedResult:(E,P)=>{E!="generalRule"&&(F[E]=P)}});let L=Zt(r),U={};p.translationServices&&p.translationServices.deepl&&(U=p.translationServices.deepl);let N={};p.translationServices&&p.translationServices.openai&&(N=p.translationServices.openai),!L&&U.authKey&&!U.provider?(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="custom"):U&&U.provider||(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="pro"),!L&&N.APIKEY&&!N.provider?(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="custom"):N&&N.provider||(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="pro");let q=Object.keys(F),A=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let E of q){let P=E;if(P==="generalRule")typeof p[P]=="object"&&(F[P]=Tl(i[P],p[P]));else if(P==="translationServices")Nw(p,F);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&A.includes(P))p[P]&&(F[P]=Object.assign(F[P],p[P])),P==="shortcuts"&&(ye()||it()?F[P]={...F[P],...a}:F[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let O=F.rules||[],H={};for(let W of O)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?k3(e.generalRule,H[W.id],W):W);F[P]=[...j,...F[P]]}if(we.PROD==="0"&&we.DEV_RULES){let O=JSON.parse(we.DEV_RULES);F[P]=[...O,...F[P]]}}else p[P]!==void 0&&(F[P]=p[P])}return F.donateUrl=e.donateUrl,F.minVersion=e.minVersion,F.feedbackUrl=e.feedbackUrl,F.rawUserConfig=s,F}async function qr(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function hs(t){await oe.storage.sync.set({userConfig:t})}async function bs(t,e){await oe.storage.local.set({[t]:e})}async function Pl(t){return(await oe.storage.local.get(t))[t]||""}var Rw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){z.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>Ot[r]);return n||"en"},fp=async()=>{let t={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:lr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Ow(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function zw(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return lr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ya({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ya({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}var Uw=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function xn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(xn(t,i))return!1;if(xn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!xn(t,o)),c;function p(){return n&&n.display?!!Uw.includes(n.display):xn(t,r)}}var Kt=xn;function Qa(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function Ts(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function Tr(t,e=!1){let n=Io;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Za(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return Tr(n,e)}function Ui(t,e){return ua(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function hp(t){let{rule:e}=t,n=qw(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function qw(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function ys(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",bt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),ut(r,Uh,e.toString());let a=hp(t);return r.append(rt.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function qi(t,e){return t.querySelector(`[${Ld}='${e}']`)}function J3(){document.querySelectorAll(`[${Ld}]`).forEach(e=>{e.remove()})}function X3(){document.querySelectorAll(`.${bt}-error`).forEach(e=>{e.remove()})}function e1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{Hi(n)&&e.push(n)}),e}function bp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},g=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),m=new RegExp(a.replace("{word}",g.map(f=>f.k).join("|")),"g");l=l.replace(m,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let g=new RegExp(p,"gi");l=l.replace(g,(m,f)=>{let T=c++;return e[`${T}`]=O3(f),o.length>2?m.replace(f,`<${o[2]}${T}>`):m.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){z.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function vs(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||d1(s)||s1(s)||c1(s)||u1(s)||l1(s)||Hw(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ll(i,n,r)}function jr(t){return t.nodeType===Node.ELEMENT_NODE}function t1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Tp(){return await At("fakeUserId","")}async function jw(){return await At("installedAt","")}async function n1(t){let n=Me().INSTALL_FROM,r=Sn(),a=await jw(),i=await Tp(),o=await Xt(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Zt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function r1(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await vp(t,e);r(a)})()},[t,e,r]),n}async function vp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!it()&&ye()||et().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>wt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>wt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}var _l=!1,Ww=ye();function p1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function Kw(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&g1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(da(i,Eu)){if(a===!0)return!0;continue}if(Ss(i.nodeName,e.inlineTags))return!0;if(!Sp(i,e))return!1}}return!0}function xp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(Ss(t.nodeName,n)||Sp(t,e)){if(da(t,Hh)||Ss(t.nodeName,["BR"]))return!1;if(da(t,Eu))return!0;if(Sp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return Kw(t,e)}else return da(t,Eu);return!1}function g1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&da(t,jh,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&da(t,Bh))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||Ss(t.nodeName,i))}function Ll(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!f1(r)&&r.length>=n}function m1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(f1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function f1(t){for(let e=0;e127)return!1;return!0}function s1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function u1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function l1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function c1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function d1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function da(t,e,n=!1){return Ep(t,e,"1",n)}function Ep(t,e,n,r=!1){return _l&&!r?t[Tn]?!!(t[Tn]&&t[Tn][e]===n):!1:t.dataset[e]===n}function Wi(t){return(t.innerText||t.textContent||"").trim()}function Cp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Fl(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function ut(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(_l&&!r?(t[Tn]||(t[Tn]={}),t[Tn][e]||(t[Tn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Ml(t,e,n=!1){if(_l&&!n){if(!t[Tn]||!t[Tn][e])return;delete t[Tn][e]}else delete t.dataset[e]}function Ki(t,e,n=!1){return _l&&!n?!t[Tn]||!t[Tn][e]?void 0:t[Tn][e]:t.dataset[e]}function Sp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!Ss(t.nodeName,n)}function Ae(){if(!globalThis||!globalThis.location)return"https://example.com";if(!Je())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function An(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){z.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else z.warn("injectCSS failed, rootDocument does not have head node",t)}function Hi(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(Ww){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function Ss(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function h1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function b1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||g1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return z.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function T1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();var v1="auto",Bl="auto",y1="auto";function S1(t){v1=t}function Nn(t){Bl=t}function yt(){return Bl!=="auto"?Bl:y1!=="auto"?y1:v1}function Il(){return Bl}function E1(t,e){let n=Object.assign({},t),r=new Map;(n.langOverrides||[]).forEach(i=>{r.set(i.id,i)});for(let i of r.keys()){let[o,s]=i.split("2");if(["auto",e.sourceLanguage].includes(o)&&["auto",e.targetLanguage].includes(s)){let u=r.get(i);if(!u)continue;if(u.extends){let l=r.get(u.extends);l&&(n=Object.assign({},n,l))}n=Object.assign({},n,u)}}return n}async function Un(t){let{url:e,config:n,state:r}=t,a=new URL(e),i="auto",{translationParagraphLanguagePattern:o,translationService:s,translationServices:u,translationTheme:l,translationThemePatterns:c,translationUrlPattern:p,targetLanguage:g,sourceLanguageUrlPattern:m,immediateTranslationPattern:f}=n,T=g||"zh-CN",b=Gi(e,o),h=Gi(e,f),C=s,D=Object.keys(u);for(let ae of D){let ie=u[ae];if(Gi(e,ie)){C=ae;break}}let M=l,B=Object.keys(c);for(let ae of B){let ie=c[ae];if(ie&&Gi(e,ie)){M=ae;break}}let S=Gi(e,p),y=x1(e,p);y||(y=wt(e,Xh)),y||(y=wt(e,n.blockUrls));let _=x1(e,n.inputTranslationUrlPattern);_||(_=wt(e,n.inputTranslationBlockUrls));let k=wt(e,n.mutationBlockUrls),v=Object.keys(m),I={};for(let ae of v){let ie=m[ae];if(ie&&ie.matches)for(let Ee of ie.matches)I[Ee]=ae}let F=Object.keys(I),L=ip(e,F);L&&(i=I[L]??"auto",I[L]&&I[L]!=="auto"&&Nn(I[L]));let U=a.hostname,N=await nr(U),q=a.pathname+a.search+a.hash,A=await nr(q),E=`https://${N}.com/${A}`,P=await Jt(),O=await Z3(),H=n.translationStartMode;H==="dynamic"&&h&&(H="immediate");let j=C;n.inputTranslationService&&n.inputTranslationService!=="inherit"&&(j=n.inputTranslationService);let W=C;n.mouseHoverTranslationService&&n.mouseHoverTranslationService!=="inherit"&&(W=n.mouseHoverTranslationService);let V=C;n.subtitleTranslateService&&n.subtitleTranslateService!=="inherit"&&(V=n.subtitleTranslateService);let se=await Mt.get(Ft,null),X=!1;se&&(X=Zt(se));let Z={targetLanguage:T,config:n,translationService:C,inputTranslationService:j,mouseHoverTranslationService:W,subtitleTranslateService:V,isTranslateUrl:S,sourceLanguage:i,mainFrame:document.body,isTranslateExcludeUrl:y,isMutationTranslationExcludeUrl:k,isInputTranslationExcludeUrl:_,rule:n.generalRule,url:e,encryptedUrl:E,state:r?Object.assign({translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},r):{translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},localConfig:P};se&&(Z.user=se,X?Z.isPro=!0:Z.isPro=!1),Z.state.translationArea==="body"&&(Z.config.generalRule.excludeTags=Z.config.generalRule.excludeTags.filter(ae=>!Z.config.generalRule.bodyTranslateTags.includes(ae)),Z.config.generalRule.additionalExcludeSelectors=Z.config.generalRule.additionalExcludeSelectors.filter(ae=>ae!==".btn"));let ue=n.translationServices[Z.translationService]||{};ue.immediateTranslationTextCount!==void 0&&Gw(ue.immediateTranslationTextCount)&&ue.immediateTranslationTextCount>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCount),Z.translationService==="deepl"&&(ue&&ue.authKey&&ue.authKey.startsWith("immersive_")||ue&&ue.provider==="pro"&&Z.user?.token)&&ue.immediateTranslationTextCountForImmersiveDeepl!==void 0&&ue.immediateTranslationTextCountForImmersiveDeepl>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCountForImmersiveDeepl),ue&&ue.translationDebounce&&typeof ue.translationDebounce=="number"&&(Z.state.translationDebounce=ue.translationDebounce);let ge=O.immediateTranslationTextCount;n.immediateTranslationTextCount!==ge&&(Z.state.immediateTranslationTextCount=n.immediateTranslationTextCount);let te=n.rules,Y;globalThis.PDFViewerApplication?Y=te.find(ae=>ae.pageType=="pdfReader"):globalThis.immersiveTranslateEbookViewer?Y=te.find(ae=>ae.pageType=="ebookReader"):globalThis.immersiveTranslateEbookBuilder?Y=te.find(ae=>ae.pageType=="ebookBuilder"):Y=te.find(ae=>Gi(e,ae)),Z.state.translationArea==="body"&&(Z.rule.paragraphMinTextCount=1,Z.rule.paragraphMinWordCount=1),Y&&Y.pageType==="ebookBuilder"&&(Z.state.translationStartMode="immediate");let be=n.generalRule;if(Y&&(Z.rule=Tl(be,Y)),Z.rule.selectors.length>0&&(Z.rule.paragraphMinTextCount=2,Z.rule.paragraphMinWordCount=1),Z.state.translationArea==="body"&&Z.rule.excludeTags&&(Z.rule.excludeTags=Z.rule.excludeTags.filter(ae=>!Z.rule.bodyTranslateTags.includes(ae)&&!Z.rule.forceTranslateTags.includes(ae))),Z.rule.mainFrameSelector){let ae=document.querySelector(Z.rule.mainFrameSelector);ae&&(Z.mainFrame=ae)}return Z}function Gi(t,e){if(!e)return!1;let{matches:n,excludeMatches:r,selectorMatches:a,excludeSelectorMatches:i}=e;return r&&r.length>0&&wt(t,r)?!1:n&&n.length>0&&wt(t,n)?!0:i&&i.length>0&&Fl(i)?!1:!!(a&&a.length>0&&Fl(a))}function x1(t,e){if(!e)return!1;let{excludeMatches:n,excludeSelectorMatches:r}=e;return!!(n&&n.length>0&&wt(t,n)||r&&r.length>0&&Fl(r))}function Gw(t){return typeof t=="number"}d();d();d();d();d();d();d();var Nq=w1(2),C1=w1(3);function w1(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var Vw=/\s+/g,$w=/[\t\n\v\f\r ]+/g;function D1(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?Yw:Qw;return String(t).replace(e.style==="html"?$w:Vw,e.trim?Zw(n):n)}function Yw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function Qw(){return" "}function Zw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var A1={}.hasOwnProperty;function Jw(t){return t==null?"":D1(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function Xw(t){return C1(" "+Jw(t)+" ")}function eD(t){let e=Xw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function sD(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function uD(t,e,n,r){e=cD(e,n,r);let a=[],i;if(e)for(i in e)Rl.call(e,i)&&a.push([i,lD(t,e[i])]);return a.length===0?Dp():a.sort(dD)}function lD(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of SD){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?I1(t)?"zh-TW":"zh-CN":e:"auto"}var O1=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Ap=new Map(O1),xD=new Map(O1.map(([t,e])=>[e,t]));function z1(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>xD.get(s));!e&&e!==0&&(e=25);let a=zl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Ap.keys()]},o=L1(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&g<.95)break;return Ap.get(p)}}let[s,u]=o[0],l=Ap.get(s);if(l&&u>.9)return l}}catch(r){z.error(r)}return"auto"}d();d();function pa(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function ED(t,e){return t<>>32-e}function Ul(t,e,n,r,a,i){return pa(ED(pa(pa(e,t),pa(r,i)),a),n)}function en(t,e,n,r,a,i,o){return Ul(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return Ul(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return Ul(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return Ul(n^(e|~r),t,e,a,i,o)}function Nl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function kp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Nl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Nl(a.concat(kp(e)),512+e.length*8),N1(Nl(i.concat(o),512+128))}function U1(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function Pp(t){return unescape(encodeURIComponent(t))}function q1(t){return CD(Pp(t))}function DD(t){return U1(q1(t))}function j1(t,e){return wD(Pp(t),Pp(e))}function AD(t,e){return U1(j1(t,e))}function kn(t,e,n){return e?n?j1(e,t):AD(e,t):n?q1(t):DD(t)}var Vi=[];async function ql(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function H1(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await LD(e,t)}async function W1(t){let e=kn(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await PD(n,e)}async function PD(t,e){let n=await ql(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function LD(t,e){let n=await ql(t);return(await FD()).includes(t)||await _D(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function _D(t){let e="cache_list",n=await ql(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Vi.push(t)},a.onerror=i=>{n.close()}}async function FD(){if(Vi&&Vi.length>0)return Vi;let t=await ql(Q+"-cacheList","cache_list");return Vi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Vi}d();d();var Lp="Original";function $e(){return Lp}function pn(t){Lp=t,K1(Lp)}d();function Hr(t){return t?.id?.endsWith("pdfWebPage")||!1}function ga(t){try{if(!t||!Hr(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Ye={},ma=async function(t,e){let{method:n,data:r}=t,a=await Ye.updateGlobalContext(),i=Date.now();if(z.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Ze(Kn,i);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Ze(Kn,i);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Ze(Kn,i);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Ze(Kn,i);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Ze(Kn,i);else if(n==="translatePage")await Ye.translatePage(a,r),Ze(Kn,i);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(vu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(_o,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Je()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Je())return JSON.stringify(a)}};function G1(t){Object.assign(Ye,t)}function V1(t){Object.assign(Ye,t)}function $1(t){Object.assign(Ye,t)}var MD=function(t,e){let{method:n,data:r}=t;if(z.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return $e();if(n==="getCurrentPageLanguage"){let a=yt();return Ye.detectCurrentPageLanguage().catch(i=>{z.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return Nn(r),yt();if(n==="getContextString"){let a=Ye.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return ga(a?.rule)}}},jl,Hl;function Y1(){let t=Wl();Je()||BD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Wl(){return jl||(jl=new br("content_script",!1).getConnection("main",ma),jl)}function BD(){return Hl||(Hl=new br("content_script",!1).getConnection("main_sync",MD,{sync:!0}),Hl)}d();var _p=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Kl="https://transmart.qq.com/api/imt",Wr=class t{static langMapReverse=new Map(_p.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await de({url:Kl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function ID(t,e){return Math.floor(Math.random()*(e-t+1))+t}var RD=30,Fp="RATE_LIMITER_TICKS",$i=class t{static strictTicks={};static clearStrictTicks(){bs(Fp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await Pl(Fp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){z.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await bs(Fp,JSON.stringify(this.strictTicks))}catch(a){z.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=ID(4,RD);await Dr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function vt(t){return await Wl().sendMessage("background:main",t)}function de(t){return mu()?wl({method:"request",data:t}):ye()||gu()?(t.fetchPolyfill=globalThis.GM_fetch,Ur(t)):vt({method:"fetch",data:t})}function qn(){return ye()?Xt():vt({method:"getConfig"})}function gn(t){return ye()?hs(t):vt({method:"setUserConfig",data:t})}function mn(){return ye()?qr():vt({method:"getUserConfig"})}function Es(){return ye()?Jt():vt({method:"getLocalConfig"})}function Gl(t){return ye()?Ht(t):vt({method:"setLocalConfig",data:t})}function Q1(t){return ye()?kl(t):vt({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=zl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||it()){if(t.translateService&&!Du.includes(t.translateService))return Promise.resolve("auto");let r=z1(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await vt({method:"detectLanguage",data:t});return Promise.resolve(e)}function Z1(){return vt({method:"detectTabLanguage"})}async function Vl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||it()){let n=t.substring(0,200);e=await Wr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function K1(t){let e=new CustomEvent(Oa,{detail:t});if(document.dispatchEvent(e),ye())return;Wl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function J1(t){return ye()?W1(t):vt({method:"queryParagraphCache",data:t})}async function X1(t){if(ye()){await H1(t);return}return vt({method:"setParagraphCache",data:t})}async function e2(){if(ye())return Promise.resolve();await vt({method:"mockRequest"})}function Yi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):vt({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function $l(t=""){return ye()||it()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function Mp(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Yl(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):vt({method:"openAboutPage"})}function Qi(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):vt({method:"openInTab",data:t})}function t2(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):vt({method:"openEbookViewerPage"})}function n2(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):vt({method:"openEbookBuilderPage"})}function r2(t){it()}function Zi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):vt({method:"openPdfViewerPage",data:{url:e}})}function a2(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):vt({method:"openSubtitleBuilderPage"})}function Ji(t){return ye()?Promise.resolve():vt({method:"setBadge",data:{text:t}})}function i2(){return ye()?(z.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):vt({method:"autoSyncLatestConfig"})}function Ql(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function o2(t,e){return ye()?$i.getDelay(t,e):vt({method:"getDelay",data:{key:t,options:e}})}function s2(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return!!(r&&e.hostname===r)}function Zl(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return r&&e.hostname===r?!0:!(Bp(t)||e.protocol!=="http:"&&e.protocol!=="https:"&&e.protocol!=="file:"&&e.protocol!=="data:")}function Bp(t){try{return new URL(t)?.pathname.toLowerCase().endsWith(".pdf")}catch{return!1}}d();d();d();d();var Ip={get:(t,e,n)=>{let r=e===void 0?t:{[t]:e};return oe.storage[n].get(r)},set:(t,e,n)=>oe.storage[n].set({[t]:e})};function Jl(t,e,n){let[r]=re(()=>typeof e=="function"?e():e),[a]=re(n),[i,o]=re(r),[s,u]=re(!1),[l,c]=re("");Ce(()=>{Ip.get(t,r,a).then(g=>{g[t]&&o(g[t]),u(!0),c("")}).catch(g=>{u(!1),c(g)})},[t,r,a]);let p=Ve(g=>{let m=typeof g=="function"?g(i):g;z.debug("new settings",m),Ip.set(t,m,a).then(()=>{o(m),u(!0),c("")}).catch(f=>{o(m),u(!1),c(f)})},[a,t,i]);return[i,p,s,l]}d();function Rp(t,e,n){let r=[];return function(){let[i,o,s,u]=Jl(t,e,n),l=Ve(c=>{for(let p of r)p(c)},[]);return Ce(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function u2(t,e){return Rp(t,e,"sync")}var OD="userConfig",zD=null,ND=u2(OD,zD);function rr(t){let[e,n,r,a]=ND(),i=Ve(o=>{let s=typeof o=="function"?o(e):o;s&&(s.updatedAt=new Date().toISOString()),n(s),t&&t(s)},[e]);return[e,i,r,a,n]}d();d();d();var Xi={},UD={root:"",lang:"en",fallbackLang:"en"};function Op(t,e){let n=Object.assign({},UD,t);Xi=e||Xi;let[r,a]=re(n.lang),[i,o]=re(Xi),[s,u]=re(!1),l=p=>{if(i.hasOwnProperty(p))return;u(!1);let g=H3(n.root||"",p);n.getUrl&&(g=n.getUrl(n.root||"",p),fetch(g).then(m=>m.json()).then(m=>{Xi[p]=m,o({...Xi}),u(!0)}).catch(m=>{o({...Xi}),u(!0)}))};return Ce(()=>{l(n.fallbackLang||"en"),l(r)},[r]),{lang:r,setLang:a,t:(p,g)=>{if(!i.hasOwnProperty(r))return p;let m=gs(i,r,p);return m===p&&r!==n.fallbackLang&&(m=gs(i,n.fallbackLang,p)),pp(m,g)},isReady:s}}d();d();var qD=0;function w(t,e,n,r,a){var i,o,s={};for(o in e)o=="ref"?i=e[o]:s[o]=e[o];var u={type:t,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--qD,__source:a,__self:r};if(typeof t=="function"&&(i=t.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Fe.vnode&&Fe.vnode(u),u}var Np=hi(null),zp={root:"assets",lang:"en",fallbackLang:"en"},eo=t=>{let{t:e,setLang:n,lang:r,isReady:a}=Op({root:t.root||zp.root,lang:t.lang||zp.lang,fallbackLang:t.fallbackLang||zp.fallbackLang,getUrl:t.getUrl},t.translations);return w(Np.Provider,{value:{t:e,setLang:n,lang:r,isReady:a},children:t.children})};function xe(){return du(Np)}d();var jD=function(t,e){let{method:n,data:r}=t;z.debug(`popup received message: ${n}`,r||" ");let a;e.active&&(a=e.id,globalThis.document.dispatchEvent(new CustomEvent(Mo,{detail:{tabId:a,payload:t}})))},Xl;function l2(){Cs()}function Cs(){return Xl||(Xl=new br("popup",!1).getConnection("main_sync",jD),Xl)}d();d();function c2(t,e=2e3){return n=>{let r,a=0;return i=>{++a==t&&(n(i),a=0),clearTimeout(r),r=setTimeout(()=>a=0,e)}}}d();var ec="DROP_DOWN_DEFAULT_VALUE";function Up(t){let{showArrow:e,onSelected:n,className:r,menus:a,maxWidth:i,style:o}=t;r=r||"",e=e??!0,i=i||80;let s=qe(null);return w("select",{ref:s,autoComplete:"off",class:`min-select ${e?"":"min-select-no-arrow"} ${r||""}`,value:ec,style:{maxWidth:`${i}px`,...o},onChange:u=>{u.preventDefault();let l=u.target.value;if(s.current&&l!==ec){s.current.value=ec,s.current?.dispatchEvent(new Event("change"));let c=a.find(p=>p.value===l);c&&n(c)}},children:[{value:ec,label:t.label}].concat(a).map((u,l)=>w("option",{value:u.value,children:u.label},"option-"+l))})}d();d();function to(t,e){return t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})>=0}var HD=({date:t})=>{let{t:e}=xe(),[n,r]=re(!1);return Ce(()=>{setTimeout(()=>{r(!0)},5e3)},[]),n?null:w("p",{class:"text-sm",children:[e("Successfully synchronized with the latest official rules:")," ",new Date(t).toLocaleString()]})},WD=({minVersion:t})=>{let{t:e}=xe();return w("p",{class:"text-sm",children:e("localVersionIsTooOld",{minVersion:t})})},KD=()=>{let{t}=xe();return w("p",{class:"text-sm",dangerouslySetInnerHTML:{__html:t("badUserscriptBrowser",{1:"https://immersivetranslate.com/docs/installation/"})}})},GD=({message:t,handleSyncing:e,date:n})=>{let{t:r}=xe();return w("p",{class:"text-sm",children:[r("failToSyncRules")," ",w("a",{onClick:e,children:r("retry")}),w("br",{}),r("failedReason"),"\uFF1A",t,w("br",{}),r("currentRuleVersion"),"\uFF1A",n]})};function qp(t){let{isShowError:e,request:n}=t,[r,a]=re(null),{t:i}=xe(),[o,s]=re(null),[u,l]=re(null),[c,p]=re(""),[g,m]=re(!1),[f,T]=re(!1),[b,h]=re(!1),[C,D]=re(null),[M,B]=re(null),S=Sn(),y=async()=>{p("");let _=o;if(o===null)try{let k=await n({url:Bo});k?(s(k),_=k,m(!0)):(p(i("unknownError")),l(null))}catch(k){l(null),p(k.message);return}_!==null?(t.setStorageBuildinConfig(_),l(!1),a(_.buildinConfigUpdatedAt)):(p(i("canNotFetchRemoteRule")),l(null))};return Ce(()=>{Xt().then(_=>{let k=_.buildinConfigUpdatedAt;D(_);let v=new Date(k);if(a(k),S==="0.0.0"){h(!0);return}n({url:Bo}).then(I=>{let F=I,L=F.minVersion,U=S;s(F);let N=F.latestVersion;if(N&&(to(U,N)?B(!0):B(!1)),to(U,L)){let q=F.buildinConfigUpdatedAt;new Date(q)>v?(l(!0),y()):l(!1)}else T(!0),l(null)}).catch(I=>{l(null),p(I.message)})})},[]),Ce(()=>{Xt().then(_=>{D(_)})},[r]),C?w("div",{class:"text-sm mt-2",style:{maxWidth:218},children:b?w(KD,{}):c?e===!1?null:w(GD,{handleSyncing:y,message:c,date:r||""}):f?e===!1?null:w(WD,{minVersion:o.minVersion}):u===null||u===!0?null:g?w(HD,{date:r}):null}):null}d();function VD(){return navigator.userAgent.indexOf("Mac")!==-1}var d2={Alt:"\u2325"};function tc(t=""){return VD()?Object.keys(d2).reduce((e,n)=>e.replace(n,d2[n]),t):t}d();d();var nc='',p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0ZGQzczNiIgZD0iTTMgN2gxN3YxMEgzeiIvPjxwYXRoIGZpbGw9InVybCgjYSkiIGQ9Ik02Ljg5NyA5LjI0MmMuNDE1IDAgLjcyLjExMS45MjguMzQ3LjIwNy4yMzUuMzE4LjUyNy4zMTguODczcy0uMTEuNjIzLS4zMTguODQ1Yy0uMjA4LjIyMi0uNTI3LjMzMy0uOTI4LjMzM2gtMS4zM1Y5LjI0MmgxLjMzWm05Ljg0NiAxLjc4OGMuMzg4IDAgLjY2NS4xNTIuODQ1LjQ1Ny4xNTIuMjY0LjIzNS41ODIuMjYzLjk4NHYuMzE5YzAgLjQ5OS0uMDgzLjg4Ny0uMjYzIDEuMTkyLS4xOC4zMDQtLjQ1Ny40NTctLjgzLjQ1Ny0uMzg5IDAtLjY2Ni0uMTUzLS44NDYtLjQ0NC0uMTUyLS4yNjMtLjIzNS0uNTk1LS4yNjMtMS4wMTF2LS4yOTFjMC0uNDg1LjA4My0uODczLjI2My0xLjE3OC4xOC0uMzA1LjQ0My0uNDg1LjgzMS0uNDg1Wm0tMy40MDctMS4xMzZhMS4xNyAxLjE3IDAgMCAwLS43MDYuMjM1IDEuNDgyIDEuNDgyIDAgMCAwLS40MTUuNWwtLjA4My4xNjUtLjA3LS44MDNoLTEuMzU3djUuNDMyaDEuNDU0di0zLjY1OWEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiA4LjEySDQuMTE0djcuMzE3aDEuNDY4VjEyLjc5aDEuMzNjLjg0NCAwIDEuNDk1LS4yMDggMS45OC0uNjM4LjQ4NS0uNDMuNzItLjk4My43Mi0xLjY5cy0uMjM1LTEuMjYxLS43Mi0xLjY5Yy0uNDQzLS4zODktMS4wMzktLjYxLTEuNzczLS42MzhsLS4yMjEtLjAxNFptOS44NDcgMS43NzRjLS44MDMgMC0xLjQyNi4yNjMtMS44ODMuNzc2LS40MTYuNDctLjYzNyAxLjA2Ny0uNjc5IDEuNzczdi4zMzNjMCAuODE4LjIyMiAxLjQ4My42NzkgMS45OTUuNDU3LjUxMyAxLjA4Ljc3NiAxLjg4My43NzYuODA0IDAgMS40MjctLjI2MyAxLjg4NC0uNzc2LjQxNS0uNDcuNjM3LTEuMDUzLjY3OC0xLjc3M3YtLjMzM2MwLS44MTctLjIyMS0xLjQ4Mi0uNjc4LTEuOTk1LS40NTctLjUxMy0xLjA4LS43NzYtMS44ODQtLjc3NlpNMTguMDAzIDZhNiA2IDAgMCAxIDAgMTJIMFY5LjQyM0EzLjQyIDMuNDIgMCAwIDEgMy40MiA2aDE0LjU4M1oiLz48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSI3LjUiIHgyPSIyMiIgeTE9IjE5IiB5Mj0iNiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyMjIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM2OTY5NjkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=",g2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIxMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzk5OSIgZD0iTTYuODk3IDMuMjQyYy40MTUgMCAuNzIuMTExLjkyOC4zNDcuMjA3LjIzNS4zMTguNTI2LjMxOC44NzMgMCAuMzQ2LS4xMS42MjMtLjMxOC44NDUtLjIwOC4yMjItLjUyNy4zMzMtLjkyOC4zMzNoLTEuMzNWMy4yNDJoMS4zM1ptOS44NDYgMS43ODhjLjM4OCAwIC42NjUuMTUyLjg0NS40NTcuMTUyLjI2NC4yMzUuNTgyLjI2My45ODR2LjMxOWMwIC40OTktLjA4My44ODctLjI2MyAxLjE5Mi0uMTguMzA0LS40NTcuNDU3LS44My40NTctLjM4OSAwLS42NjYtLjE1My0uODQ2LS40NDQtLjE1Mi0uMjYzLS4yMzUtLjU5NS0uMjYzLTEuMDExdi0uMjkxYzAtLjQ4NS4wODMtLjg3My4yNjMtMS4xNzguMTgtLjMwNS40NDMtLjQ4NS44MzEtLjQ4NVptLTMuNDA3LTEuMTM2YTEuMTcgMS4xNyAwIDAgMC0uNzA2LjIzNSAxLjQ4MiAxLjQ4MiAwIDAgMC0uNDE1LjVsLS4wODMuMTY1LS4wNy0uODAzaC0xLjM1N3Y1LjQzMmgxLjQ1NFY1Ljc2NGEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiAyLjEySDQuMTE0djcuMzE3aDEuNDY4VjYuNzloMS4zM2MuODQ0IDAgMS40OTUtLjIwOCAxLjk4LS42MzguNDg1LS40My43Mi0uOTgzLjcyLTEuNjlzLS4yMzUtMS4yNjEtLjcyLTEuNjljLS40NDMtLjM4OS0xLjAzOS0uNjEtMS43NzMtLjYzOGwtLjIyMS0uMDE0Wm05Ljg0NyAxLjc3NGMtLjgwMyAwLTEuNDI2LjI2My0xLjg4My43NzYtLjQxNi40Ny0uNjM3IDEuMDY3LS42NzkgMS43NzN2LjMzM2MwIC44MTguMjIyIDEuNDgzLjY3OSAxLjk5NS40NTcuNTEzIDEuMDguNzc2IDEuODgzLjc3Ni44MDQgMCAxLjQyNy0uMjYzIDEuODg0LS43NzYuNDE1LS40Ny42MzctMS4wNTMuNjc4LTEuNzczdi0uMzMzYzAtLjgxNy0uMjIxLTEuNDgzLS42NzgtMS45OTUtLjQ1Ny0uNTEzLTEuMDgtLjc3Ni0xLjg4NC0uNzc2Wk0xOC4wMDMgMGE2IDYgMCAwIDEgMCAxMkgwVjMuNDIzQTMuNDIgMy40MiAwIDAgMSAzLjQyIDBoMTQuNTgzWiIvPjwvc3ZnPg==";var m2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAn1BMVEUAAADt7vHu7vLu7vLv7+/n5+fFxcXu7vHv7/PHx8eamprt7fLt7fHn5+vGxsbS09Surq6fn5+ZmZmZmZnGxsbGxsbt7/K/v7/Hx8ft7vHGxsaZmZn09vnk5eeqqquenp7p6u3X2NnLy8vU1dbr7O67u7uvr6/o6evh4uPR0dLCwsLAwMDZ2ty9vb6kpaWhoaHe3+HPz8+zs7OkpKTc3d7Gt0R8AAAAGXRSTlMA779wIBDv338gv5+AgHDv7+/v36+gn3BgD0kJmgAAAS1JREFUKM9dkOmSgyAQhNFo7mTvYwYEBa9oorne/9l2hqJSbr4q+NHNdBcjAukyXgBE8SwRU5IYHmwm1iyCCdFMBJbwxDK8B2iKLGjl8VAC+JmEcqzRrmnP5yzrbm93SuOeDQCcpNToGaV8ISGmAfBGPce+qjrsjSxYSbkBGtt1tZGEueLpwsZW8A8snlj2jD0efRZVtxzw4Ia2BFgIch1qOaHCM4lsHHA0WpOpKyk7qX2WWLBhhhxU7grlKlV7I+LyAm+DUplS/sqv2HL5FiDDSio15CQOdHrrl5L6kpqEMOHwTlIiOKu0WIDy5Bfkn3+HJTYXRNdmWXtA1nmJfu1lgRNcQw2encV/2J0I7OdIXM1YIzH/FQ9WX4i1JF4RP1dBDNZ+/S7lx/onDcIfdi8x4pYpSxgAAAAASUVORK5CYII=",f2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAA51BMVEUAAABRT2tSUGpRT2tQUHBQUGjwtcxRT2tRUGtST2tSTmrvsMnvt89QUHDqTIpkXHhST2zQobmfdpPrTYrGVoHqS4nwtszvtMzvtc3vr89RT2vwtczASHb09vnIXYbt4OncqMDqTInGVoBbVnHqp8GqiKJlXHfz2+bsrsfkmrfIm7SggpvScZfKaY/q1uDtgKvRiKaNdY/MY4vy7fLy5Ozxydrxw9bhtcjnobzVlK/diam0j6jYfqHVeJyXfJWcd5TrXJOCb4l5aYNvYn3DUXzxzd3kwNDSorrth6/CjqnAeZnNdJaDb4nDaCDkAAAAGnRSTlMA73C/ICDv37+ff3AgEL+AgO/v7+/fr6BgELJb3PQAAAE/SURBVCjPXZHnUsMwEIRlOySkhw66k+24YScx6b0XOu//PJw0mozh+6Efu6ddzYlpqiWrwLlhmTmW5cLiZ4oZyzR4BsNkmhL/R0nPcx6FR6357ZbPuanyKefT62yjn37/cJwPbjeUJnuKNPeFuAaFjXhNgkUXONHDdR6CJIkh8HArlSo1UIUbx6sTEt4CZlfSaLBLOl2YeaixA2irLKrey4AzA4jpXQVG7hI6mCGBPonSaIF9StMUMe0hzrGjslhBGp7tDIUzfRPTnvhWhiHLQxjYQrwIoQ5nAXtZ3uD8AAkKYTsk0sAocNVSqqpkRaK+MYYNSTkms3wXXodCMZpAKD9FLzF6Bxg/ExMgXS+RluKHkGEZUYOi7sIf3DrTlPNAfOx2XSDyj+xM5QGg2yTIua+wLJVy7abZvKuVn7TwCyKmN+3PjJblAAAAAElFTkSuQmCC",h2="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9IkZyYW1lIj4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTguNzEwMjMgMTMuMzg3NkwxMy4yODkzIDguODA4NkwxNC4wOTc3IDguMDAwMjJMMTMuMjg5NyA3LjE5MjIyTDguNzEwMjMgMi42MTI3OUw3LjkwMjIzIDMuNDIwNzlMMTEuOTA5NSA3LjQyODc5SDEuOTA1NjZWOC41NzE2NUgxMS45MDk1TDcuOTAxODUgMTIuNTc5M0w4LjcxMDIzIDEzLjM4NzZaIiBmaWxsPSIjODM4MzgzIi8+CjwvZz4KPC9zdmc+Cg==";function b2({config:t,isLogin:e,isProUser:n}){let{t:r}=xe();return ml(t)?w("div",{}):w("div",{class:"flex items-center",children:[w("a",{class:"flex items-center text-decoration-none",target:"_blank",href:e?ku:r4,children:[w("img",{src:e?f2:m2}),w("span",{class:"text-xs ml-2 text-label",children:r(e?"loggedIn":"notLogin")})]}),w("a",{title:r(n?"popup.openProForPro":"popup.openPro"),target:"_blank",class:"ml-2",href:n?ku:a4,children:w("img",{src:n?p2:g2})})]})}d();d();var T2={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},y2={...Ot,"zh-CN":{...T2["zh-CN"],...Ot["zh-CN"]},"zh-TW":{...T2["zh-TW"],...Ot["zh-TW"]}},rc=y2;function no(t,e,n){return hr(y2,t,e,lr,n)}var fa=(t,e,n,r)=>{let a=Yh[t]||t,i=Qh[t],o=Zh[t],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[t]?s[t]:a;if(s[e]){let u=s[e];return r||t==="auto"||t==="placeholder"?u:`${u} (${a})`}else return a};d();d();d();d();d();function jp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(Vh),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${Fd}-theme-${t}`):a.push(`${_d}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(Fd):a.push(_d),a}function Hp(t){let e=["notranslate",wu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function v2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Za(n,!0),g="afterend",m=p[0],f=p[1],T=`${m}(\\d+)${f}`,b=new RegExp(T,"g"),h=rt.sanitize(u);o.length>0&&(h=h.replace(b,B=>{let S=h.indexOf(B),y=h[S-1]===" ",_=h[S+B.length]===" ",v=B.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),I=Number(v);if(isNaN(I))return B;let F=o[I];if(F&&F.type==="element"){let L=F.value.outerHTML;return y||(L=" "+L),_||(L=L+" "),L}else z.error("variable type not supported",F,B);return B}));let C=jp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&C.push(Gh);let D=Hp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${C.join(" ")}" ${ur}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${ur}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ur}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function ac(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";g&&(T=ca(Wp(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let C=Kp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",B=Ts(C+D+M),S=B[0]+h+B[1];if(C===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=Ts(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Kp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);g&&(b=ca(Wp(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",C=Ts(T+b+h),D=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(T===" ")D=D.trimStart();else{let M=Ts(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Kp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Wp(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}t.targetText=rt.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` +`,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};function Q3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Jt(){let t=await oe.storage.local.get(Fo);if(t[Fo]){let e=t[Fo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Ht(i),i}else return{}}async function Ht(t){await oe.storage.local.set({[Fo]:t})}async function kl(t){await oe.storage.local.set({[Yr]:t})}async function Z3(){let t=await oe.storage.local.get(Yr),n={...await fp(),...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let r=t[Yr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Xt(){let t=await oe.storage.local.get(Yr),e={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let E=t[Yr];if(E&&E.buildinConfigUpdatedAt){let P=new Date(E.buildinConfigUpdatedAt),O=new Date(e.buildinConfigUpdatedAt);P>O&&(e=E)}}let n=await zw(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let E=await oe.commands.getAll();for(let P of E)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await fp(),o=Q3(),s=await qr(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Jt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let E=await Rw();p.interfaceLanguage=E}let g=p.interfaceLanguage==="en",m=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!g&&!m&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,C=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(C=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(C.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,B=await At("installedAt",""),S=Number(await Nr("translage_page_daily",0)),y=Number(await At(Kn,0)),_;y>0&&(Date.now()-y0&&(Date.now()-S0){let E=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(E.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],O=Array.isArray(P)?P:[P],H=Array.from(new Set(O.concat(E.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let F=Object.assign(i,e);Ya({rule:e,valueIsArray:E=>Array.isArray(i[E]),getMergedValue:E=>i[E],onMergedResult:(E,P)=>{E!="generalRule"&&(F[E]=P)}});let L=Zt(r),U={};p.translationServices&&p.translationServices.deepl&&(U=p.translationServices.deepl);let N={};p.translationServices&&p.translationServices.openai&&(N=p.translationServices.openai),!L&&U.authKey&&!U.provider?(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="custom"):U&&U.provider||(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="pro"),!L&&N.APIKEY&&!N.provider?(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="custom"):N&&N.provider||(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="pro");let q=Object.keys(F),A=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let E of q){let P=E;if(P==="generalRule")typeof p[P]=="object"&&(F[P]=Tl(i[P],p[P]));else if(P==="translationServices")Nw(p,F);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&A.includes(P))p[P]&&(F[P]=Object.assign(F[P],p[P])),P==="shortcuts"&&(ye()||it()?F[P]={...F[P],...a}:F[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let O=F.rules||[],H={};for(let W of O)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?k3(e.generalRule,H[W.id],W):W);F[P]=[...j,...F[P]]}if(we.PROD==="0"&&we.DEV_RULES){let O=JSON.parse(we.DEV_RULES);F[P]=[...O,...F[P]]}}else p[P]!==void 0&&(F[P]=p[P])}return F.donateUrl=e.donateUrl,F.minVersion=e.minVersion,F.feedbackUrl=e.feedbackUrl,F.rawUserConfig=s,F}async function qr(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function hs(t){await oe.storage.sync.set({userConfig:t})}async function bs(t,e){await oe.storage.local.set({[t]:e})}async function Pl(t){return(await oe.storage.local.get(t))[t]||""}var Rw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){z.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>Ot[r]);return n||"en"},fp=async()=>{let t={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:lr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Ow(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function zw(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return lr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ya({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ya({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}var Uw=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function xn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(xn(t,i))return!1;if(xn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!xn(t,o)),c;function p(){return n&&n.display?!!Uw.includes(n.display):xn(t,r)}}var Kt=xn;function Qa(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function Ts(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function Tr(t,e=!1){let n=Io;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Za(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return Tr(n,e)}function Ui(t,e){return ua(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function hp(t){let{rule:e}=t,n=qw(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function qw(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function ys(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",bt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),ut(r,Uh,e.toString());let a=hp(t);return r.append(rt.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function qi(t,e){return t.querySelector(`[${Ld}='${e}']`)}function J3(){document.querySelectorAll(`[${Ld}]`).forEach(e=>{e.remove()})}function X3(){document.querySelectorAll(`.${bt}-error`).forEach(e=>{e.remove()})}function e1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{Hi(n)&&e.push(n)}),e}function bp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},g=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),m=new RegExp(a.replace("{word}",g.map(f=>f.k).join("|")),"g");l=l.replace(m,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let g=new RegExp(p,"gi");l=l.replace(g,(m,f)=>{let T=c++;return e[`${T}`]=O3(f),o.length>2?m.replace(f,`<${o[2]}${T}>`):m.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){z.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function vs(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||d1(s)||s1(s)||c1(s)||u1(s)||l1(s)||Hw(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ll(i,n,r)}function jr(t){return t.nodeType===Node.ELEMENT_NODE}function t1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Tp(){return await At("fakeUserId","")}async function jw(){return await At("installedAt","")}async function n1(t){let n=Me().INSTALL_FROM,r=Sn(),a=await jw(),i=await Tp(),o=await Xt(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Zt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function r1(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await vp(t,e);r(a)})()},[t,e,r]),n}async function vp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!it()&&ye()||et().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>wt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>wt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}var _l=!1,Ww=ye();function p1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function Kw(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&g1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(da(i,Eu)){if(a===!0)return!0;continue}if(Ss(i.nodeName,e.inlineTags))return!0;if(!Sp(i,e))return!1}}return!0}function xp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(Ss(t.nodeName,n)||Sp(t,e)){if(da(t,Hh)||Ss(t.nodeName,["BR"]))return!1;if(da(t,Eu))return!0;if(Sp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return Kw(t,e)}else return da(t,Eu);return!1}function g1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&da(t,jh,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&da(t,Bh))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||Ss(t.nodeName,i))}function Ll(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!f1(r)&&r.length>=n}function m1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(f1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function f1(t){for(let e=0;e127)return!1;return!0}function s1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function u1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function l1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function c1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function d1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function da(t,e,n=!1){return Ep(t,e,"1",n)}function Ep(t,e,n,r=!1){return _l&&!r?t[Tn]?!!(t[Tn]&&t[Tn][e]===n):!1:t.dataset[e]===n}function Wi(t){return(t.innerText||t.textContent||"").trim()}function Cp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Fl(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function ut(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(_l&&!r?(t[Tn]||(t[Tn]={}),t[Tn][e]||(t[Tn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Ml(t,e,n=!1){if(_l&&!n){if(!t[Tn]||!t[Tn][e])return;delete t[Tn][e]}else delete t.dataset[e]}function Ki(t,e,n=!1){return _l&&!n?!t[Tn]||!t[Tn][e]?void 0:t[Tn][e]:t.dataset[e]}function Sp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!Ss(t.nodeName,n)}function Ae(){if(!globalThis||!globalThis.location)return"https://example.com";if(!Je())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function An(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){z.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else z.warn("injectCSS failed, rootDocument does not have head node",t)}function Hi(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(Ww){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function Ss(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function h1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function b1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||g1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return z.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function T1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();var v1="auto",Bl="auto",y1="auto";function S1(t){v1=t}function Nn(t){Bl=t}function yt(){return Bl!=="auto"?Bl:y1!=="auto"?y1:v1}function Il(){return Bl}function E1(t,e){let n=Object.assign({},t),r=new Map;(n.langOverrides||[]).forEach(i=>{r.set(i.id,i)});for(let i of r.keys()){let[o,s]=i.split("2");if(["auto",e.sourceLanguage].includes(o)&&["auto",e.targetLanguage].includes(s)){let u=r.get(i);if(!u)continue;if(u.extends){let l=r.get(u.extends);l&&(n=Object.assign({},n,l))}n=Object.assign({},n,u)}}return n}async function Un(t){let{url:e,config:n,state:r}=t,a=new URL(e),i="auto",{translationParagraphLanguagePattern:o,translationService:s,translationServices:u,translationTheme:l,translationThemePatterns:c,translationUrlPattern:p,targetLanguage:g,sourceLanguageUrlPattern:m,immediateTranslationPattern:f}=n,T=g||"zh-CN",b=Gi(e,o),h=Gi(e,f),C=s,D=Object.keys(u);for(let ae of D){let ie=u[ae];if(Gi(e,ie)){C=ae;break}}let M=l,B=Object.keys(c);for(let ae of B){let ie=c[ae];if(ie&&Gi(e,ie)){M=ae;break}}let S=Gi(e,p),y=x1(e,p);y||(y=wt(e,Xh)),y||(y=wt(e,n.blockUrls));let _=x1(e,n.inputTranslationUrlPattern);_||(_=wt(e,n.inputTranslationBlockUrls));let k=wt(e,n.mutationBlockUrls),v=Object.keys(m),I={};for(let ae of v){let ie=m[ae];if(ie&&ie.matches)for(let Ee of ie.matches)I[Ee]=ae}let F=Object.keys(I),L=ip(e,F);L&&(i=I[L]??"auto",I[L]&&I[L]!=="auto"&&Nn(I[L]));let U=a.hostname,N=await nr(U),q=a.pathname+a.search+a.hash,A=await nr(q),E=`https://${N}.com/${A}`,P=await Jt(),O=await Z3(),H=n.translationStartMode;H==="dynamic"&&h&&(H="immediate");let j=C;n.inputTranslationService&&n.inputTranslationService!=="inherit"&&(j=n.inputTranslationService);let W=C;n.mouseHoverTranslationService&&n.mouseHoverTranslationService!=="inherit"&&(W=n.mouseHoverTranslationService);let V=C;n.subtitleTranslateService&&n.subtitleTranslateService!=="inherit"&&(V=n.subtitleTranslateService);let se=await Mt.get(Ft,null),X=!1;se&&(X=Zt(se));let Z={targetLanguage:T,config:n,translationService:C,inputTranslationService:j,mouseHoverTranslationService:W,subtitleTranslateService:V,isTranslateUrl:S,sourceLanguage:i,mainFrame:document.body,isTranslateExcludeUrl:y,isMutationTranslationExcludeUrl:k,isInputTranslationExcludeUrl:_,rule:n.generalRule,url:e,encryptedUrl:E,state:r?Object.assign({translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},r):{translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},localConfig:P};se&&(Z.user=se,X?Z.isPro=!0:Z.isPro=!1),Z.state.translationArea==="body"&&(Z.config.generalRule.excludeTags=Z.config.generalRule.excludeTags.filter(ae=>!Z.config.generalRule.bodyTranslateTags.includes(ae)),Z.config.generalRule.additionalExcludeSelectors=Z.config.generalRule.additionalExcludeSelectors.filter(ae=>ae!==".btn"));let ue=n.translationServices[Z.translationService]||{};ue.immediateTranslationTextCount!==void 0&&Gw(ue.immediateTranslationTextCount)&&ue.immediateTranslationTextCount>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCount),Z.translationService==="deepl"&&(ue&&ue.authKey&&ue.authKey.startsWith("immersive_")||ue&&ue.provider==="pro"&&Z.user?.token)&&ue.immediateTranslationTextCountForImmersiveDeepl!==void 0&&ue.immediateTranslationTextCountForImmersiveDeepl>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCountForImmersiveDeepl),ue&&ue.translationDebounce&&typeof ue.translationDebounce=="number"&&(Z.state.translationDebounce=ue.translationDebounce);let ge=O.immediateTranslationTextCount;n.immediateTranslationTextCount!==ge&&(Z.state.immediateTranslationTextCount=n.immediateTranslationTextCount);let te=n.rules,Y;globalThis.PDFViewerApplication?Y=te.find(ae=>ae.pageType=="pdfReader"):globalThis.immersiveTranslateEbookViewer?Y=te.find(ae=>ae.pageType=="ebookReader"):globalThis.immersiveTranslateEbookBuilder?Y=te.find(ae=>ae.pageType=="ebookBuilder"):Y=te.find(ae=>Gi(e,ae)),Z.state.translationArea==="body"&&(Z.rule.paragraphMinTextCount=1,Z.rule.paragraphMinWordCount=1),Y&&Y.pageType==="ebookBuilder"&&(Z.state.translationStartMode="immediate");let be=n.generalRule;if(Y&&(Z.rule=Tl(be,Y)),Z.rule.selectors.length>0&&(Z.rule.paragraphMinTextCount=2,Z.rule.paragraphMinWordCount=1),Z.state.translationArea==="body"&&Z.rule.excludeTags&&(Z.rule.excludeTags=Z.rule.excludeTags.filter(ae=>!Z.rule.bodyTranslateTags.includes(ae)&&!Z.rule.forceTranslateTags.includes(ae))),Z.rule.mainFrameSelector){let ae=document.querySelector(Z.rule.mainFrameSelector);ae&&(Z.mainFrame=ae)}return Z}function Gi(t,e){if(!e)return!1;let{matches:n,excludeMatches:r,selectorMatches:a,excludeSelectorMatches:i}=e;return r&&r.length>0&&wt(t,r)?!1:n&&n.length>0&&wt(t,n)?!0:i&&i.length>0&&Fl(i)?!1:!!(a&&a.length>0&&Fl(a))}function x1(t,e){if(!e)return!1;let{excludeMatches:n,excludeSelectorMatches:r}=e;return!!(n&&n.length>0&&wt(t,n)||r&&r.length>0&&Fl(r))}function Gw(t){return typeof t=="number"}d();d();d();d();d();d();d();var Nq=w1(2),C1=w1(3);function w1(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var Vw=/\s+/g,$w=/[\t\n\v\f\r ]+/g;function D1(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?Yw:Qw;return String(t).replace(e.style==="html"?$w:Vw,e.trim?Zw(n):n)}function Yw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function Qw(){return" "}function Zw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var A1={}.hasOwnProperty;function Jw(t){return t==null?"":D1(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function Xw(t){return C1(" "+Jw(t)+" ")}function eD(t){let e=Xw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function sD(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function uD(t,e,n,r){e=cD(e,n,r);let a=[],i;if(e)for(i in e)Rl.call(e,i)&&a.push([i,lD(t,e[i])]);return a.length===0?Dp():a.sort(dD)}function lD(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of SD){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?I1(t)?"zh-TW":"zh-CN":e:"auto"}var O1=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Ap=new Map(O1),xD=new Map(O1.map(([t,e])=>[e,t]));function z1(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>xD.get(s));!e&&e!==0&&(e=25);let a=zl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Ap.keys()]},o=L1(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&g<.95)break;return Ap.get(p)}}let[s,u]=o[0],l=Ap.get(s);if(l&&u>.9)return l}}catch(r){z.error(r)}return"auto"}d();d();function pa(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function ED(t,e){return t<>>32-e}function Ul(t,e,n,r,a,i){return pa(ED(pa(pa(e,t),pa(r,i)),a),n)}function en(t,e,n,r,a,i,o){return Ul(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return Ul(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return Ul(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return Ul(n^(e|~r),t,e,a,i,o)}function Nl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function kp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Nl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Nl(a.concat(kp(e)),512+e.length*8),N1(Nl(i.concat(o),512+128))}function U1(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function Pp(t){return unescape(encodeURIComponent(t))}function q1(t){return CD(Pp(t))}function DD(t){return U1(q1(t))}function j1(t,e){return wD(Pp(t),Pp(e))}function AD(t,e){return U1(j1(t,e))}function kn(t,e,n){return e?n?j1(e,t):AD(e,t):n?q1(t):DD(t)}var Vi=[];async function ql(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function H1(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await LD(e,t)}async function W1(t){let e=kn(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await PD(n,e)}async function PD(t,e){let n=await ql(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function LD(t,e){let n=await ql(t);return(await FD()).includes(t)||await _D(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function _D(t){let e="cache_list",n=await ql(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Vi.push(t)},a.onerror=i=>{n.close()}}async function FD(){if(Vi&&Vi.length>0)return Vi;let t=await ql(Q+"-cacheList","cache_list");return Vi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Vi}d();d();var Lp="Original";function $e(){return Lp}function pn(t){Lp=t,K1(Lp)}d();function Hr(t){return t?.id?.endsWith("pdfWebPage")||!1}function ga(t){try{if(!t||!Hr(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Ye={},ma=async function(t,e){let{method:n,data:r}=t,a=await Ye.updateGlobalContext(),i=Date.now();if(z.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Ze(Kn,i);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Ze(Kn,i);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Ze(Kn,i);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Ze(Kn,i);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Ze(Kn,i);else if(n==="translatePage")await Ye.translatePage(a,r),Ze(Kn,i);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(vu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(_o,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Je()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Je())return JSON.stringify(a)}};function G1(t){Object.assign(Ye,t)}function V1(t){Object.assign(Ye,t)}function $1(t){Object.assign(Ye,t)}var MD=function(t,e){let{method:n,data:r}=t;if(z.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return $e();if(n==="getCurrentPageLanguage"){let a=yt();return Ye.detectCurrentPageLanguage().catch(i=>{z.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return Nn(r),yt();if(n==="getContextString"){let a=Ye.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return ga(a?.rule)}}},jl,Hl;function Y1(){let t=Wl();Je()||BD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Wl(){return jl||(jl=new br("content_script",!1).getConnection("main",ma),jl)}function BD(){return Hl||(Hl=new br("content_script",!1).getConnection("main_sync",MD,{sync:!0}),Hl)}d();var _p=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Kl="https://transmart.qq.com/api/imt",Wr=class t{static langMapReverse=new Map(_p.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await de({url:Kl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function ID(t,e){return Math.floor(Math.random()*(e-t+1))+t}var RD=30,Fp="RATE_LIMITER_TICKS",$i=class t{static strictTicks={};static clearStrictTicks(){bs(Fp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await Pl(Fp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){z.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await bs(Fp,JSON.stringify(this.strictTicks))}catch(a){z.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=ID(4,RD);await Dr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function vt(t){return await Wl().sendMessage("background:main",t)}function de(t){return mu()?wl({method:"request",data:t}):ye()||gu()?(t.fetchPolyfill=globalThis.GM_fetch,Ur(t)):vt({method:"fetch",data:t})}function qn(){return ye()?Xt():vt({method:"getConfig"})}function gn(t){return ye()?hs(t):vt({method:"setUserConfig",data:t})}function mn(){return ye()?qr():vt({method:"getUserConfig"})}function Es(){return ye()?Jt():vt({method:"getLocalConfig"})}function Gl(t){return ye()?Ht(t):vt({method:"setLocalConfig",data:t})}function Q1(t){return ye()?kl(t):vt({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=zl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||it()){if(t.translateService&&!Du.includes(t.translateService))return Promise.resolve("auto");let r=z1(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await vt({method:"detectLanguage",data:t});return Promise.resolve(e)}function Z1(){return vt({method:"detectTabLanguage"})}async function Vl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||it()){let n=t.substring(0,200);e=await Wr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function K1(t){let e=new CustomEvent(Oa,{detail:t});if(document.dispatchEvent(e),ye())return;Wl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function J1(t){return ye()?W1(t):vt({method:"queryParagraphCache",data:t})}async function X1(t){if(ye()){await H1(t);return}return vt({method:"setParagraphCache",data:t})}async function e2(){if(ye())return Promise.resolve();await vt({method:"mockRequest"})}function Yi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):vt({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function $l(t=""){return ye()||it()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function Mp(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Yl(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):vt({method:"openAboutPage"})}function Qi(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):vt({method:"openInTab",data:t})}function t2(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):vt({method:"openEbookViewerPage"})}function n2(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):vt({method:"openEbookBuilderPage"})}function r2(t){it()}function Zi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):vt({method:"openPdfViewerPage",data:{url:e}})}function a2(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):vt({method:"openSubtitleBuilderPage"})}function Ji(t){return ye()?Promise.resolve():vt({method:"setBadge",data:{text:t}})}function i2(){return ye()?(z.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):vt({method:"autoSyncLatestConfig"})}function Ql(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function o2(t,e){return ye()?$i.getDelay(t,e):vt({method:"getDelay",data:{key:t,options:e}})}function s2(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return!!(r&&e.hostname===r)}function Zl(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return r&&e.hostname===r?!0:!(Bp(t)||e.protocol!=="http:"&&e.protocol!=="https:"&&e.protocol!=="file:"&&e.protocol!=="data:")}function Bp(t){try{return new URL(t)?.pathname.toLowerCase().endsWith(".pdf")}catch{return!1}}d();d();d();d();var Ip={get:(t,e,n)=>{let r=e===void 0?t:{[t]:e};return oe.storage[n].get(r)},set:(t,e,n)=>oe.storage[n].set({[t]:e})};function Jl(t,e,n){let[r]=re(()=>typeof e=="function"?e():e),[a]=re(n),[i,o]=re(r),[s,u]=re(!1),[l,c]=re("");Ce(()=>{Ip.get(t,r,a).then(g=>{g[t]&&o(g[t]),u(!0),c("")}).catch(g=>{u(!1),c(g)})},[t,r,a]);let p=Ve(g=>{let m=typeof g=="function"?g(i):g;z.debug("new settings",m),Ip.set(t,m,a).then(()=>{o(m),u(!0),c("")}).catch(f=>{o(m),u(!1),c(f)})},[a,t,i]);return[i,p,s,l]}d();function Rp(t,e,n){let r=[];return function(){let[i,o,s,u]=Jl(t,e,n),l=Ve(c=>{for(let p of r)p(c)},[]);return Ce(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function u2(t,e){return Rp(t,e,"sync")}var OD="userConfig",zD=null,ND=u2(OD,zD);function rr(t){let[e,n,r,a]=ND(),i=Ve(o=>{let s=typeof o=="function"?o(e):o;s&&(s.updatedAt=new Date().toISOString()),n(s),t&&t(s)},[e]);return[e,i,r,a,n]}d();d();d();var Xi={},UD={root:"",lang:"en",fallbackLang:"en"};function Op(t,e){let n=Object.assign({},UD,t);Xi=e||Xi;let[r,a]=re(n.lang),[i,o]=re(Xi),[s,u]=re(!1),l=p=>{if(i.hasOwnProperty(p))return;u(!1);let g=H3(n.root||"",p);n.getUrl&&(g=n.getUrl(n.root||"",p),fetch(g).then(m=>m.json()).then(m=>{Xi[p]=m,o({...Xi}),u(!0)}).catch(m=>{o({...Xi}),u(!0)}))};return Ce(()=>{l(n.fallbackLang||"en"),l(r)},[r]),{lang:r,setLang:a,t:(p,g)=>{if(!i.hasOwnProperty(r))return p;let m=gs(i,r,p);return m===p&&r!==n.fallbackLang&&(m=gs(i,n.fallbackLang,p)),pp(m,g)},isReady:s}}d();d();var qD=0;function w(t,e,n,r,a){var i,o,s={};for(o in e)o=="ref"?i=e[o]:s[o]=e[o];var u={type:t,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--qD,__source:a,__self:r};if(typeof t=="function"&&(i=t.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Fe.vnode&&Fe.vnode(u),u}var Np=hi(null),zp={root:"assets",lang:"en",fallbackLang:"en"},eo=t=>{let{t:e,setLang:n,lang:r,isReady:a}=Op({root:t.root||zp.root,lang:t.lang||zp.lang,fallbackLang:t.fallbackLang||zp.fallbackLang,getUrl:t.getUrl},t.translations);return w(Np.Provider,{value:{t:e,setLang:n,lang:r,isReady:a},children:t.children})};function xe(){return du(Np)}d();var jD=function(t,e){let{method:n,data:r}=t;z.debug(`popup received message: ${n}`,r||" ");let a;e.active&&(a=e.id,globalThis.document.dispatchEvent(new CustomEvent(Mo,{detail:{tabId:a,payload:t}})))},Xl;function l2(){Cs()}function Cs(){return Xl||(Xl=new br("popup",!1).getConnection("main_sync",jD),Xl)}d();d();function c2(t,e=2e3){return n=>{let r,a=0;return i=>{++a==t&&(n(i),a=0),clearTimeout(r),r=setTimeout(()=>a=0,e)}}}d();var ec="DROP_DOWN_DEFAULT_VALUE";function Up(t){let{showArrow:e,onSelected:n,className:r,menus:a,maxWidth:i,style:o}=t;r=r||"",e=e??!0,i=i||80;let s=qe(null);return w("select",{ref:s,autoComplete:"off",class:`min-select ${e?"":"min-select-no-arrow"} ${r||""}`,value:ec,style:{maxWidth:`${i}px`,...o},onChange:u=>{u.preventDefault();let l=u.target.value;if(s.current&&l!==ec){s.current.value=ec,s.current?.dispatchEvent(new Event("change"));let c=a.find(p=>p.value===l);c&&n(c)}},children:[{value:ec,label:t.label}].concat(a).map((u,l)=>w("option",{value:u.value,children:u.label},"option-"+l))})}d();d();function to(t,e){return t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})>=0}var HD=({date:t})=>{let{t:e}=xe(),[n,r]=re(!1);return Ce(()=>{setTimeout(()=>{r(!0)},5e3)},[]),n?null:w("p",{class:"text-sm",children:[e("Successfully synchronized with the latest official rules:")," ",new Date(t).toLocaleString()]})},WD=({minVersion:t})=>{let{t:e}=xe();return w("p",{class:"text-sm",children:e("localVersionIsTooOld",{minVersion:t})})},KD=()=>{let{t}=xe();return w("p",{class:"text-sm",dangerouslySetInnerHTML:{__html:t("badUserscriptBrowser",{1:"https://immersivetranslate.com/docs/installation/"})}})},GD=({message:t,handleSyncing:e,date:n})=>{let{t:r}=xe();return w("p",{class:"text-sm",children:[r("failToSyncRules")," ",w("a",{onClick:e,children:r("retry")}),w("br",{}),r("failedReason"),"\uFF1A",t,w("br",{}),r("currentRuleVersion"),"\uFF1A",n]})};function qp(t){let{isShowError:e,request:n}=t,[r,a]=re(null),{t:i}=xe(),[o,s]=re(null),[u,l]=re(null),[c,p]=re(""),[g,m]=re(!1),[f,T]=re(!1),[b,h]=re(!1),[C,D]=re(null),[M,B]=re(null),S=Sn(),y=async()=>{p("");let _=o;if(o===null)try{let k=await n({url:Bo});k?(s(k),_=k,m(!0)):(p(i("unknownError")),l(null))}catch(k){l(null),p(k.message);return}_!==null?(t.setStorageBuildinConfig(_),l(!1),a(_.buildinConfigUpdatedAt)):(p(i("canNotFetchRemoteRule")),l(null))};return Ce(()=>{Xt().then(_=>{let k=_.buildinConfigUpdatedAt;D(_);let v=new Date(k);if(a(k),S==="0.0.0"){h(!0);return}n({url:Bo}).then(I=>{let F=I,L=F.minVersion,U=S;s(F);let N=F.latestVersion;if(N&&(to(U,N)?B(!0):B(!1)),to(U,L)){let q=F.buildinConfigUpdatedAt;new Date(q)>v?(l(!0),y()):l(!1)}else T(!0),l(null)}).catch(I=>{l(null),p(I.message)})})},[]),Ce(()=>{Xt().then(_=>{D(_)})},[r]),C?w("div",{class:"text-sm mt-2",style:{maxWidth:218},children:b?w(KD,{}):c?e===!1?null:w(GD,{handleSyncing:y,message:c,date:r||""}):f?e===!1?null:w(WD,{minVersion:o.minVersion}):u===null||u===!0?null:g?w(HD,{date:r}):null}):null}d();function VD(){return navigator.userAgent.indexOf("Mac")!==-1}var d2={Alt:"\u2325"};function tc(t=""){return VD()?Object.keys(d2).reduce((e,n)=>e.replace(n,d2[n]),t):t}d();d();var nc='',p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0ZGQzczNiIgZD0iTTMgN2gxN3YxMEgzeiIvPjxwYXRoIGZpbGw9InVybCgjYSkiIGQ9Ik02Ljg5NyA5LjI0MmMuNDE1IDAgLjcyLjExMS45MjguMzQ3LjIwNy4yMzUuMzE4LjUyNy4zMTguODczcy0uMTEuNjIzLS4zMTguODQ1Yy0uMjA4LjIyMi0uNTI3LjMzMy0uOTI4LjMzM2gtMS4zM1Y5LjI0MmgxLjMzWm05Ljg0NiAxLjc4OGMuMzg4IDAgLjY2NS4xNTIuODQ1LjQ1Ny4xNTIuMjY0LjIzNS41ODIuMjYzLjk4NHYuMzE5YzAgLjQ5OS0uMDgzLjg4Ny0uMjYzIDEuMTkyLS4xOC4zMDQtLjQ1Ny40NTctLjgzLjQ1Ny0uMzg5IDAtLjY2Ni0uMTUzLS44NDYtLjQ0NC0uMTUyLS4yNjMtLjIzNS0uNTk1LS4yNjMtMS4wMTF2LS4yOTFjMC0uNDg1LjA4My0uODczLjI2My0xLjE3OC4xOC0uMzA1LjQ0My0uNDg1LjgzMS0uNDg1Wm0tMy40MDctMS4xMzZhMS4xNyAxLjE3IDAgMCAwLS43MDYuMjM1IDEuNDgyIDEuNDgyIDAgMCAwLS40MTUuNWwtLjA4My4xNjUtLjA3LS44MDNoLTEuMzU3djUuNDMyaDEuNDU0di0zLjY1OWEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiA4LjEySDQuMTE0djcuMzE3aDEuNDY4VjEyLjc5aDEuMzNjLjg0NCAwIDEuNDk1LS4yMDggMS45OC0uNjM4LjQ4NS0uNDMuNzItLjk4My43Mi0xLjY5cy0uMjM1LTEuMjYxLS43Mi0xLjY5Yy0uNDQzLS4zODktMS4wMzktLjYxLTEuNzczLS42MzhsLS4yMjEtLjAxNFptOS44NDcgMS43NzRjLS44MDMgMC0xLjQyNi4yNjMtMS44ODMuNzc2LS40MTYuNDctLjYzNyAxLjA2Ny0uNjc5IDEuNzczdi4zMzNjMCAuODE4LjIyMiAxLjQ4My42NzkgMS45OTUuNDU3LjUxMyAxLjA4Ljc3NiAxLjg4My43NzYuODA0IDAgMS40MjctLjI2MyAxLjg4NC0uNzc2LjQxNS0uNDcuNjM3LTEuMDUzLjY3OC0xLjc3M3YtLjMzM2MwLS44MTctLjIyMS0xLjQ4Mi0uNjc4LTEuOTk1LS40NTctLjUxMy0xLjA4LS43NzYtMS44ODQtLjc3NlpNMTguMDAzIDZhNiA2IDAgMCAxIDAgMTJIMFY5LjQyM0EzLjQyIDMuNDIgMCAwIDEgMy40MiA2aDE0LjU4M1oiLz48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSI3LjUiIHgyPSIyMiIgeTE9IjE5IiB5Mj0iNiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyMjIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM2OTY5NjkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=",g2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIxMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzk5OSIgZD0iTTYuODk3IDMuMjQyYy40MTUgMCAuNzIuMTExLjkyOC4zNDcuMjA3LjIzNS4zMTguNTI2LjMxOC44NzMgMCAuMzQ2LS4xMS42MjMtLjMxOC44NDUtLjIwOC4yMjItLjUyNy4zMzMtLjkyOC4zMzNoLTEuMzNWMy4yNDJoMS4zM1ptOS44NDYgMS43ODhjLjM4OCAwIC42NjUuMTUyLjg0NS40NTcuMTUyLjI2NC4yMzUuNTgyLjI2My45ODR2LjMxOWMwIC40OTktLjA4My44ODctLjI2MyAxLjE5Mi0uMTguMzA0LS40NTcuNDU3LS44My40NTctLjM4OSAwLS42NjYtLjE1My0uODQ2LS40NDQtLjE1Mi0uMjYzLS4yMzUtLjU5NS0uMjYzLTEuMDExdi0uMjkxYzAtLjQ4NS4wODMtLjg3My4yNjMtMS4xNzguMTgtLjMwNS40NDMtLjQ4NS44MzEtLjQ4NVptLTMuNDA3LTEuMTM2YTEuMTcgMS4xNyAwIDAgMC0uNzA2LjIzNSAxLjQ4MiAxLjQ4MiAwIDAgMC0uNDE1LjVsLS4wODMuMTY1LS4wNy0uODAzaC0xLjM1N3Y1LjQzMmgxLjQ1NFY1Ljc2NGEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiAyLjEySDQuMTE0djcuMzE3aDEuNDY4VjYuNzloMS4zM2MuODQ0IDAgMS40OTUtLjIwOCAxLjk4LS42MzguNDg1LS40My43Mi0uOTgzLjcyLTEuNjlzLS4yMzUtMS4yNjEtLjcyLTEuNjljLS40NDMtLjM4OS0xLjAzOS0uNjEtMS43NzMtLjYzOGwtLjIyMS0uMDE0Wm05Ljg0NyAxLjc3NGMtLjgwMyAwLTEuNDI2LjI2My0xLjg4My43NzYtLjQxNi40Ny0uNjM3IDEuMDY3LS42NzkgMS43NzN2LjMzM2MwIC44MTguMjIyIDEuNDgzLjY3OSAxLjk5NS40NTcuNTEzIDEuMDguNzc2IDEuODgzLjc3Ni44MDQgMCAxLjQyNy0uMjYzIDEuODg0LS43NzYuNDE1LS40Ny42MzctMS4wNTMuNjc4LTEuNzczdi0uMzMzYzAtLjgxNy0uMjIxLTEuNDgzLS42NzgtMS45OTUtLjQ1Ny0uNTEzLTEuMDgtLjc3Ni0xLjg4NC0uNzc2Wk0xOC4wMDMgMGE2IDYgMCAwIDEgMCAxMkgwVjMuNDIzQTMuNDIgMy40MiAwIDAgMSAzLjQyIDBoMTQuNTgzWiIvPjwvc3ZnPg==";var m2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAn1BMVEUAAADt7vHu7vLu7vLv7+/n5+fFxcXu7vHv7/PHx8eamprt7fLt7fHn5+vGxsbS09Surq6fn5+ZmZmZmZnGxsbGxsbt7/K/v7/Hx8ft7vHGxsaZmZn09vnk5eeqqquenp7p6u3X2NnLy8vU1dbr7O67u7uvr6/o6evh4uPR0dLCwsLAwMDZ2ty9vb6kpaWhoaHe3+HPz8+zs7OkpKTc3d7Gt0R8AAAAGXRSTlMA779wIBDv338gv5+AgHDv7+/v36+gn3BgD0kJmgAAAS1JREFUKM9dkOmSgyAQhNFo7mTvYwYEBa9oorne/9l2hqJSbr4q+NHNdBcjAukyXgBE8SwRU5IYHmwm1iyCCdFMBJbwxDK8B2iKLGjl8VAC+JmEcqzRrmnP5yzrbm93SuOeDQCcpNToGaV8ISGmAfBGPce+qjrsjSxYSbkBGtt1tZGEueLpwsZW8A8snlj2jD0efRZVtxzw4Ia2BFgIch1qOaHCM4lsHHA0WpOpKyk7qX2WWLBhhhxU7grlKlV7I+LyAm+DUplS/sqv2HL5FiDDSio15CQOdHrrl5L6kpqEMOHwTlIiOKu0WIDy5Bfkn3+HJTYXRNdmWXtA1nmJfu1lgRNcQw2encV/2J0I7OdIXM1YIzH/FQ9WX4i1JF4RP1dBDNZ+/S7lx/onDcIfdi8x4pYpSxgAAAAASUVORK5CYII=",f2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAA51BMVEUAAABRT2tSUGpRT2tQUHBQUGjwtcxRT2tRUGtST2tSTmrvsMnvt89QUHDqTIpkXHhST2zQobmfdpPrTYrGVoHqS4nwtszvtMzvtc3vr89RT2vwtczASHb09vnIXYbt4OncqMDqTInGVoBbVnHqp8GqiKJlXHfz2+bsrsfkmrfIm7SggpvScZfKaY/q1uDtgKvRiKaNdY/MY4vy7fLy5Ozxydrxw9bhtcjnobzVlK/diam0j6jYfqHVeJyXfJWcd5TrXJOCb4l5aYNvYn3DUXzxzd3kwNDSorrth6/CjqnAeZnNdJaDb4nDaCDkAAAAGnRSTlMA73C/ICDv37+ff3AgEL+AgO/v7+/fr6BgELJb3PQAAAE/SURBVCjPXZHnUsMwEIRlOySkhw66k+24YScx6b0XOu//PJw0mozh+6Efu6ddzYlpqiWrwLlhmTmW5cLiZ4oZyzR4BsNkmhL/R0nPcx6FR6357ZbPuanyKefT62yjn37/cJwPbjeUJnuKNPeFuAaFjXhNgkUXONHDdR6CJIkh8HArlSo1UIUbx6sTEt4CZlfSaLBLOl2YeaixA2irLKrey4AzA4jpXQVG7hI6mCGBPonSaIF9StMUMe0hzrGjslhBGp7tDIUzfRPTnvhWhiHLQxjYQrwIoQ5nAXtZ3uD8AAkKYTsk0sAocNVSqqpkRaK+MYYNSTkms3wXXodCMZpAKD9FLzF6Bxg/ExMgXS+RluKHkGEZUYOi7sIf3DrTlPNAfOx2XSDyj+xM5QGg2yTIua+wLJVy7abZvKuVn7TwCyKmN+3PjJblAAAAAElFTkSuQmCC",h2="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9IkZyYW1lIj4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTguNzEwMjMgMTMuMzg3NkwxMy4yODkzIDguODA4NkwxNC4wOTc3IDguMDAwMjJMMTMuMjg5NyA3LjE5MjIyTDguNzEwMjMgMi42MTI3OUw3LjkwMjIzIDMuNDIwNzlMMTEuOTA5NSA3LjQyODc5SDEuOTA1NjZWOC41NzE2NUgxMS45MDk1TDcuOTAxODUgMTIuNTc5M0w4LjcxMDIzIDEzLjM4NzZaIiBmaWxsPSIjODM4MzgzIi8+CjwvZz4KPC9zdmc+Cg==";function b2({config:t,isLogin:e,isProUser:n}){let{t:r}=xe();return ml(t)?w("div",{}):w("div",{class:"flex items-center",children:[w("a",{class:"flex items-center text-decoration-none",target:"_blank",href:e?ku:r4,children:[w("img",{src:e?f2:m2}),w("span",{class:"text-xs ml-2 text-label",children:r(e?"loggedIn":"notLogin")})]}),w("a",{title:r(n?"popup.openProForPro":"popup.openPro"),target:"_blank",class:"ml-2",href:n?ku:a4,children:w("img",{src:n?p2:g2})})]})}d();d();var T2={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},y2={...Ot,"zh-CN":{...T2["zh-CN"],...Ot["zh-CN"]},"zh-TW":{...T2["zh-TW"],...Ot["zh-TW"]}},rc=y2;function no(t,e,n){return hr(y2,t,e,lr,n)}var fa=(t,e,n,r)=>{let a=Yh[t]||t,i=Qh[t],o=Zh[t],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[t]?s[t]:a;if(s[e]){let u=s[e];return r||t==="auto"||t==="placeholder"?u:`${u} (${a})`}else return a};d();d();d();d();d();function jp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(Vh),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${Fd}-theme-${t}`):a.push(`${_d}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(Fd):a.push(_d),a}function Hp(t){let e=["notranslate",wu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function v2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Za(n,!0),g="afterend",m=p[0],f=p[1],T=`${m}(\\d+)${f}`,b=new RegExp(T,"g"),h=rt.sanitize(u);o.length>0&&(h=h.replace(b,B=>{let S=h.indexOf(B),y=h[S-1]===" ",_=h[S+B.length]===" ",v=B.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),I=Number(v);if(isNaN(I))return B;let F=o[I];if(F&&F.type==="element"){let L=F.value.outerHTML;return y||(L=" "+L),_||(L=L+" "),L}else z.error("variable type not supported",F,B);return B}));let C=jp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&C.push(Gh);let D=Hp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${C.join(" ")}" ${ur}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${ur}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ur}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function ac(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";g&&(T=ca(Wp(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let C=Kp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",B=Ts(C+D+M),S=B[0]+h+B[1];if(C===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=Ts(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Kp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);g&&(b=ca(Wp(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",C=Ts(T+b+h),D=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(T===" ")D=D.trimStart();else{let M=Ts(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Kp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Wp(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}t.targetText=rt.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` `).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(t.id),elements:[],isVertical:!1,rootFrame:t.commonAncestorContainer,text:t.text,variables:r,inline:a,preWhitespace:t.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Za(e);if(l.length>2){let c=l[2];return $D({delimiterTag:c,targetText:t.targetText,inline:a,preWhitespace:t.isPreWhitespace||!1,wrapperPrefix:e.rule.wrapperPrefix,wrapperSuffix:e.rule.wrapperSuffix,targetWrapperTag:e.rule.targetWrapperTag,translationTheme:e.state.translationTheme,translationBlockStyle:e.rule.translationBlockStyle,translationClasses:e.rule.translationClasses,variables:r}).html}else{let c=v2(u,{id:Number(t.id),url:"https://google.com",text:t.targetText,from:"auto",to:"auto",fromByClient:"auto"},e);return c.html}}function Wp(t){return(t?.innerText||t.textContent||"").replace(/\s+/g," ")||""}function $D(t){let{delimiterTag:e,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=t;o=o||[];let p=t.targetText;p=rt.sanitize(p);let g=p,m=new RegExp(`<${e}(\\d+)>(.*?)`,"g"),f=new RegExp(`<${e}(\\d+)>`);o.length>0&&(g=g.replace(m,C=>{let D=g.indexOf(C),M=g[D-1]===" ",B=g[D+C.length]===" ",S=C.match(f);if(!S)return C;let y=S[1],_=Number(y);if(isNaN(_))return C;let k=o[Number(_)];if(k&&k.type==="element"){let v=k.value.outerHTML;return M||(v=" "+v),B||(v=v+" "),v}else if(k&&k.type==="text"){let v=k.value;return M||(v=" "+v),B||(v=v+" "),v}else z.error("variable type not supported",k,C);return C}));let T=jp(l,n,r||[],s),b=Hp(l),h="";return c&&(h=`style="${c}"`),g=`<${a} ${h} class="${T.join(" ")}" ${ur}="1"><${a} class="${b.join(" ")}" ${ur}="1">${g}`,n||(i==="smart"?g=`
${g}`:g=`${i}${g}`),n&&(i!=="smart"?g=`${i}${g}`:g=`<${a} class="notranslate" ${ur}="1"> ${g}`),u==="smart"?g=`${g}`:g=`${g}${u}`,{html:g,position:"afterend"}}function Kp(t){let e=t[t.length-1];return e?e.text:""}function Gp(t){let{text:e,delimiters:n,variables:r}=t,a=e;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=e;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let p=c.match(s);if(!p)return c;let g=p[1],m=Number(g);if(isNaN(m))return c;let f=r[g];return f||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}var De=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(e,n,r){this.serviceConfig=e,this.generalConfig=n,this.translationOptions=r,e?.retry&&(this.retry=e.retry),e?.requestTimeout&&(this.requestTimeout=Number(e.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let e=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(e.limit=Number(n.limit)),n?.interval&&(e.interval=Number(n.interval)),e}formatRateLimit(e){return e.limit<1&&(e.interval=Math.round(1e3/e.limit),e.limit=1),e}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(e){throw new Error("Not implemented")}translateList(e){throw new Error("Not implemented")}async multipleTranslate(e,n,r){if(e.sentences.length===0)return{sentences:[]};let{sentences:a}=e,i=!1,o=!1,s=[],u=null,l=new Set;for(let b of a)b.from&&b.from!=="auto"&&l.add(b.from),b.refresh&&(i=!0),b.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let p=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(p=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(p=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=z3(a,c,p)}catch(b){if(r)for(let h=0;hb));let g=[],m=[],f=(b,h,C)=>{let D="";if(h.translatedTexts&&h.translatedTexts[0]&&(D=h.translatedTexts[0]),m[b]||(m[b]=h,m[b].translatedTexts=Array(h.sentenceTotalParts).fill(null)),m[b].hasError)return;if(C){let S=C instanceof $?new $(C.name,C.message).initNetWork(C.status).initData(C.data):C;m[b].hasError=!0,h.callback&&h.callback(S,null,h.sentence);return}m[b].translatedTexts[h.partIndex]=D;let M=m[b],B=0;for(let S=0;S{let B=h.from;if(h.fromByClient&&h.fromByClient!=="auto"&&(B=h.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:h.tempSentences.map(y=>y.text),forces:h.tempSentences.map(y=>y.force),xpaths:h.tempSentences.map(y=>y.xpath||""),from:B,to:h.to,url:C,options:n,refresh:i,debug:o}),sourceTempSentences:h.tempSentences};{let S=Kh;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(S=this.serviceConfig.translationTextSeparator);let y=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(y=this.serviceConfig.newlinePlaceholderDelimiters);let _=[],k=Tr(this.serviceConfig);if(h.tempSentences.forEach((q,A)=>{let E=bp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:k,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:h.to});q.force!==!0&&(E&&E.text&&E.text.trim().lengthA.text);return Promise.resolve({sourceTempSentences:h.tempSentences,text:q,from:B,to:h.to})}let v="";y&&y.length>=2?v=_.map((q,A)=>{let{item:E}=q;return A===_.length-1?E.text:E.text+y[0]+(A+1)+y[1]}).join(""):v=_.map(({item:q})=>q.text).join(S);let I=await this.translate({text:v,from:B,to:h.to,url:C,options:{...n,rawTextArrayLength:_.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=I,L=[];if(y&&y.length>=2){let q=`${y[0]}\\d+${y[1]}`;y&&y.length>=3&&(q=y[2]);let A=new RegExp(q,"g");L=F.split(A)}else L=F.split(S);let U=[];if(L.length>_.length){for(let q=0;q<_.length-1;q++)U[q]=L[q];U[_.length-1]=L.slice(_.length-1).join(S)}else if(L.length<_.length)for(let q=L.length;q<_.length;q++)L[q]="";else U=[...L];let N=h.tempSentences.map(q=>q.text);return k=Tr(this.serviceConfig,!0),U.forEach((q,A)=>{let E=_[A],P=E.index,O=E.variables||{};Object.keys(O).length>0&&(q=Gp({text:q,delimiters:k,variables:O})),N[P]=q}),{sourceTempSentences:h.tempSentences,text:N,from:I.from,to:I.to}}};g.push(M().then(B=>{let{text:S,sourceTempSentences:y}=B;for(let _=0;_{if(B instanceof $&&B.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let S=0;S{let h=b.sentence.text;return b.translatedTexts&&b.translatedTexts.length>0&&(h=b.translatedTexts.join("")),{...b.sentence,text:h}})}}async formatAndTranslateList(e){let n={...e},{forces:r}=e,a=[],i=Tr(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=e;if(l.forEach((p,g)=>{let m=bp({text:p,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:e.to});r&&r[g]!==!0&&(m&&m.text&&m.text.trim().lengthp.text),n.xpaths=a.map(p=>p.xpath)}catch(l){z.debug("formatAndTranslateList error",e,l)}let o=await this.translateList(n),{text:s}=o,u=e.text.map(l=>l);return i=Tr(this.serviceConfig,!0),s.forEach((l,c)=>{let p=a[c];if(p){let g=p.index,m=p.variables,f=Object.keys(m);u[g]=l,f.length>0&&(u[g]=Gp({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(e){return Ie({text:e,minLength:18,pageLangs:[yt(),"en"]})}detectLanguageRemotely(e){return Promise.resolve("auto")}detectLanguage(e){return e.length>=50?this.detectLanguageLocally(e):this.detectLanguageRemotely(e)}};var x2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ws=class t extends De{static langMap=new Map(x2);maxTextGroupLength=50;static langMapReverse=new Map(x2.map(([e,n])=>[n,e]));static getUTCDate(e){let n=e.getUTCFullYear(),r=`${e.getUTCMonth()+1}`.padStart(2,"0"),a=`${e.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(e,n,r){if(super(e,n,r),!e||!e.secretId||!e.secretKey)throw new $("secretId and secretKey are required");this.secretId=e.secretId?.trim(),this.secretKey=e.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceText:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async translateList(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceTextList:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:e,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await nr(a)].join(` `),p=t.getUTCDate(u),g=["TC3-HMAC-SHA256",l,`${p}/${i}/tc3_request`,await nr(c)].join(` `),m=await R3(p,`TC3${n}`),f=await El(i,m),T=await El("tc3_request",f),b=await El(g,T),h=await de({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${e}/${p}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${b}`},body:a,timeout:this.requestTimeout});if(h instanceof Error)throw h;if(h.Response&&h.Response.Error&&h.Response.Error.Message)throw new $(h.Response.Error.Message);return h}};d();var E2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],YD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Ds=class t extends De{static langMap=new Map(E2);static langMapReverse=new Map(E2.map(([e,n])=>[n,e]));isSupportList=!1;constructor(e,n,r){super(e,n,r)}async translate(e){let{text:n,from:r,to:a}=e,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await de({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:YD,timeout:this.requestTimeout});return{text:o.targetText,from:t.langMapReverse.get(o.source)||r,to:t.langMapReverse.get(o.target)||a}}};d();var C2=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Ja=class t extends De{static langMap=new Map(C2);static langMapReverse=new Map(C2.map(([e,n])=>[n,e]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(e,n,r){super(e,n,r),e?.apiUrl&&(this.apiUrl=jt(this.apiUrl,e.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(e,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}).toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(e,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}),i=this.apiUrl+"?"+a.toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}};d();d();d();function QD(t,e){return e?t+(e-t%e):t}function ZD(t,e){return t.split(e).length-1}function Vp(t){let e=Date.now(),n=1;for(let r of t)n+=ZD(r,"i");return QD(e,n)}function JD(t,e){return Math.floor(Math.random()*(e-t+1))+t}function $p(){return JD(1e6,1e8)}d();d();d();var Yp="https://www2.deepl.com/jsonrpc",Qp="auto",w2=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];d();function XD(t=w2){return t.reduce((e,n)=>(e[n.code.toLowerCase()]=n.code,e[n.language.toLowerCase()]=n.code,e),{})}function Zp(t){return XD()[t.toLowerCase()]}var eA={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function tA(t){return JSON.stringify(t).replace('"method":"',()=>{let e=t;return(e.id+3)%13===0||(e.id+5)%29===0?'"method" : "':'"method": "'})}function nA(t,e){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:t,target_lang:e}}}}async function rA(t,e,n,r,a,i,o){let s=$p(),u=nA(r,n),l=[];e.forEach(g=>{l.push({text:g,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Vp(e);let c=await de({retry:2,method:"POST",url:t,body:tA(u),headers:eA}),p={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(g=>{p.text.push(g.text)}),p}async function D2(t,e,n,r=Qp,a,i,o){return e?e&&e.length===1&&e[0]===""?{text:[""],from:r,to:n}:rA(t,e,Zp(n),Zp(r)??"auto",a,i,o):{text:[],from:r,to:n}}var A2=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],ro=class t extends De{static langMap=new Map(A2);static langMapReverse=new Map(A2.map(([e,n])=>[n,e]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Yp;constructor(e,n,r){super(e,n,r),e&&e.apiUrl&&(this.API_URL=jt(Yp,e.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(e){let{text:n,to:r,from:a}=e,i=await D2(this.API_URL,n,t.langMap.get(r)||r,t.langMap.get(a)||"auto");return{text:i.text,from:t.langMapReverse.get(i.from),to:t.langMapReverse.get(i.to)}}};d();var As=class t extends De{static langMap=new Map(_p);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(e,n,r){super(e,n,r),this.clientKey=Wr.getClientKey()}async translate(e){let{text:n,to:r}=e,a=await this.detectLanguage(n),i=t.langMap.get(a)||a,o=t.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Me(),u=e.url;s.INSTALL_FROM==="firefox_store"&&(u=k2());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),p=await de({url:Kl,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(p.header.ret_code!=="succ")throw new $(p.message||p.header.ret_code);return{text:p.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(e){let{from:n,text:r,to:a}=e,i=Me(),o=e.url;if(i.INSTALL_FROM==="firefox_store"&&(o=k2()),r.length===1){let m=await this.translate({from:n,text:r[0],to:a,url:o,options:e.options});return{text:[m.text],from:m.from,to:m.to}}let u=await this.detectLanguage(r.join(` diff --git a/dist/firefox/background.js b/dist/firefox/background.js index 93577af..5ec8de9 100644 --- a/dist/firefox/background.js +++ b/dist/firefox/background.js @@ -1,4 +1,4 @@ -(()=>{var lc=Object.defineProperty;var ma=(t,e)=>{for(var r in e)lc(t,r,{get:e[r],enumerable:!0})};var m={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var lc=Object.defineProperty;var ma=(t,e)=>{for(var r in e)lc(t,r,{get:e[r],enumerable:!0})};var m={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5165,7 +5165,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Rg,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...jl,{type:"password",name:"apikey",required:!0}],props:jl},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},RD={type:W+"ChildFrameToRootFrameIdentifier"};var ND=ut()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general";var ir="user_info",qD=ut()||jt()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",Ql=ut()||jt()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",UD=Ql+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",jD=Ql+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",qg=ut()||jt()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Bi=ut()||jt()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",Ug=ut()||jt()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",jg=ut()||jt()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",Kg=ut()||jt()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",KD=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",WD=Ug+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",HD=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Yl=Bi+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Xl=jg+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Zl=Kg+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Jl=qg+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true";var eu=pe().TRANSLATE_FILE_URL,GD=eu+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",VD=eu+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var kr=console,Fi=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let r=performance.now(),a=Math.round(r-this.#e),n=Xe.green;a>1e4?n=Xe.red:a>1e3&&(n=Xe.yellow),kr.debug(Xe.dim(nr+" TIMING:"),e,"in",n(a+"ms")),this.#e=r}},ra=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&kr.log(Xe.dim(nr+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&kr.log(Xe.green(nr+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&kr.warn(Xe.yellow(nr+" WARN:"),...e)}error(...e){this.#e<=3&&kr.error(Xe.red(nr+" ERROR:"),...e)}fatal(...e){this.#e<=4&&kr.error(Xe.red(nr+" FATAL:"),...e)}timing(){return this.level===0?new Fi:{reset:()=>{},stop:()=>{}}}},q=new ra;function Kt(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let r=ta.map(n=>n.toLowerCase()),a=r.indexOf(e);if(a===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let n=r.indexOf(e);return n===-1?"auto":ta[n]}else return"auto";else return ta[a]}function zi(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}var Oi="DENO",Xa="CHROME",Za="FIREFOX";function tu(t){let e=Xa;try{let r=navigator?.userAgent||"";/firefox/i.test(r)||typeof InstallTrigger<"u"?e=Za:/deno/i.test(r)&&(e=Oi)}catch{}return t===Xa&&e===Xa||t===Za&&e===Za||t===Oi&&e===Oi}function Mi(){return tu(Xa)}function ru(){return typeof Deno<"u"}function aa(){return tu(Za)}function au(){return Ut()?"monkey":Mi()?"chrome":aa()?"firefox":Ct()?"safari":null}var nu={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},iu={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:nu,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:nu,query:()=>{},sendMessage:()=>{}}};var T;ru()?T=iu:T=globalThis.immersiveTranslateBrowserAPI;var ou=W+"SyncStoreKey_";function Pt(t,e){let r=ou+t;return T.storage.sync.get(r).then(a=>a[r]===void 0?e:a[r])}function Wt(t,e){let r=ou+t;return T.storage.sync.set({[r]:e})}var Wg=W+"StoreKey_";function na(t,e){let r=Wg+t;return T.storage.local.get(r).then(a=>a[r]===void 0?e:a[r])}var or=W+"CacheKey_";function Hg(t,e){let r=or+t;return T.storage.local.get(r).then(a=>a[r]===void 0?e:a[r])}function Gg(){let t=T.storage.local.refresh;t&&t()}function Vg(t,e){let r=or+t;return T.storage.local.get(r).then(a=>{if(a[r]===void 0)return e;let{value:n,expired:i}=a[r];return i&&ia.startsWith(or)).filter(a=>a!==or+ir);if(r.length>0)return T.storage.local.remove(r)}}var ia={get:Hg,set:Qg,getExpired:Vg,setExpired:$g,remove:Yg,clear:Xg,refresh:Gg};function Zg(t,e){let r=t;return e&&Object.keys(e).forEach(a=>{let n=e[a];if(n===void 0)return;let i=Jg(a);if(typeof n=="object"||i){let o=n;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let l=`<${a}>`,s=r.indexOf(l);if(s!==-1){let u=o.tag||"a",c=r.indexOf(``);if(c!==-1){let d=r.substring(s+l.length,c),h=Object.keys(o).filter(b=>b!=="tag").map(b=>`${b}="${o[b]}"`).join(" ");r=r.replace(`${l}${d}`,`<${u} ${h}>${d}`)}}}else if(n){let o=new RegExp("{"+a+"}","gm");r=r.replace(o,n.toString())}}),r}function su(t,e,r){let a=t[e];if(!a)return r;if(!r)return"";let n=r.split("."),i="";do{i+=n.shift();let o=a[i];o!==void 0&&(typeof o=="object"||!n.length)?(a=o,i=""):n.length?i+=".":a=r}while(n.length);return a}function Ri(t,e,r,a,n){if(!t.hasOwnProperty(r))return e;let i=su(t,r,e);return i===e&&r!==a&&(i=su(t,a,e)),Zg(i,n)}function Jg(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function Ht(t,e,r){return Ri(_t,e,t.config.interfaceLanguage,"en",r)}function lu(t,e){let r=new Date(t),a=r.getFullYear().toString(),n=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getDate().toString().padStart(2,"0"),o=r.getHours().toString().padStart(2,"0"),l=r.getMinutes().toString().padStart(2,"0"),s=r.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",a).replace("MM",n).replace("DD",i).replace("HH",o).replace("mm",l).replace("ss",s)}function uu(t){return new Date(t).getTime()}var Gt=class extends Error{status;constructor(e,r){if(e&&r){super(r),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let r=null;if(r=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!r){let a=Ht.bind(null,e),n=this.getErrorMsg();r={type:"error",title:a("networkError"),errMsg:a("error.serveUnavailable",{serverName:a("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+a("errorReason",{message:n}),action:"changeService"}}return r}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let r=Ht.bind(null,e),a=this.message.startsWith("bingAuth"),n=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(a||n)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let r=Ht.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:r("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+r("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let r=Ht.bind(null,e),a="retry",n="network",i=r("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${r("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${r("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${r("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${r("error.gemini.429")}

${o}`:o=`${r("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${r("error.claude.403")}

${o}`:o=`${r("error.403")}

${o}`:this.status===400?o=`${r("error.400")}

${o}`:this.status===502?o=`${r("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${r("error.subscriptionExpired")}

${o}`,a="setting",n="configError",i=r("error.subscriptionExpiredTitle")),{type:n,title:i,errMsg:o,action:a}}handleFetchError(e){let r=Ht.bind(null,e);if(this.status!==-999)return;let a=this.getErrorMsg();return{type:"network",title:"",errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}handleProUser(e){let r=Ht.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:r("upgradeToProErrorTitle"),errMsg:r("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let r=Ht.bind(null,e);this.message=this.message.replace("ProQuota:","");let a=this.message;try{a=JSON.parse(this.message).error}catch{}let n=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:l,subscriptionTo:s}=n;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let d=this.data?.translationService=="deepl"?"OpenAI":"Deepl",h=this.data?.translationService=="deepl"?"Deepl":"OpenAI",b=r("errorReason",{message:a});if(i=="onetime_7day")b+=r("proQuotaExceededError.onetime7day",{anotherService:d,brandId:Se,href:Yl});else{let E="";h=="OpenAI"?E=Xl:E=Zl,o?b+=r("proQuotaExceededError.trial",{anotherService:d,brandId:Se,href:Jl}):b+=r("proQuotaExceededError.nonTrial",{anotherService:d,brandId:Se,href:E,translationService:h}),!o&&(n.cancelAtPeriodEnd==="false"||uu(s)>l)&&(b+=r("proQuotaExceededError.resetTime",{resetTime:lu(l,"YYYY-MM-DD HH:mm:ss")}))}return b}}};async function Ja(t){let e;if(t&&t.retry&&t.retry>0)try{e=await vn(cu.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(r){throw r&&r.name==="RetryError"&&r.cause?r.cause:r}else e=await cu(t);return e}async function cu(t){t.body;let{url:e,responseType:r,...a}=t;r||(r="json"),a={mode:"cors",...a};let n=!0;t.fetchPolyfill&&(n=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),n){let s=new AbortController,u=s.signal;setTimeout(()=>{s.abort()},o),a.signal=u}let l;try{l=await i(e,a)}catch(s){q.debug("fetch error",e,s);let u=s.message||"Unknown Error";throw new Gt("fetchError",u).initNetWork(-999).initStack(s.stack)}if(l.ok&&l.status>=200&&l.status<400){if(r==="json")return await l.json();if(r==="text")return await l.text();if(r==="raw"){let s=await l.text(),u=Object.fromEntries([...l.headers.entries()]),c=l.url;return c||(l.headers.get("X-Final-URL")?c=l.headers.get("X-Final-URL"):c=e),{body:s,headers:u,status:l.status,statusText:l.statusText,url:c}}else if(r==="stream"){let s="",u;if(l.body&&l.body instanceof ReadableStream)for await(let c of eh(l.body)){let d=new TextDecoder().decode(c);s+=d;let h;for(;(h=s.indexOf(` -`))>=0;){let b=s.slice(0,h).trim();if(s=s.slice(h+1),b.startsWith("event:")||b==="")continue;let E="";if(b.startsWith("data:")&&(E=b.slice(5).trim()),E==="[DONE]")break;let ne;try{ne=JSON.parse(E??"")}catch(V){q.debug("json error",V);continue}u=ne}}return u}}else{let s;try{s=await l.text()}catch(b){q.error("parse response failed",b)}s&&q.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,h=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),h&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new Gt("fetchError",c).initNetWork(l.status)}}async function*eh(t){let e=t.getReader();try{for(;;){let{done:r,value:a}=await e.read();if(r)return;yield a}}finally{e.releaseLock()}}var th=new Map;function du(t){let e=rh(64),r=new CustomEvent(Hl,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((a,n)=>{th.set(e,(i,o)=>{i?n(i):a(o)})})}function rh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var nh="";function Er(){return nh||pu.version}function mu(){try{let t=[pe().EBOOK_BUILDER_URL,pe().EBOOK_VIEWER_URL,pe().SUBTITLE_BUILDER_URL,pe().HTML_VIEWER_URL,pe().PDF_VIEWER_URL].filter(n=>!!n),e=["app.immersivetranslate.com"];ut()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(n=>{let i=new URL(n);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var oa=new Map,sr=class{fromType;logger;constructor(e,r=!1){this.logger=new ra,r&&this.logger.setLevel("debug"),this.fromType=e,oa.has(e)||(oa.set(e,new Map),T.runtime.onMessage.addListener((a,n,i)=>{let o=a.from,l=a.to,s,u,c;n.tab&&n.tab.id&&(s=n.tab.id,o=`${o}:${s}`,u=n.tab.url,c=n.tab.active),this.logger.debug(`${a.to} received message [${a.payload.method}] from ${a.from}`,a.payload.data?a.payload.data:" ");let d=qi(l),{type:h,name:b}=d;if(h!==e)return!1;let E=qi(o),V=oa.get(h).get(b);if(!V)return this.logger.debug(`no message handler for ${h}:${l}, but it's ok`),!1;let{messageHandler:f,sync:me}=V,z={type:e,name:E.name,id:s,url:u,active:c};if(me){try{let J=f(a.payload,z);i({ok:!0,data:J})}catch(J){i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.details,errorStatus:J.status})}return!1}else return f(a.payload,z).then(J=>{i({ok:!0,data:J})}).catch(J=>{i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.message,errorStatus:J.status})}),!0}))}getConnection(e,r,a){let n=!1;a&&a.sync&&(n=!0);let i=this.fromType,o=oa.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Ni(`${i}:${e}`,this.logger);return oa.get(i).set(e,{messageHandler:r,sync:n,connectionInstance:l}),l}}},Ni=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let a=qi(e),{type:n,id:i}=a;if(n!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await T.runtime.sendMessage(o);return gu(o,l,this.logger)}catch(l){if(n==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await T.tabs.sendMessage(i,o);return gu(o,l,this.logger)}}};function gu(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new Gt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new Gt("noResponse","Unknown error")}function qi(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let a=parseInt(e[2]);if(!isNaN(a))r.id=a;else throw new Error("tab id not a valid number")}return r}var ih="";function Ui(){return ih||globalThis.navigator.userAgent}function hu(){return Ui().includes("ImtFxiOS")}function oh(){return Ui().includes("ImtFxAndroid")}function ji(){let t=Ui();if(hu()||oh()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),a=r[0];return r[2]&&(a+="_"+r[2]),{name:a,version:r[1]}}}return null}var en;function sh(){return en||(en=new sr("content_script",!1).getConnection("pure_main",()=>{}),en)}var fu="G-MKMD9LWFTR";async function Tu(t){try{let e=pe(),r=e.INSTALL_FROM==="firefox_store";if(ji()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let n=Ut(),i=mu(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Pt("fakeUserId","");s||(s=await na("fakeUserId",""),s&&await Wt("fakeUserId",s));let u=Er(),c=new Date,d=await Pt("installedAt","");d||(d=await na("installedAt",""),d&&await Wt("installedAt",d)),s?d||(d=new Date(0).toISOString(),await Wt("installedAt",d)):(s=lh(32),await Wt("fakeUserId",s)),d||(d=c.toISOString(),await Wt("installedAt",d));let h=new Date(d),b=bu(h),E=bu(c),ne=b===E,V=c.getTime()-h.getTime()<7*24*60*60*1e3,f=`https://www.google-analytics.com/mp/collect?measurement_id=${fu}&api_secret=${l}`;o||(f=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${fu}&api_secret=${l}`);let me="";typeof navigator<"u"&&(me=window.navigator.userAgent);let z=ya.parse(me),J=t.map(C=>{let g=C.params||{};if(z.os&&(g.os_name=z.os.name||"unknown",g.os_version=z.os.version||"unknown",g.os_version_name=z.os.versionName||"unknown"),z.browser){g.browser_name=z.browser.name||"unknown",g.browser_version=z.browser.version||"unknown";let S=ji();S&&(g.browser_name=S.name,g.browser_version=S.version)}return z.platform&&(g.platform_type=z.platform.type||"unknown"),z.engine&&(g.engine_name=z.engine.name||"unknown",g.engine_version=z.engine.version||"unknown"),u&&(g.version=u),e.INSTALL_FROM&&(g.install_from=e.INSTALL_FROM),b&&(g.install_day=uh(h)),g.userscript=n.toString(),ne?g.is_new_user_today="1":g.is_new_user_today="0",V?g.is_new_user_this_week="1":g.is_new_user_this_week="0",i?g.main_frame=0:g.main_frame=1,{...C,params:g}}),ue=await dh({responseType:"text",url:f,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:J})})}catch{}}function lh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let b=s.slice(0,h).trim();if(s=s.slice(h+1),b.startsWith("event:")||b==="")continue;let E="";if(b.startsWith("data:")&&(E=b.slice(5).trim()),E==="[DONE]")break;let ne;try{ne=JSON.parse(E??"")}catch(V){q.debug("json error",V);continue}u=ne}}return u}}else{let s;try{s=await l.text()}catch(b){q.error("parse response failed",b)}s&&q.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,h=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),h&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new Gt("fetchError",c).initNetWork(l.status)}}async function*eh(t){let e=t.getReader();try{for(;;){let{done:r,value:a}=await e.read();if(r)return;yield a}}finally{e.releaseLock()}}var th=new Map;function du(t){let e=rh(64),r=new CustomEvent(Hl,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((a,n)=>{th.set(e,(i,o)=>{i?n(i):a(o)})})}function rh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var nh="";function Er(){return nh||pu.version}function mu(){try{let t=[pe().EBOOK_BUILDER_URL,pe().EBOOK_VIEWER_URL,pe().SUBTITLE_BUILDER_URL,pe().HTML_VIEWER_URL,pe().PDF_VIEWER_URL].filter(n=>!!n),e=["app.immersivetranslate.com"];ut()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(n=>{let i=new URL(n);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var oa=new Map,sr=class{fromType;logger;constructor(e,r=!1){this.logger=new ra,r&&this.logger.setLevel("debug"),this.fromType=e,oa.has(e)||(oa.set(e,new Map),T.runtime.onMessage.addListener((a,n,i)=>{let o=a.from,l=a.to,s,u,c;n.tab&&n.tab.id&&(s=n.tab.id,o=`${o}:${s}`,u=n.tab.url,c=n.tab.active),this.logger.debug(`${a.to} received message [${a.payload.method}] from ${a.from}`,a.payload.data?a.payload.data:" ");let d=qi(l),{type:h,name:b}=d;if(h!==e)return!1;let E=qi(o),V=oa.get(h).get(b);if(!V)return this.logger.debug(`no message handler for ${h}:${l}, but it's ok`),!1;let{messageHandler:f,sync:me}=V,z={type:e,name:E.name,id:s,url:u,active:c};if(me){try{let J=f(a.payload,z);i({ok:!0,data:J})}catch(J){i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.details,errorStatus:J.status})}return!1}else return f(a.payload,z).then(J=>{i({ok:!0,data:J})}).catch(J=>{i({ok:!1,errorName:J.name,errorMessage:J.message,errorDetails:J.message,errorStatus:J.status})}),!0}))}getConnection(e,r,a){let n=!1;a&&a.sync&&(n=!0);let i=this.fromType,o=oa.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Ni(`${i}:${e}`,this.logger);return oa.get(i).set(e,{messageHandler:r,sync:n,connectionInstance:l}),l}}},Ni=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let a=qi(e),{type:n,id:i}=a;if(n!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await T.runtime.sendMessage(o);return gu(o,l,this.logger)}catch(l){if(n==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await T.tabs.sendMessage(i,o);return gu(o,l,this.logger)}}};function gu(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new Gt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new Gt("noResponse","Unknown error")}function qi(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let a=parseInt(e[2]);if(!isNaN(a))r.id=a;else throw new Error("tab id not a valid number")}return r}var ih="";function Ui(){return ih||globalThis.navigator.userAgent}function hu(){return Ui().includes("ImtFxiOS")}function oh(){return Ui().includes("ImtFxAndroid")}function ji(){let t=Ui();if(hu()||oh()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),a=r[0];return r[2]&&(a+="_"+r[2]),{name:a,version:r[1]}}}return null}var en;function sh(){return en||(en=new sr("content_script",!1).getConnection("pure_main",()=>{}),en)}var fu="G-MKMD9LWFTR";async function Tu(t){try{let e=pe(),r=e.INSTALL_FROM==="firefox_store";if(ji()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let n=Ut(),i=mu(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Pt("fakeUserId","");s||(s=await na("fakeUserId",""),s&&await Wt("fakeUserId",s));let u=Er(),c=new Date,d=await Pt("installedAt","");d||(d=await na("installedAt",""),d&&await Wt("installedAt",d)),s?d||(d=new Date(0).toISOString(),await Wt("installedAt",d)):(s=lh(32),await Wt("fakeUserId",s)),d||(d=c.toISOString(),await Wt("installedAt",d));let h=new Date(d),b=bu(h),E=bu(c),ne=b===E,V=c.getTime()-h.getTime()<7*24*60*60*1e3,f=`https://www.google-analytics.com/mp/collect?measurement_id=${fu}&api_secret=${l}`;o||(f=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${fu}&api_secret=${l}`);let me="";typeof navigator<"u"&&(me=window.navigator.userAgent);let z=ya.parse(me),J=t.map(C=>{let g=C.params||{};if(z.os&&(g.os_name=z.os.name||"unknown",g.os_version=z.os.version||"unknown",g.os_version_name=z.os.versionName||"unknown"),z.browser){g.browser_name=z.browser.name||"unknown",g.browser_version=z.browser.version||"unknown";let S=ji();S&&(g.browser_name=S.name,g.browser_version=S.version)}return z.platform&&(g.platform_type=z.platform.type||"unknown"),z.engine&&(g.engine_name=z.engine.name||"unknown",g.engine_version=z.engine.version||"unknown"),u&&(g.version=u),e.INSTALL_FROM&&(g.install_from=e.INSTALL_FROM),b&&(g.install_day=uh(h)),g.userscript=n.toString(),ne?g.is_new_user_today="1":g.is_new_user_today="0",V?g.is_new_user_this_week="1":g.is_new_user_this_week="0",i?g.main_frame=0:g.main_frame=1,{...C,params:g}}),ue=await dh({responseType:"text",url:f,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:J})})}catch{}}function lh(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=r.length,n=0;for(;n",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 diff --git a/dist/firefox/content_script.js b/dist/firefox/content_script.js index 9785ad4..ca8abc2 100644 --- a/dist/firefox/content_script.js +++ b/dist/firefox/content_script.js @@ -1,4 +1,4 @@ -(()=>{var e6=Object.create;var gd=Object.defineProperty;var t6=Object.getOwnPropertyDescriptor;var n6=Object.getOwnPropertyNames;var r6=Object.getPrototypeOf,a6=Object.prototype.hasOwnProperty;var i6=(t,e)=>()=>(t&&(e=t(t=0)),e);var o6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},s6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n6(e))!a6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=t6(e,a))||r.enumerable});return t};var u6=(t,e,n)=>(n=t!=null?e6(r6(t)):{},s6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=i6(()=>{x={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var e6=Object.create;var gd=Object.defineProperty;var t6=Object.getOwnPropertyDescriptor;var n6=Object.getOwnPropertyNames;var r6=Object.getPrototypeOf,a6=Object.prototype.hasOwnProperty;var i6=(t,e)=>()=>(t&&(e=t(t=0)),e);var o6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),eu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},s6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of n6(e))!a6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=t6(e,a))||r.enumerable});return t};var u6=(t,e,n)=>(n=t!=null?e6(r6(t)):{},s6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=i6(()=>{x={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5262,7 +5262,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Xo,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...W4,{type:"password",name:"apikey",required:!0}],props:W4},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},Zu={type:me+"ChildFrameToRootFrameIdentifier"},W0=["youtube","netflix","webvtt","khanacademy","bilibili","udemy","hulu","text_track","text_track_dynamic","general","live","ebutt","disneyplus","fmp4.xml","multi_attach_vtt","twitter","subsrt","xml","av"],es=["Ctrl","Shift","Alt","Auto","Off","OtherCustom","Other"],hb=["ctrl","alt","shift","cmd","command","option","control"];var ez=Qt()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general",K0="user_from_plugin",Ft="user_info",ts=Qt()||Rn()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",bb=Qt()||Rn()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",Tb=bb+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",yb=bb+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Xu=Qt()||Rn()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Ai=Qt()||Rn()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",ew=Qt()||Rn()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",tw=Qt()||Rn()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",nw=Qt()||Rn()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",tz=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",nz=ew+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",vb=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",el=Ai+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Sb=tw+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",xb=nw+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Eb=Xu+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true",Cb="https://immersivetranslate.com/docs/usage/";var wb=Me().TRANSLATE_FILE_URL,rz=wb+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",Db=wb+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var ki=console,G0=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=On.green;r>1e4?a=On.red:r>1e3&&(a=On.yellow),ki.debug(On.dim(Ua+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ns=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&ki.log(On.dim(Ua+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&ki.log(On.green(Ua+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&ki.warn(On.yellow(Ua+" WARN:"),...e)}error(...e){this.#e<=3&&ki.error(On.red(Ua+" ERROR:"),...e)}fatal(...e){this.#e<=4&&ki.error(On.red(Ua+" FATAL:"),...e)}timing(){return this.level===0?new G0:{reset:()=>{},stop:()=>{}}}},B=new ns;d();d();d();var V0=/iPhone/i,Ab=/iPod/i,kb=/iPad/i,Pb=/\biOS-universal(?:.+)Mac\b/i,$0=/\bAndroid(?:.+)Mobile\b/i,Lb=/Android/i,Pi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,tl=/Silk/i,Br=/Windows Phone/i,_b=/\bWindows(?:.+)ARM\b/i,Fb=/BlackBerry/i,Mb=/BB10/i,Bb=/Opera Mini/i,Ib=/\b(CriOS|Chrome)(?:.+)Mobile/i,Rb=/Mobile(?:.+)Firefox\b/i,Ob=t=>typeof t<"u"&&t.platform==="MacIntel"&&typeof t.maxTouchPoints=="number"&&t.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function rw(t){return e=>e.test(t)}function ut(t){let e={userAgent:"",platform:"",maxTouchPoints:0};!t&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof t=="string"?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0});let n=e.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=rw(n),i={apple:{phone:a(V0)&&!a(Br),ipod:a(Ab),tablet:!a(V0)&&(a(kb)||Ob(e))&&!a(Br),universal:a(Pb),device:(a(V0)||a(Ab)||a(kb)||a(Pb)||Ob(e))&&!a(Br)},amazon:{phone:a(Pi),tablet:!a(Pi)&&a(tl),device:a(Pi)||a(tl)},android:{phone:!a(Br)&&a(Pi)||!a(Br)&&a($0),tablet:!a(Br)&&!a(Pi)&&!a($0)&&(a(tl)||a(Lb)),device:!a(Br)&&(a(Pi)||a(tl)||a($0)||a(Lb))||a(/\bokhttp\b/i)},windows:{phone:a(Br),tablet:a(_b),device:a(Br)||a(_b)},other:{blackberry:a(Fb),blackberry10:a(Mb),opera:a(Bb),firefox:a(Rb),chrome:a(Ib),device:a(Fb)||a(Mb)||a(Bb)||a(Rb)||a(Ib)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var Y0="DENO",nl="CHROME",rl="FIREFOX";function zb(t){let e=nl;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?e=rl:/deno/i.test(n)&&(e=Y0)}catch{}return t===nl&&e===nl||t===rl&&e===rl||t===Y0&&e===Y0}function aw(){return zb(nl)}function Nb(){return typeof Deno<"u"}function Ir(){return zb(rl)}function al(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function rs(t){return!!(t?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function Ub(){return ye()?"monkey":aw()?"chrome":Ir()?"firefox":et()?"safari":null}d();var qb={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},jb={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:qb,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:qb,query:()=>{},sendMessage:()=>{}}};var oe;Nb()?oe=jb:oe=globalThis.immersiveTranslateBrowserAPI;d();d();d();d();d();var Dz=Wb(2),Hb=Wb(3);function Wb(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var iw=/\s+/g,ow=/[\t\n\v\f\r ]+/g;function Kb(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?sw:uw;return String(t).replace(e.style==="html"?ow:iw,e.trim?lw(n):n)}function sw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function uw(){return" "}function lw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var Gb={}.hasOwnProperty;function cw(t){return t==null?"":Kb(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function dw(t){return Hb(" "+cw(t)+" ")}function pw(t){let e=dw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function yw(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function vw(t,e,n,r){e=xw(e,n,r);let a=[],i;if(e)for(i in e)il.call(e,i)&&a.push([i,Sw(t,e[i])]);return a.length===0?J0():a.sort(Ew)}function Sw(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of Mw){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?e3(t)?"zh-TW":"zh-CN":e:"auto"}var n3=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Z0=new Map(n3),Bw=new Map(n3.map(([t,e])=>[e,t]));function r3(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>Bw.get(s));!e&&e!==0&&(e=25);let a=sl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Z0.keys()]},o=Yb(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&m<.95)break;return Z0.get(p)}}let[s,u]=o[0],l=Z0.get(s);if(l&&u>.9)return l}}catch(r){B.error(r)}return"auto"}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=kn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":kn[a]}else return"auto";else return kn[r]}function ht(){return Te(document?.documentElement?.lang||"en")}d();function Jt(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}function a3(t){if(t){let e=new Date(t.createTime),n=Iw(e),r="free",a="unknown";return t.subscription&&t.subscription.subscriptionStatus==="active"&&(r=t.subscription.subscriptionType),t.subscription&&t.subscription.subscriptionId&&(t.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function Iw(t){try{let n=t.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}d();var i3=me+"SyncStoreKey_";function At(t,e){let n=i3+t;return oe.storage.sync.get(n).then(r=>r[n]===void 0?e:r[n])}function Xe(t,e){let n=i3+t;return oe.storage.sync.set({[n]:e})}d();var o3=me+"StoreKey_";function Rr(t,e){let n=o3+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function s3(t,e){let n=o3+t;return oe.storage.local.set({[n]:e})}d();var Ha=me+"CacheKey_";function X0(t,e){let n=Ha+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function Rw(){let t=oe.storage.local.refresh;t&&t()}function ep(t,e){let n=Ha+t;return oe.storage.local.get(n).then(r=>{if(r[n]===void 0)return e;let{value:a,expired:i}=r[n];return i&&ir.startsWith(Ha)).filter(r=>r!==Ha+Ft);if(n.length>0)return oe.storage.local.remove(n)}}var Mt={get:X0,set:np,getExpired:ep,setExpired:tp,remove:rp,clear:u3,refresh:Rw};d();d();d();d();function l3(t,e){return[t,!t||t.endsWith("/")?"":"/",e,".json"].join("")}function ap(t,e){let n=t;return e&&Object.keys(e).forEach(r=>{let a=e[r];if(a===void 0)return;let i=Ow(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let p=n.substring(u+s.length,c),m=Object.keys(o).filter(g=>g!=="tag").map(g=>`${g}="${o[g]}"`).join(" ");n=n.replace(`${s}${p}`,`<${l} ${m}>${p}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function is(t,e,n){let r=t[e];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function mr(t,e,n,r,a){if(!t.hasOwnProperty(n))return e;let i=is(t,n,e);return i===e&&n!==r&&(i=is(t,r,e)),ap(i,a)}function Ow(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function kt(t,e,n){return mr(zt,e,t.config.interfaceLanguage,"en",n)}d();function c3(t,e){let n=new Date(t),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function d3(t){return new Date(t).getTime()}var $=class extends Error{status;constructor(e,n){if(e&&n){super(n),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let n=null;if(n=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!n){let r=kt.bind(null,e),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let n=kt.bind(null,e),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let n=kt.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let n=kt.bind(null,e),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(e){let n=kt.bind(null,e);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(e){let n=kt.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let n=kt.bind(null,e);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let p=this.data?.translationService=="deepl"?"OpenAI":"Deepl",m=this.data?.translationService=="deepl"?"Deepl":"OpenAI",g=n("errorReason",{message:r});if(i=="onetime_7day")g+=n("proQuotaExceededError.onetime7day",{anotherService:p,brandId:Q,href:el});else{let f="";m=="OpenAI"?f=Sb:f=xb,o?g+=n("proQuotaExceededError.trial",{anotherService:p,brandId:Q,href:Eb}):g+=n("proQuotaExceededError.nonTrial",{anotherService:p,brandId:Q,href:f,translationService:m}),!o&&(a.cancelAtPeriodEnd==="false"||d3(u)>s)&&(g+=n("proQuotaExceededError.resetTime",{resetTime:c3(s,"YYYY-MM-DD HH:mm:ss")}))}return g}}};async function Wa(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Sd(p3.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else e=await p3(t);return e}async function p3(t){t.body;let{url:e,responseType:n,...r}=t;n||(n="json"),r={mode:"cors",...r};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(e,r)}catch(u){B.debug("fetch error",e,u);let l=u.message||"Unknown Error";throw new $("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=e),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of zw(s.body)){let p=new TextDecoder().decode(c);u+=p;let m;for(;(m=u.indexOf(` -`))>=0;){let g=u.slice(0,m).trim();if(u=u.slice(m+1),g.startsWith("event:")||g==="")continue;let f="";if(g.startsWith("data:")&&(f=g.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){B.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(g){B.error("parse response failed",g)}u&&B.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,m=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),m&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*zw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Nw=new Map;function ul(t){let e=Uw(64),n=new CustomEvent(Hu,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Nw.set(e,(i,o)=>{i?a(i):r(o)})})}function Uw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var jw="";function Nt(){return jw||ll.version}function ip(){return oe.runtime.getManifest().version}d();function He(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var os=new Map,ea=class{fromType;logger;constructor(e,n=!1){this.logger=new ns,n&&this.logger.setLevel("debug"),this.fromType=e,os.has(e)||(os.set(e,new Map),oe.runtime.onMessage.addListener((r,a,i)=>{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=sp(s),{type:m,name:g}=p;if(m!==e)return!1;let f=sp(o),b=os.get(m).get(g);if(!b)return this.logger.debug(`no message handler for ${m}:${s}, but it's ok`),!1;let{messageHandler:h,sync:E}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(E){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=os.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new op(`${i}:${e}`,this.logger);return os.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},op=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=sp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return g3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return g3(o,s,this.logger)}}};function g3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function sp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var Hw="";function Li(){return Hw||globalThis.navigator.userAgent}function up(){return Li().includes("ImtFxiOS")}function m3(){let e=Li().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function Ww(){return Li().includes("ImtFxAndroid")}function f3(){let t=Li();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function h3(){let e=Li().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function ss(){let t=Li();if(up()||Ww()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var cl;function Kw(){return cl||(cl=new ea("content_script",!1).getConnection("pure_main",()=>{}),cl)}var b3="G-MKMD9LWFTR";async function us(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(ss()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=He(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Rr("fakeUserId",""),u&&await Xe("fakeUserId",u));let l=Nt(),c=new Date,p=await At("installedAt","");p||(p=await Rr("installedAt",""),p&&await Xe("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Xe("installedAt",p)):(u=Gw(32),await Xe("fakeUserId",u)),p||(p=c.toISOString(),await Xe("installedAt",p));let m=new Date(p),g=T3(m),f=T3(c),T=g===f,b=c.getTime()-m.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${b3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${b3}&api_secret=${s}`);let E="";typeof navigator<"u"&&(E=window.navigator.userAgent);let D=mi.parse(E),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let L=ss();L&&(y.browser_name=L.name,y.browser_version=L.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),g&&(y.install_day=Vw(m)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),I=await dl({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Gw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let g=u.slice(0,m).trim();if(u=u.slice(m+1),g.startsWith("event:")||g==="")continue;let f="";if(g.startsWith("data:")&&(f=g.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){B.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(g){B.error("parse response failed",g)}u&&B.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,m=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),m&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*zw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Nw=new Map;function ul(t){let e=Uw(64),n=new CustomEvent(Hu,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Nw.set(e,(i,o)=>{i?a(i):r(o)})})}function Uw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var jw="";function Nt(){return jw||ll.version}function ip(){return oe.runtime.getManifest().version}d();function He(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var os=new Map,ea=class{fromType;logger;constructor(e,n=!1){this.logger=new ns,n&&this.logger.setLevel("debug"),this.fromType=e,os.has(e)||(os.set(e,new Map),oe.runtime.onMessage.addListener((r,a,i)=>{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=sp(s),{type:m,name:g}=p;if(m!==e)return!1;let f=sp(o),b=os.get(m).get(g);if(!b)return this.logger.debug(`no message handler for ${m}:${s}, but it's ok`),!1;let{messageHandler:h,sync:E}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(E){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=os.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new op(`${i}:${e}`,this.logger);return os.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},op=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=sp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return g3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return g3(o,s,this.logger)}}};function g3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function sp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var Hw="";function Li(){return Hw||globalThis.navigator.userAgent}function up(){return Li().includes("ImtFxiOS")}function m3(){let e=Li().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function Ww(){return Li().includes("ImtFxAndroid")}function f3(){let t=Li();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function h3(){let e=Li().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function ss(){let t=Li();if(up()||Ww()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var cl;function Kw(){return cl||(cl=new ea("content_script",!1).getConnection("pure_main",()=>{}),cl)}var b3="G-MKMD9LWFTR";async function us(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(ss()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=He(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Rr("fakeUserId",""),u&&await Xe("fakeUserId",u));let l=Nt(),c=new Date,p=await At("installedAt","");p||(p=await Rr("installedAt",""),p&&await Xe("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Xe("installedAt",p)):(u=Gw(32),await Xe("fakeUserId",u)),p||(p=c.toISOString(),await Xe("installedAt",p));let m=new Date(p),g=T3(m),f=T3(c),T=g===f,b=c.getTime()-m.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${b3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${b3}&api_secret=${s}`);let E="";typeof navigator<"u"&&(E=window.navigator.userAgent);let D=mi.parse(E),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let L=ss();L&&(y.browser_name=L.name,y.browser_version=L.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),g&&(y.install_day=Vw(m)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),I=await dl({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Gw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5421,7 +5421,7 @@ Translate the content to {{to}} Language: `,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};d();d();function pl(t){if(t.beta)return!1;if(et()&&t.spVersion)return ls(ip(),t.spVersion);if(f3()&&t.gspVersion){let e=h3();if(e)return ls(e,t.gspVersion)}if(up()&&t.ispVersion){let e=m3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function lp(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function gl(t){return Array.isArray(t)?t:t?[t]:[]}function ml(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function fl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function hl(t,e){let n={...t};return x3(n,e),Qw(n,e),n}function S3(t,e,n){let r={...e};return Ka({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ka({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function Qw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;x3(t,a)}function Ka({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Jw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=gl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!y3(s))return;c=cp(l,u)}else if(o=="remove_v"){if(!y3(s))return;c=v3(l,u)}else o==="add"?c=cp(l,u):o=="remove"&&(c=v3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=cp(l,u):c=u,r(i,c)})}function x3(t,e){return Ka({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function cp(t,e){let n;if(Array.isArray(t)){let r=gl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Jw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function y3(t){let e=Nt();return t&&ls(e,t)}function v3(t,e){if(Array.isArray(t)){let n=gl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}function E3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Zt(){let t=await oe.storage.local.get(Qo);if(t[Qo]){let e=t[Qo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Xt(i),i}else return{}}async function Xt(t){await oe.storage.local.set({[Qo]:t})}async function C3(t){await oe.storage.local.set({[Xr]:t})}async function w3(){let t=await oe.storage.local.get(Xr),n={...await dp(),..._i,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Xr]){let r=t[Xr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Pn(){let t=await oe.storage.local.get(Xr),e={..._i,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Xr]){let C=t[Xr];if(C&&C.buildinConfigUpdatedAt){let P=new Date(C.buildinConfigUpdatedAt),U=new Date(e.buildinConfigUpdatedAt);P>U&&(e=C)}}let n=await eD(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let C=await oe.commands.getAll();for(let P of C)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await dp(),o=E3(),s=await Or(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Zt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let C=await Zw();p.interfaceLanguage=C}let m=p.interfaceLanguage==="en",g=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!m&&!g&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,E=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(E=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(E.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,I=await At("installedAt",""),S=Number(await Rr("translage_page_daily",0)),y=Number(await At(Xn,0)),L;y>0&&(Date.now()-y0&&(Date.now()-S0){let C=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(C.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],U=Array.isArray(P)?P:[P],H=Array.from(new Set(U.concat(C.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let _=Object.assign(i,e);Ka({rule:e,valueIsArray:C=>Array.isArray(i[C]),getMergedValue:C=>i[C],onMergedResult:(C,P)=>{C!="generalRule"&&(_[C]=P)}});let k=Jt(r),N={};p.translationServices&&p.translationServices.deepl&&(N=p.translationServices.deepl);let z={};p.translationServices&&p.translationServices.openai&&(z=p.translationServices.openai),!k&&N.authKey&&!N.provider?(_.translationServices.deepl||(_.translationServices.deepl={}),_.translationServices.deepl.provider="custom"):N&&N.provider||(_.translationServices.deepl||(_.translationServices.deepl={}),_.translationServices.deepl.provider="pro"),!k&&z.APIKEY&&!z.provider?(_.translationServices.openai||(_.translationServices.openai={}),_.translationServices.openai.provider="custom"):z&&z.provider||(_.translationServices.openai||(_.translationServices.openai={}),_.translationServices.openai.provider="pro");let q=Object.keys(_),F=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let C of q){let P=C;if(P==="generalRule")typeof p[P]=="object"&&(_[P]=hl(i[P],p[P]));else if(P==="translationServices")tD(p,_);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&F.includes(P))p[P]&&(_[P]=Object.assign(_[P],p[P])),P==="shortcuts"&&(ye()||et()?_[P]={..._[P],...a}:_[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let U=_.rules||[],H={};for(let W of U)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?S3(e.generalRule,H[W.id],W):W);_[P]=[...j,..._[P]]}if(we.PROD==="0"&&we.DEV_RULES){let U=JSON.parse(we.DEV_RULES);_[P]=[...U,..._[P]]}}else p[P]!==void 0&&(_[P]=p[P])}return _.donateUrl=e.donateUrl,_.minVersion=e.minVersion,_.feedbackUrl=e.feedbackUrl,_.rawUserConfig=s,_}async function Or(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function cs(t){await oe.storage.sync.set({userConfig:t})}async function ds(t,e){await oe.storage.local.set({[t]:e})}async function bl(t){return(await oe.storage.local.get(t))[t]||""}var Zw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){B.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>zt[r]);return n||"en"},dp=async()=>{let t={..._i,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:pr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Xw(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function eD(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return pr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ka({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ka({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}d();d();function ta(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function nD(t,e){return t<>>32-e}function yl(t,e,n,r,a,i){return ta(nD(ta(ta(e,t),ta(r,i)),a),n)}function en(t,e,n,r,a,i,o){return yl(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return yl(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return yl(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return yl(n^(e|~r),t,e,a,i,o)}function Tl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function pp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Tl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Tl(a.concat(pp(e)),512+e.length*8),D3(Tl(i.concat(o),512+128))}function A3(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function gp(t){return unescape(encodeURIComponent(t))}function k3(t){return rD(gp(t))}function iD(t){return A3(k3(t))}function P3(t,e){return aD(gp(t),gp(e))}function oD(t,e){return A3(P3(t,e))}function Ln(t,e,n){return e?n?P3(e,t):oD(e,t):n?k3(t):iD(t)}d();function L3(t,e,n){let r=sD(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function sD(t,e){let n=[],r=[];for(let a=0;a0?Te){let E=[];mp(b,e,E);for(let D=0;D0&&T{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&mp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?g.push(T):m.push(T))});let f=g.concat(m).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:g,explicitProps:m}}var ps=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Jt(s),l=Object.keys(gr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=gr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&et())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let m=!!p.canary,g=!!p.alpha,f=!!p.beta;return c===t[e]||m&&i||g&&(r||i)||f&&(a||r||i)?!0:!g&&!f&&!m}).map(c=>vl(e,c,t))};function gs(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function _3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}var Fi=[];async function Sl(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function F3(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await cD(e,t)}async function M3(t){let e=Ln(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await lD(n,e)}async function lD(t,e){let n=await Sl(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function cD(t,e){let n=await Sl(t);return(await pD()).includes(t)||await dD(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function dD(t){let e="cache_list",n=await Sl(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Fi.push(t)},a.onerror=i=>{n.close()}}async function pD(){if(Fi&&Fi.length>0)return Fi;let t=await Sl(Q+"-cacheList","cache_list");return Fi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Fi}d();d();var fp="Original";function Qe(){return fp}function gn(t){fp=t,B3(fp)}d();var R3="auto",xl="auto",I3="auto";function O3(t){R3=t}function qn(t){xl=t}function vt(){return xl!=="auto"?xl:I3!=="auto"?I3:R3}function El(){return xl}d();function Ga(t){return t?.id?.endsWith("pdfWebPage")||!1}function ra(t){try{if(!t||!Ga(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Je={},aa=async function(t,e){let{method:n,data:r}=t,a=await Je.updateGlobalContext(),i=Date.now();if(B.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Je.translateTheWholePage(r),Xe(Xn,i);else if(n==="translateTheMainPage")await Je.translateTheMainPage(r),Xe(Xn,i);else if(n==="translateToThePageEndImmediately")await Je.translateToThePageEndImmediately(r),Xe(Xn,i);else if(n==="toggleTranslatePage")await Je.toggleTranslatePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheWholePage")await Je.toggleTranslateTheWholePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheMainPage")await Je.toggleTranslateTheMainPage(r),Xe(Xn,i);else if(n==="toggleOnlyTransation")await Je.ensureSwitchTranslationMode(r),Xe(Xn,i);else if(n==="translatePage")await Je.translatePage(a,r),Xe(Xn,i);else if(n==="toggleTranslationMask")await Je.toggleTranslationMask(r);else if(n==="restorePage")Je.restorePage();else if(n==="retryFailedParagraphs")Je.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Je.switchTranslationMode(r.mode),await Je.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Je.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Ku,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Je.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Yo,{detail:r}));else if(n==="translateWithOpenAI")await Je.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Je.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Je.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Je.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Je.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Je.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Je.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")He()||await Je.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!He())return JSON.stringify(a)}};function z3(t){Object.assign(Je,t)}function N3(t){Object.assign(Je,t)}function U3(t){Object.assign(Je,t)}var gD=function(t,e){let{method:n,data:r}=t;if(B.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Qe();if(n==="getCurrentPageLanguage"){let a=vt();return Je.detectCurrentPageLanguage().catch(i=>{B.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return qn(r),vt();if(n==="getContextString"){let a=Je.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Je.getPureGlobalContext();return ra(a?.rule)}}},Cl,wl;function q3(){let t=Dl();He()||mD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Dl(){return Cl||(Cl=new ea("content_script",!1).getConnection("main",aa),Cl)}function mD(){return wl||(wl=new ea("content_script",!1).getConnection("main_sync",gD,{sync:!0}),wl)}d();var hp=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Al="https://transmart.qq.com/api/imt",zr=class t{static langMapReverse=new Map(hp.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await ce({url:Al,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function fD(t,e){return Math.floor(Math.random()*(e-t+1))+t}var hD=30,bp="RATE_LIMITER_TICKS",Mi=class t{static strictTicks={};static clearStrictTicks(){ds(bp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await bl(bp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){B.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await ds(bp,JSON.stringify(this.strictTicks))}catch(a){B.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=fD(4,hD);await vr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function St(t){return await Dl().sendMessage("background:main",t)}function ce(t){return au()?ul({method:"request",data:t}):ye()||ru()?(t.fetchPolyfill=globalThis.GM_fetch,Wa(t)):St({method:"fetch",data:t})}function an(){return ye()?Pn():St({method:"getConfig"})}function mn(t){return ye()?cs(t):St({method:"setUserConfig",data:t})}function fn(){return ye()?Or():St({method:"getUserConfig"})}function ms(){return ye()?Zt():St({method:"getLocalConfig"})}function kl(t){return ye()?Xt(t):St({method:"setLocalConfig",data:t})}function j3(t){return ye()?C3(t):St({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=sl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||et()){if(t.translateService&&!Ju.includes(t.translateService))return Promise.resolve("auto");let r=r3(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await St({method:"detectLanguage",data:t});return Promise.resolve(e)}function H3(){return St({method:"detectTabLanguage"})}async function Pl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||et()){let n=t.substring(0,200);e=await zr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function B3(t){let e=new CustomEvent(ja,{detail:t});if(document.dispatchEvent(e),ye())return;Dl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function W3(t){return ye()?M3(t):St({method:"queryParagraphCache",data:t})}async function K3(t){if(ye()){await F3(t);return}return St({method:"setParagraphCache",data:t})}async function G3(){if(ye())return Promise.resolve();await St({method:"mockRequest"})}function Bi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):St({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function Ii(t=""){return ye()||et()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function V3(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Ll(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):St({method:"openAboutPage"})}function Ri(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):St({method:"openInTab",data:t})}function $3(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):St({method:"openEbookViewerPage"})}function Y3(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):St({method:"openEbookBuilderPage"})}function _l(t){et()}function Oi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):St({method:"openPdfViewerPage",data:{url:e}})}function Q3(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):St({method:"openSubtitleBuilderPage"})}function zi(t){return ye()?Promise.resolve():St({method:"setBadge",data:{text:t}})}function J3(){return ye()?(B.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):St({method:"autoSyncLatestConfig"})}function Fl(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function Z3(t,e){return ye()?Mi.getDelay(t,e):St({method:"getDelay",data:{key:t,options:e}})}var X3="G-MKMD9LWFTR";async function it(t,e,n){try{let r=ss(),a=Me(),i=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(i=!1);let o=ye(),s=He(),u=a.PROD==="1",l=`report_${t}`,c=t.endsWith("_daily");if(c){if(s)return;let A=await Rr(l,0),v=Ml(new Date(A)),O=Date.now(),_=Ml(new Date(O));if(v===_)return;await s3(l,O)}else if(!n.config.telemetry)return;let p="sitc4WmvShWYwfU0dANM3Q",m=await At("fakeUserId","");m||(m=await Rr("fakeUserId",""),m&&await Xe("fakeUserId",m));let g=Nt(),f=new Date,T=await At("installedAt","");T||(T=await Rr("installedAt",""),T&&await Xe("installedAt",T)),m?T||(T=new Date(0).toISOString(),await Xe("installedAt",T)):(m=bD(32),await Xe("fakeUserId",m)),T||(T=f.toISOString(),await Xe("installedAt",T));let b=new Date(T),h=Ml(b),E=Ml(f),D=h===E,M=f.getTime()-b.getTime()<7*24*60*60*1e3,I=`https://www.google-analytics.com/mp/collect?measurement_id=${X3}&api_secret=${p}`;u||(I=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${X3}&api_secret=${p}`);let S=mi.parse(window.navigator.userAgent),y=e.map(A=>{let v=A.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser&&(v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown",r&&(v.browser_name=r.name,v.browser_version=r.version)),S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),n.translationService&&(v.translation_service||(v.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(v.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?v.openai_is_official="1":v.openai_is_official="0":v.openai_is_official="1"))),n.targetLanguage&&(v.target_language=n.targetLanguage),n.config.interfaceLanguage&&(v.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?v.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":v.enable_default_always_translated_urls="0",g&&(v.version=g),n.config.enableInputTranslation?v.enable_input_translation=n.config.enableInputTranslation?"1":"0":v.enable_input_translation="0",n.config.translationTheme&&(v.translation_theme=n.config.translationTheme),n.config.alpha&&(v.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?v.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):v.always_translate_languages="none",a.INSTALL_FROM&&(v.install_from=a.INSTALL_FROM),n.config.beta&&(v.beta=n.config.alpha.toString()),n.config.translationArea&&(v.translation_area=n.config.translationArea),h&&(v.install_day=TD(b)),n.user){let _=a3(n.user);_&&Object.keys(_).forEach(k=>{v[k]=_[k]})}else v.user_type="anonymous";n.config.translationMode&&(v.translation_mode=n.config.translationMode),v.userscript=o.toString(),D?v.is_new_user_today="1":v.is_new_user_today="0",M?v.is_new_user_this_week="1":v.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?v.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():v.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),v.page_type=O,s?v.main_frame=0:v.main_frame=1,!c){let _=n.url;try{let k=new URL(_);v.site_host=k.hostname}catch{v.site_host="unknown"}n.sourceLanguage&&(v.source_language=n.sourceLanguage)}return{...A,params:v}});if(i)return;let L=await ce({responseType:"text",url:I,method:"POST",body:JSON.stringify({client_id:m,user_id:m,events:y})})}catch{}}function bD(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;ae.removeEventListener("message",n)),t.length=0}function xD(t,e,n,r){return new Promise(a=>{let i=o=>{let s=o.data;vD(e,n,s)&&s.id===r&&(t.removeEventListener("message",i),a(s.response))};t.addEventListener("message",i)})}function ED(t,e,n,r){let a=i=>{let o=i.data;a1(e,"tell",n,o)&&r(o.body)};return t.addEventListener("message",a),[t,a]}function e1(t,e,n,r,a,i){let o=async s=>{let u=s.data;if(a1(n,"ask",r,u)){let l=await i(u.body);e=s.source,e.postMessage(yD(n,r,u.id,l),s.origin)}};return t.addEventListener("message",o),[t,o]}function CD(t,e,n,r,a){let i=Math.random().toString();return t.postMessage(r1(e,"tell",n,i,r),a)}async function t1(t,e,n,r,a,i,o){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let p=setTimeout(()=>c(new Error(`Failed to get response within ${o}ms`)),o),m=await xD(t,n,r,s);clearTimeout(p),l(m)});return e.postMessage(r1(n,"ask",r,s,a),i),u}var oa=class t{constructor(e,n,r=window,a="*"){this.protocol=e;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;e1(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(e,n=10,r=500){for(let a=0;a<=n;a++)try{return await e.ping({timeout:r}),e}catch{continue}throw new Error(`Could not connect on protocol ${e.protocol.type} after ${n*r}ms`)}static parent(e,n,r="*",a=window){let i=n.contentWindow;if(ia(i))return new t(e,i,a,r);throw new Error("iframe.contentWindow was null")}static iframe(e,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new t(e,a,r,n)}static rootIframe(e,n="*",{thisWindow:r=window}={}){return new t(e,null,r,n)}getSystemProtocol(e){return{type:`system|${e}`}}listeners=[];async ping({timeout:e=1e4}){await t1(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,e)}handleTell(e,n){this.listeners.push(ED(this.thisWindow,this.protocol,e,n))}tell(e,n){CD(this.targetWindow,this.protocol,e,n,this.targetOrigin)}handleAsk(e,n){this.listeners.push(e1(this.thisWindow,this.targetWindow,this.protocol,e,this.targetOrigin,n))}ask(e,n,r=1e4){if(this.targetWindow)return t1(this.thisWindow,this.targetWindow,this.protocol,e,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){SD(this.listeners)}};var i1;async function o1(){if(He()){let e=globalThis;for(;e.top!=e.self;)e=e.top;let n=oa.iframe(Zu,"*",{targetWindow:e});i1=n,await oa.connect(n).catch(r=>{B.error("connect with parent frame error",r)})}}function s1(){return i1}d();function u1(t,e){let n=e.matches||[],r=e.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(t)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(t))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(t)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(t))return!0}return!1}d();d();d();d();d();d();function l1(t){return t.replace(//g,">")}d();var Bl=!1,wD=ye();function c1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function DD(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&d1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(sa(i,$u)){if(a===!0)return!0;continue}if(fs(i.nodeName,e.inlineTags))return!0;if(!Tp(i,e))return!1}}return!0}function yp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(fs(t.nodeName,n)||Tp(t,e)){if(sa(t,ob)||fs(t.nodeName,["BR"]))return!1;if(sa(t,$u))return!0;if(Tp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return DD(t,e)}else return sa(t,$u);return!1}function d1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&sa(t,ib,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&sa(t,J4))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||fs(t.nodeName,i))}function Ni(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!g1(r)&&r.length>=n}function p1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(g1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function g1(t){for(let e=0;e127)return!1;return!0}function m1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function f1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function h1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function b1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function T1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function sa(t,e,n=!1){return vp(t,e,"1",n)}function vp(t,e,n,r=!1){return Bl&&!r?t[xn]?!!(t[xn]&&t[xn][e]===n):!1:t.dataset[e]===n}function Ui(t){return(t.innerText||t.textContent||"").trim()}function Sp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Il(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function lt(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(Bl&&!r?(t[xn]||(t[xn]={}),t[xn][e]||(t[xn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Rl(t,e,n=!1){if(Bl&&!n){if(!t[xn]||!t[xn][e])return;delete t[xn][e]}else delete t.dataset[e]}function qi(t,e,n=!1){return Bl&&!n?!t[xn]||!t[xn][e]?void 0:t[xn][e]:t.dataset[e]}function Tp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!fs(t.nodeName,n)}function Ee(){if(!globalThis||!globalThis.location)return"https://example.com";if(!He())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function En(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){B.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else B.warn("injectCSS failed, rootDocument does not have head node",t)}function ji(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(wD){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function fs(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function y1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function v1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||d1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return B.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function S1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();d();d();var ql,Fe,D1,AD,hs,x1,A1,zl={},k1=[],kD=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function ua(t,e){for(var n in e)t[n]=e[n];return t}function P1(t){var e=t.parentNode;e&&e.removeChild(t)}function Ep(t,e,n){var r,a,i,o={};for(i in e)i=="key"?r=e[i]:i=="ref"?a=e[i]:o[i]=e[i];if(arguments.length>2&&(o.children=arguments.length>3?ql.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)o[i]===void 0&&(o[i]=t.defaultProps[i]);return Ol(t,o,r,a,null)}function Ol(t,e,n,r,a){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:a??++D1};return a==null&&Fe.vnode!=null&&Fe.vnode(i),i}function qt(t){return t.children}function Hi(t,e){this.props=t,this.context=e}function Wi(t,e){if(e==null)return t.__?Wi(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e0?Ol(g.type,g.props,g.key,g.ref?g.ref:null,g.__v):g)!=null){if(g.__=n,g.__b=n.__b+1,(m=h[c])===null||m&&g.key==m.key&&g.type===m.type)h[c]=void 0;else for(p=0;p=n.__.length&&n.__.push({__V:jl}),n.__[t]}function se(t){return bs=1,FD(G1,t)}function FD(t,e,n){var r=Wl(Ts++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):G1(void 0,e),function(i){var o=r.__N?r.__N[0]:r.__[0],s=r.t(o,i);o!==s&&(r.__N=[s,r.__[1]],r.__c.setState({}))}],r.__c=wt,!wt.u)){wt.u=!0;var a=wt.shouldComponentUpdate;wt.shouldComponentUpdate=function(i,o,s){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return c.__c});if(u.every(function(c){return!c.__N}))return!a||a.call(this,i,o,s);var l=!1;return u.forEach(function(c){if(c.__N){var p=c.__[0];c.__=c.__N,c.__N=void 0,p!==c.__[0]&&(l=!0)}}),!!l&&(!a||a.call(this,i,o,s))}}return r.__N||r.__}function Ae(t,e){var n=Wl(Ts++,3);!Fe.__s&&K1(n.__H,e)&&(n.__=t,n.i=e,wt.__H.__h.push(n))}function Ve(t){return bs=5,Ue(function(){return{current:t}},[])}function Ue(t,e){var n=Wl(Ts++,7);return K1(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function $e(t,e){return bs=8,Ue(function(){return t},e)}function Kl(t){var e=wt.context[t.__c],n=Wl(Ts++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(wt)),e.props.value):t.__}function MD(){for(var t;t=W1.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Hl),t.__H.__h.forEach(Dp),t.__H.__h=[]}catch(e){t.__H.__h=[],Fe.__e(e,t.__v)}}Fe.__b=function(t){typeof t.type!="function"||t.o||t.type===qt?t.o||(t.o=t.__&&t.__.o?t.__.o:""):t.o=(t.__&&t.__.o?t.__.o:"")+(t.__&&t.__.__k?t.__.__k.indexOf(t):0),wt=null,z1&&z1(t)},Fe.__r=function(t){N1&&N1(t),Ts=0;var e=(wt=t.__c).__H;e&&(wp===wt?(e.__h=[],wt.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=jl,n.__N=n.i=void 0})):(e.__h.forEach(Hl),e.__h.forEach(Dp),e.__h=[])),wp=wt},Fe.diffed=function(t){U1&&U1(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(W1.push(e)!==1&&O1===Fe.requestAnimationFrame||((O1=Fe.requestAnimationFrame)||BD)(MD)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==jl&&(n.__=n.__V),n.i=void 0,n.__V=jl})),wp=wt=null},Fe.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Hl),n.__h=n.__h.filter(function(r){return!r.__||Dp(r)})}catch(r){e.some(function(a){a.__h&&(a.__h=[])}),e=[],Fe.__e(r,n.__v)}}),q1&&q1(t,e)},Fe.unmount=function(t){j1&&j1(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Hl(r)}catch(a){e=a}}),n.__H=void 0,e&&Fe.__e(e,n.__v))};var H1=typeof requestAnimationFrame=="function";function BD(t){var e,n=function(){clearTimeout(r),H1&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);H1&&(e=requestAnimationFrame(n))}function Hl(t){var e=wt,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),wt=e}function Dp(t){var e=wt;t.__c=t.__(),wt=e}function K1(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function G1(t,e){return typeof e=="function"?e(t):e}d();var V1=["*://*/*","*","*://*"],Y1="immersive-translate-wildcard-placeholder.com";function Ap(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>V1.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(V1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return RD(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,Y1),m;try{m=new URL(p)}catch{return B.debug("invalid match pattern",p,"raw match value:",c),!1}let g=m.host,f=m.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=ID(l+":",$1(g),$1(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function $1(t){return t.replaceAll(Y1,"*")}function ID(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function dt(t,e){return Ap(t,e)!==null}function RD(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}var OD=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function Cn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(Cn(t,i))return!1;if(Cn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!Cn(t,o)),c;function p(){return n&&n.display?!!OD.includes(n.display):Cn(t,r)}}var Kt=Cn;function $a(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function ys(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function fr(t,e=!1){let n=Xo;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Va(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return fr(n,e)}function Vi(t,e){return na(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function kp(t){let{rule:e}=t,n=zD(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function zD(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function vs(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",yt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),lt(r,rb,e.toString());let a=kp(t);return r.append(Ye.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function $i(t,e){return t.querySelector(`[${q0}='${e}']`)}function Q1(){document.querySelectorAll(`[${q0}]`).forEach(e=>{e.remove()})}function J1(){document.querySelectorAll(`.${yt}-error`).forEach(e=>{e.remove()})}function Z1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{ji(n)&&e.push(n)}),e}function Pp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},m=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),g=new RegExp(a.replace("{word}",m.map(f=>f.k).join("|")),"g");l=l.replace(g,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let m=new RegExp(p,"gi");l=l.replace(m,(g,f)=>{let T=c++;return e[`${T}`]=l1(f),o.length>2?g.replace(f,`<${o[2]}${T}>`):g.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){B.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function Ss(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||T1(s)||m1(s)||b1(s)||f1(s)||h1(s)||UD(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ni(i,n,r)}function Nr(t){return t.nodeType===Node.ELEMENT_NODE}function X1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Lp(){return await At("fakeUserId","")}async function ND(){return await At("installedAt","")}async function Gl(t){let n=Me().INSTALL_FROM,r=Nt(),a=await ND(),i=await Lp(),o=await Pn(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Jt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function e2(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await Fp(t,e);r(a)})()},[t,e,r]),n}async function Fp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!et()&&ye()||ut().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>dt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>dt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}d();function Mp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(lb),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${H0}-theme-${t}`):a.push(`${j0}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(H0):a.push(j0),a}function Bp(t){let e=["notranslate",Qu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function a2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Va(n,!0),m="afterend",g=p[0],f=p[1],T=`${g}(\\d+)${f}`,b=new RegExp(T,"g"),h=Ye.sanitize(u);o.length>0&&(h=h.replace(b,I=>{let S=h.indexOf(I),y=h[S-1]===" ",L=h[S+I.length]===" ",v=I.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),O=Number(v);if(isNaN(O))return I;let _=o[O];if(_&&_.type==="element"){let k=_.value.outerHTML;return y||(k=" "+k),L||(k=k+" "),k}else B.error("variable type not supported",_,I);return I}));let E=Mp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&E.push(ub);let D=Bp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${E.join(" ")}" ${dr}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${dr}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${dr}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:m}}function Vl(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";m&&(T=ca(Ip(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let E=Rp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",I=ys(E+D+M),S=I[0]+h+I[1];if(E===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=ys(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Rp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);m&&(b=ca(Ip(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",E=ys(T+b+h),D=E[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+E[1];if(T===" ")D=D.trimStart();else{let M=ys(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Rp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Ip(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(m=s[c-1].text),c/g,">"))}t.targetText=Ye.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` +`)}n.push(...g)}for(let a=0;a{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&mp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?g.push(T):m.push(T))});let f=g.concat(m).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:g,explicitProps:m}}var ps=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Jt(s),l=Object.keys(gr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=gr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&et())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let m=!!p.canary,g=!!p.alpha,f=!!p.beta;return c===t[e]||m&&i||g&&(r||i)||f&&(a||r||i)?!0:!g&&!f&&!m}).map(c=>vl(e,c,t))};function gs(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function _3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}var Fi=[];async function Sl(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function F3(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await cD(e,t)}async function M3(t){let e=Ln(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await lD(n,e)}async function lD(t,e){let n=await Sl(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function cD(t,e){let n=await Sl(t);return(await pD()).includes(t)||await dD(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function dD(t){let e="cache_list",n=await Sl(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Fi.push(t)},a.onerror=i=>{n.close()}}async function pD(){if(Fi&&Fi.length>0)return Fi;let t=await Sl(Q+"-cacheList","cache_list");return Fi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Fi}d();d();var fp="Original";function Qe(){return fp}function gn(t){fp=t,B3(fp)}d();var R3="auto",xl="auto",I3="auto";function O3(t){R3=t}function qn(t){xl=t}function vt(){return xl!=="auto"?xl:I3!=="auto"?I3:R3}function El(){return xl}d();function Ga(t){return t?.id?.endsWith("pdfWebPage")||!1}function ra(t){try{if(!t||!Ga(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Je={},aa=async function(t,e){let{method:n,data:r}=t,a=await Je.updateGlobalContext(),i=Date.now();if(B.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Je.translateTheWholePage(r),Xe(Xn,i);else if(n==="translateTheMainPage")await Je.translateTheMainPage(r),Xe(Xn,i);else if(n==="translateToThePageEndImmediately")await Je.translateToThePageEndImmediately(r),Xe(Xn,i);else if(n==="toggleTranslatePage")await Je.toggleTranslatePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheWholePage")await Je.toggleTranslateTheWholePage(r),Xe(Xn,i);else if(n==="toggleTranslateTheMainPage")await Je.toggleTranslateTheMainPage(r),Xe(Xn,i);else if(n==="toggleOnlyTransation")await Je.ensureSwitchTranslationMode(r),Xe(Xn,i);else if(n==="translatePage")await Je.translatePage(a,r),Xe(Xn,i);else if(n==="toggleTranslationMask")await Je.toggleTranslationMask(r);else if(n==="restorePage")Je.restorePage();else if(n==="retryFailedParagraphs")Je.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Je.switchTranslationMode(r.mode),await Je.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Je.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Ku,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Je.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Yo,{detail:r}));else if(n==="translateWithOpenAI")await Je.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Je.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Je.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Je.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Je.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Je.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Je.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")He()||await Je.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!He())return JSON.stringify(a)}};function z3(t){Object.assign(Je,t)}function N3(t){Object.assign(Je,t)}function U3(t){Object.assign(Je,t)}var gD=function(t,e){let{method:n,data:r}=t;if(B.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Qe();if(n==="getCurrentPageLanguage"){let a=vt();return Je.detectCurrentPageLanguage().catch(i=>{B.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return qn(r),vt();if(n==="getContextString"){let a=Je.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Je.getPureGlobalContext();return ra(a?.rule)}}},Cl,wl;function q3(){let t=Dl();He()||mD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Dl(){return Cl||(Cl=new ea("content_script",!1).getConnection("main",aa),Cl)}function mD(){return wl||(wl=new ea("content_script",!1).getConnection("main_sync",gD,{sync:!0}),wl)}d();var hp=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Al="https://transmart.qq.com/api/imt",zr=class t{static langMapReverse=new Map(hp.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await ce({url:Al,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function fD(t,e){return Math.floor(Math.random()*(e-t+1))+t}var hD=30,bp="RATE_LIMITER_TICKS",Mi=class t{static strictTicks={};static clearStrictTicks(){ds(bp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await bl(bp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){B.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await ds(bp,JSON.stringify(this.strictTicks))}catch(a){B.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=fD(4,hD);await vr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function St(t){return await Dl().sendMessage("background:main",t)}function ce(t){return au()?ul({method:"request",data:t}):ye()||ru()?(t.fetchPolyfill=globalThis.GM_fetch,Wa(t)):St({method:"fetch",data:t})}function an(){return ye()?Pn():St({method:"getConfig"})}function mn(t){return ye()?cs(t):St({method:"setUserConfig",data:t})}function fn(){return ye()?Or():St({method:"getUserConfig"})}function ms(){return ye()?Zt():St({method:"getLocalConfig"})}function kl(t){return ye()?Xt(t):St({method:"setLocalConfig",data:t})}function j3(t){return ye()?C3(t):St({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=sl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||et()){if(t.translateService&&!Ju.includes(t.translateService))return Promise.resolve("auto");let r=r3(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await St({method:"detectLanguage",data:t});return Promise.resolve(e)}function H3(){return St({method:"detectTabLanguage"})}async function Pl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||et()){let n=t.substring(0,200);e=await zr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function B3(t){let e=new CustomEvent(ja,{detail:t});if(document.dispatchEvent(e),ye())return;Dl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function W3(t){return ye()?M3(t):St({method:"queryParagraphCache",data:t})}async function K3(t){if(ye()){await F3(t);return}return St({method:"setParagraphCache",data:t})}async function G3(){if(ye())return Promise.resolve();await St({method:"mockRequest"})}function Bi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):St({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function Ii(t=""){return ye()||et()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function V3(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Ll(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):St({method:"openAboutPage"})}function Ri(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):St({method:"openInTab",data:t})}function $3(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):St({method:"openEbookViewerPage"})}function Y3(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):St({method:"openEbookBuilderPage"})}function _l(t){et()}function Oi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):St({method:"openPdfViewerPage",data:{url:e}})}function Q3(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):St({method:"openSubtitleBuilderPage"})}function zi(t){return ye()?Promise.resolve():St({method:"setBadge",data:{text:t}})}function J3(){return ye()?(B.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):St({method:"autoSyncLatestConfig"})}function Fl(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function Z3(t,e){return ye()?Mi.getDelay(t,e):St({method:"getDelay",data:{key:t,options:e}})}var X3="G-MKMD9LWFTR";async function it(t,e,n){try{let r=ss(),a=Me(),i=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(i=!1);let o=ye(),s=He(),u=a.PROD==="1",l=`report_${t}`,c=t.endsWith("_daily");if(c){if(s)return;let A=await Rr(l,0),v=Ml(new Date(A)),O=Date.now(),_=Ml(new Date(O));if(v===_)return;await s3(l,O)}else if(!n.config.telemetry)return;let p="sitc4WmvShWYwfU0dANM3Q",m=await At("fakeUserId","");m||(m=await Rr("fakeUserId",""),m&&await Xe("fakeUserId",m));let g=Nt(),f=new Date,T=await At("installedAt","");T||(T=await Rr("installedAt",""),T&&await Xe("installedAt",T)),m?T||(T=new Date(0).toISOString(),await Xe("installedAt",T)):(m=bD(32),await Xe("fakeUserId",m)),T||(T=f.toISOString(),await Xe("installedAt",T));let b=new Date(T),h=Ml(b),E=Ml(f),D=h===E,M=f.getTime()-b.getTime()<7*24*60*60*1e3,I=`https://www.google-analytics.com/mp/collect?measurement_id=${X3}&api_secret=${p}`;u||(I=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${X3}&api_secret=${p}`);let S=mi.parse(window.navigator.userAgent),y=e.map(A=>{let v=A.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser&&(v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown",r&&(v.browser_name=r.name,v.browser_version=r.version)),S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),n.translationService&&(v.translation_service||(v.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(v.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?v.openai_is_official="1":v.openai_is_official="0":v.openai_is_official="1"))),n.targetLanguage&&(v.target_language=n.targetLanguage),n.config.interfaceLanguage&&(v.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?v.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":v.enable_default_always_translated_urls="0",g&&(v.version=g),n.config.enableInputTranslation?v.enable_input_translation=n.config.enableInputTranslation?"1":"0":v.enable_input_translation="0",n.config.translationTheme&&(v.translation_theme=n.config.translationTheme),n.config.alpha&&(v.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?v.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):v.always_translate_languages="none",a.INSTALL_FROM&&(v.install_from=a.INSTALL_FROM),n.config.beta&&(v.beta=n.config.alpha.toString()),n.config.translationArea&&(v.translation_area=n.config.translationArea),h&&(v.install_day=TD(b)),n.user){let _=a3(n.user);_&&Object.keys(_).forEach(k=>{v[k]=_[k]})}else v.user_type="anonymous";n.config.translationMode&&(v.translation_mode=n.config.translationMode),v.userscript=o.toString(),D?v.is_new_user_today="1":v.is_new_user_today="0",M?v.is_new_user_this_week="1":v.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?v.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():v.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),v.page_type=O,s?v.main_frame=0:v.main_frame=1,!c){let _=n.url;try{let k=new URL(_);v.site_host=k.hostname}catch{v.site_host="unknown"}n.sourceLanguage&&(v.source_language=n.sourceLanguage)}return{...A,params:v}});if(i)return;let L=await ce({responseType:"text",url:I,method:"POST",body:JSON.stringify({client_id:m,user_id:m,events:y})})}catch{}}function bD(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;ae.removeEventListener("message",n)),t.length=0}function xD(t,e,n,r){return new Promise(a=>{let i=o=>{let s=o.data;vD(e,n,s)&&s.id===r&&(t.removeEventListener("message",i),a(s.response))};t.addEventListener("message",i)})}function ED(t,e,n,r){let a=i=>{let o=i.data;a1(e,"tell",n,o)&&r(o.body)};return t.addEventListener("message",a),[t,a]}function e1(t,e,n,r,a,i){let o=async s=>{let u=s.data;if(a1(n,"ask",r,u)){let l=await i(u.body);e=s.source,e.postMessage(yD(n,r,u.id,l),s.origin)}};return t.addEventListener("message",o),[t,o]}function CD(t,e,n,r,a){let i=Math.random().toString();return t.postMessage(r1(e,"tell",n,i,r),a)}async function t1(t,e,n,r,a,i,o){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let p=setTimeout(()=>c(new Error(`Failed to get response within ${o}ms`)),o),m=await xD(t,n,r,s);clearTimeout(p),l(m)});return e.postMessage(r1(n,"ask",r,s,a),i),u}var oa=class t{constructor(e,n,r=window,a="*"){this.protocol=e;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;e1(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(e,n=10,r=500){for(let a=0;a<=n;a++)try{return await e.ping({timeout:r}),e}catch{continue}throw new Error(`Could not connect on protocol ${e.protocol.type} after ${n*r}ms`)}static parent(e,n,r="*",a=window){let i=n.contentWindow;if(ia(i))return new t(e,i,a,r);throw new Error("iframe.contentWindow was null")}static iframe(e,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new t(e,a,r,n)}static rootIframe(e,n="*",{thisWindow:r=window}={}){return new t(e,null,r,n)}getSystemProtocol(e){return{type:`system|${e}`}}listeners=[];async ping({timeout:e=1e4}){await t1(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,e)}handleTell(e,n){this.listeners.push(ED(this.thisWindow,this.protocol,e,n))}tell(e,n){CD(this.targetWindow,this.protocol,e,n,this.targetOrigin)}handleAsk(e,n){this.listeners.push(e1(this.thisWindow,this.targetWindow,this.protocol,e,this.targetOrigin,n))}ask(e,n,r=1e4){if(this.targetWindow)return t1(this.thisWindow,this.targetWindow,this.protocol,e,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){SD(this.listeners)}};var i1;async function o1(){if(He()){let e=globalThis;for(;e.top!=e.self;)e=e.top;let n=oa.iframe(Zu,"*",{targetWindow:e});i1=n,await oa.connect(n).catch(r=>{B.error("connect with parent frame error",r)})}}function s1(){return i1}d();function u1(t,e){let n=e.matches||[],r=e.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(t)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(t))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(t)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(t))return!0}return!1}d();d();d();d();d();d();function l1(t){return t.replace(//g,">")}d();var Bl=!1,wD=ye();function c1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function DD(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&d1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(sa(i,$u)){if(a===!0)return!0;continue}if(fs(i.nodeName,e.inlineTags))return!0;if(!Tp(i,e))return!1}}return!0}function yp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(fs(t.nodeName,n)||Tp(t,e)){if(sa(t,ob)||fs(t.nodeName,["BR"]))return!1;if(sa(t,$u))return!0;if(Tp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return DD(t,e)}else return sa(t,$u);return!1}function d1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&sa(t,ib,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&sa(t,J4))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||fs(t.nodeName,i))}function Ni(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!g1(r)&&r.length>=n}function p1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(g1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function g1(t){for(let e=0;e127)return!1;return!0}function m1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function f1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function h1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function b1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function T1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function sa(t,e,n=!1){return vp(t,e,"1",n)}function vp(t,e,n,r=!1){return Bl&&!r?t[xn]?!!(t[xn]&&t[xn][e]===n):!1:t.dataset[e]===n}function Ui(t){return(t.innerText||t.textContent||"").trim()}function Sp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Il(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function lt(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(Bl&&!r?(t[xn]||(t[xn]={}),t[xn][e]||(t[xn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Rl(t,e,n=!1){if(Bl&&!n){if(!t[xn]||!t[xn][e])return;delete t[xn][e]}else delete t.dataset[e]}function qi(t,e,n=!1){return Bl&&!n?!t[xn]||!t[xn][e]?void 0:t[xn][e]:t.dataset[e]}function Tp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!fs(t.nodeName,n)}function Ee(){if(!globalThis||!globalThis.location)return"https://example.com";if(!He())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function En(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){B.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else B.warn("injectCSS failed, rootDocument does not have head node",t)}function ji(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(wD){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function fs(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function y1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function v1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||d1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return B.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function S1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();d();d();var ql,Fe,D1,AD,hs,x1,A1,zl={},k1=[],kD=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function ua(t,e){for(var n in e)t[n]=e[n];return t}function P1(t){var e=t.parentNode;e&&e.removeChild(t)}function Ep(t,e,n){var r,a,i,o={};for(i in e)i=="key"?r=e[i]:i=="ref"?a=e[i]:o[i]=e[i];if(arguments.length>2&&(o.children=arguments.length>3?ql.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)o[i]===void 0&&(o[i]=t.defaultProps[i]);return Ol(t,o,r,a,null)}function Ol(t,e,n,r,a){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:a??++D1};return a==null&&Fe.vnode!=null&&Fe.vnode(i),i}function qt(t){return t.children}function Hi(t,e){this.props=t,this.context=e}function Wi(t,e){if(e==null)return t.__?Wi(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e0?Ol(g.type,g.props,g.key,g.ref?g.ref:null,g.__v):g)!=null){if(g.__=n,g.__b=n.__b+1,(m=h[c])===null||m&&g.key==m.key&&g.type===m.type)h[c]=void 0;else for(p=0;p=n.__.length&&n.__.push({__V:jl}),n.__[t]}function se(t){return bs=1,FD(G1,t)}function FD(t,e,n){var r=Wl(Ts++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):G1(void 0,e),function(i){var o=r.__N?r.__N[0]:r.__[0],s=r.t(o,i);o!==s&&(r.__N=[s,r.__[1]],r.__c.setState({}))}],r.__c=wt,!wt.u)){wt.u=!0;var a=wt.shouldComponentUpdate;wt.shouldComponentUpdate=function(i,o,s){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return c.__c});if(u.every(function(c){return!c.__N}))return!a||a.call(this,i,o,s);var l=!1;return u.forEach(function(c){if(c.__N){var p=c.__[0];c.__=c.__N,c.__N=void 0,p!==c.__[0]&&(l=!0)}}),!!l&&(!a||a.call(this,i,o,s))}}return r.__N||r.__}function Ae(t,e){var n=Wl(Ts++,3);!Fe.__s&&K1(n.__H,e)&&(n.__=t,n.i=e,wt.__H.__h.push(n))}function Ve(t){return bs=5,Ue(function(){return{current:t}},[])}function Ue(t,e){var n=Wl(Ts++,7);return K1(n.__H,e)?(n.__V=t(),n.i=e,n.__h=t,n.__V):n.__}function $e(t,e){return bs=8,Ue(function(){return t},e)}function Kl(t){var e=wt.context[t.__c],n=Wl(Ts++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(wt)),e.props.value):t.__}function MD(){for(var t;t=W1.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Hl),t.__H.__h.forEach(Dp),t.__H.__h=[]}catch(e){t.__H.__h=[],Fe.__e(e,t.__v)}}Fe.__b=function(t){typeof t.type!="function"||t.o||t.type===qt?t.o||(t.o=t.__&&t.__.o?t.__.o:""):t.o=(t.__&&t.__.o?t.__.o:"")+(t.__&&t.__.__k?t.__.__k.indexOf(t):0),wt=null,z1&&z1(t)},Fe.__r=function(t){N1&&N1(t),Ts=0;var e=(wt=t.__c).__H;e&&(wp===wt?(e.__h=[],wt.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=jl,n.__N=n.i=void 0})):(e.__h.forEach(Hl),e.__h.forEach(Dp),e.__h=[])),wp=wt},Fe.diffed=function(t){U1&&U1(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(W1.push(e)!==1&&O1===Fe.requestAnimationFrame||((O1=Fe.requestAnimationFrame)||BD)(MD)),e.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==jl&&(n.__=n.__V),n.i=void 0,n.__V=jl})),wp=wt=null},Fe.__c=function(t,e){e.some(function(n){try{n.__h.forEach(Hl),n.__h=n.__h.filter(function(r){return!r.__||Dp(r)})}catch(r){e.some(function(a){a.__h&&(a.__h=[])}),e=[],Fe.__e(r,n.__v)}}),q1&&q1(t,e)},Fe.unmount=function(t){j1&&j1(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Hl(r)}catch(a){e=a}}),n.__H=void 0,e&&Fe.__e(e,n.__v))};var H1=typeof requestAnimationFrame=="function";function BD(t){var e,n=function(){clearTimeout(r),H1&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);H1&&(e=requestAnimationFrame(n))}function Hl(t){var e=wt,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),wt=e}function Dp(t){var e=wt;t.__c=t.__(),wt=e}function K1(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function G1(t,e){return typeof e=="function"?e(t):e}d();var V1=["*://*/*","*","*://*"],Y1="immersive-translate-wildcard-placeholder.com";function Ap(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>V1.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(V1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return RD(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,Y1),m;try{m=new URL(p)}catch{return B.debug("invalid match pattern",p,"raw match value:",c),!1}let g=m.host,f=m.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=ID(l+":",$1(g),$1(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function $1(t){return t.replaceAll(Y1,"*")}function ID(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function dt(t,e){return Ap(t,e)!==null}function RD(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}var OD=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function Cn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(Cn(t,i))return!1;if(Cn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!Cn(t,o)),c;function p(){return n&&n.display?!!OD.includes(n.display):Cn(t,r)}}var Kt=Cn;function $a(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function ys(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function fr(t,e=!1){let n=Xo;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Va(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return fr(n,e)}function Vi(t,e){return na(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function kp(t){let{rule:e}=t,n=zD(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function zD(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function vs(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",yt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),lt(r,rb,e.toString());let a=kp(t);return r.append(Ye.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function $i(t,e){return t.querySelector(`[${q0}='${e}']`)}function Q1(){document.querySelectorAll(`[${q0}]`).forEach(e=>{e.remove()})}function J1(){document.querySelectorAll(`.${yt}-error`).forEach(e=>{e.remove()})}function Z1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{ji(n)&&e.push(n)}),e}function Pp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},m=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),g=new RegExp(a.replace("{word}",m.map(f=>f.k).join("|")),"g");l=l.replace(g,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let m=new RegExp(p,"gi");l=l.replace(m,(g,f)=>{let T=c++;return e[`${T}`]=l1(f),o.length>2?g.replace(f,`<${o[2]}${T}>`):g.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){B.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function Ss(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||T1(s)||m1(s)||b1(s)||f1(s)||h1(s)||UD(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ni(i,n,r)}function Nr(t){return t.nodeType===Node.ELEMENT_NODE}function X1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Lp(){return await At("fakeUserId","")}async function ND(){return await At("installedAt","")}async function Gl(t){let n=Me().INSTALL_FROM,r=Nt(),a=await ND(),i=await Lp(),o=await Pn(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Jt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function e2(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await Fp(t,e);r(a)})()},[t,e,r]),n}async function Fp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!et()&&ye()||ut().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>dt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>dt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}d();function Mp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(lb),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${H0}-theme-${t}`):a.push(`${j0}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(H0):a.push(j0),a}function Bp(t){let e=["notranslate",Qu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function a2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Va(n,!0),m="afterend",g=p[0],f=p[1],T=`${g}(\\d+)${f}`,b=new RegExp(T,"g"),h=Ye.sanitize(u);o.length>0&&(h=h.replace(b,I=>{let S=h.indexOf(I),y=h[S-1]===" ",L=h[S+I.length]===" ",v=I.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),O=Number(v);if(isNaN(O))return I;let _=o[O];if(_&&_.type==="element"){let k=_.value.outerHTML;return y||(k=" "+k),L||(k=k+" "),k}else B.error("variable type not supported",_,I);return I}));let E=Mp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&E.push(ub);let D=Bp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${E.join(" ")}" ${dr}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${dr}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${dr}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:m}}function Vl(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";m&&(T=ca(Ip(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let E=Rp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",I=ys(E+D+M),S=I[0]+h+I[1];if(E===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=ys(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Rp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);m&&(b=ca(Ip(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",E=ys(T+b+h),D=E[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+E[1];if(T===" ")D=D.trimStart();else{let M=ys(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Rp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Ip(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(m=s[c-1].text),c/g,">"))}t.targetText=Ye.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` `).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(t.id),elements:[],isVertical:!1,rootFrame:t.commonAncestorContainer,text:t.text,variables:r,inline:a,preWhitespace:t.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Va(e);if(l.length>2){let c=l[2];return qD({delimiterTag:c,targetText:t.targetText,inline:a,preWhitespace:t.isPreWhitespace||!1,wrapperPrefix:e.rule.wrapperPrefix,wrapperSuffix:e.rule.wrapperSuffix,targetWrapperTag:e.rule.targetWrapperTag,translationTheme:e.state.translationTheme,translationBlockStyle:e.rule.translationBlockStyle,translationClasses:e.rule.translationClasses,variables:r}).html}else{let c=a2(u,{id:Number(t.id),url:"https://google.com",text:t.targetText,from:"auto",to:"auto",fromByClient:"auto"},e);return c.html}}function Ip(t){return(t?.innerText||t.textContent||"").replace(/\s+/g," ")||""}function qD(t){let{delimiterTag:e,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=t;o=o||[];let p=t.targetText;p=Ye.sanitize(p);let m=p,g=new RegExp(`<${e}(\\d+)>(.*?)`,"g"),f=new RegExp(`<${e}(\\d+)>`);o.length>0&&(m=m.replace(g,E=>{let D=m.indexOf(E),M=m[D-1]===" ",I=m[D+E.length]===" ",S=E.match(f);if(!S)return E;let y=S[1],L=Number(y);if(isNaN(L))return E;let A=o[Number(L)];if(A&&A.type==="element"){let v=A.value.outerHTML;return M||(v=" "+v),I||(v=v+" "),v}else if(A&&A.type==="text"){let v=A.value;return M||(v=" "+v),I||(v=v+" "),v}else B.error("variable type not supported",A,E);return E}));let T=Mp(l,n,r||[],s),b=Bp(l),h="";return c&&(h=`style="${c}"`),m=`<${a} ${h} class="${T.join(" ")}" ${dr}="1"><${a} class="${b.join(" ")}" ${dr}="1">${m}`,n||(i==="smart"?m=`
${m}`:m=`${i}${m}`),n&&(i!=="smart"?m=`${i}${m}`:m=`<${a} class="notranslate" ${dr}="1"> ${m}`),u==="smart"?m=`${m}`:m=`${m}${u}`,{html:m,position:"afterend"}}function Rp(t){let e=t[t.length-1];return e?e.text:""}function Op(t){let{text:e,delimiters:n,variables:r}=t,a=e;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=e;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let p=c.match(s);if(!p)return c;let m=p[1],g=Number(m);if(isNaN(g))return c;let f=r[m];return f||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}var De=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(e,n,r){this.serviceConfig=e,this.generalConfig=n,this.translationOptions=r,e?.retry&&(this.retry=e.retry),e?.requestTimeout&&(this.requestTimeout=Number(e.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let e=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(e.limit=Number(n.limit)),n?.interval&&(e.interval=Number(n.interval)),e}formatRateLimit(e){return e.limit<1&&(e.interval=Math.round(1e3/e.limit),e.limit=1),e}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(e){throw new Error("Not implemented")}translateList(e){throw new Error("Not implemented")}async multipleTranslate(e,n,r){if(e.sentences.length===0)return{sentences:[]};let{sentences:a}=e,i=!1,o=!1,s=[],u=null,l=new Set;for(let b of a)b.from&&b.from!=="auto"&&l.add(b.from),b.refresh&&(i=!0),b.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let p=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(p=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(p=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=L3(a,c,p)}catch(b){if(r)for(let h=0;hb));let m=[],g=[],f=(b,h,E)=>{let D="";if(h.translatedTexts&&h.translatedTexts[0]&&(D=h.translatedTexts[0]),g[b]||(g[b]=h,g[b].translatedTexts=Array(h.sentenceTotalParts).fill(null)),g[b].hasError)return;if(E){let S=E instanceof $?new $(E.name,E.message).initNetWork(E.status).initData(E.data):E;g[b].hasError=!0,h.callback&&h.callback(S,null,h.sentence);return}g[b].translatedTexts[h.partIndex]=D;let M=g[b],I=0;for(let S=0;S{let I=h.from;if(h.fromByClient&&h.fromByClient!=="auto"&&(I=h.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:h.tempSentences.map(y=>y.text),forces:h.tempSentences.map(y=>y.force),xpaths:h.tempSentences.map(y=>y.xpath||""),from:I,to:h.to,url:E,options:n,refresh:i,debug:o}),sourceTempSentences:h.tempSentences};{let S=sb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(S=this.serviceConfig.translationTextSeparator);let y=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(y=this.serviceConfig.newlinePlaceholderDelimiters);let L=[],A=fr(this.serviceConfig);if(h.tempSentences.forEach((q,F)=>{let C=Pp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:A,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:h.to});q.force!==!0&&(C&&C.text&&C.text.trim().lengthF.text);return Promise.resolve({sourceTempSentences:h.tempSentences,text:q,from:I,to:h.to})}let v="";y&&y.length>=2?v=L.map((q,F)=>{let{item:C}=q;return F===L.length-1?C.text:C.text+y[0]+(F+1)+y[1]}).join(""):v=L.map(({item:q})=>q.text).join(S);let O=await this.translate({text:v,from:I,to:h.to,url:E,options:{...n,rawTextArrayLength:L.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:_}=O,k=[];if(y&&y.length>=2){let q=`${y[0]}\\d+${y[1]}`;y&&y.length>=3&&(q=y[2]);let F=new RegExp(q,"g");k=_.split(F)}else k=_.split(S);let N=[];if(k.length>L.length){for(let q=0;qq.text);return A=fr(this.serviceConfig,!0),N.forEach((q,F)=>{let C=L[F],P=C.index,U=C.variables||{};Object.keys(U).length>0&&(q=Op({text:q,delimiters:A,variables:U})),z[P]=q}),{sourceTempSentences:h.tempSentences,text:z,from:O.from,to:O.to}}};m.push(M().then(I=>{let{text:S,sourceTempSentences:y}=I;for(let L=0;L{if(I instanceof $&&I.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let S=0;S{let h=b.sentence.text;return b.translatedTexts&&b.translatedTexts.length>0&&(h=b.translatedTexts.join("")),{...b.sentence,text:h}})}}async formatAndTranslateList(e){let n={...e},{forces:r}=e,a=[],i=fr(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=e;if(l.forEach((p,m)=>{let g=Pp({text:p,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:e.to});r&&r[m]!==!0&&(g&&g.text&&g.text.trim().lengthp.text),n.xpaths=a.map(p=>p.xpath)}catch(l){B.debug("formatAndTranslateList error",e,l)}let o=await this.translateList(n),{text:s}=o,u=e.text.map(l=>l);return i=fr(this.serviceConfig,!0),s.forEach((l,c)=>{let p=a[c];if(p){let m=p.index,g=p.variables,f=Object.keys(g);u[m]=l,f.length>0&&(u[m]=Op({text:l,delimiters:i,variables:g}))}}),{...o,text:u}}detectLanguageLocally(e){return Ie({text:e,minLength:18,pageLangs:[vt(),"en"]})}detectLanguageRemotely(e){return Promise.resolve("auto")}detectLanguage(e){return e.length>=50?this.detectLanguageLocally(e):this.detectLanguageRemotely(e)}};d();d();var Qi="input is invalid type",zp=typeof window=="object",da=zp?window:{};da.JS_SHA256_NO_WINDOW&&(zp=!1);var jD=!zp&&typeof self=="object",HD=!da.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;HD?da=global:jD&&(da=self);var jH=!da.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,HH=typeof define=="function"&&define.amd,xs=!da.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),WD=[-2147483648,8388608,32768,128],er=[24,16,8,0],$l=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Yl=["hex","array","digest","arrayBuffer"],jt=[];(da.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});xs&&(da.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var o2=function(t,e){return function(n){return new Ht(e,!0).update(n)[t]()}},u2=function(t){var e=o2("hex",t);e.create=function(){return new Ht(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};Ht.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=WD[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};Ht.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,m,g,f,T,b,h,E,D;for(l=16;l<64;++l)g=u[l-15],c=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=u[l-2],p=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,g=u[0]-1413257819,s=g-150054599<<0,r=g+24177077<<0):(b=704751109,g=u[0]-210244248,s=g-1521486534<<0,r=g+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,m=b^t&n^D,T=a&i^~a&o,g=s+p+T+$l[l]+u[l],f=c+m,s=r+g<<0,r=g+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,m=h^r&e^b,T=s&a^~s&i,g=o+p+T+$l[l+1]+u[l+1],f=c+m,o=n+g<<0,n=g+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),E=n&r,m=E^n&t^h,T=o&s^~o&a,g=i+p+T+$l[l+2]+u[l+2],f=c+m,i=e+g<<0,e=g+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,m=D^e&r^E,T=i&o^~i&s,g=a+p+T+$l[l+3]+u[l+3],f=c+m,a=t+g<<0,t=g+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};Ht.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};Ht.prototype.toString=Ht.prototype.hex;Ht.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};Ht.prototype.array=Ht.prototype.digest;Ht.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Ql(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Qi);if(xs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!xs||!ArrayBuffer.isView(t)))throw new Error(Qi)}else throw new Error(Qi);t.length>64&&(t=new Ht(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}Ht.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Ql.prototype=new Ht;Ql.prototype.finalize=function(){if(Ht.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();Ht.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Ht.prototype.finalize.call(this)}};var Ji=u2();Ji.sha256=Ji;Ji.sha224=u2(!0);Ji.sha256.hmac=l2();Ji.sha224.hmac=l2(!0);var c2=Ji;var d2=c2.sha256;function tr(t){return Promise.resolve(d2(t))}function Jl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function pa(t,e){let n=d2.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function p2(t,e){let n=await pa(t,e);return Jl(n)}async function Zl(t,e){let n=KD(e),r=await pa(t,n);return Jl(r)}function KD(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}var g2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Es=class t extends De{static langMap=new Map(g2);maxTextGroupLength=50;static langMapReverse=new Map(g2.map(([e,n])=>[n,e]));static getUTCDate(e){let n=e.getUTCFullYear(),r=`${e.getUTCMonth()+1}`.padStart(2,"0"),a=`${e.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(e,n,r){if(super(e,n,r),!e||!e.secretId||!e.secretKey)throw new $("secretId and secretKey are required");this.secretId=e.secretId?.trim(),this.secretKey=e.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceText:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async translateList(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceTextList:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:e,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await tr(a)].join(` `),p=t.getUTCDate(u),m=["TC3-HMAC-SHA256",l,`${p}/${i}/tc3_request`,await tr(c)].join(` `),g=await p2(p,`TC3${n}`),f=await Zl(i,g),T=await Zl("tc3_request",f),b=await Zl(m,T),h=await ce({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${e}/${p}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${b}`},body:a,timeout:this.requestTimeout});if(h instanceof Error)throw h;if(h.Response&&h.Response.Error&&h.Response.Error.Message)throw new $(h.Response.Error.Message);return h}};d();var m2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],GD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Cs=class t extends De{static langMap=new Map(m2);static langMapReverse=new Map(m2.map(([e,n])=>[n,e]));isSupportList=!1;constructor(e,n,r){super(e,n,r)}async translate(e){let{text:n,from:r,to:a}=e,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await ce({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:GD,timeout:this.requestTimeout});return{text:o.targetText,from:t.langMapReverse.get(o.source)||r,to:t.langMapReverse.get(o.target)||a}}};d();var f2=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Ya=class t extends De{static langMap=new Map(f2);static langMapReverse=new Map(f2.map(([e,n])=>[n,e]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(e,n,r){super(e,n,r),e?.apiUrl&&(this.apiUrl=Ut(this.apiUrl,e.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(e,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}).toString();return{data:await ce({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(e,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}),i=this.apiUrl+"?"+a.toString();return{data:await ce({retry:this.retry,url:i,timeout:this.requestTimeout})}}};d();d();d();function VD(t,e){return e?t+(e-t%e):t}function $D(t,e){return t.split(e).length-1}function Np(t){let e=Date.now(),n=1;for(let r of t)n+=$D(r,"i");return VD(e,n)}function YD(t,e){return Math.floor(Math.random()*(e-t+1))+t}function Up(){return YD(1e6,1e8)}d();d();d();var qp="https://www2.deepl.com/jsonrpc",jp="auto",h2=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];d();function QD(t=h2){return t.reduce((e,n)=>(e[n.code.toLowerCase()]=n.code,e[n.language.toLowerCase()]=n.code,e),{})}function Hp(t){return QD()[t.toLowerCase()]}var JD={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function ZD(t){return JSON.stringify(t).replace('"method":"',()=>{let e=t;return(e.id+3)%13===0||(e.id+5)%29===0?'"method" : "':'"method": "'})}function XD(t,e){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:t,target_lang:e}}}}async function eA(t,e,n,r,a,i,o){let s=Up(),u=XD(r,n),l=[];e.forEach(m=>{l.push({text:m,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Np(e);let c=await ce({retry:2,method:"POST",url:t,body:ZD(u),headers:JD}),p={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(m=>{p.text.push(m.text)}),p}async function b2(t,e,n,r=jp,a,i,o){return e?e&&e.length===1&&e[0]===""?{text:[""],from:r,to:n}:eA(t,e,Hp(n),Hp(r)??"auto",a,i,o):{text:[],from:r,to:n}}var T2=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Zi=class t extends De{static langMap=new Map(T2);static langMapReverse=new Map(T2.map(([e,n])=>[n,e]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=qp;constructor(e,n,r){super(e,n,r),e&&e.apiUrl&&(this.API_URL=Ut(qp,e.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(e){let{text:n,to:r,from:a}=e,i=await b2(this.API_URL,n,t.langMap.get(r)||r,t.langMap.get(a)||"auto");return{text:i.text,from:t.langMapReverse.get(i.from),to:t.langMapReverse.get(i.to)}}};d();var ws=class t extends De{static langMap=new Map(hp);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(e,n,r){super(e,n,r),this.clientKey=zr.getClientKey()}async translate(e){let{text:n,to:r}=e,a=await this.detectLanguage(n),i=t.langMap.get(a)||a,o=t.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Me(),u=e.url;s.INSTALL_FROM==="firefox_store"&&(u=y2());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),p=await ce({url:Al,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(p.header.ret_code!=="succ")throw new $(p.message||p.header.ret_code);return{text:p.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(e){let{from:n,text:r,to:a}=e,i=Me(),o=e.url;if(i.INSTALL_FROM==="firefox_store"&&(o=y2()),r.length===1){let g=await this.translate({from:n,text:r[0],to:a,url:o,options:e.options});return{text:[g.text],from:g.from,to:g.to}}let u=await this.detectLanguage(r.join(` diff --git a/dist/firefox/content_start.js b/dist/firefox/content_start.js index c5b0178..0792161 100644 --- a/dist/firefox/content_start.js +++ b/dist/firefox/content_start.js @@ -1,4 +1,4 @@ -(()=>{var nu=Object.defineProperty;var qn=(t,e)=>{for(var r in e)nu(t,r,{get:e[r],enumerable:!0})};var b={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var nu=Object.defineProperty;var qn=(t,e)=>{for(var r in e)nu(t,r,{get:e[r],enumerable:!0})};var b={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5162,7 +5162,7 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:Us,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...Rs,{type:"password",name:"apikey",required:!0}],props:Rs},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},TD={type:V+"ChildFrameToRootFrameIdentifier"};var vD=Je()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general";var Ft="user_info",yD=Je()||St()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",js=Je()||St()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",SD=js+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",xD=js+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Fm=Je()||St()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Ha=Je()||St()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",Bm=Je()||St()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",Im=Je()||St()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",zm=Je()||St()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",wD=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",AD=Bm+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",DD=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Ws=Ha+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Ks=Im+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Gs=zm+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Vs=Fm+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true";var $s=Oe().TRANSLATE_FILE_URL,ED=$s+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",_D=$s+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var cr=console,ja=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let r=performance.now(),n=Math.round(r-this.#e),a=Ye.green;n>1e4?a=Ye.red:n>1e3&&(a=Ye.yellow),cr.debug(Ye.dim(Vt+" TIMING:"),e,"in",a(n+"ms")),this.#e=r}},Hr=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&cr.log(Ye.dim(Vt+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&cr.log(Ye.green(Vt+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&cr.warn(Ye.yellow(Vt+" WARN:"),...e)}error(...e){this.#e<=3&&cr.error(Ye.red(Vt+" ERROR:"),...e)}fatal(...e){this.#e<=4&&cr.error(Ye.red(Vt+" FATAL:"),...e)}timing(){return this.level===0?new ja:{reset:()=>{},stop:()=>{}}}},$e=new Hr;function Sn(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let r=yn.map(a=>a.toLowerCase()),n=r.indexOf(e);if(n===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=r.indexOf(e);return a===-1?"auto":yn[a]}else return"auto";else return yn[n]}function dr(t){return!!(t&&t.subscription&&t.subscription.subscriptionStatus==="active")}var Qs=V+"SyncStoreKey_";function Bt(t,e){let r=Qs+t;return se.storage.sync.get(r).then(n=>n[r]===void 0?e:n[r])}function pr(t,e){let r=Qs+t;return se.storage.sync.set({[r]:e})}var Mm=V+"StoreKey_";function jr(t,e){let r=Mm+t;return se.storage.local.get(r).then(n=>n[r]===void 0?e:n[r])}var Qt=V+"CacheKey_";function Om(t,e){let r=Qt+t;return se.storage.local.get(r).then(n=>n[r]===void 0?e:n[r])}function Rm(){let t=se.storage.local.refresh;t&&t()}function Nm(t,e){let r=Qt+t;return se.storage.local.get(r).then(n=>{if(n[r]===void 0)return e;let{value:a,expired:i}=n[r];return i&&in.startsWith(Qt)).filter(n=>n!==Qt+Ft);if(r.length>0)return se.storage.local.remove(r)}}var mr={get:Om,set:Um,getExpired:Nm,setExpired:qm,remove:Hm,clear:jm,refresh:Rm};function Wm(t,e){let r=t;return e&&Object.keys(e).forEach(n=>{let a=e[n];if(a===void 0)return;let i=Gm(n);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let l=`<${n}>`,s=r.indexOf(l);if(s!==-1){let u=o.tag||"a",c=r.indexOf(``);if(c!==-1){let d=r.substring(s+l.length,c),g=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");r=r.replace(`${l}${d}`,`<${u} ${g}>${d}`)}}}else if(a){let o=new RegExp("{"+n+"}","gm");r=r.replace(o,a.toString())}}),r}function Ys(t,e,r){let n=t[e];if(!n)return r;if(!r)return"";let a=r.split("."),i="";do{i+=a.shift();let o=n[i];o!==void 0&&(typeof o=="object"||!a.length)?(n=o,i=""):a.length?i+=".":n=r}while(a.length);return n}function Km(t,e,r,n,a){if(!t.hasOwnProperty(r))return e;let i=Ys(t,r,e);return i===e&&r!==n&&(i=Ys(t,n,e)),Wm(i,a)}function Gm(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function It(t,e,r){return Km(qr,e,t.config.interfaceLanguage,"en",r)}function Xs(t,e){let r=new Date(t),n=r.getFullYear().toString(),a=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getDate().toString().padStart(2,"0"),o=r.getHours().toString().padStart(2,"0"),l=r.getMinutes().toString().padStart(2,"0"),s=r.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",n).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",l).replace("ss",s)}function Zs(t){return new Date(t).getTime()}var zt=class extends Error{status;constructor(e,r){if(e&&r){super(r),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let r=null;if(r=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!r){let n=It.bind(null,e),a=this.getErrorMsg();r={type:"error",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:a}),action:"changeService"}}return r}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let r=It.bind(null,e),n=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(n||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let r=It.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:r("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+r("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let r=It.bind(null,e),n="retry",a="network",i=r("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${r("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${r("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${r("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${r("error.gemini.429")}

${o}`:o=`${r("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${r("error.claude.403")}

${o}`:o=`${r("error.403")}

${o}`:this.status===400?o=`${r("error.400")}

${o}`:this.status===502?o=`${r("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${r("error.subscriptionExpired")}

${o}`,n="setting",a="configError",i=r("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:n}}handleFetchError(e){let r=It.bind(null,e);if(this.status!==-999)return;let n=this.getErrorMsg();return{type:"network",title:"",errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:n}),action:"changeService"}}handleProUser(e){let r=It.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:r("upgradeToProErrorTitle"),errMsg:r("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:r("notLoginPro"),errMsg:r("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let r=It.bind(null,e);this.message=this.message.replace("ProQuota:","");let n=this.message;try{n=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:l,subscriptionTo:s}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let d=this.data?.translationService=="deepl"?"OpenAI":"Deepl",g=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=r("errorReason",{message:n});if(i=="onetime_7day")m+=r("proQuotaExceededError.onetime7day",{anotherService:d,brandId:ke,href:Ws});else{let T="";g=="OpenAI"?T=Ks:T=Gs,o?m+=r("proQuotaExceededError.trial",{anotherService:d,brandId:ke,href:Vs}):m+=r("proQuotaExceededError.nonTrial",{anotherService:d,brandId:ke,href:T,translationService:g}),!o&&(a.cancelAtPeriodEnd==="false"||Zs(s)>l)&&(m+=r("proQuotaExceededError.resetTime",{resetTime:Xs(l,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function el(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Kn(Js.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(r){throw r&&r.name==="RetryError"&&r.cause?r.cause:r}else e=await Js(t);return e}async function Js(t){t.body;let{url:e,responseType:r,...n}=t;r||(r="json"),n={mode:"cors",...n};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let s=new AbortController,u=s.signal;setTimeout(()=>{s.abort()},o),n.signal=u}let l;try{l=await i(e,n)}catch(s){$e.debug("fetch error",e,s);let u=s.message||"Unknown Error";throw new zt("fetchError",u).initNetWork(-999).initStack(s.stack)}if(l.ok&&l.status>=200&&l.status<400){if(r==="json")return await l.json();if(r==="text")return await l.text();if(r==="raw"){let s=await l.text(),u=Object.fromEntries([...l.headers.entries()]),c=l.url;return c||(l.headers.get("X-Final-URL")?c=l.headers.get("X-Final-URL"):c=e),{body:s,headers:u,status:l.status,statusText:l.statusText,url:c}}else if(r==="stream"){let s="",u;if(l.body&&l.body instanceof ReadableStream)for await(let c of Vm(l.body)){let d=new TextDecoder().decode(c);s+=d;let g;for(;(g=s.indexOf(` -`))>=0;){let m=s.slice(0,g).trim();if(s=s.slice(g+1),m.startsWith("event:")||m==="")continue;let T="";if(m.startsWith("data:")&&(T=m.slice(5).trim()),T==="[DONE]")break;let j;try{j=JSON.parse(T??"")}catch(k){$e.debug("json error",k);continue}u=j}}return u}}else{let s;try{s=await l.text()}catch(m){$e.error("parse response failed",m)}s&&$e.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),g&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new zt("fetchError",c).initNetWork(l.status)}}async function*Vm(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}var $m=new Map;function tl(t){let e=Qm(64),r=new CustomEvent(Ns,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((n,a)=>{$m.set(e,(i,o)=>{i?a(i):n(o)})})}function Qm(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var Xm="";function Wr(){return Xm||rl.version}function xn(){try{let t=[Oe().EBOOK_BUILDER_URL,Oe().EBOOK_VIEWER_URL,Oe().SUBTITLE_BUILDER_URL,Oe().HTML_VIEWER_URL,Oe().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Je()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var Kr=new Map,Gr=class{fromType;logger;constructor(e,r=!1){this.logger=new Hr,r&&this.logger.setLevel("debug"),this.fromType=e,Kr.has(e)||(Kr.set(e,new Map),se.runtime.onMessage.addListener((n,a,i)=>{let o=n.from,l=n.to,s,u,c;a.tab&&a.tab.id&&(s=a.tab.id,o=`${o}:${s}`,u=a.tab.url,c=a.tab.active),this.logger.debug(`${n.to} received message [${n.payload.method}] from ${n.from}`,n.payload.data?n.payload.data:" ");let d=Ka(l),{type:g,name:m}=d;if(g!==e)return!1;let T=Ka(o),k=Kr.get(g).get(m);if(!k)return this.logger.debug(`no message handler for ${g}:${l}, but it's ok`),!1;let{messageHandler:h,sync:Q}=k,P={type:e,name:T.name,id:s,url:u,active:c};if(Q){try{let $=h(n.payload,P);i({ok:!0,data:$})}catch($){i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.details,errorStatus:$.status})}return!1}else return h(n.payload,P).then($=>{i({ok:!0,data:$})}).catch($=>{i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.message,errorStatus:$.status})}),!0}))}getConnection(e,r,n){let a=!1;n&&n.sync&&(a=!0);let i=this.fromType,o=Kr.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Wa(`${i}:${e}`,this.logger);return Kr.get(i).set(e,{messageHandler:r,sync:a,connectionInstance:l}),l}}},Wa=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let n=Ka(e),{type:a,id:i}=n;if(a!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await se.runtime.sendMessage(o);return nl(o,l,this.logger)}catch(l){if(a==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await se.tabs.sendMessage(i,o);return nl(o,l,this.logger)}}};function nl(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new zt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new zt("noResponse","Unknown error")}function Ka(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let n=parseInt(e[2]);if(!isNaN(n))r.id=n;else throw new Error("tab id not a valid number")}return r}var Zm="";function Ga(){return Zm||globalThis.navigator.userAgent}function al(){return Ga().includes("ImtFxiOS")}function Jm(){return Ga().includes("ImtFxAndroid")}function Va(){let t=Ga();if(al()||Jm()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),n=r[0];return r[2]&&(n+="_"+r[2]),{name:n,version:r[1]}}}return null}var wn;function $a(){return wn||(wn=new Gr("content_script",!1).getConnection("pure_main",()=>{}),wn)}var il="G-MKMD9LWFTR";async function sl(t){try{let e=Oe(),r=e.INSTALL_FROM==="firefox_store";if(Va()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let a=Ge(),i=xn(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Bt("fakeUserId","");s||(s=await jr("fakeUserId",""),s&&await pr("fakeUserId",s));let u=Wr(),c=new Date,d=await Bt("installedAt","");d||(d=await jr("installedAt",""),d&&await pr("installedAt",d)),s?d||(d=new Date(0).toISOString(),await pr("installedAt",d)):(s=eg(32),await pr("fakeUserId",s)),d||(d=c.toISOString(),await pr("installedAt",d));let g=new Date(d),m=ol(g),T=ol(c),j=m===T,k=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${il}&api_secret=${l}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${il}&api_secret=${l}`);let Q="";typeof navigator<"u"&&(Q=window.navigator.userAgent);let P=nn.parse(Q),$=t.map(A=>{let f=A.params||{};if(P.os&&(f.os_name=P.os.name||"unknown",f.os_version=P.os.version||"unknown",f.os_version_name=P.os.versionName||"unknown"),P.browser){f.browser_name=P.browser.name||"unknown",f.browser_version=P.browser.version||"unknown";let y=Va();y&&(f.browser_name=y.name,f.browser_version=y.version)}return P.platform&&(f.platform_type=P.platform.type||"unknown"),P.engine&&(f.engine_name=P.engine.name||"unknown",f.engine_version=P.engine.version||"unknown"),u&&(f.version=u),e.INSTALL_FROM&&(f.install_from=e.INSTALL_FROM),m&&(f.install_day=tg(g)),f.userscript=a.toString(),j?f.is_new_user_today="1":f.is_new_user_today="0",k?f.is_new_user_this_week="1":f.is_new_user_this_week="0",i?f.main_frame=0:f.main_frame=1,{...A,params:f}}),oe=await ng({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:$})})}catch{}}function eg(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=s.slice(0,g).trim();if(s=s.slice(g+1),m.startsWith("event:")||m==="")continue;let T="";if(m.startsWith("data:")&&(T=m.slice(5).trim()),T==="[DONE]")break;let j;try{j=JSON.parse(T??"")}catch(k){$e.debug("json error",k);continue}u=j}}return u}}else{let s;try{s=await l.text()}catch(m){$e.error("parse response failed",m)}s&&$e.error("fail response",s);let u="";s&&(u=s.slice(0,500));let c=u,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+u),g&&u.includes("quota exceeded")&&(c="ProQuota:"+u),new zt("fetchError",c).initNetWork(l.status)}}async function*Vm(t){let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)return;yield n}}finally{e.releaseLock()}}var $m=new Map;function tl(t){let e=Qm(64),r=new CustomEvent(Ns,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(r),new Promise((n,a)=>{$m.set(e,(i,o)=>{i?a(i):n(o)})})}function Qm(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var Xm="";function Wr(){return Xm||rl.version}function xn(){try{let t=[Oe().EBOOK_BUILDER_URL,Oe().EBOOK_VIEWER_URL,Oe().SUBTITLE_BUILDER_URL,Oe().HTML_VIEWER_URL,Oe().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Je()||e.push("localhost:38001");let r=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return r.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}var Kr=new Map,Gr=class{fromType;logger;constructor(e,r=!1){this.logger=new Hr,r&&this.logger.setLevel("debug"),this.fromType=e,Kr.has(e)||(Kr.set(e,new Map),se.runtime.onMessage.addListener((n,a,i)=>{let o=n.from,l=n.to,s,u,c;a.tab&&a.tab.id&&(s=a.tab.id,o=`${o}:${s}`,u=a.tab.url,c=a.tab.active),this.logger.debug(`${n.to} received message [${n.payload.method}] from ${n.from}`,n.payload.data?n.payload.data:" ");let d=Ka(l),{type:g,name:m}=d;if(g!==e)return!1;let T=Ka(o),k=Kr.get(g).get(m);if(!k)return this.logger.debug(`no message handler for ${g}:${l}, but it's ok`),!1;let{messageHandler:h,sync:Q}=k,P={type:e,name:T.name,id:s,url:u,active:c};if(Q){try{let $=h(n.payload,P);i({ok:!0,data:$})}catch($){i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.details,errorStatus:$.status})}return!1}else return h(n.payload,P).then($=>{i({ok:!0,data:$})}).catch($=>{i({ok:!1,errorName:$.name,errorMessage:$.message,errorDetails:$.message,errorStatus:$.status})}),!0}))}getConnection(e,r,n){let a=!1;n&&n.sync&&(a=!0);let i=this.fromType,o=Kr.get(i);if(o.has(e))return o.get(e).connectionInstance;{let l=new Wa(`${i}:${e}`,this.logger);return Kr.get(i).set(e,{messageHandler:r,sync:a,connectionInstance:l}),l}}},Wa=class{from;logger;constructor(e,r){this.from=e,this.logger=r}async sendMessage(e,r){let n=Ka(e),{type:a,id:i}=n;if(a!=="content_script"){let o={to:e,from:this.from,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let l=await se.runtime.sendMessage(o);return nl(o,l,this.logger)}catch(l){if(a==="popup"){let s=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(r)}`;return this.logger.debug(s,r,e,l),Promise.resolve({message:s})}else throw l}}else{let o={from:this.from,to:e,payload:r};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let l=await se.tabs.sendMessage(i,o);return nl(o,l,this.logger)}}};function nl(t,e,r){if(e){if(e.ok)return r.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new zt(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new zt("noResponse","Unknown error")}function Ka(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let r={type:e[0],name:e[1]};if(e[0]==="content_script"){let n=parseInt(e[2]);if(!isNaN(n))r.id=n;else throw new Error("tab id not a valid number")}return r}var Zm="";function Ga(){return Zm||globalThis.navigator.userAgent}function al(){return Ga().includes("ImtFxiOS")}function Jm(){return Ga().includes("ImtFxAndroid")}function Va(){let t=Ga();if(al()||Jm()){let e=t.match(/Imt[\w/.]+/);if(e){let r=e[0].split("/"),n=r[0];return r[2]&&(n+="_"+r[2]),{name:n,version:r[1]}}}return null}var wn;function $a(){return wn||(wn=new Gr("content_script",!1).getConnection("pure_main",()=>{}),wn)}var il="G-MKMD9LWFTR";async function sl(t){try{let e=Oe(),r=e.INSTALL_FROM==="firefox_store";if(Va()?.name?.startsWith("ImtFx")&&(r=!1),r)return;let a=Ge(),i=xn(),o=e.PROD==="1",l="sitc4WmvShWYwfU0dANM3Q",s=await Bt("fakeUserId","");s||(s=await jr("fakeUserId",""),s&&await pr("fakeUserId",s));let u=Wr(),c=new Date,d=await Bt("installedAt","");d||(d=await jr("installedAt",""),d&&await pr("installedAt",d)),s?d||(d=new Date(0).toISOString(),await pr("installedAt",d)):(s=eg(32),await pr("fakeUserId",s)),d||(d=c.toISOString(),await pr("installedAt",d));let g=new Date(d),m=ol(g),T=ol(c),j=m===T,k=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${il}&api_secret=${l}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${il}&api_secret=${l}`);let Q="";typeof navigator<"u"&&(Q=window.navigator.userAgent);let P=nn.parse(Q),$=t.map(A=>{let f=A.params||{};if(P.os&&(f.os_name=P.os.name||"unknown",f.os_version=P.os.version||"unknown",f.os_version_name=P.os.versionName||"unknown"),P.browser){f.browser_name=P.browser.name||"unknown",f.browser_version=P.browser.version||"unknown";let y=Va();y&&(f.browser_name=y.name,f.browser_version=y.version)}return P.platform&&(f.platform_type=P.platform.type||"unknown"),P.engine&&(f.engine_name=P.engine.name||"unknown",f.engine_version=P.engine.version||"unknown"),u&&(f.version=u),e.INSTALL_FROM&&(f.install_from=e.INSTALL_FROM),m&&(f.install_day=tg(g)),f.userscript=a.toString(),j?f.is_new_user_today="1":f.is_new_user_today="0",k?f.is_new_user_this_week="1":f.is_new_user_this_week="0",i?f.main_frame=0:f.main_frame=1,{...A,params:f}}),oe=await ng({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:s,user_id:s,events:$})})}catch{}}function eg(t){let e="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=r.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 diff --git a/dist/firefox/manifest.json b/dist/firefox/manifest.json index a6c1340..285ba33 100644 --- a/dist/firefox/manifest.json +++ b/dist/firefox/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_brandName__", "description": "__MSG_brandDescription__", - "version": "1.4.3", + "version": "1.4.4", "default_locale": "en", "background": { "scripts": [ diff --git a/dist/firefox/options.js b/dist/firefox/options.js index b0925cf..8c16487 100644 --- a/dist/firefox/options.js +++ b/dist/firefox/options.js @@ -1,4 +1,4 @@ -(()=>{var GS=Object.create;var yd=Object.defineProperty;var VS=Object.getOwnPropertyDescriptor;var $S=Object.getOwnPropertyNames;var YS=Object.getPrototypeOf,QS=Object.prototype.hasOwnProperty;var ZS=(e,t)=>()=>(e&&(t=e(e=0)),t);var JS=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ol=(e,t)=>{for(var n in t)yd(e,n,{get:t[n],enumerable:!0})},XS=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $S(t))!QS.call(e,a)&&a!==n&&yd(e,a,{get:()=>t[a],enumerable:!(r=VS(t,a))||r.enumerable});return e};var eC=(e,t,n)=>(n=e!=null?GS(YS(e)):{},XS(t||!e||!e.__esModule?yd(n,"default",{value:e,enumerable:!0}):n,e));var E,p=ZS(()=>{E={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var GS=Object.create;var yd=Object.defineProperty;var VS=Object.getOwnPropertyDescriptor;var $S=Object.getOwnPropertyNames;var YS=Object.getPrototypeOf,QS=Object.prototype.hasOwnProperty;var ZS=(e,t)=>()=>(e&&(t=e(e=0)),t);var JS=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ol=(e,t)=>{for(var n in t)yd(e,n,{get:t[n],enumerable:!0})},XS=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of $S(t))!QS.call(e,a)&&a!==n&&yd(e,a,{get:()=>t[a],enumerable:!(r=VS(t,a))||r.enumerable});return e};var eC=(e,t,n)=>(n=e!=null?GS(YS(e)):{},XS(t||!e||!e.__esModule?yd(n,"default",{value:e,enumerable:!0}):n,e));var E,p=ZS(()=>{E={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5176,13 +5176,13 @@ ass, HTML, arquivos TXT`,"description.subtitlePrompt":`Em cen\xE1rios de legenda {env.imt_trans_field}: tradu\xE7\xE3o`,"subtitle.quickButton.green":"verde","subtitle.quickButton.magenta":"Magenta","translationServices.claude":"Claude","subtitle.quickButton.white":"branco","subtitle.quickButton.translationTextColor":"Cor da fonte da tradu\xE7\xE3o","subtitle.quickButton.backgroundOpacity":"opacidade de fundo","subtitle.quickButton.sourceFontSize":"Tamanho original da fonte","subtitle.quickButton.backgroundColor":"cor de fundo","subtitle.quickButton.setting":"configura\xE7\xE3o","subtitle.quickButton.blue":"azul","subtitle.quickButton.translationPositionBottom":"\u539F\u6587\u4E0B\u65B9","subtitle.quickButton.yellow":"Amarelo","subtitle.quickButton.translationPositionTop":"Acima do texto original","subtitle.quickButton.sourceTextColor":"Cor original da fonte","subtitle.quickButton.red":"vermelho","subtitle.quickButton.translationPosition":"Posi\xE7\xE3o de tradu\xE7\xE3o","subtitle.quickButton.cyan":"Azul","subtitle.quickButton.black":"preto","subtitle.quickButton.translationFontSize":"Tamanho da fonte do texto traduzido",attachSubtitleTranslating:"Usando {service} para traduzir...","error.claude.403":"Sem permiss\xE3o para acessar o servi\xE7o, pode estar relacionado com as restri\xE7\xF5es de \xE1rea de Claude, voc\xEA pode tentar alterar o seu endere\xE7o IP, ou usar outros servi\xE7os de tradu\xE7\xE3o.","browser.brandDescriptionForSafari":"\u3010Tradu\xE7\xE3o imersiva\u3011Um plugin de tradu\xE7\xE3o de p\xE1ginas da web bilingue (original/tradu\xE7\xE3o) gratuito, que suporta a tradu\xE7\xE3o de PDF e EPUB e mant\xE9m a formata\xE7\xE3o original do documento, a tradu\xE7\xE3o de legendas bilingues de v\xEDdeos online como Youtube/Netflix, e suporta servi\xE7os de tradu\xE7\xE3o mainstream como Deepl/Google;","browser.PdfProFile":"AI impulsionado pela tradu\xE7\xE3o do PDF Pro","browser.textTranslate":"Tradu\xE7\xE3o de texto"};var Lb=[{code:"zh-CN",messages:hb},{code:"zh-TW",messages:bb},{code:"en",messages:yb},{code:"ja",messages:Tb},{code:"ar",messages:vb},{code:"de",messages:Sb},{code:"es",messages:Cb},{code:"fa",messages:xb},{code:"fr",messages:Eb},{code:"hi",messages:wb},{code:"it",messages:Db},{code:"ru",messages:Ab},{code:"ko",messages:kb},{code:"pt",messages:Pb}];var Mb="immersiveTranslateDeeplGlobalState",hp="immersiveTranslateBingGlobalState",bp="immersiveTranslateYandexGlobalState",nn={};for(let e of Lb)nn[e.code]=e.messages;var Di="Immersive Translate",ee="immersive-translate";var be="immersiveTranslate",sc="759003177173-mfm15s5nd77vfmo6e7lanof1emnanf0e.apps.googleusercontent.com",_a=be+"GoogleAccessToken",tu=be+"AuthFlow",uc="immersive-translate-config-latest.json",yp=be+"AuthState",lc=be+"IframeMessage",bj=be+"WaitForRateLimit",Fb=be+"DocumentMessageAsk",Yt=be+"DocumentMessageTellThirdParty",Ai=be+"showError",Bb=be+"DocumentMessageThirdPartyTell",Ib=be+"DocumentMessageEventUpload",Q8=be+"DocumentMessageHandler",cc=`${be}Share`,nu=`${be}ToggleMouseHoverTranslateDirectly`,Rb=`${be}ReqDraft`,Ob=`${be}ResDraft`,Z8=`${be}Container`,zb=`${be}SpecifiedContainer`,ia="buildinConfig",Ao="localConfig",ru="openOptionsPage",Tp="openAboutPage",Nb="translateLocalPdfFile";var au="openEbookViewer",iu="openEbookBuilder";var ki=`${be}PageTranslatedStatus`,yj=`${be}PageUrlChanged`,oa=`${be}ReceiveCommand`,Ub=be+"LastUseMouseHoverTime",dc=be+"LastUseInputTime",yr=be+"LastUseManualTranslatePageTime",Tj=`${be}PopupReceiveMessage`,J8="immersivetranslate.com",X8="config.immersivetranslate.com",vj=`https://${J8}/`,Ma=`https://${X8}/default_config.json`,Sj=`${be}Mark`,In=`${be}Root`,qb=`${be}Walked`,Cj=`data-${ee}-walked`,jb=`${be}Paragraph`,Hb=`data-${ee}-paragraph`,Fr=`data-${ee}-translation-element-mark`,Wb=`${be}TranslationElementMark`,xj=`${be}TranslatedMark`,Kb=`${be}LoadingId`,vp=`data-${ee}-loading-id`,Gb=`${be}ErrorId`,gc=`data-${ee}-error-id`,e7=`${be}AtomicBlockMark`,Vb=`${be}ExcludeMark`,Ej=`data-${ee}-exclude-mark`,t7=`${be}StayOriginalMark`,wj=`${be}PreWhitespaceMark`,pc=`${be}InlineMark`,$b=`${be}BlockMark`,Dj=`${be}Left`,Aj=`${be}Right`,kj=`${be}Width`,Pj=`${be}Height`,Lj=`${be}Top`,_j=`${be}FontSize`,Yb="lastRunTime",Mj=`${be}GlobalStyleMark`,ou=["@","#"],mc=" --- ",Qb=` `,Lt=`${ee}-target-wrapper`,Fj=`${ee}-pdf-target-container`,fc=`${ee}-target-inner`,Bj=`${ee}-source-wrapper`,Sp=`${ee}-target-translation-block-wrapper`,Ij=`${ee}-root-translation-theme`,ko=`${be}RootTranslationTheme`,Zb=`${ee}-target-translation-vertical-block-wrapper`,Rj=`${ee}-target-translation-pdf-block-wrapper`,Jb=`${ee}-target-translation-pre-whitespace`,Cp=`${ee}-target-translation-inline-wrapper`,xp=["none","dashed","underline","dashedBorder","solidBorder","mask","opacity","dotted","dividingLine","highlight","marker","marker2","blockquote","weakening","grey","paper","italic","bold","thinDashed","wavy","nativeDotted","nativeDashed","nativeUnderline"],su={underline:[{name:"borderColor",required:!1,type:"color"}],nativeUnderline:[{name:"borderColor",required:!1,type:"color"}],nativeDashed:[{name:"borderColor",required:!1,type:"color"}],nativeDotted:[{name:"borderColor",required:!1,type:"color"}],dotted:[{name:"borderColor",required:!1,type:"color"}],dividingLine:[{name:"borderColor",required:!1,type:"color"}],highlight:[{name:"backgroundColor",required:!1,type:"color"}],marker:[{name:"backgroundColor",required:!1,type:"color"}],dashed:[{name:"borderColor",required:!1,type:"color"}],blockquote:[{name:"borderColor",required:!1,type:"color"}],thinDashed:[{name:"borderColor",required:!1,type:"color"}],dashedBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],solidBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],marker2:[{name:"backgroundColor",required:!1,type:"color"}],wavy:[{name:"borderColor",required:!1,type:"color"}],opacity:[{name:"opacity",required:!1,type:"number",default:10}]},Rn=["auto","zh-CN","zh-TW","en","ja","ko","es","de","fr","pt","pt-br","ru","ar","it","ms","id","vi","af","th","ur","yue","zh-CN-NE","bo","wyw","am","az","be","bg","bn","bs","ca","ceb","co","cs","cy","da","el","eo","et","eu","fa","fi","fil","fj","fy","ga","gd","gl","gu","ha","haw","he","hi","hmn","hr","ht","hu","hy","ig","is","jw","ka","kk","km","kn","ku","ky","la","lb","lo","lt","lv","mg","mi","mk","ml","mn","mr","mt","mww","my","ne","nl","no","ny","otq","pa","pl","ps","ro","sa","sd","si","sk","sl","sm","sn","so","sq","sr","sr-Cyrl","sr-Latn","st","su","sv","sw","ta","te","tg","tlh","tlh-Qaak","to","tr","ty","ug","uk","uz","xh","yi","yo","yua","zu"],Xb={af:"Afrikaans",am:"Amharic",ar:"Arabic",auto:"Auto Detect",az:"Azerbaijani",be:"Belarusian",bg:"Bulgarian",tn:"Zana",bn:"Bengali",bs:"Bosnian",bo:"Tibetan",ca:"Catalan",ceb:"Cebuano",co:"Corsican",cs:"Czech",cy:"Welsh",da:"Danish",de:"German",el:"Greek",en:"English",eo:"Esperanto",es:"Spanish",et:"Estonian",eu:"Basque",sa:"Sanskrit",fa:"Persian",fi:"Finnish",fil:"Filipino",fj:"Fijian",fr:"French",fy:"Frisian",ga:"Irish",gd:"Scottish Gaelic",gl:"Galician",gu:"Gujarati",ha:"Hausa",haw:"Hawaiian",he:"Hebrew",hi:"Hindi",hmn:"Hmong",hr:"Croatian",ht:"Haitian Creole",hu:"Hungarian",hy:"Armenian",id:"Indonesian",ig:"Igbo",is:"Icelandic",it:"Italian",ja:"Japanese",jw:"Javanese",ka:"Georgian",kk:"Kazakh",km:"Khmer",kn:"Kannada",ko:"Korean",ku:"Kurdish",ky:"Kyrgyz",la:"Latin",lb:"Luxembourgish",lo:"Lao",lt:"Lithuanian",lv:"Latvian",mg:"Malagasy",mi:"Maori",mk:"Macedonian",ml:"Malayalam",mn:"Mongolian",mr:"Marathi",ms:"Malay",mt:"Maltese",mww:"Hmong Daw",my:"Burmese",ne:"Nepali",nl:"Dutch",no:"Norwegian",ny:"Chichewa",otq:"Quer\xE9taro Otomi",pa:"Punjabi",pl:"Polish",ps:"Pashto",pt:"Portuguese","pt-br":"Portuguese (Brazil)",ro:"Romanian",ru:"Russian",sd:"Sindhi",si:"Sinhala",sk:"Slovak",sl:"Slovenian",sm:"Samoan",sn:"Shona",so:"Somali",sq:"Albanian",sr:"Serbian","sr-Cyrl":"Serbian (Cyrillic)","sr-Latn":"Serbian (Latin)",st:"Sesotho",su:"Sundanese",sv:"Swedish",sw:"Swahili",ta:"Tamil",te:"Telugu",tg:"Tajik",th:"Thai",tlh:"Klingon","tlh-Qaak":"Klingon (piqaD)",to:"Tongan",tr:"Turkish",ty:"Tahitian",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",vi:"Vietnamese",wyw:"Classical Chinese",xh:"Xhosa",placeholder:"Please Select",yi:"Yiddish",yo:"Yoruba",yua:"Yucatec Maya",yue:"Cantonese (Traditional)","zh-CN":"Simplified Chinese","zh-TW":"Traditional Chinese","zh-CN-NE":"Northeastern Chinese",zu:"Zulu","":"All Languages"},e1={placeholder:"\u8BF7\u9009\u62E9",af:"\u5357\u975E\u8377\u5170\u8BED",am:"\u963F\u59C6\u54C8\u62C9\u8BED",ar:"\u963F\u62C9\u4F2F\u8BED",auto:"\u81EA\u52A8\u68C0\u6D4B",az:"\u963F\u585E\u62DC\u7586\u8BED",be:"\u767D\u4FC4\u7F57\u65AF\u8BED",bg:"\u4FDD\u52A0\u5229\u4E9A\u8BED",tn:"\u8D5E\u7EB3\u8BED",bn:"\u5B5F\u52A0\u62C9\u8BED",bs:"\u6CE2\u65AF\u5C3C\u4E9A\u8BED",bo:"\u85CF\u8BED",ca:"\u52A0\u6CF0\u7F57\u5C3C\u4E9A\u8BED",ceb:"\u5BBF\u52A1\u8BED",co:"\u79D1\u897F\u5609\u8BED",cs:"\u6377\u514B\u8BED",cy:"\u5A01\u5C14\u58EB\u8BED",da:"\u4E39\u9EA6\u8BED",de:"\u5FB7\u8BED",el:"\u5E0C\u814A\u8BED",en:"\u82F1\u8BED",eo:"\u4E16\u754C\u8BED",es:"\u897F\u73ED\u7259\u8BED",et:"\u7231\u6C99\u5C3C\u4E9A\u8BED",eu:"\u5DF4\u65AF\u514B\u8BED",sa:"\u68B5\u8BED",fa:"\u6CE2\u65AF\u8BED",fi:"\u82AC\u5170\u8BED",fil:"\u83F2\u5F8B\u5BBE\u8BED",fj:"\u6590\u6D4E\u8BED",fr:"\u6CD5\u8BED",fy:"\u5F17\u91CC\u65AF\u5170\u8BED",ga:"\u7231\u5C14\u5170\u8BED",gd:"\u82CF\u683C\u5170\u76D6\u5C14\u8BED",gl:"\u52A0\u5229\u897F\u4E9A\u8BED",gu:"\u53E4\u5409\u62C9\u7279\u8BED",ha:"\u8C6A\u8428\u8BED",haw:"\u590F\u5A01\u5937\u8BED",he:"\u5E0C\u4F2F\u6765\u8BED",hi:"\u5370\u5730\u8BED",hmn:"\u82D7\u8BED",hr:"\u514B\u7F57\u5730\u4E9A\u8BED",ht:"\u6D77\u5730\u514B\u91CC\u5965\u5C14\u8BED",hu:"\u5308\u7259\u5229\u8BED",hy:"\u4E9A\u7F8E\u5C3C\u4E9A\u8BED",id:"\u5370\u5EA6\u5C3C\u897F\u4E9A\u8BED",ig:"\u4F0A\u535A\u8BED",is:"\u51B0\u5C9B\u8BED",it:"\u610F\u5927\u5229\u8BED",ja:"\u65E5\u672C\u8BED",jw:"\u722A\u54C7\u8BED",ka:"\u683C\u9C81\u5409\u4E9A\u8BED",kk:"\u54C8\u8428\u514B\u8BED",km:"\u9AD8\u68C9\u8BED",kn:"\u5361\u7EB3\u8FBE\u8BED",ko:"\u97E9\u8BED",ku:"\u5E93\u5C14\u5FB7\u8BED",ky:"\u5409\u5C14\u5409\u65AF\u8BED",la:"\u62C9\u4E01\u8BED",lb:"\u5362\u68EE\u5821\u8BED",lo:"\u8001\u631D\u8BED",lt:"\u7ACB\u9676\u5B9B\u8BED",lv:"\u62C9\u8131\u7EF4\u4E9A\u8BED",mg:"\u9A6C\u62C9\u52A0\u65AF\u8BED",mi:"\u6BDB\u5229\u8BED",mk:"\u9A6C\u5176\u987F\u8BED",ml:"\u9A6C\u62C9\u96C5\u62C9\u59C6\u8BED",mn:"\u8499\u53E4\u8BED",mr:"\u9A6C\u62C9\u5730\u8BED",ms:"\u9A6C\u6765\u8BED",mt:"\u9A6C\u8033\u4ED6\u8BED",mww:"\u767D\u82D7\u8BED",my:"\u7F05\u7538\u8BED",ne:"\u5C3C\u6CCA\u5C14\u8BED",nl:"\u8377\u5170\u8BED",no:"\u632A\u5A01\u8BED",ny:"\u9F50\u5207\u74E6\u8BED\uFF08\u5C3C\u626C\u8D3E\u8BED\uFF09",otq:"\u514B\u96F7\u5854\u7F57\u5965\u6258\u7C73\u8BED",pa:"\u65C1\u906E\u666E\u8BED",pl:"\u6CE2\u5170\u8BED",ps:"\u666E\u4EC0\u56FE\u8BED",pt:"\u8461\u8404\u7259\u8BED","pt-br":"\u8461\u8404\u7259\u8BED\uFF08\u5DF4\u897F\uFF09",ro:"\u7F57\u9A6C\u5C3C\u4E9A\u8BED",ru:"\u4FC4\u8BED",sd:"\u4FE1\u5FB7\u8BED",si:"\u50E7\u4F3D\u7F57\u8BED",sk:"\u65AF\u6D1B\u4F10\u514B\u8BED",sl:"\u65AF\u6D1B\u6587\u5C3C\u4E9A\u8BED",sm:"\u8428\u6469\u4E9A\u8BED",sn:"\u4FEE\u7EB3\u8BED",so:"\u7D22\u9A6C\u91CC\u8BED",sq:"\u963F\u5C14\u5DF4\u5C3C\u4E9A\u8BED",sr:"\u585E\u5C14\u7EF4\u4E9A\u8BED","sr-Cyrl":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u897F\u91CC\u5C14\u6587\uFF09","sr-Latn":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u62C9\u4E01\u6587\uFF09",st:"\u585E\u7D22\u6258\u8BED",su:"\u5DFD\u4ED6\u8BED",sv:"\u745E\u5178\u8BED",sw:"\u65AF\u74E6\u5E0C\u91CC\u8BED",ta:"\u6CF0\u7C73\u5C14\u8BED",te:"\u6CF0\u5362\u56FA\u8BED",tg:"\u5854\u5409\u514B\u8BED",th:"\u6CF0\u8BED",tlh:"\u514B\u6797\u8D21\u8BED","tlh-Qaak":"\u514B\u6797\u8D21\u8BED\uFF08piqaD\uFF09",to:"\u6C64\u52A0\u8BED",tr:"\u571F\u8033\u5176\u8BED",ty:"\u5854\u5E0C\u63D0\u8BED",ug:"\u7EF4\u543E\u5C14\u8BED",uk:"\u4E4C\u514B\u5170\u8BED",ur:"\u4E4C\u5C14\u90FD\u8BED",uz:"\u4E4C\u5179\u522B\u514B\u8BED",vi:"\u8D8A\u5357\u8BED",wyw:"\u6587\u8A00\u6587",xh:"\u73ED\u56FE\u8BED",yi:"\u610F\u7B2C\u7EEA\u8BED",yo:"\u7EA6\u9C81\u5DF4\u8BED",yua:"\u5C24\u5361\u5766\u739B\u96C5\u8BED",yue:"\u7CA4\u8BED","zh-CN":"\u7B80\u4F53\u4E2D\u6587","zh-TW":"\u7E41\u4F53\u4E2D\u6587","zh-CN-NE":"\u4E1C\u5317\u8BDD",zu:"\u7956\u9C81\u8BED","":"\u6240\u6709\u8BED\u8A00"},t1={placeholder:"\u8ACB\u9078\u64C7",af:"\u963F\u975E\u5229\u5361\u8A9E",am:"\u963F\u59C6\u54C8\u62C9\u8A9E",ar:"\u963F\u62C9\u4F2F\u8A9E",auto:"\u81EA\u52D5\u6AA2\u6E2C",az:"\u963F\u585E\u62DC\u7586\u8A9E",be:"\u767D\u4FC4\u7F85\u65AF\u8A9E",bg:"\u4FDD\u52A0\u5229\u4E9E\u8A9E",tn:"\u8D0A\u7D0D\u8A9E",bn:"\u5B5F\u52A0\u62C9\u8A9E",bs:"\u6CE2\u65AF\u5C3C\u4E9E\u8A9E",bo:"\u85CF\u8A9E",ca:"\u52A0\u6CF0\u862D\u8A9E",ceb:"\u5BBF\u9727\u8A9E",co:"\u79D1\u897F\u5609\u8A9E",cs:"\u6377\u514B\u8A9E",cy:"\u5A01\u723E\u65AF\u8A9E",da:"\u4E39\u9EA5\u8A9E",de:"\u5FB7\u8A9E",el:"\u5E0C\u81D8\u8A9E",en:"\u82F1\u8A9E",eo:"\u4E16\u754C\u8A9E",es:"\u897F\u73ED\u7259\u8A9E",et:"\u611B\u6C99\u5C3C\u4E9E\u8A9E",eu:"\u5DF4\u65AF\u514B\u8A9E",sa:"\u68B5\u8A9E",fa:"\u6CE2\u65AF\u8A9E",fi:"\u82AC\u862D\u8A9E",fil:"\u83F2\u5F8B\u8CD3\u8A9E",fj:"\u6590\u6FDF\u8A9E",fr:"\u6CD5\u8A9E",fy:"\u5F17\u91CC\u897F\u8A9E",ga:"\u611B\u723E\u862D\u8A9E",gd:"\u8607\u683C\u862D\u84CB\u723E\u8A9E",gl:"\u52A0\u5229\u897F\u4E9E\u8A9E",gu:"\u53E4\u5409\u62C9\u7279\u8A9E",ha:"\u8C6A\u6492\u8A9E",haw:"\u590F\u5A01\u5937\u8A9E",he:"\u5E0C\u4F2F\u4F86\u8A9E",hi:"\u5370\u5730\u8A9E",hmn:"\u82D7\u8A9E",hr:"\u514B\u7F85\u5730\u4E9E\u8A9E",ht:"\u6D77\u5730\u514B\u91CC\u5967\u723E\u8A9E",hu:"\u5308\u7259\u5229\u8A9E",hy:"\u4E9E\u7F8E\u5C3C\u4E9E\u8A9E",id:"\u5370\u5C3C\u8A9E",ig:"\u4F0A\u535A\u8A9E",is:"\u51B0\u5CF6\u8A9E",it:"\u610F\u5927\u5229\u8A9E",ja:"\u65E5\u8A9E",jw:"\u722A\u54C7\u8A9E",ka:"\u55AC\u6CBB\u4E9E\u8A9E",kk:"\u54C8\u85A9\u514B\u8A9E",km:"\u9AD8\u68C9\u8A9E",kn:"\u574E\u7D0D\u9054\u8A9E",ko:"\u97D3\u8A9E",ku:"\u5EAB\u723E\u5FB7\u8A9E",ky:"\u5409\u723E\u5409\u65AF\u8A9E",la:"\u62C9\u4E01\u8A9E",lb:"\u76E7\u68EE\u5821\u8A9E",lo:"\u8001\u64BE\u8A9E",lt:"\u7ACB\u9676\u5B9B\u8A9E",lv:"\u62C9\u812B\u7DAD\u4E9E\u8A9E",mg:"\u99AC\u62C9\u52A0\u65AF\u8A9E",mi:"\u6BDB\u5229\u8A9E",mk:"\u99AC\u5176\u9813\u8A9E",ml:"\u99AC\u62C9\u96C5\u62C9\u59C6\u8A9E",mn:"\u8499\u53E4\u8A9E",mr:"\u99AC\u62C9\u5730\u8A9E",ms:"\u99AC\u4F86\u8A9E",mt:"\u99AC\u723E\u4ED6\u8A9E",mww:"\u767D\u82D7\u8A9E",my:"\u7DEC\u7538\u8A9E",ne:"\u5C3C\u6CCA\u723E\u8A9E",nl:"\u8377\u862D\u8A9E",no:"\u632A\u5A01\u8A9E",ny:"\u9F4A\u5207\u74E6\u8A9E",otq:"\u594E\u96F7\u5854\u7F85\u5967\u6258\u7C73\u8A9E",pa:"\u65C1\u906E\u666E\u8A9E",pl:"\u6CE2\u862D\u8A9E",ps:"\u666E\u4EC0\u5716\u8A9E",pt:"\u8461\u8404\u7259\u8A9E","pt-br":"\u8461\u8404\u7259\u8A9E\uFF08\u5DF4\u897F\uFF09",ro:"\u7F85\u99AC\u5C3C\u4E9E\u8A9E",ru:"\u4FC4\u8A9E",sd:"\u4FE1\u5FB7\u8A9E",si:"\u50E7\u4F3D\u7F85\u8A9E",sk:"\u65AF\u6D1B\u4F10\u514B\u8A9E",sl:"\u65AF\u6D1B\u7DAD\u5C3C\u4E9E\u8A9E",sm:"\u85A9\u6469\u4E9E\u8A9E",sn:"\u7D39\u7D0D\u8A9E",so:"\u7D22\u99AC\u91CC\u8A9E",sq:"\u963F\u723E\u5DF4\u5C3C\u4E9E\u8A9E",sr:"\u585E\u723E\u7DAD\u4E9E\u8A9E","sr-Cyrl":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u897F\u91CC\u723E\u6587)","sr-Latn":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u62C9\u4E01\u6587)",st:"\u585E\u7D22\u6258\u8A9E",su:"\u5DFD\u4ED6\u8A9E",sv:"\u745E\u5178\u8A9E",sw:"\u65AF\u74E6\u5E0C\u91CC\u8A9E",ta:"\u6CF0\u7C73\u723E\u8A9E",te:"\u6CF0\u76E7\u56FA\u8A9E",tg:"\u5854\u5409\u514B\u8A9E",th:"\u6CF0\u8A9E",tlh:"\u514B\u6797\u8CA2\u8A9E","tlh-Qaak":"\u514B\u6797\u8CA2\u8A9E (piqaD)",to:"\u6771\u52A0\u8A9E",tr:"\u571F\u8033\u5176\u8A9E",ty:"\u5854\u5E0C\u63D0\u8A9E",ug:"\u7DAD\u543E\u723E\u8A9E",uk:"\u70CF\u514B\u862D\u8A9E",ur:"\u70CF\u723E\u90FD\u8A9E",uz:"\u70CF\u8332\u5225\u514B\u8A9E",vi:"\u8D8A\u5357\u8A9E",wyw:"\u6587\u8A00\u6587",xh:"\u79D1\u85A9\u8A9E",yi:"\u610F\u7B2C\u7DD2\u8A9E",yo:"\u7D04\u9B6F\u5DF4\u8A9E",yua:"\u5C24\u52A0\u6566\u99AC\u96C5\u8A9E",yue:"\u5EE3\u6771\u8A71 (\u50B3\u7D71)","zh-CN":"\u7C21\u9AD4\u4E2D\u6587","zh-TW":"\u7E41\u9AD4\u4E2D\u6587","zh-CN-NE":"\u6771\u5317\u8A71",zu:"\u7956\u9B6F\u8A9E","":"\u6240\u6709\u8A9E\u8A00"};var hc=[{name:"touch",shortcuts:[{command:"touchShortcutsToggleTranslatePage",type:"finger"},{command:"touchShortcutsToggleTranslationMask",type:"finger"},{command:"touchShortcutsToggleTranslatePageOnlyTranslation",type:"finger"},{command:"touchShortcutsToggleTranslateTouchElement",type:"finger"}]},{name:"main",shortcuts:["toggleTranslatePage","shareToDraft","translateInputBox"]},{name:"mouse",shortcuts:[{command:"mouseHoverHoldKey",type:"mouseHoverHoldKey"},"toggleMouseHoverTranslateDirectly"]},{name:"others",shortcuts:["toggleTranslationMask","toggleTranslateToThePageEndImmediately","toggleTranslateTheMainPage","toggleOnlyTransation","toggleTranslateTheWholePage","toggleVideoSubtitlePreTranslation"]},{name:"shortcutsForTranslationServices",shortcuts:["translateWithDeepL","translateWithGoogle","translateWithOpenAI","translateWithBing","translateWithTransmart","translateWithGemini"]}],n1=["https://immersive-translate.owenyoung.com/options/","https://immersive-translate.owenyoung.com/auth-done/","https://dash.immersivetranslate.com/","https://dash.immersivetranslate.com/auth-done/","http://localhost:8000/dist/userscript/options/","http://localhost:8000/auth-done/","http://192.168.50.9:8000/dist/userscript/options/","http://192.168.31.51:8000/dist/userscript/options/","http://192.168.1.72:8000/dist/userscript/options/","https://www.deepl.com/translator","translate.google.com","http://localhost:8000/options/","http://192.168.50.9:8000/options/","http://192.168.31.51:8000/options/","http://192.168.1.72:8000/options/"],Br="zh-CN",bc="https://immersivetranslate.com/docs/communities/",_b=[{type:"select",name:"codename",labelKey:"field.translationEngine",default:"youdao",required:!1,options:[{label:"translationServices.google",value:"google"},{label:"translationServices.deepl",value:"deepl"},{label:"translationServices.youdao",value:"youdao"},{label:"translationServices.tencent",value:"tencent"},{label:"translationServices.aliyun",value:"aliyun"},{label:"translationServices.baidu",value:"baidu"},{label:"translationServices.caiyun",value:"caiyun"},{label:"translationServices.wechat",value:"wechat"},{label:"translationServices.ibm",value:"ibm"},{label:"translationServices.azure",value:"azure"},{label:"translationServices.aws",value:"aws"}]}],yc=["caiyun","cai"],nr={bing:{name:"\u5FAE\u8F6F\u7FFB\u8BD1",homepage:"https://www.bing.com/translator"},google:{name:"Google",homepage:"https://translate.google.com/"},deepl:{name:"DeepL",homepage:"https://www.deepl.com/translator",docUrl:"https://immersivetranslate.com/docs/services/deepL/",providers:[{name:"pro",nameKey:"deepLProName",descriptionKey:"deepLProDescription",descriptionKeyForNormal:"deeplProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"deepLCustomName",descriptionKey:"deepLCustomDescription",descriptionLink1:"https://www.deepl.com/translator",descriptionLink2:"https://immersivetranslate.com/docs/services/deepL/"}],allProps:[{name:"authKey",providers:["custom"],label:"Auth Key",required:!0,type:"password"}]},openai:{name:"Open AI",homepage:"https://openai.com/api/",docUrl:"https://immersivetranslate.com/docs/services/openai/",providers:[{name:"pro",nameKey:"openaiProName",descriptionKey:"openaiProDescription",descriptionKeyForNormal:"openaiProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"openaiCustomName",descriptionKey:"openaiCustomDescription",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/"}],allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",required:!1,type:"model-select",default:"gpt-3.5-turbo-1106",providers:["custom"],options:[{providers:["custom","pro"],label:"gpt-3.5-turbo",value:"gpt-3.5-turbo"},{providers:["custom"],label:"gpt-3.5-turbo-0125",value:"gpt-3.5-turbo-0125"},{providers:["custom","pro"],label:"gpt-3.5-turbo-1106",value:"gpt-3.5-turbo-1106"},{providers:["custom","pro"],label:"gpt-3.5-turbo-0613",value:"gpt-3.5-turbo-0613"},{providers:["custom"],label:"gpt-4-1106-preview",value:"gpt-4-1106-preview"},{providers:["custom"],label:"gpt-4-0125-preview",value:"gpt-4-0125-preview"},{providers:["custom"],label:"gpt-4",value:"gpt-4"}]},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.limitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:10,providers:["custom"]},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.openai.com/v1/chat/completions",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",optional:!0,providers:["custom"]},{name:"systemPrompt",label:"System Prompt",required:!1,descriptionKey:"description.systemPrompt",type:"textarea",optional:!0,default:"You are a translation engine, you can only translate text and cannot interpret it, and do not explain."},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:`Translate the text to {{to}}, please do not explain any sentences, just translate or leave them as they are.: -{{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:ou,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[..._b,{type:"password",name:"apikey",required:!0}],props:_b},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},Tc={type:be+"ChildFrameToRootFrameIdentifier"},Ep=["youtube","netflix","webvtt","khanacademy","bilibili","udemy","hulu","text_track","text_track_dynamic","general","live","ebutt","disneyplus","fmp4.xml","multi_attach_vtt","twitter","subsrt","xml","av"],sa=["Ctrl","Shift","Alt","Auto","Off","OtherCustom","Other"],r1=["ctrl","alt","shift","cmd","command","option","control"],vc=[{key:"/"},{key:"="},{key:";"},{key:","},{key:"."},{key:":"},{key:"space",labelKey:"spaceKey",skipForStarting:!0},{key:"none",labelKey:"noneKey",skipForTrailing:!0}],Oj=pn()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general",uu="user_from_plugin",ht="user_info",Pi=pn()||tr()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",Sc=pn()||tr()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",a1=Sc+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",i1=Sc+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Li=pn()||tr()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",Fa=pn()||tr()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",n7=pn()||tr()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",r7=pn()||tr()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",a7=pn()||tr()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",zj=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",o1=n7+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",s1=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Cc=Fa+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",u1=r7+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",l1=a7+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",c1=Li+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true",xc="https://immersivetranslate.com/docs/usage/",d1="https://immersivetranslate.com/docs/communities/",g1=Le().TRANSLATE_FILE_URL,p1=g1+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",m1=g1+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var Po=console,wp=class{#e=performance.now();reset(){this.#e=performance.now()}stop(t){let n=performance.now(),r=Math.round(n-this.#e),a=Zn.green;r>1e4?a=Zn.red:r>1e3&&(a=Zn.yellow),Po.debug(Zn.dim(Di+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},lu=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&Po.log(Zn.dim(Di+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&Po.log(Zn.green(Di+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&Po.warn(Zn.yellow(Di+" WARN:"),...t)}error(...t){this.#e<=3&&Po.error(Zn.red(Di+" ERROR:"),...t)}fatal(...t){this.#e<=4&&Po.error(Zn.red(Di+" FATAL:"),...t)}timing(){return this.level===0?new wp:{reset:()=>{},stop:()=>{}}}},R=new lu;p();function ot(){try{let e=[Le().EBOOK_BUILDER_URL,Le().EBOOK_VIEWER_URL,Le().SUBTITLE_BUILDER_URL,Le().HTML_VIEWER_URL,Le().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];pn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&t.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}p();p();var Ec={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.3",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};p();p();p();var Dp=/iPhone/i,f1=/iPod/i,h1=/iPad/i,b1=/\biOS-universal(?:.+)Mac\b/i,Ap=/\bAndroid(?:.+)Mobile\b/i,y1=/Android/i,Lo=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wc=/Silk/i,ua=/Windows Phone/i,T1=/\bWindows(?:.+)ARM\b/i,v1=/BlackBerry/i,S1=/BB10/i,C1=/Opera Mini/i,x1=/\b(CriOS|Chrome)(?:.+)Mobile/i,E1=/Mobile(?:.+)Firefox\b/i,w1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function o7(e){return t=>t.test(e)}function st(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=o7(n),i={apple:{phone:a(Dp)&&!a(ua),ipod:a(f1),tablet:!a(Dp)&&(a(h1)||w1(t))&&!a(ua),universal:a(b1),device:(a(Dp)||a(f1)||a(h1)||a(b1)||w1(t))&&!a(ua)},amazon:{phone:a(Lo),tablet:!a(Lo)&&a(wc),device:a(Lo)||a(wc)},android:{phone:!a(ua)&&a(Lo)||!a(ua)&&a(Ap),tablet:!a(ua)&&!a(Lo)&&!a(Ap)&&(a(wc)||a(y1)),device:!a(ua)&&(a(Lo)||a(wc)||a(Ap)||a(y1))||a(/\bokhttp\b/i)},windows:{phone:a(ua),tablet:a(T1),device:a(ua)||a(T1)},other:{blackberry:a(v1),blackberry10:a(S1),opera:a(C1),firefox:a(E1),chrome:a(x1),device:a(v1)||a(S1)||a(C1)||a(E1)||a(x1)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var kp="DENO",Dc="CHROME",Ac="FIREFOX";function D1(e){let t=Dc;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Ac:/deno/i.test(n)&&(t=kp)}catch{}return e===Dc&&t===Dc||e===Ac&&t===Ac||e===kp&&t===kp}function Pp(){return D1(Dc)}function A1(){return typeof Deno<"u"}function rr(){return D1(Ac)}function Ba(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function k1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function _i(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function P1(){return pe()?"monkey":Pp()?"chrome":rr()?"firefox":Ge()?"safari":null}p();var L1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},_1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:L1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:L1,query:()=>{},sendMessage:()=>{}}};var Z;A1()?Z=_1:Z=globalThis.immersiveTranslateBrowserAPI;var s7="";function On(){return s7||Ec.version}function Ir(){return Z.runtime.getManifest().version}p();function M1(e){return e.replace(//g,">")}p();function Qt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function F1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function B1(e){if(e){let t=new Date(e.createTime),n=u7(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function u7(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}p();p();function ve(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Rn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Rn[a]}else return"auto";else return Rn[r]}function At(){return ve(document?.documentElement?.lang||"en")}function cu(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+o.text.length>t||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function l7(e,t){let n=[],r=[];for(let a=0;a0?y1e4?a=Zn.red:r>1e3&&(a=Zn.yellow),Po.debug(Zn.dim(Di+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},lu=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&Po.log(Zn.dim(Di+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&Po.log(Zn.green(Di+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&Po.warn(Zn.yellow(Di+" WARN:"),...t)}error(...t){this.#e<=3&&Po.error(Zn.red(Di+" ERROR:"),...t)}fatal(...t){this.#e<=4&&Po.error(Zn.red(Di+" FATAL:"),...t)}timing(){return this.level===0?new wp:{reset:()=>{},stop:()=>{}}}},R=new lu;p();function ot(){try{let e=[Le().EBOOK_BUILDER_URL,Le().EBOOK_VIEWER_URL,Le().SUBTITLE_BUILDER_URL,Le().HTML_VIEWER_URL,Le().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];pn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&t.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}p();p();var Ec={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.4",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};p();p();p();var Dp=/iPhone/i,f1=/iPod/i,h1=/iPad/i,b1=/\biOS-universal(?:.+)Mac\b/i,Ap=/\bAndroid(?:.+)Mobile\b/i,y1=/Android/i,Lo=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,wc=/Silk/i,ua=/Windows Phone/i,T1=/\bWindows(?:.+)ARM\b/i,v1=/BlackBerry/i,S1=/BB10/i,C1=/Opera Mini/i,x1=/\b(CriOS|Chrome)(?:.+)Mobile/i,E1=/Mobile(?:.+)Firefox\b/i,w1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function o7(e){return t=>t.test(e)}function st(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=o7(n),i={apple:{phone:a(Dp)&&!a(ua),ipod:a(f1),tablet:!a(Dp)&&(a(h1)||w1(t))&&!a(ua),universal:a(b1),device:(a(Dp)||a(f1)||a(h1)||a(b1)||w1(t))&&!a(ua)},amazon:{phone:a(Lo),tablet:!a(Lo)&&a(wc),device:a(Lo)||a(wc)},android:{phone:!a(ua)&&a(Lo)||!a(ua)&&a(Ap),tablet:!a(ua)&&!a(Lo)&&!a(Ap)&&(a(wc)||a(y1)),device:!a(ua)&&(a(Lo)||a(wc)||a(Ap)||a(y1))||a(/\bokhttp\b/i)},windows:{phone:a(ua),tablet:a(T1),device:a(ua)||a(T1)},other:{blackberry:a(v1),blackberry10:a(S1),opera:a(C1),firefox:a(E1),chrome:a(x1),device:a(v1)||a(S1)||a(C1)||a(E1)||a(x1)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var kp="DENO",Dc="CHROME",Ac="FIREFOX";function D1(e){let t=Dc;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Ac:/deno/i.test(n)&&(t=kp)}catch{}return e===Dc&&t===Dc||e===Ac&&t===Ac||e===kp&&t===kp}function Pp(){return D1(Dc)}function A1(){return typeof Deno<"u"}function rr(){return D1(Ac)}function Ba(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function k1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function _i(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}function P1(){return pe()?"monkey":Pp()?"chrome":rr()?"firefox":Ge()?"safari":null}p();var L1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},_1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:L1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:L1,query:()=>{},sendMessage:()=>{}}};var Z;A1()?Z=_1:Z=globalThis.immersiveTranslateBrowserAPI;var s7="";function On(){return s7||Ec.version}function Ir(){return Z.runtime.getManifest().version}p();function M1(e){return e.replace(//g,">")}p();function Qt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function F1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function B1(e){if(e){let t=new Date(e.createTime),n=u7(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function u7(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,i]=n.split("/");return n=`${i}-${r}-${a}`,n}catch{return"unknown"}}p();p();function ve(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Rn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Rn[a]}else return"auto";else return Rn[r]}function At(){return ve(document?.documentElement?.lang||"en")}function cu(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+o.text.length>t||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function l7(e,t){let n=[],r=[];for(let a=0;a0?yt){let x=[];Lp(T,t,x);for(let w=0;w0&&y{let s=e.lastIndexOf(o,t);return s>i?s:i},-1);if(a===-1){let i=e.slice(0,t);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),e.length>t&&Lp(e.slice(t),t,n)}else{let i=e.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){g.forEach(y=>{c.length>0&&y.providers&&y.providers.length>0&&!y.providers.includes(l)||(y.optional?m.push(y):f.push(y))});let h=m.concat(f).filter(y=>y.required);if(h.length>0){for(let y of h)if(!i[y.name]){u=!1;break}}}return{...a,id:t,selected:n[e]===t,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:g,optionalProps:m,explicitProps:f}}var Mi=(e,t)=>{let{config:n}=e,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=e.user,u=Qt(s),l=Object.keys(nr);return t!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let g=nr[c];if(c.startsWith("mock"))return o?!0:c===e.config[t];if(c===e.config[t])return!0;if(c==="openai"&&Ge())return e.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let f=!!g.canary,m=!!g.alpha,h=!!g.beta;return c===e[t]||f&&i||m&&(r||i)||h&&(a||r||i)?!0:!m&&!h&&!f}).map(c=>_o(t,c,e))};function du(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function R1(e){return e.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}p();var O1=be+"SyncStoreKey_";function qt(e,t){let n=O1+e;return Z.storage.sync.get(n).then(r=>r[n]===void 0?t:r[n])}function at(e,t){let n=O1+e;return Z.storage.sync.set({[n]:t})}p();var Fi=be+"CacheKey_";function _p(e,t){let n=Fi+e;return Z.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function c7(){let e=Z.storage.local.refresh;e&&e()}function Mp(e,t){let n=Fi+e;return Z.storage.local.get(n).then(r=>{if(r[n]===void 0)return t;let{value:a,expired:i}=r[n];return i&&ir.startsWith(Fi)).filter(r=>r!==Fi+ht);if(n.length>0)return Z.storage.local.remove(n)}}var it={get:_p,set:Bp,getExpired:Mp,setExpired:Fp,remove:Ip,clear:Rp,refresh:c7};p();var z1=["*://*/*","*","*://*"],U1="immersive-translate-wildcard-placeholder.com";function Op(e,t){try{let n=[];if(!t||(t&&!Array.isArray(t)?n=[t]:n=t,n.length===0))return null;if(n.some(s=>z1.includes(s)))return e;let r=new URL(e);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(z1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,g=l.port===o;return l.port?c&&g:c}else return g7(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let T=u.split("://");l=T[0],l==="*"&&T.length>1&&(l="*",u="https://"+T[1])}else l="*",u="https://"+u;let g=u.replace(/\*/g,U1),f;try{f=new URL(g)}catch{return R.debug("invalid match pattern",g,"raw match value:",c),!1}let m=f.host,h=f.pathname;h==="/"&&(c.replace("://","").includes("/")||(h="/*"));let y=d7(l+":",N1(m),N1(h));if(y){let T=new URL(a);return y.test(T.href)}else return!1}});if(s)return s}return null}catch{return null}}function N1(e){return e.replaceAll(U1,"*")}function d7(e,t,n){let r="^";return e==="*:"?r+="(http:|https:|file:)":r+=e,r+="//",t&&(e==="file:"||(t==="*"?r+="[^/]+?":(t.match(/^\*\./)&&(r+="[^/]*?",t=t.substring(1)),r+=t.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function _t(e,t){return Op(e,t)!==null}function g7(e,t){let n=new URL(e),r=new URL(t);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}p();p();var q1=be+"StoreKey_";function la(e,t){let n=q1+e;return Z.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function j1(e,t){let n=q1+e;return Z.storage.local.set({[n]:t})}p();p();p();p();function H1(e,t){return[e,!e||e.endsWith("/")?"":"/",t,".json"].join("")}function zp(e,t){let n=e;return t&&Object.keys(t).forEach(r=>{let a=t[r];if(a===void 0)return;let i=p7(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let g=n.substring(u+s.length,c),f=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");n=n.replace(`${s}${g}`,`<${l} ${f}>${g}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function gu(e,t,n){let r=e[t];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function Rr(e,t,n,r,a){if(!e.hasOwnProperty(n))return t;let i=gu(e,n,t);return i===t&&n!==r&&(i=gu(e,r,t)),zp(i,a)}function p7(e){if(typeof e=="number")return!0;if(e){let t=parseInt(e);return!isNaN(t)}else return!1}function jt(e,t,n){return Rr(nn,t,e.config.interfaceLanguage,"en",n)}p();function W1(e,t){let n=new Date(e),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return t.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function K1(e){return new Date(e).getTime()}var Q=class extends Error{status;constructor(t,n){if(t&&n){super(n),this.name=t;return}super(t)}initNetWork(t){return t&&(this.status=t),this}initStack(t){return t&&(this.stack=t),this}initData(t){return this.data=t,this}data;uiConfig(t){if(!this.message)return{};let n=null;if(n=this.handleProQuota(t)||this.handleUnavailableError(t)||this.handleProUser(t)||this.handleServiceMissingConfig(t)||this.handleNetwork(t)||this.handleFetchError(t),!n){let r=jt.bind(null,t),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(t){let n=jt.bind(null,t),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(t){let n=jt.bind(null,t);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(t){let n=jt.bind(null,t),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(t){let n=jt.bind(null,t);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(t){let n=jt.bind(null,t);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return t.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(t){if(!this.message.startsWith("ProQuota:")||!t.user?.subscription)return;let n=jt.bind(null,t);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=t.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let g=this.data?.translationService=="deepl"?"OpenAI":"Deepl",f=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=n("errorReason",{message:r});if(i=="onetime_7day")m+=n("proQuotaExceededError.onetime7day",{anotherService:g,brandId:ee,href:Cc});else{let h="";f=="OpenAI"?h=u1:h=l1,o?m+=n("proQuotaExceededError.trial",{anotherService:g,brandId:ee,href:c1}):m+=n("proQuotaExceededError.nonTrial",{anotherService:g,brandId:ee,href:h,translationService:f}),!o&&(a.cancelAtPeriodEnd==="false"||K1(u)>s)&&(m+=n("proQuotaExceededError.resetTime",{resetTime:W1(s,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function Tr(e){let t;if(e&&e.retry&&e.retry>0)try{t=await eg(G1.bind(null,e),{multiplier:2,maxAttempts:e.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else t=await G1(e);return t}async function G1(e){e.body;let{url:t,responseType:n,...r}=e;n||(n="json"),r={mode:"cors",...r};let a=!0;e.fetchPolyfill&&(a=!1);let i=e.fetchPolyfill||fetch,o=3e4;if(e.timeout&&(o=e.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(t,r)}catch(u){R.debug("fetch error",t,u);let l=u.message||"Unknown Error";throw new Q("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=t),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of m7(s.body)){let g=new TextDecoder().decode(c);u+=g;let f;for(;(f=u.indexOf(` -`))>=0;){let m=u.slice(0,f).trim();if(u=u.slice(f+1),m.startsWith("event:")||m==="")continue;let h="";if(m.startsWith("data:")&&(h=m.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(T){R.debug("json error",T);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(m){R.error("parse response failed",m)}u&&R.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,f=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),f&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new Q("fetchError",c).initNetWork(s.status)}}async function*m7(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}p();var f7=new Map;function kc(e){let t=h7(64),n=new CustomEvent(Fb,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{f7.set(t,(i,o)=>{i?a(i):r(o)})})}function h7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=Up(s),{type:f,name:m}=g;if(f!==t)return!1;let h=Up(o),T=pu.get(f).get(m);if(!T)return this.logger.debug(`no message handler for ${f}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=T,w={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let L=b(r.payload,w);i({ok:!0,data:L})}catch(L){i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.details,errorStatus:L.status})}return!1}else return b(r.payload,w).then(L=>{i({ok:!0,data:L})}).catch(L=>{i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.message,errorStatus:L.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=pu.get(i);if(o.has(t))return o.get(t).connectionInstance;{let s=new Np(`${i}:${t}`,this.logger);return pu.get(i).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Np=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=Up(t),{type:a,id:i}=r;if(a!=="content_script"){let o={to:t,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await Z.runtime.sendMessage(o);return V1(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:t,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await Z.tabs.sendMessage(i,o);return V1(o,s,this.logger)}}};function V1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new Q(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new Q("noResponse","Unknown error")}function Up(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}p();var b7="";function Mo(){return b7||globalThis.navigator.userAgent}function qp(){return Mo().includes("ImtFxiOS")}function $1(){let t=Mo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function y7(){return Mo().includes("ImtFxAndroid")}function Y1(){let e=Mo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Q1(){let t=Mo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function mu(){let e=Mo();if(qp()||y7()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Pc;function T7(){return Pc||(Pc=new ca("content_script",!1).getConnection("pure_main",()=>{}),Pc)}var Z1="G-MKMD9LWFTR";async function Bi(e){try{let t=Le(),n=t.INSTALL_FROM==="firefox_store";if(mu()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=pe(),i=ot(),o=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await qt("fakeUserId","");u||(u=await la("fakeUserId",""),u&&await at("fakeUserId",u));let l=On(),c=new Date,g=await qt("installedAt","");g||(g=await la("installedAt",""),g&&await at("installedAt",g)),u?g||(g=new Date(0).toISOString(),await at("installedAt",g)):(u=v7(32),await at("fakeUserId",u)),g||(g=c.toISOString(),await at("installedAt",g));let f=new Date(g),m=J1(f),h=J1(c),y=m===h,T=c.getTime()-f.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${Z1}&api_secret=${s}`;o||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Z1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let w=po.parse(x),L=e.map(C=>{let v=C.params||{};if(w.os&&(v.os_name=w.os.name||"unknown",v.os_version=w.os.version||"unknown",v.os_version_name=w.os.versionName||"unknown"),w.browser){v.browser_name=w.browser.name||"unknown",v.browser_version=w.browser.version||"unknown";let A=mu();A&&(v.browser_name=A.name,v.browser_version=A.version)}return w.platform&&(v.platform_type=w.platform.type||"unknown"),w.engine&&(v.engine_name=w.engine.name||"unknown",v.engine_version=w.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),m&&(v.install_day=S7(f)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",T?v.is_new_user_this_week="1":v.is_new_user_this_week="0",i?v.main_frame=0:v.main_frame=1,{...C,params:v}}),M=await Lc({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:L})})}catch{}}function v7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=u.slice(0,f).trim();if(u=u.slice(f+1),m.startsWith("event:")||m==="")continue;let h="";if(m.startsWith("data:")&&(h=m.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(T){R.debug("json error",T);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(m){R.error("parse response failed",m)}u&&R.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,f=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),f&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new Q("fetchError",c).initNetWork(s.status)}}async function*m7(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}p();var f7=new Map;function kc(e){let t=h7(64),n=new CustomEvent(Fb,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{f7.set(t,(i,o)=>{i?a(i):r(o)})})}function h7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=Up(s),{type:f,name:m}=g;if(f!==t)return!1;let h=Up(o),T=pu.get(f).get(m);if(!T)return this.logger.debug(`no message handler for ${f}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=T,w={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let L=b(r.payload,w);i({ok:!0,data:L})}catch(L){i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.details,errorStatus:L.status})}return!1}else return b(r.payload,w).then(L=>{i({ok:!0,data:L})}).catch(L=>{i({ok:!1,errorName:L.name,errorMessage:L.message,errorDetails:L.message,errorStatus:L.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=pu.get(i);if(o.has(t))return o.get(t).connectionInstance;{let s=new Np(`${i}:${t}`,this.logger);return pu.get(i).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Np=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=Up(t),{type:a,id:i}=r;if(a!=="content_script"){let o={to:t,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await Z.runtime.sendMessage(o);return V1(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:t,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await Z.tabs.sendMessage(i,o);return V1(o,s,this.logger)}}};function V1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new Q(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new Q("noResponse","Unknown error")}function Up(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}p();var b7="";function Mo(){return b7||globalThis.navigator.userAgent}function qp(){return Mo().includes("ImtFxiOS")}function $1(){let t=Mo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function y7(){return Mo().includes("ImtFxAndroid")}function Y1(){let e=Mo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Q1(){let t=Mo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function mu(){let e=Mo();if(qp()||y7()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Pc;function T7(){return Pc||(Pc=new ca("content_script",!1).getConnection("pure_main",()=>{}),Pc)}var Z1="G-MKMD9LWFTR";async function Bi(e){try{let t=Le(),n=t.INSTALL_FROM==="firefox_store";if(mu()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=pe(),i=ot(),o=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await qt("fakeUserId","");u||(u=await la("fakeUserId",""),u&&await at("fakeUserId",u));let l=On(),c=new Date,g=await qt("installedAt","");g||(g=await la("installedAt",""),g&&await at("installedAt",g)),u?g||(g=new Date(0).toISOString(),await at("installedAt",g)):(u=v7(32),await at("fakeUserId",u)),g||(g=c.toISOString(),await at("installedAt",g));let f=new Date(g),m=J1(f),h=J1(c),y=m===h,T=c.getTime()-f.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${Z1}&api_secret=${s}`;o||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Z1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let w=po.parse(x),L=e.map(C=>{let v=C.params||{};if(w.os&&(v.os_name=w.os.name||"unknown",v.os_version=w.os.version||"unknown",v.os_version_name=w.os.versionName||"unknown"),w.browser){v.browser_name=w.browser.name||"unknown",v.browser_version=w.browser.version||"unknown";let A=mu();A&&(v.browser_name=A.name,v.browser_version=A.version)}return w.platform&&(v.platform_type=w.platform.type||"unknown"),w.engine&&(v.engine_name=w.engine.name||"unknown",v.engine_version=w.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),m&&(v.install_day=S7(f)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",T?v.is_new_user_this_week="1":v.is_new_user_this_week="0",i?v.main_frame=0:v.main_frame=1,{...C,params:v}}),M=await Lc({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:L})})}catch{}}function v7(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5353,7 +5353,7 @@ ${s}} `+t.rule.additionalInjectedCss.join(` `):t.rule.additionalInjectedCss&&(s+=` `+t.rule.additionalInjectedCss)),s&&Kn(e,s,"immersive-translate-dynamic-injected-css")}p();p();p();var R7=0;function d(e,t,n,r,a){var i,o,s={};for(o in t)o=="ref"?i=t[o]:s[o]=t[o];var u={type:e,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--R7,__source:a,__self:r};if(typeof e=="function"&&(i=e.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Oe.vnode&&Oe.vnode(u),u}function Jp({value:e,defaultCase:t=null,cases:n}){return e==null?null:d(xe,{children:n[e]!=null?n[e]:t})}p();function Xp(){let[e,t]=K(location.hash);return le(()=>{let n=()=>t(location.hash);return globalThis.addEventListener("hashchange",n,!1),()=>{globalThis.removeEventListener("hashchange",n)}},[]),e}p();p();p();var Dy={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},Ay={...nn,"zh-CN":{...Dy["zh-CN"],...nn["zh-CN"]},"zh-TW":{...Dy["zh-TW"],...nn["zh-TW"]}},Uo=Ay;function ja(e,t,n){return Rr(Ay,e,t,Br,n)}var Nc=()=>Rn.filter(e=>e!=="auto"),Zt=(e,t,n,r)=>{let a=Xb[e]||e,i=e1[e],o=t1[e],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[e]?s[e]:a;if(s[t]){let u=s[t];return r||e==="auto"||e==="placeholder"?u:`${u} (${a})`}else return a};p();p();p();p();p();p();p();p();p();p();var zr=class{accessToken;constructor(t){this.accessToken=t}async listAll(){let t=[],n="";do{let{nextPageToken:r,files:a}=await this.list(n).catch(i=>{throw i});t.push(...a),n=r||""}while(n);return t}async getConfig(t){try{return await(await fetch(`https://www.googleapis.com/drive/v3/files/${t}?alt=media`,{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(n){return R.error("get config error, use default",n),{}}}async delete(t){await fetch(`https://www.googleapis.com/drive/v3/files/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${this.accessToken}`}})}findByName(t){return this.list(void 0,`name = '${t}'`)}uploadConfig(t,n=uc){let r=new Blob([JSON.stringify(t,null,2)],{type:"application/json"});return this.upload({name:n,parents:["appDataFolder"],mimeType:"application/json"},r)}updateConfig(t,n){let r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"});return this.updateContent(t,r)}async upload(t,n){let r=new FormData;r.append("metadata",new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"})),r.append("file",n);let a=await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart",{method:"POST",headers:{Authorization:`Bearer ${this.accessToken}`},body:r});return a.ok?await a.json():Promise.reject(a.text())}async list(t,n){let r=new URL("https://www.googleapis.com/drive/v3/files");t&&r.searchParams.append("pageToken",t),n&&r.searchParams.append("q",n),r.searchParams.append("spaces","appDataFolder"),r.searchParams.append("fields","files(id,name,createdTime,modifiedTime,size)"),r.searchParams.append("pageSize","100"),r.searchParams.append("orderBy","createdTime desc");try{return R.debug("list api:",r.toString(),this.accessToken),await(await fetch(r.toString(),{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(a){throw R.error("fetch google ip error",a),a}}async updateContent(t,n){return await(await fetch(`https://www.googleapis.com/upload/drive/v3/files/${t}?uploadType=media`,{method:"PATCH",headers:{Authorization:`Bearer ${this.accessToken}`},body:n})).text()}};function ky(e,t){let n=["https://www.googleapis.com/auth/drive.appdata"];return`https://accounts.google.com/o/oauth2/v2/auth?client_id=${sc}&response_type=token&redirect_uri=${encodeURIComponent(t)}&scope=${encodeURIComponent(n.join(" "))}&state=${encodeURIComponent(JSON.stringify(e))}`}function Py(e){let t=e.match(/[#?](.*)/);return!t||t.length<1?null:{access_token:new URLSearchParams(t[1].split("#")[0]).get("access_token")}}async function em(e,t,n,r,a,i,o){if(R.debug(`autoSyncStrategy accessToken: ${e}`),t===null){R.debug("autoSyncStrategy settings is null");return}let s=new zr(e);try{let u=(await s.findByName(uc)).files;R.debug("files",u);let l=u[0]?.id,c=null;if(l&&(c=await s.getConfig(l).then(g=>({fileId:l,config:g}))),c){let{config:g,fileId:f}=c,m=g.updatedAt?new Date(g.updatedAt):new Date(0),h=t.updatedAt?new Date(t.updatedAt):new Date(0);if(R.debug("remoteUpdatedAt",m,"localUpdatedAt",h),m>h)R.debug("remote is newer, update local config",g),n(g),i&&i(!0);else if(m.getTime()===h.getTime())R.debug("remote and local are the same, do nothing"),i&&i(!1);else if(m(await e.removeAuthInfo(),eu()&&globalThis.location.reload(),r))}static async getAuthInfo(){let t=await Z.storage.local.get(_a);if(t[_a])return t[_a]}static async removeAuthInfo(){return await Z.storage.local.remove(_a)}static setAuthInfo(t){return Z.storage.local.set({[_a]:t})}async auth(t=!1){let n=await e.getAuthInfo();if(R.debug(this.CLASSNAME,"token from cache:",n),n&&n.access_token&&await Ly(n.access_token).then(i=>!0).catch(i=>!1))return Promise.resolve(n);let r=ky(this._state,this._redirectUrl);return R.debug(this.CLASSNAME,"auth url: "+r),eu()?this.userscriptAuthWorkflow(r,t):this.extensionAuthWorkflow(r).then(a=>(e.setAuthInfo(a),a))}async userscriptAuthWorkflow(t,n){return n&&await Z.storage.local.set({[tu]:!0}),globalThis.open(t,"_self"),Promise.resolve({})}extensionAuthWorkflow(t){let n,r=!1;return new Promise((a,i)=>{let o=()=>{Z.tabs.onUpdated.removeListener(s),Z.tabs.onRemoved.removeListener(u)},s=(f,m,h)=>{if(R.debug(this.CLASSNAME,"create tab onUpdated: "+h.url),n===f){let y=new URL(h.url||""),T=Py(h.url);y.pathname.startsWith("/auth-done")&&T?.access_token&&(R.debug(this.CLASSNAME,"auth done: "+h.url),a({access_token:T.access_token}),r=!0,Z.tabs.remove(f),o())}},u=(f,m)=>{R.debug(this.CLASSNAME,"create tab onRemoved: "+f),(f===n||!r)&&(o(),i(new Error("auth failed")))},l=Math.min(500,screen.availWidth),c=Math.min(650,screen.availHeight),g;Z.windows===void 0?g=Z.tabs.create({url:t}).then(f=>{n=f.id}):g=Z.windows.create({url:t,type:"popup",width:l,height:c,left:Math.round((screen.width-l)/2),top:Math.round((screen.height-c)/2)}).then(f=>{n=f.tabs[0].id}),g.then(()=>{Z.tabs.onUpdated.addListener(s),Z.tabs.onRemoved.addListener(u)}).catch(f=>{R.debug(this.CLASSNAME,"create tab failed: "+f),i(f)})})}};var z7="https://www.googleapis.com/oauth2/v3/tokeninfo",N7=sc,U7=Le().REDIRECT_URL;function Ly(e){if(!e)throw"Authorization failure";let t=`${z7}?access_token=${e}`,n=new Request(t,{method:"GET"});function r(a){return new Promise((i,o)=>{a.status!=200&&o("Token validation error"),a.json().then(s=>{s.aud&&s.aud===N7?i(e):o("Token validation error")})})}return fetch(n).then(r)}function _y(e,t=!1){let n=U7;if(typeof window<"u"&&window.location.protocol.startsWith("http")){let a=window.location.hostname,i=window.location.port;n=`${window.location.protocol}//${a}${i?`:${i}`:""}/auth-done/`}return new Ha(e,n).auth(t)}function tm(e,t=!1){return _y(e,t).then(n=>n.access_token||null)}p();p();p();function Wa(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function q7(e,t){return e<>>32-t}function qc(e,t,n,r,a,i){return Wa(q7(Wa(Wa(t,e),Wa(r,i)),a),n)}function mn(e,t,n,r,a,i,o){return qc(t&n|~t&r,e,t,a,i,o)}function fn(e,t,n,r,a,i,o){return qc(t&r|n&~r,e,t,a,i,o)}function hn(e,t,n,r,a,i,o){return qc(t^n^r,e,t,a,i,o)}function bn(e,t,n,r,a,i,o){return qc(n^(t|~r),e,t,a,i,o)}function Uc(e,t){e[t>>5]|=128<>>9<<4)+14]=t;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>t%32&255);return n}function nm(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(e.charCodeAt(t/8)&255)<16&&(r=Uc(r,e.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Uc(a.concat(nm(t)),512+t.length*8),My(Uc(i.concat(o),512+128))}function Fy(e){var t="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+t.charAt(r&15);return n}function rm(e){return unescape(encodeURIComponent(e))}function By(e){return j7(rm(e))}function W7(e){return Fy(By(e))}function Iy(e,t){return H7(rm(e),rm(t))}function K7(e,t){return Fy(Iy(e,t))}function Gn(e,t,n){return t?n?Iy(t,e):K7(t,e):n?By(e):W7(e)}var qo=[];async function xu(e,t){return await new Promise((n,r)=>{let a=e,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=t||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function am(e){let t=`${ee}-${e.service}@${e.from}->${e.to}`;return await V7(t,e)}async function im(e){let t=Gn(e.originalText),n=`${ee}-${e.service}@${e.from}->${e.to}`;return await G7(n,t)}async function G7(e,t){let n=await xu(e);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(t);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function V7(e,t){let n=await xu(e);return(await om()).includes(e)||await $7(e),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(t);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function $7(e){let t="cache_list",n=await xu(ee+"-cacheList",t),a=n.transaction([t],"readwrite").objectStore(t).put({key:e});a.onsuccess=i=>{n.close(),qo.push(e)},a.onerror=i=>{n.close()}}async function om(){if(qo&&qo.length>0)return qo;let e=await xu(ee+"-cacheList","cache_list");return qo=await new Promise(t=>{let n="cache_list",a=e.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{e.close(),t(a.result)},a.onerror=i=>{e.close(),t([])}}),qo}async function sm(){try{let e=[];(await om()).forEach(r=>{e.push(Y7(r))});let n=await Promise.all(e);return cu(n.reduce((r,a)=>r+a,0))}catch{return cu(0)}}async function Y7(e){let t=await xu(e),r=[...t.objectStoreNames].reduce((o,s)=>{let u=Q7(t,s);return o.push(u),o},[]),a=await Promise.all(r);return t.close(),a.reduce((o,s)=>o+s,0)}async function Q7(e,t){return await new Promise((n,r)=>{if(e==null)return r();let a=0,i=e.transaction([t]).objectStore(t).openCursor();i.onsuccess=o=>{let s=i.result;if(s){let u=s.value,l=JSON.stringify(u);a+=l.length,s.continue()}else n(a)},i.onerror=o=>r("error in "+t+": "+o)})}async function Ry(){try{let t=(await om()).map(r=>Z7(r));return!!(await Promise.all(t)).every(r=>r)}catch{return!1}}async function Z7(e){return await new Promise(t=>{let n=indexedDB.deleteDatabase(e);n.onsuccess=()=>{t(!0)},n.onerror=r=>{t(!1)}})}p();function J7(e,t){return Math.floor(Math.random()*(t-e+1))+e}var X7=30,um="RATE_LIMITER_TICKS",qi=class e{static strictTicks={};static clearStrictTicks(){bu(um,"{}")}static async getStrictTicks(t,n){if(n)return this.strictTicks[t]||[];try{let r=await Fc(um);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){R.debug("Error setting rate limiter ticks",r),this.strictTicks[t]=[]}finally{return this.strictTicks[t]||[]}}static wait(t,n){return new Promise((r,a)=>{e.getDelay(t,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(t,n,r){try{if(this.strictTicks[t]=n,r)return;await bu(um,JSON.stringify(this.strictTicks))}catch(a){R.debug("Error setting rate limiter ticks",a)}}static async getDelay(t,n,r=!1){if(!r){let l=J7(4,X7);await xn(l)}let a=await this.getStrictTicks(t,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(t,a,r),0):(a.push(u),await this.setStrictTicks(t,a,r),u-s)}};var Eu=Pp()?["action"]:["browser_action","page_action"],tD=[{id:"toggleTranslatePage",contexts:["page","frame","selection",...Eu]},{id:ru,contexts:Eu},{id:au,contexts:Eu},{id:iu,contexts:Eu},{id:Nb,contexts:Eu}];async function jc(e){e=e||await bt(),R.debug("update ContextMenu",e);for(let t of tD){let n=!0;e.isShowContextMenu===!1&&t.id==="toggleTranslatePage"&&(n=!1);let r=ja(`browser.${t.id}`,e.interfaceLanguage);Z.contextMenus.update(t.id,{title:r,visible:n})}}p();function Oy(e,t){let n=t;n||(n=Le().IMMERSIVE_TRANSLATE_INJECTED_CSS||"");let a=`${`--immersive-translate-${e}`}: (.+?);`,i=new RegExp(a),o=n.match(i);return o?o[1]:""}p();function jo(e,t,n=[],r){let a=["notranslate"];return r&&a.push(Jb),e&&(a.push(`${ee}-target-translation-theme-${e}`),t?a.push(`${Cp}-theme-${e}`):a.push(`${Sp}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Cp):a.push(Sp),a}function Ho(e){let t=["notranslate",fc];return e&&t.push(`${ee}-target-translation-theme-${e}-inner`),t}function zy(e,t,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=e;o=o||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,g=Ni(n,!0),f="afterend",m=g[0],h=g[1],y=`${m}(\\d+)${h}`,T=new RegExp(y,"g"),b=rt.sanitize(u);o.length>0&&(b=b.replace(T,M=>{let C=b.indexOf(M),v=b[C-1]===" ",A=b[C+M.length]===" ",S=M.replace(new RegExp(g[0],"g"),"").replace(new RegExp(g[1],"g"),""),N=Number(S);if(isNaN(N))return M;let F=o[N];if(F&&F.type==="element"){let P=F.value.outerHTML;return v||(P=" "+P),A||(P=P+" "),P}else R.error("variable type not supported",F,M);return M}));let x=jo(i,e.inline,r.translationClasses||[],e.preWhitespace);s&&x.push(Zb);let w=Ho(i),L="";return r.translationBlockStyle&&(L=`style="${r.translationBlockStyle}"`),b=`<${n.rule.targetWrapperTag} ${L} class="${x.join(" ")}" ${Fr}="1"><${r.targetWrapperTag} class="${w.join(" ")}" ${Fr}="1">${b}`,e.inline||(l==="smart"?b=`
${b}`:b=`${l}${b}`),e.inline&&(l!=="smart"?b=`${l}${b}`:b=`<${r.targetWrapperTag} class="notranslate" ${Fr}="1"> ${b}`),c==="smart"?b=`${b}`:b=`${b}${c}`,{html:b,position:f}}p();function ut(e){fp({type:"success",text:e})}function an(e){fp({type:"error",text:e})}p();p();p();p();var lm={get:(e,t,n)=>{let r=t===void 0?e:{[e]:t};return Z.storage[n].get(r)},set:(e,t,n)=>Z.storage[n].set({[e]:t})};function Hc(e,t,n){let[r]=K(()=>typeof t=="function"?t():t),[a]=K(n),[i,o]=K(r),[s,u]=K(!1),[l,c]=K("");le(()=>{lm.get(e,r,a).then(f=>{f[e]&&o(f[e]),u(!0),c("")}).catch(f=>{u(!1),c(f)})},[e,r,a]);let g=qe(f=>{let m=typeof f=="function"?f(i):f;R.debug("new settings",m),lm.set(e,m,a).then(()=>{o(m),u(!0),c("")}).catch(h=>{o(m),u(!1),c(h)})},[a,e,i]);return[i,g,s,l]}p();function Wc(e,t,n){let r=[];return function(){let[i,o,s,u]=Hc(e,t,n),l=qe(c=>{for(let g of r)g(c)},[]);return le(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function Ny(e,t){return Wc(e,t,"local")}function Uy(e,t){return Wc(e,t,"sync")}var nD="userConfig",rD=null,aD=Uy(nD,rD);function $e(e){let[t,n,r,a]=aD(),i=qe(o=>{let s=typeof o=="function"?o(t):o;s&&(s.updatedAt=new Date().toISOString()),n(s),e&&e(s)},[t]);return[t,i,r,a,n]}p();p();p();p();function Kc(e,t){let n=e.original||e,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=t,s=[],u={};for(let l=0;l2&&(b=`<${i[2]}${T}>`),u[T]=c,s.push({text:b,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let y=c.textContent||"";f&&(y=Na(cm(c))),s.push({text:y,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&ln(c,a)){let T=Object.keys(u).length,b=`${i[0]}${T}${i[1]}`;i.length>2&&(b=`<${i[2]}${T}>`),u[T]=c;let x=dm(s).endsWith(" ")?" ":"",w=Na(c.innerText||c.textContent),L=Na(c.nextSibling).startsWith(" ")?" ":"",M=yu(x+w+L),C=M[0]+b+M[1];if(x===" ")C=C.trimStart();else if(!C.startsWith(" ")){let v=yu(c.previousSibling)[1];v===""&&(v=" "),C=v+C}s.push({text:C,type:"variable"})}else{let y=dm(s).endsWith(" ")?" ":"",T=Na(c.innerText||c.textContent);f&&(T=Na(cm(c)));let b=Na(c.nextSibling).startsWith(" ")?" ":"",x=yu(y+T+b),w=x[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+x[1];if(y===" ")w=w.trimStart();else{let L=yu(c.previousSibling)[1];L===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(L=" "),w=L+w}s.push({text:w,type:"text"})}else{let y=dm(s).endsWith(" ")?" ":"",T="";c.textContent&&(T=Na(cm(c))),y===" "&&(T=T.trimStart()),s.push({text:T,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(f=s[c-1].text),c/g,">"))}e.targetText=rt.sanitize(e.targetText);let a=!1,i=e.text,o=i.split(" ").length,s=i.split(` -`).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ni(t);if(l.length>2){let c=l[2];return iD({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=zy(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function cm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function iD(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;o=o||[];let g=e.targetText;g=rt.sanitize(g);let f=g,m=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);o.length>0&&(f=f.replace(m,x=>{let w=f.indexOf(x),L=f[w-1]===" ",M=f[w+x.length]===" ",C=x.match(h);if(!C)return x;let v=C[1],A=Number(v);if(isNaN(A))return x;let D=o[Number(A)];if(D&&D.type==="element"){let S=D.value.outerHTML;return L||(S=" "+S),M||(S=S+" "),S}else if(D&&D.type==="text"){let S=D.value;return L||(S=" "+S),M||(S=S+" "),S}else R.error("variable type not supported",D,x);return x}));let y=jo(l,n,r||[],s),T=Ho(l),b="";return c&&(b=`style="${c}"`),f=`<${a} ${b} class="${y.join(" ")}" ${Fr}="1"><${a} class="${T.join(" ")}" ${Fr}="1">${f}`,n||(i==="smart"?f=`
${f}`:f=`${i}${f}`),n&&(i!=="smart"?f=`${i}${f}`:f=`<${a} class="notranslate" ${Fr}="1"> ${f}`),u==="smart"?f=`${f}`:f=`${f}${u}`,{html:f,position:"afterend"}}function dm(e){let t=e[e.length-1];return t?t.text:""}function gm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let g=c.match(s);if(!g)return c;let f=g[1],m=Number(f);if(isNaN(m))return c;let h=r[f];return h||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}p();p();p();p();p();p();var H$=Hy(2),jy=Hy(3);function Hy(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-e+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+e);return r}}p();var oD=/\s+/g,sD=/[\t\n\v\f\r ]+/g;function Wy(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?uD:lD;return String(e).replace(t.style==="html"?sD:oD,t.trim?cD(n):n)}function uD(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function lD(){return" "}function cD(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var Ky={}.hasOwnProperty;function dD(e){return e==null?"":Wy(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function gD(e){return jy(" "+dD(e)+" ")}function pD(e){let t=gD(e),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function vD(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function SD(e,t,n,r){t=xD(t,n,r);let a=[],i;if(t)for(i in t)Gc.call(t,i)&&a.push([i,CD(e,t[i])]);return a.length===0?mm():a.sort(ED)}function CD(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharacterso+s.length,0));let i=e.length-r;for(let o of BD){let s=o[1],u=o[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/i>.5?t==="zh-CN"?Xy(e)?"zh-TW":"zh-CN":t:"auto"}var tT=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],fm=new Map(tT),ID=new Map(tT.map(([e,t])=>[t,e]));function nT(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>ID.get(s));!t&&t!==0&&(t=25);let a=$c(e);if(a!=="auto")return a;let i={minLength:t,whitelist:[...fm.keys()]},o=$y(e,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(g=="eng"&&f<.95)break;return fm.get(g)}}let[s,u]=o[0],l=fm.get(s);if(l&&u>.9)return l}}catch(r){R.error(r)}return"auto"}p();p();var hm="Original";function et(){return hm}function An(e){hm=e,rT(hm)}p();var iT="auto",Yc="auto",aT="auto";function oT(e){iT=e}function ar(e){Yc=e}function Mt(){return Yc!=="auto"?Yc:aT!=="auto"?aT:iT}function Qc(){return Yc}p();function ji(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ga(e){try{if(!e||!ji(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";t=o.getAttribute(i)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var tt={},Va=async function(e,t){let{method:n,data:r}=e,a=await tt.updateGlobalContext(),i=Date.now();if(R.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await tt.translateTheWholePage(r),at(yr,i);else if(n==="translateTheMainPage")await tt.translateTheMainPage(r),at(yr,i);else if(n==="translateToThePageEndImmediately")await tt.translateToThePageEndImmediately(r),at(yr,i);else if(n==="toggleTranslatePage")await tt.toggleTranslatePage(r),at(yr,i);else if(n==="toggleTranslateTheWholePage")await tt.toggleTranslateTheWholePage(r),at(yr,i);else if(n==="toggleTranslateTheMainPage")await tt.toggleTranslateTheMainPage(r),at(yr,i);else if(n==="toggleOnlyTransation")await tt.ensureSwitchTranslationMode(r),at(yr,i);else if(n==="translatePage")await tt.translatePage(a,r),at(yr,i);else if(n==="toggleTranslationMask")await tt.toggleTranslationMask(r);else if(n==="restorePage")tt.restorePage();else if(n==="retryFailedParagraphs")tt.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await tt.switchTranslationMode(r.mode),await tt.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")tt.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(cc,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await tt.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(nu,{detail:r}));else if(n==="translateWithOpenAI")await tt.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await tt.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await tt.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await tt.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await tt.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await tt.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await tt.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")ot()||await tt.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!ot())return JSON.stringify(a)}};function sT(e){Object.assign(tt,e)}function uT(e){Object.assign(tt,e)}function lT(e){Object.assign(tt,e)}var RD=function(e,t){let{method:n,data:r}=e;if(R.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return et();if(n==="getCurrentPageLanguage"){let a=Mt();return tt.detectCurrentPageLanguage().catch(i=>{R.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return ar(r),Mt();if(n==="getContextString"){let a=tt.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=tt.getPureGlobalContext();return Ga(a?.rule)}}},Zc,Jc;function cT(){let e=Xc();ot()||OD(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Xc(){return Zc||(Zc=new ca("content_script",!1).getConnection("main",Va),Zc)}function OD(){return Jc||(Jc=new ca("content_script",!1).getConnection("main_sync",RD,{sync:!0}),Jc)}p();var bm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],e0="https://transmart.qq.com/api/imt",pa=class e{static langMapReverse=new Map(bm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:e0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=e.langMapReverse.get(a);return i||a}};async function Ft(e){return await Xc().sendMessage("background:main",e)}function de(e){return oc()?kc({method:"request",data:e}):pe()||ic()?(e.fetchPolyfill=globalThis.GM_fetch,Tr(e)):Ft({method:"fetch",data:e})}function ir(){return pe()?bt():Ft({method:"getConfig"})}function kn(e){return pe()?Oi(e):Ft({method:"setUserConfig",data:e})}function Pn(){return pe()?vr():Ft({method:"getUserConfig"})}function Du(){return pe()?Wt():Ft({method:"getLocalConfig"})}function t0(e){return pe()?Kt(e):Ft({method:"setLocalConfig",data:e})}function dT(e){return pe()?ry(e):Ft({method:"setBuildinConfig",data:e})}async function Ue(e){if(e.text){let n=$c(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(pe()||Ge()){if(e.translateService&&!yc.includes(e.translateService))return Promise.resolve("auto");let r=nT(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Ft({method:"detectLanguage",data:e});return Promise.resolve(t)}function gT(){return Ft({method:"detectTabLanguage"})}async function n0(e){let t=await Ue({text:e,pageLangs:["en"]});try{if(pe()||Ge()){let n=e.substring(0,200);t=await pa.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function rT(e){let t=new CustomEvent(ki,{detail:e});if(document.dispatchEvent(t),pe())return;Xc().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function pT(e){return pe()?im(e):Ft({method:"queryParagraphCache",data:e})}async function mT(e){if(pe()){await am(e);return}return Ft({method:"setParagraphCache",data:e})}async function fT(){if(pe())return Promise.resolve();await Ft({method:"mockRequest"})}function Wo(e=!1,t=""){return pe()?(Z.runtime.openOptionsPage(e,t),Promise.resolve()):Ft({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function r0(e=""){return pe()||Ge()?Le().OPTIONS_URL:Z.runtime.getURL("options.html")}function hT(e=""){return Z&&Z.runtime&&Z.runtime.getURL?Z.runtime.getURL("options.html"):""}function a0(e=!1){return pe()?(Z.extra.openAboutPage(e),Promise.resolve()):Ft({method:"openAboutPage"})}function Ko(e){return pe()?(Z.extra.openInTab(e),Promise.resolve()):Ft({method:"openInTab",data:e})}function bT(e=!1){return pe()?(Z.extra.openEbookViewerPage(e),Promise.resolve()):Ft({method:"openEbookViewerPage"})}function yT(e=!1){return pe()?(Z.extra.openEbookBuilderPage(e),Promise.resolve()):Ft({method:"openEbookBuilderPage"})}function TT(e){Ge()}function Go(e=!1,t){return pe()?(Z.extra.openPdfViewerPage(e),Promise.resolve()):Ft({method:"openPdfViewerPage",data:{url:t}})}function vT(e=!1){return pe()?(Z.extra.openSubtitleBuilderPage(e),Promise.resolve()):Ft({method:"openSubtitleBuilderPage"})}function Vo(e){return pe()?Promise.resolve():Ft({method:"setBadge",data:{text:e}})}function ST(){return pe()?(R.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Ft({method:"autoSyncLatestConfig"})}function i0(e,t=!1){return pe()?Z.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function CT(e,t){return pe()?qi.getDelay(e,t):Ft({method:"getDelay",data:{key:e,options:t}})}var Pe=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,i=!1,o=!1,s=[],u=null,l=new Set;for(let T of a)T.from&&T.from!=="auto"&&l.add(T.from),T.refresh&&(i=!0),T.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=I1(a,c,g)}catch(T){if(r)for(let b=0;bT));let f=[],m=[],h=(T,b,x)=>{let w="";if(b.translatedTexts&&b.translatedTexts[0]&&(w=b.translatedTexts[0]),m[T]||(m[T]=b,m[T].translatedTexts=Array(b.sentenceTotalParts).fill(null)),m[T].hasError)return;if(x){let C=x instanceof Q?new Q(x.name,x.message).initNetWork(x.status).initData(x.data):x;m[T].hasError=!0,b.callback&&b.callback(C,null,b.sentence);return}m[T].translatedTexts[b.partIndex]=w;let L=m[T],M=0;for(let C=0;C{let M=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(M=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:M,to:b.to,url:x,options:n,refresh:i,debug:o}),sourceTempSentences:b.tempSentences};{let C=Qb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(C=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let A=[],D=Or(this.serviceConfig);if(b.tempSentences.forEach((q,I)=>{let k=Kp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});q.force!==!0&&(k&&k.text&&k.text.trim().lengthI.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:q,from:M,to:b.to})}let S="";v&&v.length>=2?S=A.map((q,I)=>{let{item:k}=q;return I===A.length-1?k.text:k.text+v[0]+(I+1)+v[1]}).join(""):S=A.map(({item:q})=>q.text).join(C);let N=await this.translate({text:S,from:M,to:b.to,url:x,options:{...n,rawTextArrayLength:A.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=N,P=[];if(v&&v.length>=2){let q=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(q=v[2]);let I=new RegExp(q,"g");P=F.split(I)}else P=F.split(C);let O=[];if(P.length>A.length){for(let q=0;qq.text);return D=Or(this.serviceConfig,!0),O.forEach((q,I)=>{let k=A[I],_=k.index,B=k.variables||{};Object.keys(B).length>0&&(q=gm({text:q,delimiters:D,variables:B})),z[_]=q}),{sourceTempSentences:b.tempSentences,text:z,from:N.from,to:N.to}}};f.push(L().then(M=>{let{text:C,sourceTempSentences:v}=M;for(let A=0;A{if(M instanceof Q&&M.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let C=0;C{let b=T.sentence.text;return T.translatedTexts&&T.translatedTexts.length>0&&(b=T.translatedTexts.join("")),{...T.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],i=Or(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,f)=>{let m=Kp({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[f]!==!0&&(m&&m.text&&m.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){R.debug("formatAndTranslateList error",t,l)}let o=await this.translateList(n),{text:s}=o,u=t.text.map(l=>l);return i=Or(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let f=g.index,m=g.variables,h=Object.keys(m);u[f]=l,h.length>0&&(u[f]=gm({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(t){return Ue({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};p();p();var $o="input is invalid type",ym=typeof window=="object",$a=ym?window:{};$a.JS_SHA256_NO_WINDOW&&(ym=!1);var zD=!ym&&typeof self=="object",ND=!$a.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;ND?$a=global:zD&&($a=self);var pQ=!$a.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,mQ=typeof define=="function"&&define.amd,Au=!$a.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Te="0123456789abcdef".split(""),UD=[-2147483648,8388608,32768,128],Sr=[24,16,8,0],o0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s0=["hex","array","digest","arrayBuffer"],on=[];($a.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});Au&&($a.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var xT=function(e,t){return function(n){return new sn(t,!0).update(n)[e]()}},wT=function(e){var t=xT("hex",e);t.create=function(){return new sn(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};sn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=UD[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};sn.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,g,f,m,h,y,T,b,x,w;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],g=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(w=t&n,l=0;l<64;l+=4)this.first?(this.is224?(T=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(T=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),T=e&t,f=T^e&n^w,y=a&i^~a&o,m=s+g+y+o0[l]+u[l],h=c+f,s=r+m<<0,r=m+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,f=b^r&t^T,y=s&a^~s&i,m=o+g+y+o0[l+1]+u[l+1],h=c+f,o=n+m<<0,n=m+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=n&r,f=x^n&e^b,y=o&s^~o&a,m=i+g+y+o0[l+2]+u[l+2],h=c+f,i=t+m<<0,t=m+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),w=t&n,f=w^t&r^x,y=i&o^~i&s,m=a+g+y+o0[l+3]+u[l+3],h=c+f,a=e+m<<0,e=m+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};sn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=Te[e>>28&15]+Te[e>>24&15]+Te[e>>20&15]+Te[e>>16&15]+Te[e>>12&15]+Te[e>>8&15]+Te[e>>4&15]+Te[e&15]+Te[t>>28&15]+Te[t>>24&15]+Te[t>>20&15]+Te[t>>16&15]+Te[t>>12&15]+Te[t>>8&15]+Te[t>>4&15]+Te[t&15]+Te[n>>28&15]+Te[n>>24&15]+Te[n>>20&15]+Te[n>>16&15]+Te[n>>12&15]+Te[n>>8&15]+Te[n>>4&15]+Te[n&15]+Te[r>>28&15]+Te[r>>24&15]+Te[r>>20&15]+Te[r>>16&15]+Te[r>>12&15]+Te[r>>8&15]+Te[r>>4&15]+Te[r&15]+Te[a>>28&15]+Te[a>>24&15]+Te[a>>20&15]+Te[a>>16&15]+Te[a>>12&15]+Te[a>>8&15]+Te[a>>4&15]+Te[a&15]+Te[i>>28&15]+Te[i>>24&15]+Te[i>>20&15]+Te[i>>16&15]+Te[i>>12&15]+Te[i>>8&15]+Te[i>>4&15]+Te[i&15]+Te[o>>28&15]+Te[o>>24&15]+Te[o>>20&15]+Te[o>>16&15]+Te[o>>12&15]+Te[o>>8&15]+Te[o>>4&15]+Te[o&15];return this.is224||(u+=Te[s>>28&15]+Te[s>>24&15]+Te[s>>20&15]+Te[s>>16&15]+Te[s>>12&15]+Te[s>>8&15]+Te[s>>4&15]+Te[s&15]),u};sn.prototype.toString=sn.prototype.hex;sn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};sn.prototype.array=sn.prototype.digest;sn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function u0(e,t,n){var r,a=typeof e;if(a==="string"){var i=[],o=e.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);e=i}else if(a==="object"){if(e===null)throw new Error($o);if(Au&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!Au||!ArrayBuffer.isView(e)))throw new Error($o)}else throw new Error($o);e.length>64&&(e=new sn(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}sn.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}u0.prototype=new sn;u0.prototype.finalize=function(){if(sn.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();sn.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),sn.prototype.finalize.call(this)}};var Yo=wT();Yo.sha256=Yo;Yo.sha224=wT(!0);Yo.sha256.hmac=DT();Yo.sha224.hmac=DT(!0);var AT=Yo;var kT=AT.sha256;function Cr(e){return Promise.resolve(kT(e))}function l0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Ya(e,t){let n=kT.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function PT(e,t){let n=await Ya(e,t);return l0(n)}async function c0(e,t){let n=qD(t),r=await Ya(e,n);return l0(r)}function qD(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var LT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ku=class e extends Pe{static langMap=new Map(LT);maxTextGroupLength=50;static langMapReverse=new Map(LT.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new Q("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await Cr(a)].join(` +`).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ni(t);if(l.length>2){let c=l[2];return iD({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=zy(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function cm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function iD(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;o=o||[];let g=e.targetText;g=rt.sanitize(g);let f=g,m=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);o.length>0&&(f=f.replace(m,x=>{let w=f.indexOf(x),L=f[w-1]===" ",M=f[w+x.length]===" ",C=x.match(h);if(!C)return x;let v=C[1],A=Number(v);if(isNaN(A))return x;let D=o[Number(A)];if(D&&D.type==="element"){let S=D.value.outerHTML;return L||(S=" "+S),M||(S=S+" "),S}else if(D&&D.type==="text"){let S=D.value;return L||(S=" "+S),M||(S=S+" "),S}else R.error("variable type not supported",D,x);return x}));let y=jo(l,n,r||[],s),T=Ho(l),b="";return c&&(b=`style="${c}"`),f=`<${a} ${b} class="${y.join(" ")}" ${Fr}="1"><${a} class="${T.join(" ")}" ${Fr}="1">${f}`,n||(i==="smart"?f=`
${f}`:f=`${i}${f}`),n&&(i!=="smart"?f=`${i}${f}`:f=`<${a} class="notranslate" ${Fr}="1"> ${f}`),u==="smart"?f=`${f}`:f=`${f}${u}`,{html:f,position:"afterend"}}function dm(e){let t=e[e.length-1];return t?t.text:""}function gm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let g=c.match(s);if(!g)return c;let f=g[1],m=Number(f);if(isNaN(m))return c;let h=r[f];return h||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}p();p();p();p();p();p();var H$=Hy(2),jy=Hy(3);function Hy(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-e+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+e);return r}}p();var oD=/\s+/g,sD=/[\t\n\v\f\r ]+/g;function Wy(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?uD:lD;return String(e).replace(t.style==="html"?sD:oD,t.trim?cD(n):n)}function uD(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function lD(){return" "}function cD(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var Ky={}.hasOwnProperty;function dD(e){return e==null?"":Wy(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function gD(e){return jy(" "+dD(e)+" ")}function pD(e){let t=gD(e),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function vD(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function SD(e,t,n,r){t=xD(t,n,r);let a=[],i;if(t)for(i in t)Gc.call(t,i)&&a.push([i,CD(e,t[i])]);return a.length===0?mm():a.sort(ED)}function CD(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharacterso+s.length,0));let i=e.length-r;for(let o of BD){let s=o[1],u=o[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/i>.5?t==="zh-CN"?Xy(e)?"zh-TW":"zh-CN":t:"auto"}var tT=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],fm=new Map(tT),ID=new Map(tT.map(([e,t])=>[t,e]));function nT(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>ID.get(s));!t&&t!==0&&(t=25);let a=$c(e);if(a!=="auto")return a;let i={minLength:t,whitelist:[...fm.keys()]},o=$y(e,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(g=="eng"&&f<.95)break;return fm.get(g)}}let[s,u]=o[0],l=fm.get(s);if(l&&u>.9)return l}}catch(r){R.error(r)}return"auto"}p();p();var hm="Original";function et(){return hm}function An(e){hm=e,rT(hm)}p();var iT="auto",Yc="auto",aT="auto";function oT(e){iT=e}function ar(e){Yc=e}function Mt(){return Yc!=="auto"?Yc:aT!=="auto"?aT:iT}function Qc(){return Yc}p();function ji(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ga(e){try{if(!e||!ji(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";t=o.getAttribute(i)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var tt={},Va=async function(e,t){let{method:n,data:r}=e,a=await tt.updateGlobalContext(),i=Date.now();if(R.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await tt.translateTheWholePage(r),at(yr,i);else if(n==="translateTheMainPage")await tt.translateTheMainPage(r),at(yr,i);else if(n==="translateToThePageEndImmediately")await tt.translateToThePageEndImmediately(r),at(yr,i);else if(n==="toggleTranslatePage")await tt.toggleTranslatePage(r),at(yr,i);else if(n==="toggleTranslateTheWholePage")await tt.toggleTranslateTheWholePage(r),at(yr,i);else if(n==="toggleTranslateTheMainPage")await tt.toggleTranslateTheMainPage(r),at(yr,i);else if(n==="toggleOnlyTransation")await tt.ensureSwitchTranslationMode(r),at(yr,i);else if(n==="translatePage")await tt.translatePage(a,r),at(yr,i);else if(n==="toggleTranslationMask")await tt.toggleTranslationMask(r);else if(n==="restorePage")tt.restorePage();else if(n==="retryFailedParagraphs")tt.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await tt.switchTranslationMode(r.mode),await tt.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")tt.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(cc,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await tt.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(nu,{detail:r}));else if(n==="translateWithOpenAI")await tt.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await tt.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await tt.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await tt.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await tt.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await tt.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await tt.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")ot()||await tt.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!ot())return JSON.stringify(a)}};function sT(e){Object.assign(tt,e)}function uT(e){Object.assign(tt,e)}function lT(e){Object.assign(tt,e)}var RD=function(e,t){let{method:n,data:r}=e;if(R.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return et();if(n==="getCurrentPageLanguage"){let a=Mt();return tt.detectCurrentPageLanguage().catch(i=>{R.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return ar(r),Mt();if(n==="getContextString"){let a=tt.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=tt.getPureGlobalContext();return Ga(a?.rule)}}},Zc,Jc;function cT(){let e=Xc();ot()||OD(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Xc(){return Zc||(Zc=new ca("content_script",!1).getConnection("main",Va),Zc)}function OD(){return Jc||(Jc=new ca("content_script",!1).getConnection("main_sync",RD,{sync:!0}),Jc)}p();var bm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],e0="https://transmart.qq.com/api/imt",pa=class e{static langMapReverse=new Map(bm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:e0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=e.langMapReverse.get(a);return i||a}};async function Ft(e){return await Xc().sendMessage("background:main",e)}function de(e){return oc()?kc({method:"request",data:e}):pe()||ic()?(e.fetchPolyfill=globalThis.GM_fetch,Tr(e)):Ft({method:"fetch",data:e})}function ir(){return pe()?bt():Ft({method:"getConfig"})}function kn(e){return pe()?Oi(e):Ft({method:"setUserConfig",data:e})}function Pn(){return pe()?vr():Ft({method:"getUserConfig"})}function Du(){return pe()?Wt():Ft({method:"getLocalConfig"})}function t0(e){return pe()?Kt(e):Ft({method:"setLocalConfig",data:e})}function dT(e){return pe()?ry(e):Ft({method:"setBuildinConfig",data:e})}async function Ue(e){if(e.text){let n=$c(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(pe()||Ge()){if(e.translateService&&!yc.includes(e.translateService))return Promise.resolve("auto");let r=nT(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Ft({method:"detectLanguage",data:e});return Promise.resolve(t)}function gT(){return Ft({method:"detectTabLanguage"})}async function n0(e){let t=await Ue({text:e,pageLangs:["en"]});try{if(pe()||Ge()){let n=e.substring(0,200);t=await pa.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function rT(e){let t=new CustomEvent(ki,{detail:e});if(document.dispatchEvent(t),pe())return;Xc().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function pT(e){return pe()?im(e):Ft({method:"queryParagraphCache",data:e})}async function mT(e){if(pe()){await am(e);return}return Ft({method:"setParagraphCache",data:e})}async function fT(){if(pe())return Promise.resolve();await Ft({method:"mockRequest"})}function Wo(e=!1,t=""){return pe()?(Z.runtime.openOptionsPage(e,t),Promise.resolve()):Ft({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function r0(e=""){return pe()||Ge()?Le().OPTIONS_URL:Z.runtime.getURL("options.html")}function hT(e=""){return Z&&Z.runtime&&Z.runtime.getURL?Z.runtime.getURL("options.html"):""}function a0(e=!1){return pe()?(Z.extra.openAboutPage(e),Promise.resolve()):Ft({method:"openAboutPage"})}function Ko(e){return pe()?(Z.extra.openInTab(e),Promise.resolve()):Ft({method:"openInTab",data:e})}function bT(e=!1){return pe()?(Z.extra.openEbookViewerPage(e),Promise.resolve()):Ft({method:"openEbookViewerPage"})}function yT(e=!1){return pe()?(Z.extra.openEbookBuilderPage(e),Promise.resolve()):Ft({method:"openEbookBuilderPage"})}function TT(e){Ge()}function Go(e=!1,t){return pe()?(Z.extra.openPdfViewerPage(e),Promise.resolve()):Ft({method:"openPdfViewerPage",data:{url:t}})}function vT(e=!1){return pe()?(Z.extra.openSubtitleBuilderPage(e),Promise.resolve()):Ft({method:"openSubtitleBuilderPage"})}function Vo(e){return pe()?Promise.resolve():Ft({method:"setBadge",data:{text:e}})}function ST(){return pe()?(R.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Ft({method:"autoSyncLatestConfig"})}function i0(e,t=!1){return pe()?Z.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function CT(e,t){return pe()?qi.getDelay(e,t):Ft({method:"getDelay",data:{key:e,options:t}})}var Pe=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,i=!1,o=!1,s=[],u=null,l=new Set;for(let T of a)T.from&&T.from!=="auto"&&l.add(T.from),T.refresh&&(i=!0),T.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=I1(a,c,g)}catch(T){if(r)for(let b=0;bT));let f=[],m=[],h=(T,b,x)=>{let w="";if(b.translatedTexts&&b.translatedTexts[0]&&(w=b.translatedTexts[0]),m[T]||(m[T]=b,m[T].translatedTexts=Array(b.sentenceTotalParts).fill(null)),m[T].hasError)return;if(x){let C=x instanceof Q?new Q(x.name,x.message).initNetWork(x.status).initData(x.data):x;m[T].hasError=!0,b.callback&&b.callback(C,null,b.sentence);return}m[T].translatedTexts[b.partIndex]=w;let L=m[T],M=0;for(let C=0;C{let M=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(M=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:M,to:b.to,url:x,options:n,refresh:i,debug:o}),sourceTempSentences:b.tempSentences};{let C=Qb;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(C=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let A=[],D=Or(this.serviceConfig);if(b.tempSentences.forEach((q,I)=>{let k=Kp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});q.force!==!0&&(k&&k.text&&k.text.trim().lengthI.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:q,from:M,to:b.to})}let S="";v&&v.length>=2?S=A.map((q,I)=>{let{item:k}=q;return I===A.length-1?k.text:k.text+v[0]+(I+1)+v[1]}).join(""):S=A.map(({item:q})=>q.text).join(C);let N=await this.translate({text:S,from:M,to:b.to,url:x,options:{...n,rawTextArrayLength:A.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=N,P=[];if(v&&v.length>=2){let q=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(q=v[2]);let I=new RegExp(q,"g");P=F.split(I)}else P=F.split(C);let O=[];if(P.length>A.length){for(let q=0;qq.text);return D=Or(this.serviceConfig,!0),O.forEach((q,I)=>{let k=A[I],_=k.index,B=k.variables||{};Object.keys(B).length>0&&(q=gm({text:q,delimiters:D,variables:B})),z[_]=q}),{sourceTempSentences:b.tempSentences,text:z,from:N.from,to:N.to}}};f.push(L().then(M=>{let{text:C,sourceTempSentences:v}=M;for(let A=0;A{if(M instanceof Q&&M.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let C=0;C{let b=T.sentence.text;return T.translatedTexts&&T.translatedTexts.length>0&&(b=T.translatedTexts.join("")),{...T.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],i=Or(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,f)=>{let m=Kp({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[f]!==!0&&(m&&m.text&&m.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){R.debug("formatAndTranslateList error",t,l)}let o=await this.translateList(n),{text:s}=o,u=t.text.map(l=>l);return i=Or(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let f=g.index,m=g.variables,h=Object.keys(m);u[f]=l,h.length>0&&(u[f]=gm({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(t){return Ue({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};p();p();var $o="input is invalid type",ym=typeof window=="object",$a=ym?window:{};$a.JS_SHA256_NO_WINDOW&&(ym=!1);var zD=!ym&&typeof self=="object",ND=!$a.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;ND?$a=global:zD&&($a=self);var pQ=!$a.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,mQ=typeof define=="function"&&define.amd,Au=!$a.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Te="0123456789abcdef".split(""),UD=[-2147483648,8388608,32768,128],Sr=[24,16,8,0],o0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s0=["hex","array","digest","arrayBuffer"],on=[];($a.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});Au&&($a.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var xT=function(e,t){return function(n){return new sn(t,!0).update(n)[e]()}},wT=function(e){var t=xT("hex",e);t.create=function(){return new sn(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};sn.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=UD[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};sn.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,g,f,m,h,y,T,b,x,w;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],g=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(w=t&n,l=0;l<64;l+=4)this.first?(this.is224?(T=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(T=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),T=e&t,f=T^e&n^w,y=a&i^~a&o,m=s+g+y+o0[l]+u[l],h=c+f,s=r+m<<0,r=m+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,f=b^r&t^T,y=s&a^~s&i,m=o+g+y+o0[l+1]+u[l+1],h=c+f,o=n+m<<0,n=m+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),x=n&r,f=x^n&e^b,y=o&s^~o&a,m=i+g+y+o0[l+2]+u[l+2],h=c+f,i=t+m<<0,t=m+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),w=t&n,f=w^t&r^x,y=i&o^~i&s,m=a+g+y+o0[l+3]+u[l+3],h=c+f,a=e+m<<0,e=m+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};sn.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=Te[e>>28&15]+Te[e>>24&15]+Te[e>>20&15]+Te[e>>16&15]+Te[e>>12&15]+Te[e>>8&15]+Te[e>>4&15]+Te[e&15]+Te[t>>28&15]+Te[t>>24&15]+Te[t>>20&15]+Te[t>>16&15]+Te[t>>12&15]+Te[t>>8&15]+Te[t>>4&15]+Te[t&15]+Te[n>>28&15]+Te[n>>24&15]+Te[n>>20&15]+Te[n>>16&15]+Te[n>>12&15]+Te[n>>8&15]+Te[n>>4&15]+Te[n&15]+Te[r>>28&15]+Te[r>>24&15]+Te[r>>20&15]+Te[r>>16&15]+Te[r>>12&15]+Te[r>>8&15]+Te[r>>4&15]+Te[r&15]+Te[a>>28&15]+Te[a>>24&15]+Te[a>>20&15]+Te[a>>16&15]+Te[a>>12&15]+Te[a>>8&15]+Te[a>>4&15]+Te[a&15]+Te[i>>28&15]+Te[i>>24&15]+Te[i>>20&15]+Te[i>>16&15]+Te[i>>12&15]+Te[i>>8&15]+Te[i>>4&15]+Te[i&15]+Te[o>>28&15]+Te[o>>24&15]+Te[o>>20&15]+Te[o>>16&15]+Te[o>>12&15]+Te[o>>8&15]+Te[o>>4&15]+Te[o&15];return this.is224||(u+=Te[s>>28&15]+Te[s>>24&15]+Te[s>>20&15]+Te[s>>16&15]+Te[s>>12&15]+Te[s>>8&15]+Te[s>>4&15]+Te[s&15]),u};sn.prototype.toString=sn.prototype.hex;sn.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};sn.prototype.array=sn.prototype.digest;sn.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function u0(e,t,n){var r,a=typeof e;if(a==="string"){var i=[],o=e.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);e=i}else if(a==="object"){if(e===null)throw new Error($o);if(Au&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!Au||!ArrayBuffer.isView(e)))throw new Error($o)}else throw new Error($o);e.length>64&&(e=new sn(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}sn.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}u0.prototype=new sn;u0.prototype.finalize=function(){if(sn.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();sn.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),sn.prototype.finalize.call(this)}};var Yo=wT();Yo.sha256=Yo;Yo.sha224=wT(!0);Yo.sha256.hmac=DT();Yo.sha224.hmac=DT(!0);var AT=Yo;var kT=AT.sha256;function Cr(e){return Promise.resolve(kT(e))}function l0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Ya(e,t){let n=kT.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function PT(e,t){let n=await Ya(e,t);return l0(n)}async function c0(e,t){let n=qD(t),r=await Ya(e,n);return l0(r)}function qD(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var LT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ku=class e extends Pe{static langMap=new Map(LT);maxTextGroupLength=50;static langMapReverse=new Map(LT.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new Q("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,i=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:e.langMapReverse.get(o.Response.Source)||r,to:e.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await Cr(a)].join(` `),g=e.getUTCDate(u),f=["TC3-HMAC-SHA256",l,`${g}/${i}/tc3_request`,await Cr(c)].join(` `),m=await PT(g,`TC3${n}`),h=await c0(i,m),y=await c0("tc3_request",h),T=await c0(f,y),b=await de({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${t}/${g}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${T}`},body:a,timeout:this.requestTimeout});if(b instanceof Error)throw b;if(b.Response&&b.Response.Error&&b.Response.Error.Message)throw new Q(b.Response.Error.Message);return b}};p();var _T=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],jD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Pu=class e extends Pe{static langMap=new Map(_T);static langMapReverse=new Map(_T.map(([t,n])=>[n,t]));isSupportList=!1;constructor(t,n,r){super(t,n,r)}async translate(t){let{text:n,from:r,to:a}=t,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await de({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:jD,timeout:this.requestTimeout});return{text:o.targetText,from:e.langMapReverse.get(o.source)||r,to:e.langMapReverse.get(o.target)||a}}};p();var MT=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Hi=class e extends Pe{static langMap=new Map(MT);static langMapReverse=new Map(MT.map(([t,n])=>[n,t]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(t,n,r){super(t,n,r),t?.apiUrl&&(this.apiUrl=rn(this.apiUrl,t.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=e.langMap.get(r)||"auto",o=e.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new Q("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new Q("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=e.langMap.get(r)||"auto",o=e.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new Q("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new Q("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(t,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}).toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(t,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}),i=this.apiUrl+"?"+a.toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}};p();p();p();function HD(e,t){return t?e+(t-e%t):e}function WD(e,t){return e.split(t).length-1}function Tm(e){let t=Date.now(),n=1;for(let r of e)n+=WD(r,"i");return HD(t,n)}function KD(e,t){return Math.floor(Math.random()*(t-e+1))+e}function vm(){return KD(1e6,1e8)}p();p();p();var Sm="https://www2.deepl.com/jsonrpc",Cm="auto",FT=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];p();function GD(e=FT){return e.reduce((t,n)=>(t[n.code.toLowerCase()]=n.code,t[n.language.toLowerCase()]=n.code,t),{})}function xm(e){return GD()[e.toLowerCase()]}var VD={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function $D(e){return JSON.stringify(e).replace('"method":"',()=>{let t=e;return(t.id+3)%13===0||(t.id+5)%29===0?'"method" : "':'"method": "'})}function YD(e,t){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:e,target_lang:t}}}}async function QD(e,t,n,r,a,i,o){let s=vm(),u=YD(r,n),l=[];t.forEach(f=>{l.push({text:f,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Tm(t);let c=await de({retry:2,method:"POST",url:e,body:$D(u),headers:VD}),g={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(f=>{g.text.push(f.text)}),g}async function BT(e,t,n,r=Cm,a,i,o){return t?t&&t.length===1&&t[0]===""?{text:[""],from:r,to:n}:QD(e,t,xm(n),xm(r)??"auto",a,i,o):{text:[],from:r,to:n}}var IT=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Qo=class e extends Pe{static langMap=new Map(IT);static langMapReverse=new Map(IT.map(([t,n])=>[n,t]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Sm;constructor(t,n,r){super(t,n,r),t&&t.apiUrl&&(this.API_URL=rn(Sm,t.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(t){let{text:n,to:r,from:a}=t,i=await BT(this.API_URL,n,e.langMap.get(r)||r,e.langMap.get(a)||"auto");return{text:i.text,from:e.langMapReverse.get(i.from),to:e.langMapReverse.get(i.to)}}};p();var Lu=class e extends Pe{static langMap=new Map(bm);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(t,n,r){super(t,n,r),this.clientKey=pa.getClientKey()}async translate(t){let{text:n,to:r}=t,a=await this.detectLanguage(n),i=e.langMap.get(a)||a,o=e.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Le(),u=t.url;s.INSTALL_FROM==="firefox_store"&&(u=RT());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),g=await de({url:e0,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(g.header.ret_code!=="succ")throw new Q(g.message||g.header.ret_code);return{text:g.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(t){let{from:n,text:r,to:a}=t,i=Le(),o=t.url;if(i.INSTALL_FROM==="firefox_store"&&(o=RT()),r.length===1){let m=await this.translate({from:n,text:r[0],to:a,url:o,options:t.options});return{text:[m.text],from:m.from,to:m.to}}let u=await this.detectLanguage(r.join(` `));if(u===a)return{text:r,from:u,to:a};let l=e.langMap.get(u)||u,c=e.langMap.get(a)||a,g=JSON.stringify({header:{fn:"auto_translation",client_key:this.clientKey},source:{text_list:r,lang:l,orig_url:o},target:{lang:c},type:"plain"}),f=await de({url:e0,body:g,method:"POST"});if(f.header.ret_code!=="succ")throw new Q(f.message||f.header.ret_code);return{text:f.auto_translation,from:u||"auto",to:a}}detectLanguageLocally(t){return this.detectLanguageRemotely(t)}detectLanguageRemotely(t){return pa.detectLanguageRemotelyByTransmart(t)}};function RT(){let e=new Date;return e.setMinutes(e.getMinutes()-e.getMinutes()%5),e.setSeconds(0),e.setMilliseconds(0),`https://google.com/search?q=google&_t=${e.getTime()/1e3}`}p();p();function Em(){return Math.random()>=.1}var Zo=class extends Pe{isSupportList=!1;maxTextLength=1200;maxTextGroupLength=1;async translate(t){let{text:n}=t;if(!Em())throw new Q("404","\u6A21\u62DF\u9519\u8BEF");let r=n.match(/^\s*/)[0].length;return{text:n.slice(0,r)+"\u6A21\u62DF\uFF1A"+n.slice(r,-6),from:t.from,to:t.to}}async translateList(t){let{text:n,from:r,to:a}=t;if(await fT(),!Em())throw new Q("404","\u6A21\u62DF\u9519\u8BEF");return n.length===0?{from:r,to:a,text:[""]}:{from:r,to:a,text:n.map(i=>{let o=i.match(/^\s*/)[0].length;return i.slice(0,o)+"\u6A21\u62DF\uFF1A"+i.slice(o,-6)})}}};p();var zT=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh"],["en","en"],["ja","ja"],["de","de"],["fr","fr"],["it","it"],["es","es"],["nl","nl"],["pl","pl"],["pt","pt"],["ru","ru"]],wm=new Map(zT),OT=new Map(zT.map(([e,t])=>[t,e])),Dm=class e extends Pe{static langMap=wm;static DEFAULT_CODENAME="deepl";apikey="";codename=e.DEFAULT_CODENAME;isSupportList=!1;maxTextGroupLength=1;constructor(t,n,r){if(super(t,n,r),!t||!t.apikey)throw new Q("apikey are required");this.apikey=t.apikey?.trim(),t.codename&&(this.codename=t.codename)}async translate(t){let{text:n,from:r,to:a}=t,i=await de({retry:this.retry,url:`https://api.openl.club/services/${this.codename}/translate`,headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify({apikey:this.apikey,text:n,source_lang:wm.get(r)||"auto",target_lang:wm.get(a)||a}),timeout:this.requestTimeout});if(i.status){let o=i;return o.result&&a=="zh-TW",{text:o.result,from:OT.get(o.source_lang),to:OT.get(o.target_lang)}}else throw new Q(i.msg)}},d0=Dm;p();var NT=[["auto",""],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ar","AR"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["pt-br","PT-BR"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],_u=new Map(NT),ZD=new Map(NT.map(([e,t])=>[t,e])),Am=class extends Pe{static langMap=_u;authKey="";maxTextLength=1800;freeApiUrl="https://api-free.deepl.com/v2/translate";proApiUrl="https://api.deepl.com/v2/translate";immersiveTranslateApiUrl="https://deepl.immersivetranslate.com/v2/translate";immersiveTranslateDeeplTokenUrl="https://api.immersivetranslate.com";immersiveTranslateDeeplProApiUrl=pn()||tr()?"https://api2.immersivetranslate.com/deepl/translate":"https://test-api2.immersivetranslate.com/deepl/translate";provider="custom";splitor="";qualityNoSymabol="";qualityMinTextLength;apiKeys=[];static async clearState(){}getRandomKey(){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}constructor(t,n,r){if(super(t,n,r),t=t||{},this.splitor=t.qualityDelimiterBetaV3||"",this.qualityNoSymabol=t.qualityNoSymoblBetaV3||"",this.qualityMinTextLength=t.qualityMinTextLengthV3||0,t.provider==="pro")if(this.provider="pro",r.userToken){if(!r.isPro)throw new Q("Please activate Pro membership first, \u8BF7\u5148\u5F00\u901A Pro \u4F1A\u5458\u3002");this.authKey=r.userToken,this.apiKeys=this.authKey.split(",").map(a=>a.trim())}else throw new Q("Login required, \u767B\u5F55\u540E\u624D\u53EF\u4EE5\u4F7F\u7528\u3002");else if(this.authKey=t.authKey?.trim(),this.apiKeys=this.authKey.split(",").map(a=>a.trim()),!this.authKey)throw new Q("authKey are required");if(!this.authKey)throw new Q("authKey are required");t&&t.freeApiUrl&&(this.freeApiUrl=rn(this.freeApiUrl,t.freeApiUrl)),t&&t.proApiUrl&&(this.proApiUrl=rn(this.proApiUrl,t.proApiUrl)),t&&t.immersiveTranslateApiUrl&&(this.immersiveTranslateApiUrl=rn(this.immersiveTranslateApiUrl,t.immersiveTranslateApiUrl)),t&&t.immersiveTranslateDeeplTokenUrl&&(this.immersiveTranslateDeeplTokenUrl=rn(this.immersiveTranslateDeeplTokenUrl,t.immersiveTranslateDeeplTokenUrl)),t&&t.immersiveTranslateDeeplProApiUrl&&(this.immersiveTranslateDeeplProApiUrl=rn(this.immersiveTranslateDeeplProApiUrl,t.immersiveTranslateDeeplProApiUrl))}async init(){}getRateLimiter(){let t=super.getRateLimiter();if(this.provider==="pro"){if(this.serviceConfig?.immersiveTranslateProLimit){let n=Number(this.serviceConfig.immersiveTranslateProLimit);return isNaN(n)&&(n=15),{limit:n,interval:t?.interval||1050}}return{limit:15,interval:t?.interval||1050}}return super.getRateLimiter()}getDefaultRateLimit(){return{limit:3,interval:1250}}async translateList(t){let{from:n,to:r}=t,a=this.getRandomKey(),{text:i,merged:o}=this.optimizationText(t),s={source_lang:_u.get(n)||"",target_lang:_u.get(r)||r,tag_handling:"html"};this.serviceConfig?.tag_handling&&(this.serviceConfig.tag_handling==="none"?delete s.tag_handling:s.tag_handling=this.serviceConfig.tag_handling);let u=new URLSearchParams(s);i.forEach(T=>{u.append("text",T)});let l=u.toString(),c={text:i,source_lang:_u.get(n)||"auto",target_lang:_u.get(r)||r},g=this.freeApiUrl;a.endsWith(":im")?g=this.immersiveTranslateApiUrl:a.endsWith(":fx")||(g=this.proApiUrl);let f,m={};t.refresh&&(m={"X-Refresh":"True"}),t.debug&&(m={...m,"X-Debug":"True"}),this.provider==="pro"?f=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...m,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):a.startsWith("immersive_")?f=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...m,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):f=await de({retry:2,url:g,method:"POST",body:l,headers:{Authorization:"DeepL-Auth-Key "+a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},extra:{overrideMimeType:"application/json; charset=utf-8"}});let{translations:h}=this.restoreText(f,o,!!t.debug),y=h.map(T=>T.text);if(r==="zh-TW"){let T=this.serviceConfig||{};T&&T.googleApiUrl&&(T.apiUrl=T.googleApiUrl);let x=await new Hi(this.serviceConfig,this.generalConfig,this.translationOptions).translate({from:"zh-CN",to:"zh-TW",text:h.map(w=>w.text).join(` diff --git a/dist/firefox/popup.js b/dist/firefox/popup.js index 56f1eb9..8a7cc6e 100644 --- a/dist/firefox/popup.js +++ b/dist/firefox/popup.js @@ -1,4 +1,4 @@ -(()=>{var J9=Object.create;var gd=Object.defineProperty;var X9=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var t6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var r6=(t,e)=>()=>(t&&(e=t(t=0)),e);var a6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},i6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of e6(e))!n6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=X9(e,a))||r.enumerable});return t};var o6=(t,e,n)=>(n=t!=null?J9(t6(t)):{},i6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=r6(()=>{x={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var J9=Object.create;var gd=Object.defineProperty;var X9=Object.getOwnPropertyDescriptor;var e6=Object.getOwnPropertyNames;var t6=Object.getPrototypeOf,n6=Object.prototype.hasOwnProperty;var r6=(t,e)=>()=>(t&&(e=t(t=0)),e);var a6=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),tu=(t,e)=>{for(var n in e)gd(t,n,{get:e[n],enumerable:!0})},i6=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of e6(e))!n6.call(t,a)&&a!==n&&gd(t,a,{get:()=>e[a],enumerable:!(r=X9(e,a))||r.enumerable});return t};var o6=(t,e,n)=>(n=t!=null?J9(t6(t)):{},i6(e||!t||!t.__esModule?gd(n,"default",{value:t,enumerable:!0}):n,t));var x,d=r6(()=>{x={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5176,13 +5176,13 @@ Event: ${Ir(t)}`),!0):TC(t,e.denyUrls)?(!1&&Se.warn(`Event dropped due to being Event: ${Ir(t)}. Url: ${ul(t)}`),!0):yC(t,e.allowUrls)?!1:(!1&&Se.warn(`Event dropped due to not being matched by \`allowUrls\` option. Event: ${Ir(t)}. -Url: ${ul(t)}`),!0)}function bC(t,e){return!e||!e.length?!1:vC(t).some(n=>e.some(r=>Gu(n,r)))}function TC(t,e){if(!e||!e.length)return!1;let n=ul(t);return n?e.some(r=>Gu(n,r)):!1}function yC(t,e){if(!e||!e.length)return!0;let n=ul(t);return n?e.some(r=>Gu(n,r)):!0}function vC(t){if(t.message)return[t.message];if(t.exception)try{let{type:e="",value:n=""}=t.exception.values&&t.exception.values[0]||{};return[`${n}`,`${e}: ${n}`]}catch{return!1&&Se.error(`Cannot extract message for event ${Ir(t)}`),[]}return[]}function SC(t){try{return t.exception.values[0].type==="SentryError"}catch{}return!1}function xC(t=[]){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n&&n.filename!==""&&n.filename!=="[native code]")return n.filename||null}return null}function ul(t){try{let e;try{e=t.exception.values[0].stacktrace.frames}catch{}return e?xC(e):null}catch{return!1&&Se.error(`Cannot extract url for event ${Ir(t)}`),null}}d();d();function W0(t,e){let n=K0(t,e),r={type:e&&e.name,value:DC(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function EC(t,e,n,r){let a={exception:{values:[{type:$o(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:`Non-Error ${r?"promise rejection":"exception"} captured with keys: ${Tb(e)}`}]},extra:{__serialized__:P0(e)}};if(n){let i=K0(t,n);i.length&&(a.exception.values[0].stacktrace={frames:i})}return a}function j0(t,e){return{exception:{values:[W0(t,e)]}}}function K0(t,e){let n=e.stacktrace||e.stack||"",r=wC(e);try{return t(n,r)}catch{}return[]}var CC=/Minified React error #\d+;/i;function wC(t){if(t){if(typeof t.framesToPop=="number")return t.framesToPop;if(CC.test(t.message))return 1}return 0}function DC(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function $b(t,e,n,r){let a=n&&n.syntheticException||void 0,i=ll(t,e,a,r);return Xr(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),vn(i)}function Yb(t,e,n="info",r,a){let i=r&&r.syntheticException||void 0,o=H0(t,e,i,a);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),vn(o)}function ll(t,e,n,r,a){let i;if(Wu(e)&&e.error)return j0(t,e.error);if(sb(e)){let o=e;if("stack"in e)i=j0(t,e);else{let s=o.name||"DOMException",u=o.message?`${s}: ${o.message}`:s;i=H0(t,u,n,r),Xo(i,u)}return"code"in o&&(i.tags={...i.tags,"DOMException.code":`${o.code}`}),i}return Hu(e)?j0(t,e):Zn(e)||$o(e)?(i=EC(t,e,n,a),Xr(i,{synthetic:!0}),i):(i=H0(t,e,n,r),Xo(i,`${e}`,void 0),Xr(i,{synthetic:!0}),i)}function H0(t,e,n,r){let a={message:e};if(r&&n){let i=K0(t,n);i.length&&(a.exception={values:[{value:e,stacktrace:{frames:i}}]})}return a}d();var G0="Breadcrumbs",ta=class t{static id=G0;name=t.id;options;constructor(e){this.options={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e}}setupOnce(){this.options.console&&er("console",kC),this.options.dom&&er("dom",AC(this.options.dom)),this.options.xhr&&er("xhr",PC),this.options.fetch&&er("fetch",LC),this.options.history&&er("history",_C)}};function AC(t){function e(n){let r,a=typeof t=="object"?t.serializeAttribute:void 0;typeof a=="string"&&(a=[a]);try{r=n.event.target?Yo(n.event.target,a):Yo(n.event,a)}catch{r=""}r.length!==0&&Le().addBreadcrumb({category:`ui.${n.name}`,message:r},{event:n.event,name:n.name,global:n.global})}return e}function kC(t){let e={category:"console",data:{arguments:t.args,logger:"console"},level:kb(t.level),message:y0(t.args," ")};if(t.level==="assert")if(t.args[0]===!1)e.message=`Assertion failed: ${y0(t.args.slice(1)," ")||"console.assert"}`,e.data.arguments=t.args.slice(1);else return;Le().addBreadcrumb(e,{input:t.args,level:t.level})}function PC(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;let{method:e,url:n,status_code:r,body:a}=t.xhr.__sentry_xhr__||{};Le().addBreadcrumb({category:"xhr",data:{method:e,url:n,status_code:r},type:"http"},{xhr:t.xhr,input:a});return}}function LC(t){t.endTimestamp&&(t.fetchData.url.match(/sentry_key/)&&t.fetchData.method==="POST"||(t.error?Le().addBreadcrumb({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args}):Le().addBreadcrumb({category:"fetch",data:{...t.fetchData,status_code:t.response.status},type:"http"},{input:t.args,response:t.response})))}function _C(t){let e=at(),n=t.from,r=t.to,a=Vu(e.location.href),i=Vu(n),o=Vu(r);i.path||(i=a),a.protocol===o.protocol&&a.host===o.host&&(r=o.relative),a.protocol===i.protocol&&a.host===i.host&&(n=i.relative),Le().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}d();var dl=at(),cl;function V0(){if(cl)return cl;if(Sb(fetch))return cl=fetch.bind(dl);let t=dl.document,e=fetch;if(t&&typeof t.createElement=="function")try{let n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n);let r=n.contentWindow;r&&r.fetch&&(e=r.fetch),t.head.removeChild(n)}catch(n){!1&&Se.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return cl=e.bind(dl)}function Qb(t,e){Object.prototype.toString.call(dl&&navigator)==="[object Navigator]"&&typeof navigator.sendBeacon=="function"?navigator.sendBeacon.bind(navigator)(t,e):vb()&&V0()(t,{body:e,method:"POST",credentials:"omit",keepalive:!0}).then(null,i=>{!1&&Se.error(i)})}var $0=at(),Mi=class extends rs{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:Fi}],version:Fi},super(e),e.sendClientReports&&$0.document&&$0.document.addEventListener("visibilitychange",()=>{$0.document.visibilityState==="hidden"&&this._flushOutcomes()})}eventFromException(e,n){return $b(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Yb(this._options.stackParser,e,n,r,this._options.attachStacktrace)}sendEvent(e,n){let r=this.getIntegrationById(G0);r&&r.options&&r.options.sentry&&Le().addBreadcrumb({category:`sentry.${e.type==="transaction"?"transaction":"event"}`,event_id:e.event_id,level:e.level,message:Ir(e)},{event:e}),super.sendEvent(e,n)}_prepareEvent(e,n,r){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r)}_flushOutcomes(){let e=this._clearOutcomes();if(e.length===0){!1&&Se.log("No outcomes to send");return}if(!this._dsn){!1&&Se.log("No dsn provided, will not send outcomes");return}!1&&Se.log("Sending outcomes:",e);let n=ns(this._dsn,this._options),r=Fb(e,this._options.tunnel&&qa(this._dsn));try{Qb(n,Yu(r))}catch(a){!1&&Se.error(a)}}};d();d();function is(t,e=V0()){function n(r){let a={body:r.body,method:"POST",referrerPolicy:"origin",headers:t.headers,...t.fetchOptions};return e(t.url,a).then(i=>({statusCode:i.status,headers:{"x-sentry-rate-limits":i.headers.get("X-Sentry-Rate-Limits"),"retry-after":i.headers.get("Retry-After")}}))}return as(t,n)}d();var Bi="?",FC=10,MC=20,BC=30,IC=40,RC=50;function os(t,e,n,r){let a={filename:t,function:e,in_app:!0};return n!==void 0&&(a.lineno=n),r!==void 0&&(a.colno=r),a}var OC=/^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zC=/\((\S*)(?::(\d+))(?::(\d+))\)/,NC=t=>{let e=OC.exec(t);if(e){if(e[2]&&e[2].indexOf("eval")===0){let i=zC.exec(e[2]);i&&(e[2]=i[1],e[3]=i[2],e[4]=i[3])}let[r,a]=Xb(e[1]||Bi,e[2]);return os(a,r,e[3]?+e[3]:void 0,e[4]?+e[4]:void 0)}},Y0=[BC,NC],UC=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,qC=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,jC=t=>{let e=UC.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){let i=qC.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],a=e[1]||Bi;return[a,r]=Xb(a,r),os(r,a,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Q0=[RC,jC],HC=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,WC=t=>{let e=HC.exec(t);return e?os(e[2],e[1]||Bi,+e[3],e[4]?+e[4]:void 0):void 0},Z0=[IC,WC],KC=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,GC=t=>{let e=KC.exec(t);return e?os(e[2],e[3]||Bi,+e[1]):void 0},Zb=[FC,GC],VC=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,$C=t=>{let e=VC.exec(t);return e?os(e[5],e[3]||e[4]||Bi,+e[1],+e[2]):void 0},Jb=[MC,$C],J0=[Y0,Q0,Z0],pl=C0(...J0),Xb=(t,e)=>{let n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};d();d();var X0=0;function ep(){return X0>0}function YC(){X0+=1,setTimeout(()=>{X0-=1})}function zr(t,e={},n){if(typeof t!="function")return t;try{let a=t.__sentry_wrapped__;if(a)return a;if(Ai(t))return t}catch{return t}let r=function(){let a=Array.prototype.slice.call(arguments);try{n&&typeof n=="function"&&n.apply(this,arguments);let i=a.map(o=>zr(o,e));return t.apply(this,i)}catch(i){throw YC(),_i(o=>{o.addEventProcessor(s=>(e.mechanism&&(Xo(s,void 0,void 0),Xr(s,e.mechanism)),s.extra={...s.extra,arguments:a},s)),Li(i)}),i}};try{for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}catch{}S0(r,t),Zo(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}var tp={};tu(tp,{Breadcrumbs:()=>ta,Dedupe:()=>ia,GlobalHandlers:()=>fr,HttpContext:()=>aa,LinkedErrors:()=>ra,TryCatch:()=>na});d();d();var fr=class t{static id="GlobalHandlers";name=t.id;_options;_installFunc={onerror:QC,onunhandledrejection:ZC};constructor(e){this._options={onerror:!0,onunhandledrejection:!0,...e}}setupOnce(){let e=this._options;for(let n in e){let r=this._installFunc[n];r&&e[n]&&(ew(n),r(),this._installFunc[n]=void 0)}}};function QC(){er("error",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let{msg:a,url:i,line:o,column:s,error:u}=t;if(ep()||u&&u.__sentry_own_request__)return;let l=u===void 0&&Fr(a)?XC(a,i,o,s):e3(ll(n,u||a,void 0,r,!1),i,o,s);l.level="error",t3(e,u,l,"onerror")})}function ZC(){er("unhandledrejection",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let a=t;try{"reason"in t?a=t.reason:"detail"in t&&"reason"in t.detail&&(a=t.detail.reason)}catch{}if(ep()||a&&a.__sentry_own_request__)return!0;let i=Vo(a)?JC(a):ll(n,a,void 0,r,!0);i.level="error",t3(e,a,i,"onunhandledrejection")})}function JC(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function XC(t,e,n,r){let a=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=Wu(t)?t.message:t,o="Error",s=i.match(a);return s&&(o=s[1],i=s[2]),e3({exception:{values:[{type:o,value:i}]}},e,n,r)}function e3(t,e,n,r){let a=t.exception=t.exception||{},i=a.values=a.values||[],o=i[0]=i[0]||{},s=o.stacktrace=o.stacktrace||{},u=s.frames=s.frames||[],l=isNaN(parseInt(r,10))?void 0:r,c=isNaN(parseInt(n,10))?void 0:n,p=Fr(e)&&e.length>0?e:pb();return u.length===0&&u.push({colno:l,filename:p,function:"?",in_app:!0,lineno:c}),t}function ew(t){!1&&Se.log(`Global Handler attached: ${t}`)}function t3(t,e,n,r){Xr(n,{handled:!1,type:r}),t.captureEvent(n,{originalException:e})}function n3(){let t=Le(),e=t.getClient(),n=e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1};return[t,n.stackParser,n.attachStacktrace]}d();var tw=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],na=class t{static id="TryCatch";name=t.id;_options;constructor(e){this._options={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e}}setupOnce(){let e=at();this._options.setTimeout&&Jn(e,"setTimeout",r3),this._options.setInterval&&Jn(e,"setInterval",r3),this._options.requestAnimationFrame&&Jn(e,"requestAnimationFrame",nw),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&Jn(XMLHttpRequest.prototype,"send",rw);let n=this._options.eventTarget;n&&(Array.isArray(n)?n:tw).forEach(aw)}};function r3(t){return function(...e){let n=e[0];return e[0]=zr(n,{mechanism:{data:{function:Xn(t)},handled:!0,type:"instrument"}}),t.apply(this,e)}}function nw(t){return function(e){return t.apply(this,[zr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Xn(t)},handled:!0,type:"instrument"}})])}}function rw(t){return function(...e){let n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(a=>{a in n&&typeof n[a]=="function"&&Jn(n,a,function(i){let o={mechanism:{data:{function:a,handler:Xn(i)},handled:!0,type:"instrument"}},s=Ai(i);return s&&(o.mechanism.data.handler=Xn(s)),zr(i,o)})}),t.apply(this,e)}}function aw(t){let e=at(),n=e[t]&&e[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Jn(n,"addEventListener",function(r){return function(a,i,o){try{typeof i.handleEvent=="function"&&(i.handleEvent=zr(i.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Xn(i),target:t},handled:!0,type:"instrument"}}))}catch{}let s=zr(i,{mechanism:{data:{function:"addEventListener",handler:Xn(i),target:t},handled:!0,type:"instrument"}}),u=[a,s,o];return r.apply(this,u)}}),Jn(n,"removeEventListener",function(r){return function(a,i,o){let s=i;try{let u=s&&s.__sentry_wrapped__;u&&r.call(this,a,u,o)}catch{}return r.call(this,a,s,o)}}))}d();var iw="cause",ow=5,ra=class t{static id="LinkedErrors";name=t.id;_key;_limit;constructor(e={}){this._key=e.key||iw,this._limit=e.limit||ow}setupOnce(){let e=Le().getClient();e&&mr((n,r)=>{let a=Le().getIntegration(t);return a?sw(e.getOptions().stackParser,a._key,a._limit,n,r):n})}};function sw(t,e,n,r,a){if(!r.exception||!r.exception.values||!a||!dr(a.originalException,Error))return r;let i=a3(t,n,a.originalException,e);return r.exception.values=[...i,...r.exception.values],r}function a3(t,e,n,r,a=[]){if(!dr(n[r],Error)||a.length+1>=e)return a;let i=W0(t,n[r]);return a3(t,e,n[r],r,[i,...a])}d();var i3=at(),aa=class t{static id="HttpContext";name=t.id;setupOnce(){mr(e=>{if(Le().getIntegration(t)){if(!navigator&&!location&&!i3.document)return e;let n=e.request&&e.request.url||location&&location.href,{referrer:r}=i3.document||{},{userAgent:a}=navigator||{},i={...e.request&&e.request.headers,...r&&{Referer:r},...a&&{"User-Agent":a}},o={...n&&{url:n},headers:i};return{...e,request:o}}return e})}};d();var ia=class t{static id="Dedupe";name=t.id;_previousEvent;setupOnce(e,n){let r=a=>{let i=n().getIntegration(t);if(i){try{if(uw(a,i._previousEvent))return!1&&Se.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{return i._previousEvent=a}return i._previousEvent=a}return a};r.id=this.name,e(r)}};function uw(t,e){return e?!!(lw(t,e)||cw(t,e)):!1}function lw(t,e){let n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!l3(t,e)||!u3(t,e))}function cw(t,e){let n=o3(e),r=o3(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!l3(t,e)||!u3(t,e))}function u3(t,e){let n=s3(t),r=s3(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let a=0;a"u"){!1&&Se.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");return}let n=Le();n.captureSession&&(c3(n),er("history",({from:r,to:a})=>{r===void 0||r===a||c3(Le())}))}var y3={},rp=at();rp.Sentry&&rp.Sentry.Integrations&&(y3=rp.Sentry.Integrations);var pw={...y3,...Va,...tp};var gw=Ru.alert;d();var Ii=console,ap=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=In.green;r>1e4?a=In.red:r>1e3&&(a=In.yellow),Ii.debug(In.dim(Ia+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ss=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&Ii.log(In.dim(Ia+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&Ii.log(In.green(Ia+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&Ii.warn(In.yellow(Ia+" WARN:"),...e)}error(...e){this.#e<=3&&Ii.error(In.red(Ia+" ERROR:"),...e)}fatal(...e){this.#e<=4&&Ii.error(In.red(Ia+" FATAL:"),...e)}timing(){return this.level===0?new ap:{reset:()=>{},stop:()=>{}}}},z=new ss;var v3=["*://*/*","*","*://*"],x3="immersive-translate-wildcard-placeholder.com";function ip(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>v3.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(v3.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return fw(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,x3),g;try{g=new URL(p)}catch{return z.debug("invalid match pattern",p,"raw match value:",c),!1}let m=g.host,f=g.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=mw(l+":",S3(m),S3(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function S3(t){return t.replaceAll(x3,"*")}function mw(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function wt(t,e){return ip(t,e)!==null}function fw(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}d();d();var gl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.3",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var bw="";function Sn(){return bw||gl.version}function op(){return oe.runtime.getManifest().version}d();d();var Tw="";function Ri(){return Tw||globalThis.navigator.userAgent}function sp(){return Ri().includes("ImtFxiOS")}function E3(){let e=Ri().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function yw(){return Ri().includes("ImtFxAndroid")}function C3(){let t=Ri();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function w3(){let e=Ri().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function us(){let t=Ri();if(sp()||yw()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}function ml(t){if(t.beta)return!1;if(it()&&t.spVersion)return ls(op(),t.spVersion);if(C3()&&t.gspVersion){let e=w3();if(e)return ls(e,t.gspVersion)}if(sp()&&t.ispVersion){let e=E3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function up(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function fl(t){return Array.isArray(t)?t:t?[t]:[]}function hl(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function bl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function Tl(t,e){let n={...t};return P3(n,e),vw(n,e),n}function k3(t,e,n){let r={...e};return Ya({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ya({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function vw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;P3(t,a)}function Ya({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Sw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=fl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!D3(s))return;c=lp(l,u)}else if(o=="remove_v"){if(!D3(s))return;c=A3(l,u)}else o==="add"?c=lp(l,u):o=="remove"&&(c=A3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=lp(l,u):c=u,r(i,c)})}function P3(t,e){return Ya({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function lp(t,e){let n;if(Array.isArray(t)){let r=fl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Sw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function D3(t){let e=Sn();return t&&ls(e,t)}function A3(t,e){if(Array.isArray(t)){let n=fl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}d();d();var Oi="input is invalid type",cp=typeof window=="object",oa=cp?window:{};oa.JS_SHA256_NO_WINDOW&&(cp=!1);var xw=!cp&&typeof self=="object",Ew=!oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;Ew?oa=global:xw&&(oa=self);var SN=!oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,xN=typeof define=="function"&&define.amd,cs=!oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),Cw=[-2147483648,8388608,32768,128],tr=[24,16,8,0],yl=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],vl=["hex","array","digest","arrayBuffer"],Ut=[];(oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});cs&&(oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var L3=function(t,e){return function(n){return new qt(e,!0).update(n)[t]()}},F3=function(t){var e=L3("hex",t);e.create=function(){return new qt(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};qt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Cw[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};qt.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,g,m,f,T,b,h,C,D;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],p=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(b=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,g=b^t&n^D,T=a&i^~a&o,m=s+p+T+yl[l]+u[l],f=c+g,s=r+m<<0,r=m+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,g=h^r&e^b,T=s&a^~s&i,m=o+p+T+yl[l+1]+u[l+1],f=c+g,o=n+m<<0,n=m+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),C=n&r,g=C^n&t^h,T=o&s^~o&a,m=i+p+T+yl[l+2]+u[l+2],f=c+g,i=e+m<<0,e=m+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,g=D^e&r^C,T=i&o^~i&s,m=a+p+T+yl[l+3]+u[l+3],f=c+g,a=t+m<<0,t=m+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};qt.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};qt.prototype.toString=qt.prototype.hex;qt.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};qt.prototype.array=qt.prototype.digest;qt.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Sl(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Oi);if(cs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cs||!ArrayBuffer.isView(t)))throw new Error(Oi)}else throw new Error(Oi);t.length>64&&(t=new qt(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}qt.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Sl.prototype=new qt;Sl.prototype.finalize=function(){if(qt.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();qt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),qt.prototype.finalize.call(this)}};var zi=F3();zi.sha256=zi;zi.sha224=F3(!0);zi.sha256.hmac=M3();zi.sha224.hmac=M3(!0);var B3=zi;var I3=B3.sha256;function nr(t){return Promise.resolve(I3(t))}function xl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function sa(t,e){let n=I3.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function R3(t,e){let n=await sa(t,e);return xl(n)}async function El(t,e){let n=ww(e),r=await sa(t,n);return xl(r)}function ww(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}d();d();function Je(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();d();function O3(t){return t.replace(//g,">")}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=wn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":wn[a]}else return"auto";else return wn[r]}function ft(){return Te(document?.documentElement?.lang||"en")}function z3(t,e,n){let r=Dw(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function Dw(t,e){let n=[],r=[];for(let a=0;a0?Te.some(r=>Gu(n,r)))}function TC(t,e){if(!e||!e.length)return!1;let n=ul(t);return n?e.some(r=>Gu(n,r)):!1}function yC(t,e){if(!e||!e.length)return!0;let n=ul(t);return n?e.some(r=>Gu(n,r)):!0}function vC(t){if(t.message)return[t.message];if(t.exception)try{let{type:e="",value:n=""}=t.exception.values&&t.exception.values[0]||{};return[`${n}`,`${e}: ${n}`]}catch{return!1&&Se.error(`Cannot extract message for event ${Ir(t)}`),[]}return[]}function SC(t){try{return t.exception.values[0].type==="SentryError"}catch{}return!1}function xC(t=[]){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n&&n.filename!==""&&n.filename!=="[native code]")return n.filename||null}return null}function ul(t){try{let e;try{e=t.exception.values[0].stacktrace.frames}catch{}return e?xC(e):null}catch{return!1&&Se.error(`Cannot extract url for event ${Ir(t)}`),null}}d();d();function W0(t,e){let n=K0(t,e),r={type:e&&e.name,value:DC(e)};return n.length&&(r.stacktrace={frames:n}),r.type===void 0&&r.value===""&&(r.value="Unrecoverable error caught"),r}function EC(t,e,n,r){let a={exception:{values:[{type:$o(e)?e.constructor.name:r?"UnhandledRejection":"Error",value:`Non-Error ${r?"promise rejection":"exception"} captured with keys: ${Tb(e)}`}]},extra:{__serialized__:P0(e)}};if(n){let i=K0(t,n);i.length&&(a.exception.values[0].stacktrace={frames:i})}return a}function j0(t,e){return{exception:{values:[W0(t,e)]}}}function K0(t,e){let n=e.stacktrace||e.stack||"",r=wC(e);try{return t(n,r)}catch{}return[]}var CC=/Minified React error #\d+;/i;function wC(t){if(t){if(typeof t.framesToPop=="number")return t.framesToPop;if(CC.test(t.message))return 1}return 0}function DC(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function $b(t,e,n,r){let a=n&&n.syntheticException||void 0,i=ll(t,e,a,r);return Xr(i),i.level="error",n&&n.event_id&&(i.event_id=n.event_id),vn(i)}function Yb(t,e,n="info",r,a){let i=r&&r.syntheticException||void 0,o=H0(t,e,i,a);return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),vn(o)}function ll(t,e,n,r,a){let i;if(Wu(e)&&e.error)return j0(t,e.error);if(sb(e)){let o=e;if("stack"in e)i=j0(t,e);else{let s=o.name||"DOMException",u=o.message?`${s}: ${o.message}`:s;i=H0(t,u,n,r),Xo(i,u)}return"code"in o&&(i.tags={...i.tags,"DOMException.code":`${o.code}`}),i}return Hu(e)?j0(t,e):Zn(e)||$o(e)?(i=EC(t,e,n,a),Xr(i,{synthetic:!0}),i):(i=H0(t,e,n,r),Xo(i,`${e}`,void 0),Xr(i,{synthetic:!0}),i)}function H0(t,e,n,r){let a={message:e};if(r&&n){let i=K0(t,n);i.length&&(a.exception={values:[{value:e,stacktrace:{frames:i}}]})}return a}d();var G0="Breadcrumbs",ta=class t{static id=G0;name=t.id;options;constructor(e){this.options={console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0,...e}}setupOnce(){this.options.console&&er("console",kC),this.options.dom&&er("dom",AC(this.options.dom)),this.options.xhr&&er("xhr",PC),this.options.fetch&&er("fetch",LC),this.options.history&&er("history",_C)}};function AC(t){function e(n){let r,a=typeof t=="object"?t.serializeAttribute:void 0;typeof a=="string"&&(a=[a]);try{r=n.event.target?Yo(n.event.target,a):Yo(n.event,a)}catch{r=""}r.length!==0&&Le().addBreadcrumb({category:`ui.${n.name}`,message:r},{event:n.event,name:n.name,global:n.global})}return e}function kC(t){let e={category:"console",data:{arguments:t.args,logger:"console"},level:kb(t.level),message:y0(t.args," ")};if(t.level==="assert")if(t.args[0]===!1)e.message=`Assertion failed: ${y0(t.args.slice(1)," ")||"console.assert"}`,e.data.arguments=t.args.slice(1);else return;Le().addBreadcrumb(e,{input:t.args,level:t.level})}function PC(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;let{method:e,url:n,status_code:r,body:a}=t.xhr.__sentry_xhr__||{};Le().addBreadcrumb({category:"xhr",data:{method:e,url:n,status_code:r},type:"http"},{xhr:t.xhr,input:a});return}}function LC(t){t.endTimestamp&&(t.fetchData.url.match(/sentry_key/)&&t.fetchData.method==="POST"||(t.error?Le().addBreadcrumb({category:"fetch",data:t.fetchData,level:"error",type:"http"},{data:t.error,input:t.args}):Le().addBreadcrumb({category:"fetch",data:{...t.fetchData,status_code:t.response.status},type:"http"},{input:t.args,response:t.response})))}function _C(t){let e=at(),n=t.from,r=t.to,a=Vu(e.location.href),i=Vu(n),o=Vu(r);i.path||(i=a),a.protocol===o.protocol&&a.host===o.host&&(r=o.relative),a.protocol===i.protocol&&a.host===i.host&&(n=i.relative),Le().addBreadcrumb({category:"navigation",data:{from:n,to:r}})}d();var dl=at(),cl;function V0(){if(cl)return cl;if(Sb(fetch))return cl=fetch.bind(dl);let t=dl.document,e=fetch;if(t&&typeof t.createElement=="function")try{let n=t.createElement("iframe");n.hidden=!0,t.head.appendChild(n);let r=n.contentWindow;r&&r.fetch&&(e=r.fetch),t.head.removeChild(n)}catch(n){!1&&Se.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",n)}return cl=e.bind(dl)}function Qb(t,e){Object.prototype.toString.call(dl&&navigator)==="[object Navigator]"&&typeof navigator.sendBeacon=="function"?navigator.sendBeacon.bind(navigator)(t,e):vb()&&V0()(t,{body:e,method:"POST",credentials:"omit",keepalive:!0}).then(null,i=>{!1&&Se.error(i)})}var $0=at(),Mi=class extends rs{constructor(e){e._metadata=e._metadata||{},e._metadata.sdk=e._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:Fi}],version:Fi},super(e),e.sendClientReports&&$0.document&&$0.document.addEventListener("visibilitychange",()=>{$0.document.visibilityState==="hidden"&&this._flushOutcomes()})}eventFromException(e,n){return $b(this._options.stackParser,e,n,this._options.attachStacktrace)}eventFromMessage(e,n="info",r){return Yb(this._options.stackParser,e,n,r,this._options.attachStacktrace)}sendEvent(e,n){let r=this.getIntegrationById(G0);r&&r.options&&r.options.sentry&&Le().addBreadcrumb({category:`sentry.${e.type==="transaction"?"transaction":"event"}`,event_id:e.event_id,level:e.level,message:Ir(e)},{event:e}),super.sendEvent(e,n)}_prepareEvent(e,n,r){return e.platform=e.platform||"javascript",super._prepareEvent(e,n,r)}_flushOutcomes(){let e=this._clearOutcomes();if(e.length===0){!1&&Se.log("No outcomes to send");return}if(!this._dsn){!1&&Se.log("No dsn provided, will not send outcomes");return}!1&&Se.log("Sending outcomes:",e);let n=ns(this._dsn,this._options),r=Fb(e,this._options.tunnel&&qa(this._dsn));try{Qb(n,Yu(r))}catch(a){!1&&Se.error(a)}}};d();d();function is(t,e=V0()){function n(r){let a={body:r.body,method:"POST",referrerPolicy:"origin",headers:t.headers,...t.fetchOptions};return e(t.url,a).then(i=>({statusCode:i.status,headers:{"x-sentry-rate-limits":i.headers.get("X-Sentry-Rate-Limits"),"retry-after":i.headers.get("Retry-After")}}))}return as(t,n)}d();var Bi="?",FC=10,MC=20,BC=30,IC=40,RC=50;function os(t,e,n,r){let a={filename:t,function:e,in_app:!0};return n!==void 0&&(a.lineno=n),r!==void 0&&(a.colno=r),a}var OC=/^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zC=/\((\S*)(?::(\d+))(?::(\d+))\)/,NC=t=>{let e=OC.exec(t);if(e){if(e[2]&&e[2].indexOf("eval")===0){let i=zC.exec(e[2]);i&&(e[2]=i[1],e[3]=i[2],e[4]=i[3])}let[r,a]=Xb(e[1]||Bi,e[2]);return os(a,r,e[3]?+e[3]:void 0,e[4]?+e[4]:void 0)}},Y0=[BC,NC],UC=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,qC=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,jC=t=>{let e=UC.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){let i=qC.exec(e[3]);i&&(e[1]=e[1]||"eval",e[3]=i[1],e[4]=i[2],e[5]="")}let r=e[3],a=e[1]||Bi;return[a,r]=Xb(a,r),os(r,a,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Q0=[RC,jC],HC=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,WC=t=>{let e=HC.exec(t);return e?os(e[2],e[1]||Bi,+e[3],e[4]?+e[4]:void 0):void 0},Z0=[IC,WC],KC=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,GC=t=>{let e=KC.exec(t);return e?os(e[2],e[3]||Bi,+e[1]):void 0},Zb=[FC,GC],VC=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,$C=t=>{let e=VC.exec(t);return e?os(e[5],e[3]||e[4]||Bi,+e[1],+e[2]):void 0},Jb=[MC,$C],J0=[Y0,Q0,Z0],pl=C0(...J0),Xb=(t,e)=>{let n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};d();d();var X0=0;function ep(){return X0>0}function YC(){X0+=1,setTimeout(()=>{X0-=1})}function zr(t,e={},n){if(typeof t!="function")return t;try{let a=t.__sentry_wrapped__;if(a)return a;if(Ai(t))return t}catch{return t}let r=function(){let a=Array.prototype.slice.call(arguments);try{n&&typeof n=="function"&&n.apply(this,arguments);let i=a.map(o=>zr(o,e));return t.apply(this,i)}catch(i){throw YC(),_i(o=>{o.addEventProcessor(s=>(e.mechanism&&(Xo(s,void 0,void 0),Xr(s,e.mechanism)),s.extra={...s.extra,arguments:a},s)),Li(i)}),i}};try{for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}catch{}S0(r,t),Zo(t,"__sentry_wrapped__",r);try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch{}return r}var tp={};tu(tp,{Breadcrumbs:()=>ta,Dedupe:()=>ia,GlobalHandlers:()=>fr,HttpContext:()=>aa,LinkedErrors:()=>ra,TryCatch:()=>na});d();d();var fr=class t{static id="GlobalHandlers";name=t.id;_options;_installFunc={onerror:QC,onunhandledrejection:ZC};constructor(e){this._options={onerror:!0,onunhandledrejection:!0,...e}}setupOnce(){let e=this._options;for(let n in e){let r=this._installFunc[n];r&&e[n]&&(ew(n),r(),this._installFunc[n]=void 0)}}};function QC(){er("error",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let{msg:a,url:i,line:o,column:s,error:u}=t;if(ep()||u&&u.__sentry_own_request__)return;let l=u===void 0&&Fr(a)?XC(a,i,o,s):e3(ll(n,u||a,void 0,r,!1),i,o,s);l.level="error",t3(e,u,l,"onerror")})}function ZC(){er("unhandledrejection",t=>{let[e,n,r]=n3();if(!e.getIntegration(fr))return;let a=t;try{"reason"in t?a=t.reason:"detail"in t&&"reason"in t.detail&&(a=t.detail.reason)}catch{}if(ep()||a&&a.__sentry_own_request__)return!0;let i=Vo(a)?JC(a):ll(n,a,void 0,r,!0);i.level="error",t3(e,a,i,"onunhandledrejection")})}function JC(t){return{exception:{values:[{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(t)}`}]}}}function XC(t,e,n,r){let a=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,i=Wu(t)?t.message:t,o="Error",s=i.match(a);return s&&(o=s[1],i=s[2]),e3({exception:{values:[{type:o,value:i}]}},e,n,r)}function e3(t,e,n,r){let a=t.exception=t.exception||{},i=a.values=a.values||[],o=i[0]=i[0]||{},s=o.stacktrace=o.stacktrace||{},u=s.frames=s.frames||[],l=isNaN(parseInt(r,10))?void 0:r,c=isNaN(parseInt(n,10))?void 0:n,p=Fr(e)&&e.length>0?e:pb();return u.length===0&&u.push({colno:l,filename:p,function:"?",in_app:!0,lineno:c}),t}function ew(t){!1&&Se.log(`Global Handler attached: ${t}`)}function t3(t,e,n,r){Xr(n,{handled:!1,type:r}),t.captureEvent(n,{originalException:e})}function n3(){let t=Le(),e=t.getClient(),n=e&&e.getOptions()||{stackParser:()=>[],attachStacktrace:!1};return[t,n.stackParser,n.attachStacktrace]}d();var tw=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],na=class t{static id="TryCatch";name=t.id;_options;constructor(e){this._options={XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0,...e}}setupOnce(){let e=at();this._options.setTimeout&&Jn(e,"setTimeout",r3),this._options.setInterval&&Jn(e,"setInterval",r3),this._options.requestAnimationFrame&&Jn(e,"requestAnimationFrame",nw),this._options.XMLHttpRequest&&"XMLHttpRequest"in e&&Jn(XMLHttpRequest.prototype,"send",rw);let n=this._options.eventTarget;n&&(Array.isArray(n)?n:tw).forEach(aw)}};function r3(t){return function(...e){let n=e[0];return e[0]=zr(n,{mechanism:{data:{function:Xn(t)},handled:!0,type:"instrument"}}),t.apply(this,e)}}function nw(t){return function(e){return t.apply(this,[zr(e,{mechanism:{data:{function:"requestAnimationFrame",handler:Xn(t)},handled:!0,type:"instrument"}})])}}function rw(t){return function(...e){let n=this;return["onload","onerror","onprogress","onreadystatechange"].forEach(a=>{a in n&&typeof n[a]=="function"&&Jn(n,a,function(i){let o={mechanism:{data:{function:a,handler:Xn(i)},handled:!0,type:"instrument"}},s=Ai(i);return s&&(o.mechanism.data.handler=Xn(s)),zr(i,o)})}),t.apply(this,e)}}function aw(t){let e=at(),n=e[t]&&e[t].prototype;!n||!n.hasOwnProperty||!n.hasOwnProperty("addEventListener")||(Jn(n,"addEventListener",function(r){return function(a,i,o){try{typeof i.handleEvent=="function"&&(i.handleEvent=zr(i.handleEvent,{mechanism:{data:{function:"handleEvent",handler:Xn(i),target:t},handled:!0,type:"instrument"}}))}catch{}let s=zr(i,{mechanism:{data:{function:"addEventListener",handler:Xn(i),target:t},handled:!0,type:"instrument"}}),u=[a,s,o];return r.apply(this,u)}}),Jn(n,"removeEventListener",function(r){return function(a,i,o){let s=i;try{let u=s&&s.__sentry_wrapped__;u&&r.call(this,a,u,o)}catch{}return r.call(this,a,s,o)}}))}d();var iw="cause",ow=5,ra=class t{static id="LinkedErrors";name=t.id;_key;_limit;constructor(e={}){this._key=e.key||iw,this._limit=e.limit||ow}setupOnce(){let e=Le().getClient();e&&mr((n,r)=>{let a=Le().getIntegration(t);return a?sw(e.getOptions().stackParser,a._key,a._limit,n,r):n})}};function sw(t,e,n,r,a){if(!r.exception||!r.exception.values||!a||!dr(a.originalException,Error))return r;let i=a3(t,n,a.originalException,e);return r.exception.values=[...i,...r.exception.values],r}function a3(t,e,n,r,a=[]){if(!dr(n[r],Error)||a.length+1>=e)return a;let i=W0(t,n[r]);return a3(t,e,n[r],r,[i,...a])}d();var i3=at(),aa=class t{static id="HttpContext";name=t.id;setupOnce(){mr(e=>{if(Le().getIntegration(t)){if(!navigator&&!location&&!i3.document)return e;let n=e.request&&e.request.url||location&&location.href,{referrer:r}=i3.document||{},{userAgent:a}=navigator||{},i={...e.request&&e.request.headers,...r&&{Referer:r},...a&&{"User-Agent":a}},o={...n&&{url:n},headers:i};return{...e,request:o}}return e})}};d();var ia=class t{static id="Dedupe";name=t.id;_previousEvent;setupOnce(e,n){let r=a=>{let i=n().getIntegration(t);if(i){try{if(uw(a,i._previousEvent))return!1&&Se.warn("Event dropped due to being a duplicate of previously captured event."),null}catch{return i._previousEvent=a}return i._previousEvent=a}return a};r.id=this.name,e(r)}};function uw(t,e){return e?!!(lw(t,e)||cw(t,e)):!1}function lw(t,e){let n=t.message,r=e.message;return!(!n&&!r||n&&!r||!n&&r||n!==r||!l3(t,e)||!u3(t,e))}function cw(t,e){let n=o3(e),r=o3(t);return!(!n||!r||n.type!==r.type||n.value!==r.value||!l3(t,e)||!u3(t,e))}function u3(t,e){let n=s3(t),r=s3(e);if(!n&&!r)return!0;if(n&&!r||!n&&r||(n=n,r=r,r.length!==n.length))return!1;for(let a=0;a"u"){!1&&Se.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");return}let n=Le();n.captureSession&&(c3(n),er("history",({from:r,to:a})=>{r===void 0||r===a||c3(Le())}))}var y3={},rp=at();rp.Sentry&&rp.Sentry.Integrations&&(y3=rp.Sentry.Integrations);var pw={...y3,...Va,...tp};var gw=Ru.alert;d();var Ii=console,ap=class{#e=performance.now();reset(){this.#e=performance.now()}stop(e){let n=performance.now(),r=Math.round(n-this.#e),a=In.green;r>1e4?a=In.red:r>1e3&&(a=In.yellow),Ii.debug(In.dim(Ia+" TIMING:"),e,"in",a(r+"ms")),this.#e=n}},ss=class{#e=1;get level(){return this.#e}setLevel(e){switch(e){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...e){this.#e<=0&&Ii.log(In.dim(Ia+" DEBUG:"),...e)}v(...e){this.#e<=0}info(...e){this.#e<=1&&Ii.log(In.green(Ia+" INFO:"),...e)}l(...e){this.#e<=1}warn(...e){this.#e<=2&&Ii.warn(In.yellow(Ia+" WARN:"),...e)}error(...e){this.#e<=3&&Ii.error(In.red(Ia+" ERROR:"),...e)}fatal(...e){this.#e<=4&&Ii.error(In.red(Ia+" FATAL:"),...e)}timing(){return this.level===0?new ap:{reset:()=>{},stop:()=>{}}}},z=new ss;var v3=["*://*/*","*","*://*"],x3="immersive-translate-wildcard-placeholder.com";function ip(t,e){try{let n=[];if(!e||(e&&!Array.isArray(e)?n=[e]:n=e,n.length===0))return null;if(n.some(s=>v3.includes(s)))return t;let r=new URL(t);r.hash="",r.search="";let a=r.href,i=r.hostname,o=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===i)return!0;if(v3.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===i,p=l.port===o;return l.port?c&&p:c}else return fw(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let b=u.split("://");l=b[0],l==="*"&&b.length>1&&(l="*",u="https://"+b[1])}else l="*",u="https://"+u;let p=u.replace(/\*/g,x3),g;try{g=new URL(p)}catch{return z.debug("invalid match pattern",p,"raw match value:",c),!1}let m=g.host,f=g.pathname;f==="/"&&(c.replace("://","").includes("/")||(f="/*"));let T=mw(l+":",S3(m),S3(f));if(T){let b=new URL(a);return T.test(b.href)}else return!1}});if(s)return s}return null}catch{return null}}function S3(t){return t.replaceAll(x3,"*")}function mw(t,e,n){let r="^";return t==="*:"?r+="(http:|https:|file:)":r+=t,r+="//",e&&(t==="file:"||(e==="*"?r+="[^/]+?":(e.match(/^\*\./)&&(r+="[^/]*?",e=e.substring(1)),r+=e.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function wt(t,e){return ip(t,e)!==null}function fw(t,e){let n=new URL(t),r=new URL(e);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}d();d();var gl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.4",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var bw="";function Sn(){return bw||gl.version}function op(){return oe.runtime.getManifest().version}d();d();var Tw="";function Ri(){return Tw||globalThis.navigator.userAgent}function sp(){return Ri().includes("ImtFxiOS")}function E3(){let e=Ri().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function yw(){return Ri().includes("ImtFxAndroid")}function C3(){let t=Ri();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(t)}function w3(){let e=Ri().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return e?e[1]:null}function us(){let t=Ri();if(sp()||yw()){let e=t.match(/Imt[\w/.]+/);if(e){let n=e[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}function ml(t){if(t.beta)return!1;if(it()&&t.spVersion)return ls(op(),t.spVersion);if(C3()&&t.gspVersion){let e=w3();if(e)return ls(e,t.gspVersion)}if(sp()&&t.ispVersion){let e=E3();if(e)return ls(e,t.ispVersion)}return!1}function ls(t,e){let n=t.split(".").reverse(),r=e.split(".").reverse(),a=0,i=0,o=1;for(let s=0;s<3;s++)a+=o*Number(r[s]||"0"),i+=o*Number(n[s]||"0"),o*=100;return i>=a}function up(t){t.message?.indexOf("token invalid")>=0&&Mt.remove(Ft)}d();function fl(t){return Array.isArray(t)?t:t?[t]:[]}function hl(t,e){return e?(Array.isArray(e)||(e=[e]),Array.from(new Set([...e,t]))):[t]}function bl(t,e){return e?(Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),e.filter(n=>!t.includes(n))):[]}function Tl(t,e){let n={...t};return P3(n,e),vw(n,e),n}function k3(t,e,n){let r={...e};return Ya({rule:r,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>t[a],onMergedResult:(a,i)=>r[a]=i}),Ya({rule:n,valueIsArray:a=>Array.isArray(t[a]),getMergedValue:a=>r[a],onMergedResult:(a,i)=>r[a]=i}),r}function vw(t,e){if(!e.condition)return;let n=e.condition.enableSubtitle?.true||{},r=e.condition.enableSubtitle?.false||{},a=t.enableSubtitle?n:r;P3(t,a)}function Ya({rule:t,getMergedValue:e,valueIsArray:n,onMergedResult:r}){Object.keys(t).sort().forEach(a=>{let[i,o,s]=Sw(a);if(!i||t[a]===void 0)return;let u=t[a];n(i)&&(u=fl(t[a]));let l=e(i);if(l==null){r(i,u);return}let c;if(o=="add_v"){if(!D3(s))return;c=lp(l,u)}else if(o=="remove_v"){if(!D3(s))return;c=A3(l,u)}else o==="add"?c=lp(l,u):o=="remove"&&(c=A3(l,u));if(c){r(i,c);return}Array.isArray(t[i])&&i.startsWith("additional")?c=lp(l,u):c=u,r(i,c)})}function P3(t,e){return Ya({rule:e,valueIsArray:n=>Array.isArray(t[n]),getMergedValue:n=>t[n],onMergedResult:(n,r)=>{t[n]=r}}),t}function lp(t,e){let n;if(Array.isArray(t)){let r=fl(e);n=[...t,...r],n=Array.from(new Set(n))}else typeof t=="object"&&typeof e=="object"?n={...t,...e}:n=e;return n}function Sw(t){let e=t.lastIndexOf("["),n="",r=t;return e>0&&(n=t.slice(e+1,t.length-1),r=t.slice(0,e-1)),[...r.split("."),n]}function D3(t){let e=Sn();return t&&ls(e,t)}function A3(t,e){if(Array.isArray(t)){let n=fl(e);return t=t.filter(r=>!n.includes(r)),Array.from(new Set(t))}else if(typeof t=="object"&&typeof e=="object")Object.keys(e).forEach(n=>{delete t[n]});else return e;return t}d();d();var Oi="input is invalid type",cp=typeof window=="object",oa=cp?window:{};oa.JS_SHA256_NO_WINDOW&&(cp=!1);var xw=!cp&&typeof self=="object",Ew=!oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;Ew?oa=global:xw&&(oa=self);var SN=!oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,xN=typeof define=="function"&&define.amd,cs=!oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",he="0123456789abcdef".split(""),Cw=[-2147483648,8388608,32768,128],tr=[24,16,8,0],yl=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],vl=["hex","array","digest","arrayBuffer"],Ut=[];(oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return Object.prototype.toString.call(t)==="[object Array]"});cs&&(oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer});var L3=function(t,e){return function(n){return new qt(e,!0).update(n)[t]()}},F3=function(t){var e=L3("hex",t);e.create=function(){return new qt(t)},e.update=function(a){return e.create().update(a)};for(var n=0;n>2]|=t[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};qt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Cw[e&3],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}};qt.prototype.hash=function(){var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=this.blocks,l,c,p,g,m,f,T,b,h,C,D;for(l=16;l<64;++l)m=u[l-15],c=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,m=u[l-2],p=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,u[l]=u[l-16]+c+u[l-7]+p<<0;for(D=e&n,l=0;l<64;l+=4)this.first?(this.is224?(b=300032,m=u[0]-1413257819,s=m-150054599<<0,r=m+24177077<<0):(b=704751109,m=u[0]-210244248,s=m-1521486534<<0,r=m+143694565<<0),this.first=!1):(c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),p=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),b=t&e,g=b^t&n^D,T=a&i^~a&o,m=s+p+T+yl[l]+u[l],f=c+g,s=r+m<<0,r=m+f<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),p=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),h=r&t,g=h^r&e^b,T=s&a^~s&i,m=o+p+T+yl[l+1]+u[l+1],f=c+g,o=n+m<<0,n=m+f<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),p=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),C=n&r,g=C^n&t^h,T=o&s^~o&a,m=i+p+T+yl[l+2]+u[l+2],f=c+g,i=e+m<<0,e=m+f<<0,c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),p=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),D=e&n,g=D^e&r^C,T=i&o^~i&s,m=a+p+T+yl[l+3]+u[l+3],f=c+g,a=t+m<<0,t=m+f<<0;this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+i<<0,this.h6=this.h6+o<<0,this.h7=this.h7+s<<0};qt.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=he[t>>28&15]+he[t>>24&15]+he[t>>20&15]+he[t>>16&15]+he[t>>12&15]+he[t>>8&15]+he[t>>4&15]+he[t&15]+he[e>>28&15]+he[e>>24&15]+he[e>>20&15]+he[e>>16&15]+he[e>>12&15]+he[e>>8&15]+he[e>>4&15]+he[e&15]+he[n>>28&15]+he[n>>24&15]+he[n>>20&15]+he[n>>16&15]+he[n>>12&15]+he[n>>8&15]+he[n>>4&15]+he[n&15]+he[r>>28&15]+he[r>>24&15]+he[r>>20&15]+he[r>>16&15]+he[r>>12&15]+he[r>>8&15]+he[r>>4&15]+he[r&15]+he[a>>28&15]+he[a>>24&15]+he[a>>20&15]+he[a>>16&15]+he[a>>12&15]+he[a>>8&15]+he[a>>4&15]+he[a&15]+he[i>>28&15]+he[i>>24&15]+he[i>>20&15]+he[i>>16&15]+he[i>>12&15]+he[i>>8&15]+he[i>>4&15]+he[i&15]+he[o>>28&15]+he[o>>24&15]+he[o>>20&15]+he[o>>16&15]+he[o>>12&15]+he[o>>8&15]+he[o>>4&15]+he[o&15];return this.is224||(u+=he[s>>28&15]+he[s>>24&15]+he[s>>20&15]+he[s>>16&15]+he[s>>12&15]+he[s>>8&15]+he[s>>4&15]+he[s&15]),u};qt.prototype.toString=qt.prototype.hex;qt.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3,a=this.h4,i=this.h5,o=this.h6,s=this.h7,u=[t>>24&255,t>>16&255,t>>8&255,t&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,i>>24&255,i>>16&255,i>>8&255,i&255,o>>24&255,o>>16&255,o>>8&255,o&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};qt.prototype.array=qt.prototype.digest;qt.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),this.is224||e.setUint32(28,this.h7),t};function Sl(t,e,n){var r,a=typeof t;if(a==="string"){var i=[],o=t.length,s=0,u;for(r=0;r>6,i[s++]=128|u&63):u<55296||u>=57344?(i[s++]=224|u>>12,i[s++]=128|u>>6&63,i[s++]=128|u&63):(u=65536+((u&1023)<<10|t.charCodeAt(++r)&1023),i[s++]=240|u>>18,i[s++]=128|u>>12&63,i[s++]=128|u>>6&63,i[s++]=128|u&63);t=i}else if(a==="object"){if(t===null)throw new Error(Oi);if(cs&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!Array.isArray(t)&&(!cs||!ArrayBuffer.isView(t)))throw new Error(Oi)}else throw new Error(Oi);t.length>64&&(t=new qt(e,!0).update(t).array());var l=[],c=[];for(r=0;r<64;++r){var p=t[r]||0;l[r]=92^p,c[r]=54^p}qt.call(this,e,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}Sl.prototype=new qt;Sl.prototype.finalize=function(){if(qt.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();qt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),qt.prototype.finalize.call(this)}};var zi=F3();zi.sha256=zi;zi.sha224=F3(!0);zi.sha256.hmac=M3();zi.sha224.hmac=M3(!0);var B3=zi;var I3=B3.sha256;function nr(t){return Promise.resolve(I3(t))}function xl(t){return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function sa(t,e){let n=I3.hmac.create(e);return n.update(t),Promise.resolve(n.array())}async function R3(t,e){let n=await sa(t,e);return xl(n)}async function El(t,e){let n=ww(e),r=await sa(t,n);return xl(r)}function ww(t){let e=[];return t.replace(/../g,function(n){return e.push(parseInt(n,16)),""}),new Uint8Array(e).buffer}d();d();function Je(){try{let t=[Me().EBOOK_BUILDER_URL,Me().EBOOK_VIEWER_URL,Me().SUBTITLE_BUILDER_URL,Me().HTML_VIEWER_URL,Me().PDF_VIEWER_URL].filter(a=>!!a),e=["app.immersivetranslate.com"];Qt()||e.push("localhost:38001");let n=globalThis.location.pathname;return t.find(a=>{let i=new URL(a);return n.startsWith(i.pathname)&&e.includes(i.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();d();function O3(t){return t.replace(//g,">")}d();d();function Te(t){if(typeof t!="string")return"auto";let e=t.toLowerCase();if(e==="und")return"auto";if(e==="zh"||e.startsWith("zh-hans"))return"zh-CN";if(e.startsWith("zh-hant")||e.startsWith("zh-hk")||e.startsWith("zh-tw"))return"zh-TW";if(e.startsWith("zh-"))return"zh-CN";if(e==="iw")return"he";if(e==="jv")return"jw";let n=wn.map(a=>a.toLowerCase()),r=n.indexOf(e);if(r===-1)if(e.indexOf("-")>=0){e=e.split("-")[0];let a=n.indexOf(e);return a===-1?"auto":wn[a]}else return"auto";else return wn[r]}function ft(){return Te(document?.documentElement?.lang||"en")}function z3(t,e,n){let r=Dw(t,e),a=[],i={from:t[0].from,fromByClient:t[0].fromByClient,to:t[0].to,tempSentences:[],url:t[0].url};for(let o of r)(i.tempSentences.reduce((u,l)=>u+l.text.length,0)+o.text.length>e||i.tempSentences.length>=n)&&(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}),(i.from!==o.from||i.to!==o.to)&&(i.tempSentences.length>0?(a.push(i),i={fromByClient:i.fromByClient,from:o.from,to:o.to,tempSentences:[],url:o.url}):(i.from=o.from,i.to=o.to)),i.tempSentences.push(o);return i.tempSentences.length>0&&a.push(i),a}function Dw(t,e){let n=[],r=[];for(let a=0;a0?Te){let C=[];dp(b,e,C);for(let D=0;D0&&T{let s=t.lastIndexOf(o,e);return s>i?s:i},-1);if(a===-1){let i=t.slice(0,e);if(i&&!i.trim())return;n.push({text:i,prefix:"",suffix:""}),t.length>e&&dp(t.slice(e),e,n)}else{let i=t.slice(0,a+1);if(i&&i.trim()==="")return;i.startsWith(" ")?n.push({text:i.slice(1),prefix:" ",suffix:""}):n.push({text:i,prefix:"",suffix:""}),a+10){p.forEach(T=>{c.length>0&&T.providers&&T.providers.length>0&&!T.providers.includes(l)||(T.optional?m.push(T):g.push(T))});let f=m.concat(g).filter(T=>T.required);if(f.length>0){for(let T of f)if(!i[T.name]){u=!1;break}}}return{...a,id:e,selected:n[t]===e,ok:u,currentProvider:l,config:i,providers:a.providers||[],props:a.props||[],allProps:p,optionalProps:m,explicitProps:g}}var ds=(t,e)=>{let{config:n}=t,r=n.alpha,a=n.beta,i=n.canary,o=n.debug,s=t.user,u=Zt(s),l=Object.keys(cr);return e!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let p=cr[c];if(c.startsWith("mock"))return o?!0:c===t.config[e];if(c===t.config[e])return!0;if(c==="openai"&&it())return t.config.showOpenaiOnSafari||u?!0:!!(a||r||i||u);let g=!!p.canary,m=!!p.alpha,f=!!p.beta;return c===t[e]||g&&i||m&&(r||i)||f&&(a||r||i)?!0:!m&&!f&&!g}).map(c=>Cl(e,c,t))};function ps(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function N3(t){return t.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}d();var U3=me+"SyncStoreKey_";function At(t,e){let n=U3+t;return oe.storage.sync.get(n).then(r=>r[n]===void 0?e:r[n])}function Ze(t,e){let n=U3+t;return oe.storage.sync.set({[n]:e})}d();d();var q3=me+"StoreKey_";function Nr(t,e){let n=q3+t;return oe.storage.local.get(n).then(r=>r[n]===void 0?e:r[n])}function j3(t,e){let n=q3+t;return oe.storage.local.set({[n]:e})}d();d();d();d();function H3(t,e){return[t,!t||t.endsWith("/")?"":"/",e,".json"].join("")}function pp(t,e){let n=t;return e&&Object.keys(e).forEach(r=>{let a=e[r];if(a===void 0)return;let i=Aw(r);if(typeof a=="object"||i){let o=a;i&&typeof o=="string"&&(o={tag:"a",href:o,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=o.tag||"a",c=n.indexOf(``);if(c!==-1){let p=n.substring(u+s.length,c),g=Object.keys(o).filter(m=>m!=="tag").map(m=>`${m}="${o[m]}"`).join(" ");n=n.replace(`${s}${p}`,`<${l} ${g}>${p}`)}}}else if(a){let o=new RegExp("{"+r+"}","gm");n=n.replace(o,a.toString())}}),n}function gs(t,e,n){let r=t[e];if(!r)return n;if(!n)return"";let a=n.split("."),i="";do{i+=a.shift();let o=r[i];o!==void 0&&(typeof o=="object"||!a.length)?(r=o,i=""):a.length?i+=".":r=n}while(a.length);return r}function hr(t,e,n,r,a){if(!t.hasOwnProperty(n))return e;let i=gs(t,n,e);return i===e&&n!==r&&(i=gs(t,r,e)),pp(i,a)}function Aw(t){if(typeof t=="number")return!0;if(t){let e=parseInt(t);return!isNaN(e)}else return!1}function kt(t,e,n){return hr(Ot,e,t.config.interfaceLanguage,"en",n)}d();function W3(t,e){let n=new Date(t),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),i=n.getDate().toString().padStart(2,"0"),o=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return e.replace("YYYY",r).replace("MM",a).replace("DD",i).replace("HH",o).replace("mm",s).replace("ss",u)}function K3(t){return new Date(t).getTime()}var $=class extends Error{status;constructor(e,n){if(e&&n){super(n),this.name=e;return}super(e)}initNetWork(e){return e&&(this.status=e),this}initStack(e){return e&&(this.stack=e),this}initData(e){return this.data=e,this}data;uiConfig(e){if(!this.message)return{};let n=null;if(n=this.handleProQuota(e)||this.handleUnavailableError(e)||this.handleProUser(e)||this.handleServiceMissingConfig(e)||this.handleNetwork(e)||this.handleFetchError(e),!n){let r=kt.bind(null,e),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(e){let n=kt.bind(null,e),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(e){let n=kt.bind(null,e);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(e){let n=kt.bind(null,e),r="retry",a="network",i=n("networkError");if(!this.status||this.status<0)return;let o=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?o=`${n("error.googleLimitIp")}

${o}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?o=`${n("error.openAIFreeLimit")}

${o}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?o=`${n("error.openAIExceededQuota")}

${o}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?o=`${n("error.gemini.429")}

${o}`:o=`${n("error.429")}

${o}`:this.status===403?this.data?.translationService=="claude"?o=`${n("error.claude.403")}

${o}`:o=`${n("error.403")}

${o}`:this.status===400?o=`${n("error.400")}

${o}`:this.status===502?o=`${n("error.502")}

${o}`:this.status===404&&o.includes("User subscription not found")&&(o=`${n("error.subscriptionExpired")}

${o}`,r="setting",a="configError",i=n("error.subscriptionExpiredTitle")),{type:a,title:i,errMsg:o,action:r}}handleFetchError(e){let n=kt.bind(null,e);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+e.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(e){let n=kt.bind(null,e);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return e.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(e){if(!this.message.startsWith("ProQuota:")||!e.user?.subscription)return;let n=kt.bind(null,e);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=e.user.subscription,{subscriptionType:i,isTrial:o,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let p=this.data?.translationService=="deepl"?"OpenAI":"Deepl",g=this.data?.translationService=="deepl"?"Deepl":"OpenAI",m=n("errorReason",{message:r});if(i=="onetime_7day")m+=n("proQuotaExceededError.onetime7day",{anotherService:p,brandId:Q,href:Pu});else{let f="";g=="OpenAI"?f=i4:f=o4,o?m+=n("proQuotaExceededError.trial",{anotherService:p,brandId:Q,href:s4}):m+=n("proQuotaExceededError.nonTrial",{anotherService:p,brandId:Q,href:f,translationService:g}),!o&&(a.cancelAtPeriodEnd==="false"||K3(u)>s)&&(m+=n("proQuotaExceededError.resetTime",{resetTime:W3(s,"YYYY-MM-DD HH:mm:ss")}))}return m}}};async function Ur(t){let e;if(t&&t.retry&&t.retry>0)try{e=await Hd(G3.bind(null,t),{multiplier:2,maxAttempts:t.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else e=await G3(t);return e}async function G3(t){t.body;let{url:e,responseType:n,...r}=t;n||(n="json"),r={mode:"cors",...r};let a=!0;t.fetchPolyfill&&(a=!1);let i=t.fetchPolyfill||fetch,o=3e4;if(t.timeout&&(o=t.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},o),r.signal=l}let s;try{s=await i(e,r)}catch(u){z.debug("fetch error",e,u);let l=u.message||"Unknown Error";throw new $("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=e),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of kw(s.body)){let p=new TextDecoder().decode(c);u+=p;let g;for(;(g=u.indexOf(` -`))>=0;){let m=u.slice(0,g).trim();if(u=u.slice(g+1),m.startsWith("event:")||m==="")continue;let f="";if(m.startsWith("data:")&&(f=m.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){z.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(m){z.error("parse response failed",m)}u&&z.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*kw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Pw=new Map;function wl(t){let e=Lw(64),n=new CustomEvent(Ph,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Pw.set(e,(i,o)=>{i?a(i):r(o)})})}function Lw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=mp(s),{type:g,name:m}=p;if(g!==e)return!1;let f=mp(o),b=ms.get(g).get(m);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(C){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=ms.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new gp(`${i}:${e}`,this.logger);return ms.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},gp=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=mp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return V3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return V3(o,s,this.logger)}}};function V3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function mp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}var Dl;function _w(){return Dl||(Dl=new br("content_script",!1).getConnection("pure_main",()=>{}),Dl)}var $3="G-MKMD9LWFTR";async function fs(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(us()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=Je(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Nr("fakeUserId",""),u&&await Ze("fakeUserId",u));let l=Sn(),c=new Date,p=await At("installedAt","");p||(p=await Nr("installedAt",""),p&&await Ze("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Ze("installedAt",p)):(u=Fw(32),await Ze("fakeUserId",u)),p||(p=c.toISOString(),await Ze("installedAt",p));let g=new Date(p),m=Y3(g),f=Y3(c),T=m===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${$3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${$3}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let D=Ei.parse(C),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let _=us();_&&(y.browser_name=_.name,y.browser_version=_.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),m&&(y.install_day=Mw(g)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),B=await Al({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Fw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let m=u.slice(0,g).trim();if(u=u.slice(g+1),m.startsWith("event:")||m==="")continue;let f="";if(m.startsWith("data:")&&(f=m.slice(5).trim()),f==="[DONE]")break;let T;try{T=JSON.parse(f??"")}catch(b){z.debug("json error",b);continue}l=T}}return l}}else{let u;try{u=await s.text()}catch(m){z.error("parse response failed",m)}u&&z.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(e).hostname.endsWith(".immersivetranslate.com");throw e.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new $("fetchError",c).initNetWork(s.status)}}async function*kw(t){let e=t.getReader();try{for(;;){let{done:n,value:r}=await e.read();if(n)return;yield r}}finally{e.releaseLock()}}d();var Pw=new Map;function wl(t){let e=Lw(64),n=new CustomEvent(Ph,{detail:JSON.stringify({...t,type:"ask",id:e})});return document.dispatchEvent(n),new Promise((r,a)=>{Pw.set(e,(i,o)=>{i?a(i):r(o)})})}function Lw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let o=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,o=`${o}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let p=mp(s),{type:g,name:m}=p;if(g!==e)return!1;let f=mp(o),b=ms.get(g).get(m);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,D={type:e,name:f.name,id:u,url:l,active:c};if(C){try{let M=h(r.payload,D);i({ok:!0,data:M})}catch(M){i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.details,errorStatus:M.status})}return!1}else return h(r.payload,D).then(M=>{i({ok:!0,data:M})}).catch(M=>{i({ok:!1,errorName:M.name,errorMessage:M.message,errorDetails:M.message,errorStatus:M.status})}),!0}))}getConnection(e,n,r){let a=!1;r&&r.sync&&(a=!0);let i=this.fromType,o=ms.get(i);if(o.has(e))return o.get(e).connectionInstance;{let s=new gp(`${i}:${e}`,this.logger);return ms.get(i).set(e,{messageHandler:n,sync:a,connectionInstance:s}),s}}},gp=class{from;logger;constructor(e,n){this.from=e,this.logger=n}async sendMessage(e,n){let r=mp(e),{type:a,id:i}=r;if(a!=="content_script"){let o={to:e,from:this.from,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");try{let s=await oe.runtime.sendMessage(o);return V3(o,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${e} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,e,s),Promise.resolve({message:u})}else throw s}}else{let o={from:this.from,to:e,payload:n};this.logger.debug(`${o.from} send message [${o.payload.method}] to ${o.to}`,o.payload.data?o.payload.data:" ");let s=await oe.tabs.sendMessage(i,o);return V3(o,s,this.logger)}}};function V3(t,e,n){if(e){if(e.ok)return n.debug(`${t.from} received response from ${t.to}:`,e.data?e.data:" "),e.data;throw new $(e.errorName||"UnknownError",e.errorMessage||"Unknown error").initNetWork(e.errorStatus)}else throw new $("noResponse","Unknown error")}function mp(t){let e=t.split(":");if(e.length<2)throw new Error("not a valid to string");let n={type:e[0],name:e[1]};if(e[0]==="content_script"){let r=parseInt(e[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}var Dl;function _w(){return Dl||(Dl=new br("content_script",!1).getConnection("pure_main",()=>{}),Dl)}var $3="G-MKMD9LWFTR";async function fs(t){try{let e=Me(),n=e.INSTALL_FROM==="firefox_store";if(us()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=ye(),i=Je(),o=e.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await At("fakeUserId","");u||(u=await Nr("fakeUserId",""),u&&await Ze("fakeUserId",u));let l=Sn(),c=new Date,p=await At("installedAt","");p||(p=await Nr("installedAt",""),p&&await Ze("installedAt",p)),u?p||(p=new Date(0).toISOString(),await Ze("installedAt",p)):(u=Fw(32),await Ze("fakeUserId",u)),p||(p=c.toISOString(),await Ze("installedAt",p));let g=new Date(p),m=Y3(g),f=Y3(c),T=m===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${$3}&api_secret=${s}`;o||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${$3}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let D=Ei.parse(C),M=t.map(S=>{let y=S.params||{};if(D.os&&(y.os_name=D.os.name||"unknown",y.os_version=D.os.version||"unknown",y.os_version_name=D.os.versionName||"unknown"),D.browser){y.browser_name=D.browser.name||"unknown",y.browser_version=D.browser.version||"unknown";let _=us();_&&(y.browser_name=_.name,y.browser_version=_.version)}return D.platform&&(y.platform_type=D.platform.type||"unknown"),D.engine&&(y.engine_name=D.engine.name||"unknown",y.engine_version=D.engine.version||"unknown"),l&&(y.version=l),e.INSTALL_FROM&&(y.install_from=e.INSTALL_FROM),m&&(y.install_day=Mw(g)),y.userscript=a.toString(),T?y.is_new_user_today="1":y.is_new_user_today="0",b?y.is_new_user_this_week="1":y.is_new_user_this_week="0",i?y.main_frame=0:y.main_frame=1,{...S,params:y}}),B=await Al({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:M})})}catch{}}function Fw(t){let e="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5338,7 +5338,7 @@ Translate the content to {{to}} Language: `,selectors:["h3 a[data-clk]","div.gs_rs","td a.gsc_a_at","td div.gs_gray:last-of-type","div.gsc_oci_value","#gs_opinion"],extraInlineSelectors:["br"],atomicBlockSelectors:["h3 a[data-clk]"]},{id:"googleMail",matches:"mail.google.com",detectParagraphLanguage:!0,selectors:["h2[data-thread-perm-id]","span[data-thread-id]","div[data-message-id] div[class='']",".messageBody","#views"],globalStyles:{"[role='listitem'] > div":"height:auto!important;white-space:unset!important;"}},{id:"googleNews",matches:"news.google.com",blockMinTextCount:26,blockMinWordCount:5,globalStyles:{".MCAGUe":"height: auto;",".To2ZZb.DbQnIe":"height: unset;",".cp7Yvc > h2":"display: block;",".oovtQ":"height: auto;",h4:"-webkit-line-clamp: unset;"},excludeSelectors:[".EyERq",".AOl7G.eejsDc","[aria-label='Home']","[aria-label='For you']","[aria-label='Following']","[aria-label='World']","[aria-label='Local']",".gb_Fc",".wBQf7b",".yPI8Rb",".jKHa4e",".u43Gd",".Zgjpyb","[role='button']","[jsname='rymPhb']",".cbz1ld",".VfPpkd-P5QLlc",".XvhY1d"]},{id:"outlook",matches:"outlook.live.com",excludeSelectors:[".jHAG3.XG5Jd",".OZZZK",".lDdSm"]},{id:"producthunt",matches:"www.producthunt.com",excludeMatches:"https://www.producthunt.com/stories/*",selectors:["h2","div[class^='styles_htmlText__']","[class^='styles_tagline']","a[href^='/discussions/'].fontWeight-600","button[class^='styles_textButton'] > div > span","h5 + p","div[data-test=product-item-name] + div",".noOfLines-1,.noOfLines-2,.noOfLines-3",".fontWeight-600","[class*='styles_dropdown']","[class*='styles_aboutText']"],globalStyles:{"h5 + p":"height:unset;",".noOfLines-1,.noOfLines-2,.noOfLines-3":"-webkit-line-clamp:unset;"},"excludeTags.remove":["PRE"]},{id:"codeforces",matches:"https://codeforces.com/*","stayOriginalTags.add":["[class^='MathJax']"]},{id:"discord",matches:"https://discord.com/channels/*",isTranslateTitle:!1,selectors:["li[id^=chat-messages] div[id^=message-content]","div[class^=headerText]","section[aria-label='Search Results'] div[id^=message-content]"],extraBlockSelectors:["[class^='embedFieldValue']","li[class^='card'] div[class^='message']","[data-list-item-id^='forum-channel-list'] div[class^='headerText']"],globalStyles:{"div[class^=headerText]":"max-height: unset;","div[class^=message]":"max-height: unset;","div[class^=text]":"max-height: unset;","h3[data-text-variant='heading-lg/semibold']":"-webkit-line-clamp: none;"},detectParagraphLanguage:!0,wrapperPrefix:"
",wrapperSuffix:"",paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"telegram",matches:["web.telegram.org/z/*","web.telegram.org/a/*"],isTranslateTitle:!1,selectors:[".text-content",".message",".reply-markup-button-text",".bot-commands-list-element-description"],"extraBlockSelectors.add":[".message.spoilers-container em",".message.spoilers-container strong"],excludeSelectors:[".time",".peer-title",".document-wrapper",".message.spoilers-container custom-emoji-element"],detectParagraphLanguage:!0},{id:"telegramK",matches:["web.telegram.org/k/*","web.telegram.org/k/"],selectors:[".message",".reply-markup-button-text",".bot-commands-list-element-description"],"extraBlockSelectors.add":[".message.spoilers-container em",".message.spoilers-container strong"],excludeSelectors:[".time",".peer-title",".document-wrapper",".message.spoilers-container custom-emoji-element"],detectParagraphLanguage:!0},{id:"githubGist",matches:"gist.github.com",selectors:[".markdown-body",".readme"],detectParagraphLanguage:!0},{id:"lobste",matches:"lobste.rs",excludeMatches:["https://lobste.rs/about","https://lobste.rs/chat"],selectors:[".u-repost-of",".comment_text",".story_text"]},{id:"slack",matches:"*.slack.com",selectors:[".p-rich_text_block",".p-message_pane__foreword",".c-alert__message","[data-qa=message_attachment_text]"],additionalStayOriginalSelectors:["[data-qa=emoji]"],detectParagraphLanguage:!0},{id:"artstationArtwork",matches:"www.artstation.com/artwork/*",excludeSelectors:".project-description a",selectors:[".project-description","div.project-comment-text"],detectParagraphLanguage:!0},{id:"artstationLearning",matches:"www.artstation.com/learning/courses/*",additionalSelectors:["footer.learning-course-description.ng-star-inserted > span"],excludeSelectors:[".learning-card-meta",".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/subtitles/.*\\.(vtt|webvtt)$",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"},videoSelector:"video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:[".vjs-text-track-display {display: none;}",".captions-text: {margin-bottom: 10%;}"]}}},{id:"artstationBlog",matches:["https://www.artstation.com/blogs","https://www.artstation.com/blogs/*"],detectParagraphLanguage:!0,additionalSelectors:[".comment-item-body"],atomicBlockSelectors:[".author-headline",".author-location"],excludeSelectors:["blog-card-thumbnail","blog-card-header",".blog-card-author",".blog-card-meta",".blog-view-header",".blog-grid-title",".post-meta-header"]},{id:"figmaCommunity",matches:"www.figma.com/community/*",normalizeBody:"div.ql-editor[contenteditable='false']",excludeSelectors:["div[class*='metadataRight']","div[class*='commentMetaAndOptions']"],globalStyles:{"div[class*='mini_cardBottomRowSizing']":"height: 3em;"},additionalSelectors:["div[class*='mini_cardBottomRow_Metadata']"],stayOriginalSelectors:["[data-tooltip='tooltip-user-info']"]},{id:"googleIndex",matches:["https://www.google.com/","https://www.google.com.hk/"],excludeSelectors:["#gb","#SIvCob"],inputTutorialsText:"\u8BD5\u8BD5\u8F93\u5165\u4E2D\u6587\u540E\u5FEB\u901F\u8FDE\u51FB 3 \u6B21\u7A7A\u683C\u952E\u7FFB\u8BD1\uFF08\u4EC5\u63D0\u793A\u4E00\u6B21\uFF09",inputTutorialsSelectors:["textarea#APjFqb"],"inputConfig.add":{tutorialsText:"\u8BD5\u8BD5\u8F93\u5165\u4E2D\u6587\u540E\u5FEB\u901F\u8FDE\u51FB 3 \u6B21\u7A7A\u683C\u952E\u7FFB\u8BD1\uFF08\u4EC5\u63D0\u793A\u4E00\u6B21\uFF09",tutorialsSelectors:["textarea#APjFqb"]}},{id:"googleSearch",matches:"www.google.*/search*",blockMinTextCount:32,blockMinWordCount:3,wrapperSuffix:"",detectParagraphLanguage:!0,excludeSelectors:["a h3 + div","div#sfooter","a[role=presentation] > div > div:first-child",".b5ZQcf",".CEMjEf",".MgUUmf.NUnG9d","#result-stats","[role=navigation]","div.sCuL3","div.eFM0qc.BCF2pd","div.WZ8Tjf","div.adDDi","#headerSection","#rateChatDiv","[id=bres]",".title-D5Lgyj","[data-attrid='VisualDigestVideoResult']",".search-enhance-WDIEkP h4",".SPZz6b h2",".CtCigf",".VLkRKc",".EbH0bb",".Wr0c6d",".jleFbf","#searchform",".yg51vc",".CbAZb"],extraBlockSelectors:[".MUFPAc"],"additionalExcludeSelectors.add":["[jscontroller='UsftYd']"],globalStyles:{".V82bz":"-webkit-line-clamp: unset;max-height: unset;margin-bottom:30px",".pe7FNb":"-webkit-line-clamp: unset;",".promotion-3PDMAb":"display: none;",".uAKcGb":"-webkit-line-clamp: unset;max-height: unset;margin-bottom:30px","div[data-content-feature='1'] > div":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:2']":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:3']":"-webkit-line-clamp: unset;max-height: unset;","div[style='-webkit-line-clamp:4']":"-webkit-line-clamp: unset;max-height: unset;",".Pw4Ldf.RsCEN":"height:unset;",".related-question-pair":"overflow:auto;"},ignoreZhCNandZhTW:!0,isTranslateTitle:!1,searchEnhancementConfig:[{id:"google",urlMatch:"https://www\\.google\\..+/search",style:{source:"font-size:12px; margin-bottom: 6px;",enTitle:"margin-top:6px;font-size:14px;",searchTitle:"margin-top:6px;position:relative;padding-right:24px;",more:"color:#1a0dab;margin-top:8px;",enTitleClassName:"immersive-translate-search-enhancement-en-title"},keyword:{value:"[0]$1",matches:[{source:"url",matchRegex:"q=(.+?)&"}]},showCount:5}]},{id:"lowendtalk",matches:"lowendtalk.com",selectors:["[role=heading]","h1",".userContent"]},{id:"linkedinJobs",matches:"www.linkedin.com/jobs/*",selectors:["#job-details > span",".decorated-job-posting__details"]},{id:"linkedinFeed",matches:"https://linkedin.com/feed/*",selectors:["h1",".feed-shared-update-v2__description-wrapper"]},{id:"indiehackers",matches:"www.indiehackers.com",selectors:[".content","h1","h3.story__title",".feed-item__title-link",".article-body",".interview-body"]},{id:"libreddit",matches:"libreddit.de",selectors:["h2.post_title",".comment_body > .md"]},{id:"notionSite",matches:["notion.site","*.notion.site"],normalizeBody:"body",selectors:["div[data-block-id]"]},{id:"notion_so",matches:["www.notion.so"],injectedCss:["[aria-label='Templates'] font br {display:none;}"]},{id:"newyorker",matches:"www.newyorker.com",additionalSelectors:["h1","[data-testid=SummaryItemHed]"],excludeSelectors:["[data-testid=PersistentTop]","[data-testid=StackedNavigationHeader]"],urlChangeDelay:2e3},{id:"startme",matches:"start.me",selectors:[".rss-article__title",".rss-articles-list__article-link",".rss-showcase__title",".rss-showcase__text"]},{id:"scmp",matches:"www.scmp.com",additionalSelectors:[".info__subHeadline",".section-content h2"],globalStyles:{".topic__article-list":"height: unset;",".adverisers__adveriser":"height: unset;",".advertiser__content":"height: unset;",".content-title__link":"display:unset;overflow:unset;-webkit-line-clamp:unset;",".title__text":"max-height:unset; -webkit-line-clamp:unset;",".news-list-item__news-title":"max-height:unset; -webkit-line-clamp:unset;","a[class*='link'] > .link__headline":"max-height:unset; -webkit-line-clamp:unset;"},"bodyRule.add":{bodySelector:"[data-qa='ArticleList-Item']",articleSelector:"[data-qa='GenericArticle-Content']",xpathRule:["datatype:p"]}},{id:"lesswrong",matches:"www.lesswrong.com",extraBlockSelectors:["span.commentOnSelection"]},{id:"mastodon",matches:["mastodon.social","mastodon.online","kolektiva.social","indieweb.social","mastodon.world","infosec.exchange"],isTranslateTitle:!1,selectorMatches:["div#mastodon"],selectors:["div.status__content__text",".about__section__body",".content",".form-container",".account__header__extra"],globalAttributes:{"[class='notranslate app-holder']":{class:"app-holder"}},detectLanguage:!0},{id:"cnbc",matches:"www.cnbc.com",urlChangeDelay:1e3,globalStyles:{"div.Card-titleContainer > div":"-webkit-line-clamp: unset;max-height: unset;"},"excludeSelectors.add":["#GlobalNavigation","#GlobalFooter",".LiveBlogHeader-timestampAndShareBarContainer",".LiveBlogHeader-liveUpdatesPill"]},{id:"dailyDev",matches:"app.daily.dev",selectors:["h1",".typo-body","article h3","[class^=markdown_markdown]"],globalStyles:{".line-clamp-3":"-webkit-line-clamp: unset"}},{id:"pornhub",matches:["*.pornhub.com","pornhub.com"],excludeMatches:["*.pornhub.com/insights/*","pornhub.com/insights/*"],extraBlockSelectors:[".trendingNow",".searchItem",".tagcloud > a"],detectParagraphLanguage:!0,wrapperPrefix:"
",wrapperSuffix:` `,globalStyles:{"span.title":"height:unset; max-height:unset;",".detailedInfo":"max-height:unset;",".pcVideoListItem":"max-height:unset;",".wrap":"height:unset;",".entry-header":"height:unset;",".entry-title > a":"height:unset;-webkit-line-clamp:unset;"}},{id:"yourporn",matches:"https://www.youporn.com/*",extraBlockSelectors:[".button"],globalStyles:{".video-box":"max-height:unset;",".video-box-title":"white-space:unset;"}},{id:"modelhub",matches:"https://www.modelhub.com/*",globalStyles:{".videoTitle":"height:unset;",a:"height:unset;"}},{id:"xvideos",matches:"https://www.xvideos.com/*",globalStyles:{".title":"-webkit-line-clamp:unset;max-height:unset;",".mozaique":"display:flex; flex-wrap:wrap;"},excludeSelectors:[".video-hd-mark"]},{id:"missav",matches:"https://missav.com/*",globalStyles:{".truncate":"white-space:unset;",".overflow-y-hidden":"max-height:unset;overflow-y:unset;"},"subtitleRule.add":{type:"av",avSerial:{type:"url",regexStr:".+/([a-z0-9-]+)$"},videoSelector:".plyr__video-wrapper video",attachRule:{appendSelector:".plyr--video",injectedGlobalCSS:""},quickButtonRule:{appendSelector:".plyr__controls",insertBeforeSelector:'[data-plyr="captions"]'}}},{id:"javbus",matches:"https://www.javbus.com/*",globalStyles:{".photo-info":"height:unset;"},excludeSelectors:[".item-tag","date"]},{id:"spankbang",matches:"https://spankbang.com/*",globalStyles:{".video-item > a":"white-space:unset;"},excludeSelectors:[".stats",".thumb"],extraBlockSelectors:[".searches > a",".tag > a",".extra > a",".positions > li"]},{id:"javdb",matches:"https://javdb*.com/*",globalStyles:{".video-title":"white-space:unset;"},excludeSelectors:[".video-number",".score",".has-addons"]},{id:"jable",matches:"https://jable.tv/*",globalStyles:{".title":"white-space:unset;max-height:unset;",".img-box > a":"position:relative;"}},{id:"netflav.player",matches:["https://netflavns1.com","https://embedrise.com"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"av",avSerial:{type:"url",regexStr:"code=([a-z0-9-]+)"},videoSelector:"#vplayer video",attachRule:{appendSelector:"#vplayer"},quickButtonRule:{appendSelector:"#vplayer .jw-button-container",insertBeforeSelector:"#vplayer .jw-button-container .jw-icon-cc"}}},{id:"netflav",matches:["https://netflav*.com/*"],globalStyles:{".grid_title":"max-height:unset;"},extraBlockSelectors:[".genre_filter_item","button"],"subtitleRule.add":{type:"av",avSerial:{type:"selector",selector:".videodetail_2_field_values",serialAttachIframe:"#iframe-block"}}},{id:"czechvideo",matches:"https://czechvideo.co/*",globalStyles:{".short-story":"height:unset;",".short-title":"height:unset;"},globalAttributes:{header:{translate:"unset;"}}},{id:"weibo",matches:["weibo.com","*.weibo.*"],selectors:["div[class^='detail_wbtext']",".weibo-text"],"stayOriginalSelectors.add":[".expand"]},{id:"medium",matches:["medium.com","*.medium.com"],selectorMatches:["meta[property='al:ios:url'][content^='medium://']"],urlChangeDelay:20,"additionalExcludeSelectors.remove":["i.fa","i[class^=fa-]",".navmenu-container",".google-symbols"],selectors:["h1","h2","h3","article section","[aria-hidden='false'] pre","article p",".postMetaInline","a .u-fontSize24"],excludeSelectors:["[aria-label='Post Preview Reading Time']",".al.b.bl.ag.bp",".al.b.bl.ag.ai",".hx.hy.hz.ia.ib.ab",".qb.ab",".ai.bn.n.mj",".speechify-ignore"],globalStyles:{"h2,h3":"-webkit-line-clamp: unset;max-height:unset;","article p":"-webkit-line-clamp: unset;max-height:unset;"},injectedCss:[".u-lineClamp4,.u-lineClamp3,.u-lineClamp2 {-webkit-line-clamp:unset!important;max-height:unset!important;}"]},{id:"nitter",selectorMatches:["meta[property='og:site_name'][content='Nitter']"],selectors:[".tweet-content",".quote-text"]},{id:"economist",matches:"www.economist.com",extraInlineSelectors:["span[data-caps='initial']"],excludeSelectors:["footer.ds-footer"],injectedCss:["a::before {position:relative!important;}"]},{id:"healthline",matches:"www.healthline.com",excludeSelectors:[".icon-hl-trusted-source-after"]},{id:"ebay",matches:"www.ebay.com",excludeSelectors:["headers","[itemprop=offers]",".dne-itemtile-original-price"],paragraphMinTextCount:4,paragraphMinWordCount:2,globalStyles:{"[itemprop=name]":"-webkit-line-clamp: unset;max-height: unset;",".merch-item-title":"-webkit-line-clamp: unset;max-height: unset;"}},{id:"skinstore",matches:"www.skinstore.com",excludeSelectors:[".responsiveFlyoutMenu_levelOneLink"],paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"tripadvisor",matches:"www.tripadvisor.com",paragraphMinTextCount:4,paragraphMinWordCount:2},{id:"primevideo",matches:["www.primevideo.com","https://*.amazon.co.*/*video*","https://*.amazon.com/*video*"],"excludeSelectors.add":["#dv-web-player"],"mutationExcludeSelectors.add":["#dv-web-player *"],"subtitleRule.add":{type:"ebutt",hookType:"xhr",subtitleUrlRegExp:"\\.ttml2$",loadingContainerSelector:"#dv-web-player"}},{id:"amazon",matches:"www.amazon.com",paragraphMinTextCount:4,paragraphMinWordCount:2,extraBlockSelectors:[".a-size-small.a-link-normal.page-banner-link.a-nowrap"],globalStyles:{".a-carousel-viewport":"height:unset;","[class*='clamp']":"max-height: unset;-webkit-line-clamp: unset;","[data-rows]":"max-height: unset;-webkit-line-clamp: unset;","[data-a-expander-name='review_text_read_more']":" max-height: unset;"},excludeSelectors:["#navFooter","#navbar-main",".s-price-instructions-style","[class*='-star ']","[data-hook='acr-average-stars-rating-text']",".a-color-price"]},{id:"visualstudioMarketplace",matches:"marketplace.visualstudio.com",additionalExcludeSelectors:[".core-info-second-row",".core-info-third-row",".meta-data-list",".item-title",".breadcrumb",".itemDetails-right",".ux-user-name",".ux-updated-date",".ux-item-second-row-wrapper",".stats-and-offer",".header-container"],atomicBlockSelectors:[".core-info-cell > div.name"],globalStyles:{".item-details-control-root.ux-item-shortdesc":"height: unset; overflow: visible; max-height:unset;"}},{id:"bloomberg",matches:"www.bloomberg.com",urlChangeDelay:2e3,excludeSelectors:[".ticker-bar","nav","[aria-label=Banner]","aside","[data-component=ticker-bar]","footer.bb-global-footer",".vjs-text-track-display"],"bodyRule.add":{bodySelector:"main article",articleSelector:".body-content"},"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"webvtt$",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"baiduXueshu",matches:"xueshu.baidu.com",globalStyles:{".abstract_wr":"height: unset; overflow: visible; max-height:unset;"}},{id:"sciencedirect",matches:"www.sciencedirect.com",urlChangeDelay:2e3,stayOriginalSelectors:["span.display","span.math"],extraBlockSelectors:["span.captions","span[id^=cap]"],globalAttributes:{"#abspara0010 br":{style:"display:none;"}}},{id:"thehighestofthemountains",matches:"www.thehighestofthemountains.com",extraBlockSelectors:"div"},{id:"telegraph1",matches:"te.legra.ph",normalizeBody:"div.ql-editor[contenteditable='false']",urlChangeDelay:500},{id:"telegraph2",matches:["telegra.ph"],normalizeBody:"div.ql-editor[contenteditable='false']",wrapperPrefix:` `},{id:"annasArchive",matches:["*.annas-archive.org","annas-archive.org"],selectors:[],globalStyles:{"div[id^='link-index-']":"height: unset; max-height: unset;","main div[class*='h-[125]']":"height:auto"},normalizeBody:"body",extraBlockSelectors:["a.custom-a"]},{id:"explainshell",matches:["explainshell.com"],selectors:["[class='help-box']"]},{id:"apnews",matches:["apnews.com"],urlChangeDelay:2e3},{id:"googlePlay",matches:"play.google.com",excludeSelectors:[".vlGucd",".ubGTjb"],globalStyles:{".Epkrse":"-webkit-line-clamp:unset;"}},{id:"tumblr",matches:["www.tumblr.com"],selectors:["article h1","article > header + div","[data-testid=notes-root] p","div.k31gt","p","article ul","article h2","article h3","article h4","article h5","article h6","article blockquote","article ol"],excludeSelectors:["div.fAAi8","div.wvu3V"],preWhitespaceDetectedTags:["DIV","SPAN","P"]},{id:"tinytask",matches:"https://www.tinytask.net",globalStyles:{"table > tbody > tr > td > center > table > tbody > tr > td > ul > li":"height: 100%"}},{id:"foxnews",matches:"www.foxnews.com",shadowRootSelectors:["[data-spot-im-module-default-area='conversation'] > div"],"excludeTags.add":["TEXT","IMG","SUB","SUP","CODE","TT","ASIDE"],excludeSelectors:[".site-footer",".components-MessageDetails-index__message-details-wrapper","div[class^=SlideDown__container]",".components-MessageActions-index__messageActionsWrapper","span[data-openweb-allow-amp]","div.spcv_typing-users"]},{id:"afreecatv",matches:"www.afreecatv.com",globalStyles:{"a.title":"max-height:unset;-webkit-line-clamp:unset;"}},{id:"opennet",matches:"opennet.ru","excludeTags.add":["LABEL","IMG","SUB","SUP","CODE","TT"],"excludeTags.remove":["LINK","G","MATH","TTS-SENTENCE","AIO-CODE"]},{id:"construct",matches:["www.construct.net"],excludeMatches:["preview.construct.net","editor.construct.net"],additionalSelectors:["aside","div.manualContent"],atomicBlockSelectors:[],stayOriginalSelectors:["a.usernameReference"],additionalInlineSelectors:["a.forumLink"],additionalExcludeSelectors:["div.topNav","div.usernameLink","ul.authorDetails","ul.tagViewer","ul.breadCrumbNav","ul.subForumForums","ul.postTools","li.comment ul.controls","div.forumTopNavWrap","div.downloadWrap","div.articleLeftMenu","div.usernameTextWrap","div.favouriteWrap","div.bannerWrapper","div.viewAddonRightMenu","div.extendedMenu.addonsSubMenu","#BottomLinks.bottomLinks","div#LeftSide.leftSide","div#BottomWrap.bottomWrap","div.courseListWrap div.overview","div.conversationControls","div.contentWrapper h1","div.conversationControls","td.location a#LocationLink","#TopLevelComments .topBar","#TopLevelComments .controls",".tagViewWrap",".changeCount",".otherStats",".FilterMenu",".mobileTopicStats",".forumControlsWrapper",".forumsBottomNavWrap",".breadCrumbNav",".favouriteWrap",".usernameLink",".followWrapper",".blogPostStats",".manualContent dl dt"],globalStyles:{"td.location a#LocationLink":"padding-top: 4px;","div.articleMain .tutCourseWrap":"align-items: flex-start;"}},{id:"getpocket",matches:"getpocket.com",selectors:["h2","div.excerpt p","article","h1"],globalStyles:{"h2.title":"max-height:unset;-webkit-line-clamp:unset;","div.excerpt p":"max-height:unset;-webkit-line-clamp:unset;"}},{id:"fandom",matches:"*.fandom.com",urlChangeDelay:800,normalizeBody:"#mw-content-text",globalStyles:{"#mw-content-text > div > div:nth-child(1)":"height:100%;"},additionalExcludeSelectors:["header.fandom-community-header","div.ph-registration-buttons"]},{id:"huggingface",matches:"huggingface.co",globalStyles:{".line-clamp-2":"-webkit-line-clamp:unset;max-height:unset;"}},{id:"statista",matches:"www.statista.com",globalStyles:{".itemContent__text":"height:unset;max-height:unset;",".itemContent__subline":"height:unset;max-height:unset;"}},{id:"epubReader",matches:"epub-reader.online",globalStyles:{"span.slide-contents-item-label":"overflow:visible;max-height:unset;white-space:normal;"},atomicBlockSelectors:["div.slide-contents-item"]},{id:"you",matches:"https://you.com/search",globalStyles:{h3:"max-height:unset;-webkit-line-clamp:unset;",".caKYaC":"max-height:unset;-webkit-line-clamp:unset;",".dDwDsu":"max-height:unset;-webkit-line-clamp:unset;"},excludeSelectors:["div.hpIWZO"]},{id:"auth0Openai",matches:"auth0.openai.com",excludeSelectors:["form","header > h1"]},{id:"chatOpenai",matches:"chat.openai.com",excludeSelectors:["div.absolute.bottom-0.left-0.w-full","h1","div#headlessui-portal-root","nav","ul[aria-multiselectable]",".markdown *","div[class='flex flex-col items-start']","div[class='flex items-center justify-center gap-1 border-b border-black/10 bg-gray-50 p-3 text-gray-500 dark:border-gray-900/50 dark:bg-gray-700 dark:text-gray-300']"],"excludeTags.remove":["BUTTON"],isTranslateTitle:!1,wrapperPrefix:"",globalStyles:{"[class*='line-clamp']":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},aiRule:{streamingSelector:".result-streaming.markdown",messageWrapperSelector:".markdown",streamingChange:!0,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"poe",matches:["https://poe.com/*"],excludeSelectors:[".Markdown_markdownContainer__Tz3HQ *",".MarkdownLink_linkifiedLink__KxC9G","menu","aside"],aiRule:{streamingSelector:".ChatStopMessageButton_stopButton__LWNj6",messageWrapperSelector:".Markdown_markdownContainer__Tz3HQ",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"glasp",matches:"glasp.co",excludeSelectors:[".home_overview_list_content_wrapper"]},{id:"developerChrome",matches:"developer.chrome.com",excludeSelectors:["web-tabs","ul.code-sections--summary"]},{id:"android",matches:["developer.android.google.cn","developer.android.com"],observeUrlChange:!0,additionalSelectors:["aside","google-codelab-step"]},{id:"ft",matches:"www.ft.com",excludeSelectors:["header","[aria-labelledby=cookie-banner-aria-label]","footer","[aria-label='Primary navigation']"]},{id:"microsoft",matches:"https://apps.microsoft.com/store/detail/*",additionalSelectors:["pre"],globalStyles:{".line-clamp":"-webkit-line-clamp:unset;max-height:unset;"},isTransformPreTagNewLine:!0},{id:"gitlab",matches:"gitlab.com",excludeSelectors:[".tree-content-holder","nav",".home-panel-metadata","div[data-testid=project_topic_list]",".commit"]},{id:"tiktok",matches:"https://www.tiktok.com/*/video/*",selectors:["[data-e2e^=comment-level]","[data-e2e=browse-video-desc] > span"]},{id:"rfcEditor",matches:["www.rfc-editor.org","docs.haproxy.org"],isTransformPreTagNewLine:!0,"excludeTags.add":["IMG","SUB","SUP","CODE","TT","ASIDE","FOOTER"],"excludeTags.remove":["LINK","G","PRE","TTS-SENTENCE","AIO-CODE"]},{id:"steamcommunity",matches:"steamcommunity.com",globalStyles:{".forum_topic,.rightbox_list_option":"height:auto;",".forum_topic_name":"white-space:normal;line-height: 1.25rem; padding: 6px 20px 0 0;",".forum_topic_op":"clear: left; padding: 0 0 6px 2rem;"},excludeSelectors:[".forum_paging",".forum_topic_reply_count",".forum_topic_lastpost",".forum_topic_award_count",".discussion_search_pagingcontrols"]},{id:"steampoweredApp",matches:"store.steampowered.com/app/*",selectors:[".game_description_snippet",".game_area_description","#earlyAccessHeader","[id^='ReviewContent'] .content",".ModalOverlayContent"],excludeSelectors:["#global_actions","#store_controls","#foryou_tab","[class*=persona]","[class*=game_title_area]","a.btn_medium",".persona_name",".hours.ellipsis",".checkcol",".postedDate",".dev_row .summary",".already_in_library",".game_header_image_ctn .grid_content",".ds_flag.ds_wishlist_flag",".early_access_review.tooltip",".communitylink_achievement_images",".user_reviews_summary_row.summary",".review_award_ctn",".add_to_wishlist_area",".next_in_queue_content",".glance_tags.popular_tags",".game_purchase_action",".vote_button_ctn","#VoteUpDownBtnCtn","#footer","#ViewAllReviewssummary"],atomicBlockSelectors:[".game_area_sys_req_leftCol",".game_area_sys_req_rightCol"],extraInlineSelectors:[".pulldown"],additionalSelectors:[".game_page_autocollapse_ctn iframe"],globalStyles:{".game_description_snippet":"max-height:unset; overflow: scroll;",".game_purchase_area_friends_want":"height: auto; padding-bottom: 6px;",".div.early_access_banner":"height: 84px",".franchise_notice > *":"height: 84px"},detectParagraphLanguage:!0},{id:"steampowered",matches:"store.steampowered.com",detectParagraphLanguage:!0},{id:"nature",matches:"https://www.nature.com/articles/*",excludeSelectors:[".c-header",".c-recommendations-header",".c-recommendations-list-container",".c-article-references__links",".c-article-identifiers",".c-article-author-list",".c-article-metrics-bar__wrapper",".c-article__pill-button","#author-information-content","#article-info-section"]},{id:"webofscience",matches:"https://www.webofscience.com/*",globalStyles:{".abstract":"height:auto !important;",".show-more-lines":"height:unset !important;"},excludeSelectors:[".summary-left-panel",".authors","app-full-record-keywords mark"],mutationObserverContainerSelectors:["[data-ta='summary-record-title-link']","#FullRTa-fullRecordtitle-0"],extraBlockSelectors:["app-summary-authors + div","app-full-record-keywords span span"],observeUrlChange:!0,urlChangeDelay:600,mutationChangeDelay:600},{id:"appleinsider",matches:["appleinsider.com"],excludeSelectors:["#topic-nav"]},{id:"jetbrains",matches:"https://www.jetbrains.com/help/*",extraBlockSelectors:["[data-test=prompt]"]},{id:"crates",matches:["https://crates.io/search*"],selectors:["div[class^=_description-box] div[class^=_description]"]},{id:"theverge",matches:"www.theverge.com",shadowRootSelectors:["div#coral_thread > div"]},{id:"simp",matches:"https://beta.simp.red/trans*",mainFrameSelector:".simpread-read-root"},{id:"lookintobitcoin",matches:"https://www.lookintobitcoin.com/charts/*",excludeSelectors:["svg"]},{id:"openaiAccount",matches:"https://platform.openai.com/account/api-keys*",urlChangeDelay:1500},{id:"openaiDocs",matches:"https://platform.openai.com/docs*","excludeSelectors.add":[".pheader"]},{id:"pkgStd",matches:"https://pkg.go.dev/std",selectors:["td.UnitDirectories-desktopSynopsis"]},{id:"pkg",matches:"https://pkg.go.dev/*",selectors:["div.UnitDetails p"]},{id:"explainpaper",matches:["https://www.explainpaper.com/reader*"],isTranslateTitle:!1,selectors:[".leading-relaxed",".chat-messages p",".text-sm"]},{id:"colab",matches:"https://colab.research.google.com/*",excludeSelectors:["code","view-line"]},{id:"gatesnotes",matches:"www.gatesnotes.com",minZIndex:-1},{id:"kakao",matches:"page.kakao.com",shadowRootSelectors:["div[style^='visibility: visible'"]},{id:"coinmarketcap",matches:"coinmarketcap.com",extraBlockSelectors:["div[class='sc-3502f6cd-0 JxHqg']"]},{id:"wandb",matches:"wandb.ai",additionalSelectors:[".report-page-top"],additionalStayOriginalSelectors:["span[data-slate-inline=true]"],extraInlineSelectors:[]},{id:"paulgraham",matches:"paulgraham.com",additionalSelectors:["font[face=verdana]"],extraBlockSelectors:"font[face=verdana]"},{id:"zendesk",matches:"https://*.zendesk.com/agent/*",selectors:["[data-test-id*=subject]",".zd-comment",".title"]},{id:"migadu",matches:"webmail.migadu.com",selectors:[".bodyText"]},{id:"thehackernews",matches:"thehackernews.com",excludeSelectors:["span#blog-pager-older-link","span.h-datetime"],additionalSelectors:[".pop-title"]},{id:"brown",matches:"cs.brown.edu",excludeSelectors:[".SCodeFlow"]},{id:"tass",matches:"tass.ru",globalStyles:{"#__next":"font-size: 19px;line-height:28px;"}},{id:"chatGoogle",matches:"chat.google.com",selectors:["[jsname=bgckF]"]},{id:"fiverr",matches:"https://www.fiverr.com/inbox/*",selectors:[".message-body"]},{id:"fiverr-main",matches:"*.fiverr.com",globalStyles:{"h3 > a":"-webkit-line-clamp:unset;overflow:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",h5:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;",".YLycza2.u9KHmsf":"height:unset;max-height:unset;",".lt2ar2q.EhHcMiw":"height:unset; max-height: unset;"},excludeSelectors:[".popular"]},{id:"jira",matches:["jira.*.com/browse/*","jira.*.com/projects/*"],selectors:["[id=descriptionmodule]","[id=summary-val]","div.action-body","td.stsummary"]},{id:"ahaIo",matches:["*.aha.io"],selectors:["[tabindex='0']","div.user-content","div.comments__body","span.name"]},{id:"thehill",matches:"thehill.com",injectedCss:[".most-popular-item { max-height: unset !important; }",".most-popular-item__link { -webkit-line-clamp: unset !important; }"],excludeSelectors:["div.featured-cards__byline","div.list-item__meta",".tags__item","div.extended-scroll__header",".submitted-by",".site-header--has-alert-banner",".homepage__container__opinion__item__byline",".homepage__container__header",".archive__item__meta"]},{id:"ubuntu",matches:"manpages.ubuntu.com",selectors:["pre"],atomicBlockTags:["pre"]},{id:"spiedigitallibrary",matches:"www.spiedigitallibrary.org","excludeTags.add":["IMG","SUB","SUP","CODE","TT","ASIDE","FOOTER"],"excludeTags.remove":["LINK"]},{id:"promptingguide",matches:"www.promptingguide.ai",selectors:["article","li"]},{id:"ground",matches:"ground.news",globalStyles:{".line-clamp-3":"-webkit-line-clamp: unset !important;"}},{id:"ietf",matches:"*.ietf.org/doc/html/*",additionalSelectors:["pre"],isTransformPreTagNewLine:!0,preWhitespaceDetectedTags:["DIV","SPAN","PRE"]},{id:"newsminimalist",matches:"https://www.newsminimalist.com/",extraBlockSelectors:[".inline-flex"],"excludeTags.remove":["BUTTON"]},{id:"yandexIndex",matches:"https://yandex.com/",selectors:[".tabs__item-text"]},{id:"yandexSearch",matches:"https://yandex.com/search/*",excludeSelectors:[".KeyValue-Row",".EntityFeedbackFooter",".Organic-Subtitle",".SerpFooter-Content",".serp-user",".Pager"],globalStyles:{".ExtendedText-Toggle":"white-space:normal;"}},{id:"yandex",matches:"https://yandex.com/video/*",selectors:[".serp-item__title",".serp-item__text",".Keypoints-ItemTitle",".bes-epmjnzm-idtktyj",".OrganicTitle-LinkText","h1.VideoTitle"],globalStyles:{".serp-item__title":"-webkit-line-clamp: unset;max-height:unset;",".serp-item__text":"-webkit-line-clamp: unset;max-height:unset;",".OrganicTitle-LinkText":"-webkit-line-clamp: unset;max-height:unset;","h1.VideoTitle":"-webkit-line-clamp: unset;max-height:unset;",".link .serp-item__keypoints":"bottom:2px;",".OrganicTitle":"max-height:unset;"}},{id:"perplexity",matches:"https://www.perplexity.ai",globalStyles:{".line-clamp-1":"-webkit-line-clamp: unset !important;",".line-clamp-2":"-webkit-line-clamp: unset !important;"},"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3},additionalStayOriginalSelectors:["a.citation"],selectors:[".prose",".my-md",".line-clamp-2",".line-clamp-1"]},{id:"allmyfaves",matches:"https://allmyfaves.com/",selectors:["p"],paragraphMinTextCount:2,paragraphMinWordCount:1},{id:"man7",matches:"man7.org",isTransformPreTagNewLine:!0,globalStyles:{pre:"white-space: inherit;"}},{id:"kadaza",matches:"https://www.kadaza.com/",selectors:[".header span.title",".custom-content-footer"],containerMinTextCount:2,containerMinWordCount:1,paragraphMinTextCount:2,paragraphMinWordCount:1},{id:"urlChangeDelay",matches:["https://babelnovel.com/books/*","https://www.webnovel.com/book/*","https://platform.openai.com/docs/*","docs.oracle.com","docs-cortex.paloaltonetworks.com","forum.m5stack.com/topic/*","community.m5stack.com/topic/*"],urlChangeDelay:0,_comment:"\u89E3\u51B3url\u53D8\u5316\u91CD\u590D\u7FFB\u8BD1\u95EE\u9898"},{id:"genuine",matches:"blog.genuine.com",excludeSelectors:["div.enlighter"]},{id:"chinadaily",matches:"www.chinadaily.com.cn",injectedCss:["a { height: unset !important; }","li { height: unset !important; }","div { height: unset !important; }",".immersive-translate-target-inner {color:black;}"],excludeSelectors:[".topNav",".topNav2_art > span",".topNav_art2 > .dropdown",".dibu-three",".topBar"]},{id:"braynzarsoft",matches:"www.braynzarsoft.net",selectors:["div#view-question-desc"]},{globalAttributes:{"#stimulus":{translate:"off",class:"stimulus"},"#stem":{translate:"off",class:"stem"}},id:"lawhub",matches:"https://lawhub.lsac.org/question/*"},{id:"yuque",matches:"https://www.yuque.com/*",excludeSelectors:[".lark-virtual-tree"]},{id:"bearblog",matches:"https://bearblog.dev/discover/*",excludeTags:["small"]},{id:"researchgate",matches:"www.researchgate.net",excludeSelectors:[".nova-legacy-v-publication-item__meta-data",".nova-legacy-v-publication-item__person-list",".js-authors-list"]},{id:"theatlantic",matches:["www.theatlantic.com","https://mashable.com/*"],"excludeSelectors.add":["footer:last-of-type","nav","header div.subtitle-2.w-full"],initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},"nav:last-of-type":{translate:"no"},nav:{translate:"no"}}},{id:"youtrackJetbrains",matches:"youtrack.jetbrains.com/articles/*",selectors:["[role=presentation]","[data-test=article-content]"],excludeSelectors:[".toolbar__ee8"]},{id:"dw",matches:"www.dw.com",initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},"nav:last-of-type":{translate:"no"},nav:{translate:"no"}},excludeSelectors:[".focus-menu-shown"]},{id:"sentry",matches:"docs.sentry.io",initialSelectorGlobalAttributes:{"footer:last-of-type":{translate:"no"},".navbar":{translate:"no"}},"extraInlineSelectors.add":[".term-wrapper","span.description"]},{id:"openai-blog",matches:"https://openai.com/blog/*","stayOriginalTags.remove":["CODE"]},{id:"urlComment",selectorMatches:["meta[name='generator'][content^='Discourse']"],urlChangeDelay:0,_comment:"\u89E3\u51B3url\u53D8\u5316\u4F46\u662F\u9875\u9762\u4E0D\u53D8\u7684\u95EE\u9898"},{id:"feedly",matches:"feedly.com",globalStyles:{".TitleOnlyLayout":"height:unset !important;",".EntrySummary--u4":"-webkit-line-clamp: unset;max-height:unset;",".EntrySummary--u5":"-webkit-line-clamp: unset;max-height:unset;"},excludeSelectors:[".Leftnav"]},{id:"bardGoogle",matches:"bard.google.com",excludeSelectors:["mat-sidenav","div.capabilities-disclaimer","#cdk-overlay-6","message-actions button",".mdc-button__label .ng-star-inserted",".mdc-list-item__primary-text"],isTranslateTitle:!1,"excludeTags.add":["mat-tooltip-component"],"excludeTags.remove":["BUTTON"]},{id:"whatsapp",matches:"web.whatsapp.com",selectors:[".copyable-text > span"],wrapperPrefix:` -`,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};function Q3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Jt(){let t=await oe.storage.local.get(Fo);if(t[Fo]){let e=t[Fo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Ht(i),i}else return{}}async function Ht(t){await oe.storage.local.set({[Fo]:t})}async function kl(t){await oe.storage.local.set({[Yr]:t})}async function Z3(){let t=await oe.storage.local.get(Yr),n={...await fp(),...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let r=t[Yr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Xt(){let t=await oe.storage.local.get(Yr),e={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let E=t[Yr];if(E&&E.buildinConfigUpdatedAt){let P=new Date(E.buildinConfigUpdatedAt),O=new Date(e.buildinConfigUpdatedAt);P>O&&(e=E)}}let n=await zw(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let E=await oe.commands.getAll();for(let P of E)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await fp(),o=Q3(),s=await qr(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Jt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let E=await Rw();p.interfaceLanguage=E}let g=p.interfaceLanguage==="en",m=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!g&&!m&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,C=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(C=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(C.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,B=await At("installedAt",""),S=Number(await Nr("translage_page_daily",0)),y=Number(await At(Kn,0)),_;y>0&&(Date.now()-y0&&(Date.now()-S0){let E=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(E.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],O=Array.isArray(P)?P:[P],H=Array.from(new Set(O.concat(E.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let F=Object.assign(i,e);Ya({rule:e,valueIsArray:E=>Array.isArray(i[E]),getMergedValue:E=>i[E],onMergedResult:(E,P)=>{E!="generalRule"&&(F[E]=P)}});let L=Zt(r),U={};p.translationServices&&p.translationServices.deepl&&(U=p.translationServices.deepl);let N={};p.translationServices&&p.translationServices.openai&&(N=p.translationServices.openai),!L&&U.authKey&&!U.provider?(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="custom"):U&&U.provider||(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="pro"),!L&&N.APIKEY&&!N.provider?(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="custom"):N&&N.provider||(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="pro");let q=Object.keys(F),A=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let E of q){let P=E;if(P==="generalRule")typeof p[P]=="object"&&(F[P]=Tl(i[P],p[P]));else if(P==="translationServices")Nw(p,F);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&A.includes(P))p[P]&&(F[P]=Object.assign(F[P],p[P])),P==="shortcuts"&&(ye()||it()?F[P]={...F[P],...a}:F[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let O=F.rules||[],H={};for(let W of O)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?k3(e.generalRule,H[W.id],W):W);F[P]=[...j,...F[P]]}if(we.PROD==="0"&&we.DEV_RULES){let O=JSON.parse(we.DEV_RULES);F[P]=[...O,...F[P]]}}else p[P]!==void 0&&(F[P]=p[P])}return F.donateUrl=e.donateUrl,F.minVersion=e.minVersion,F.feedbackUrl=e.feedbackUrl,F.rawUserConfig=s,F}async function qr(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function hs(t){await oe.storage.sync.set({userConfig:t})}async function bs(t,e){await oe.storage.local.set({[t]:e})}async function Pl(t){return(await oe.storage.local.get(t))[t]||""}var Rw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){z.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>Ot[r]);return n||"en"},fp=async()=>{let t={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:lr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Ow(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function zw(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return lr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ya({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ya({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}var Uw=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function xn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(xn(t,i))return!1;if(xn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!xn(t,o)),c;function p(){return n&&n.display?!!Uw.includes(n.display):xn(t,r)}}var Kt=xn;function Qa(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function Ts(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function Tr(t,e=!1){let n=Io;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Za(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return Tr(n,e)}function Ui(t,e){return ua(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function hp(t){let{rule:e}=t,n=qw(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function qw(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function ys(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",bt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),ut(r,Uh,e.toString());let a=hp(t);return r.append(rt.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function qi(t,e){return t.querySelector(`[${Ld}='${e}']`)}function J3(){document.querySelectorAll(`[${Ld}]`).forEach(e=>{e.remove()})}function X3(){document.querySelectorAll(`.${bt}-error`).forEach(e=>{e.remove()})}function e1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{Hi(n)&&e.push(n)}),e}function bp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},g=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),m=new RegExp(a.replace("{word}",g.map(f=>f.k).join("|")),"g");l=l.replace(m,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let g=new RegExp(p,"gi");l=l.replace(g,(m,f)=>{let T=c++;return e[`${T}`]=O3(f),o.length>2?m.replace(f,`<${o[2]}${T}>`):m.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){z.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function vs(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||d1(s)||s1(s)||c1(s)||u1(s)||l1(s)||Hw(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ll(i,n,r)}function jr(t){return t.nodeType===Node.ELEMENT_NODE}function t1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Tp(){return await At("fakeUserId","")}async function jw(){return await At("installedAt","")}async function n1(t){let n=Me().INSTALL_FROM,r=Sn(),a=await jw(),i=await Tp(),o=await Xt(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Zt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function r1(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await vp(t,e);r(a)})()},[t,e,r]),n}async function vp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!it()&&ye()||et().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>wt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>wt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}var _l=!1,Ww=ye();function p1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function Kw(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&g1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(da(i,Eu)){if(a===!0)return!0;continue}if(Ss(i.nodeName,e.inlineTags))return!0;if(!Sp(i,e))return!1}}return!0}function xp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(Ss(t.nodeName,n)||Sp(t,e)){if(da(t,Hh)||Ss(t.nodeName,["BR"]))return!1;if(da(t,Eu))return!0;if(Sp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return Kw(t,e)}else return da(t,Eu);return!1}function g1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&da(t,jh,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&da(t,Bh))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||Ss(t.nodeName,i))}function Ll(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!f1(r)&&r.length>=n}function m1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(f1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function f1(t){for(let e=0;e127)return!1;return!0}function s1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function u1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function l1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function c1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function d1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function da(t,e,n=!1){return Ep(t,e,"1",n)}function Ep(t,e,n,r=!1){return _l&&!r?t[Tn]?!!(t[Tn]&&t[Tn][e]===n):!1:t.dataset[e]===n}function Wi(t){return(t.innerText||t.textContent||"").trim()}function Cp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Fl(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function ut(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(_l&&!r?(t[Tn]||(t[Tn]={}),t[Tn][e]||(t[Tn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Ml(t,e,n=!1){if(_l&&!n){if(!t[Tn]||!t[Tn][e])return;delete t[Tn][e]}else delete t.dataset[e]}function Ki(t,e,n=!1){return _l&&!n?!t[Tn]||!t[Tn][e]?void 0:t[Tn][e]:t.dataset[e]}function Sp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!Ss(t.nodeName,n)}function Ae(){if(!globalThis||!globalThis.location)return"https://example.com";if(!Je())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function An(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){z.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else z.warn("injectCSS failed, rootDocument does not have head node",t)}function Hi(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(Ww){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function Ss(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function h1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function b1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||g1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return z.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function T1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();var v1="auto",Bl="auto",y1="auto";function S1(t){v1=t}function Nn(t){Bl=t}function yt(){return Bl!=="auto"?Bl:y1!=="auto"?y1:v1}function Il(){return Bl}function E1(t,e){let n=Object.assign({},t),r=new Map;(n.langOverrides||[]).forEach(i=>{r.set(i.id,i)});for(let i of r.keys()){let[o,s]=i.split("2");if(["auto",e.sourceLanguage].includes(o)&&["auto",e.targetLanguage].includes(s)){let u=r.get(i);if(!u)continue;if(u.extends){let l=r.get(u.extends);l&&(n=Object.assign({},n,l))}n=Object.assign({},n,u)}}return n}async function Un(t){let{url:e,config:n,state:r}=t,a=new URL(e),i="auto",{translationParagraphLanguagePattern:o,translationService:s,translationServices:u,translationTheme:l,translationThemePatterns:c,translationUrlPattern:p,targetLanguage:g,sourceLanguageUrlPattern:m,immediateTranslationPattern:f}=n,T=g||"zh-CN",b=Gi(e,o),h=Gi(e,f),C=s,D=Object.keys(u);for(let ae of D){let ie=u[ae];if(Gi(e,ie)){C=ae;break}}let M=l,B=Object.keys(c);for(let ae of B){let ie=c[ae];if(ie&&Gi(e,ie)){M=ae;break}}let S=Gi(e,p),y=x1(e,p);y||(y=wt(e,Xh)),y||(y=wt(e,n.blockUrls));let _=x1(e,n.inputTranslationUrlPattern);_||(_=wt(e,n.inputTranslationBlockUrls));let k=wt(e,n.mutationBlockUrls),v=Object.keys(m),I={};for(let ae of v){let ie=m[ae];if(ie&&ie.matches)for(let Ee of ie.matches)I[Ee]=ae}let F=Object.keys(I),L=ip(e,F);L&&(i=I[L]??"auto",I[L]&&I[L]!=="auto"&&Nn(I[L]));let U=a.hostname,N=await nr(U),q=a.pathname+a.search+a.hash,A=await nr(q),E=`https://${N}.com/${A}`,P=await Jt(),O=await Z3(),H=n.translationStartMode;H==="dynamic"&&h&&(H="immediate");let j=C;n.inputTranslationService&&n.inputTranslationService!=="inherit"&&(j=n.inputTranslationService);let W=C;n.mouseHoverTranslationService&&n.mouseHoverTranslationService!=="inherit"&&(W=n.mouseHoverTranslationService);let V=C;n.subtitleTranslateService&&n.subtitleTranslateService!=="inherit"&&(V=n.subtitleTranslateService);let se=await Mt.get(Ft,null),X=!1;se&&(X=Zt(se));let Z={targetLanguage:T,config:n,translationService:C,inputTranslationService:j,mouseHoverTranslationService:W,subtitleTranslateService:V,isTranslateUrl:S,sourceLanguage:i,mainFrame:document.body,isTranslateExcludeUrl:y,isMutationTranslationExcludeUrl:k,isInputTranslationExcludeUrl:_,rule:n.generalRule,url:e,encryptedUrl:E,state:r?Object.assign({translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},r):{translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},localConfig:P};se&&(Z.user=se,X?Z.isPro=!0:Z.isPro=!1),Z.state.translationArea==="body"&&(Z.config.generalRule.excludeTags=Z.config.generalRule.excludeTags.filter(ae=>!Z.config.generalRule.bodyTranslateTags.includes(ae)),Z.config.generalRule.additionalExcludeSelectors=Z.config.generalRule.additionalExcludeSelectors.filter(ae=>ae!==".btn"));let ue=n.translationServices[Z.translationService]||{};ue.immediateTranslationTextCount!==void 0&&Gw(ue.immediateTranslationTextCount)&&ue.immediateTranslationTextCount>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCount),Z.translationService==="deepl"&&(ue&&ue.authKey&&ue.authKey.startsWith("immersive_")||ue&&ue.provider==="pro"&&Z.user?.token)&&ue.immediateTranslationTextCountForImmersiveDeepl!==void 0&&ue.immediateTranslationTextCountForImmersiveDeepl>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCountForImmersiveDeepl),ue&&ue.translationDebounce&&typeof ue.translationDebounce=="number"&&(Z.state.translationDebounce=ue.translationDebounce);let ge=O.immediateTranslationTextCount;n.immediateTranslationTextCount!==ge&&(Z.state.immediateTranslationTextCount=n.immediateTranslationTextCount);let te=n.rules,Y;globalThis.PDFViewerApplication?Y=te.find(ae=>ae.pageType=="pdfReader"):globalThis.immersiveTranslateEbookViewer?Y=te.find(ae=>ae.pageType=="ebookReader"):globalThis.immersiveTranslateEbookBuilder?Y=te.find(ae=>ae.pageType=="ebookBuilder"):Y=te.find(ae=>Gi(e,ae)),Z.state.translationArea==="body"&&(Z.rule.paragraphMinTextCount=1,Z.rule.paragraphMinWordCount=1),Y&&Y.pageType==="ebookBuilder"&&(Z.state.translationStartMode="immediate");let be=n.generalRule;if(Y&&(Z.rule=Tl(be,Y)),Z.rule.selectors.length>0&&(Z.rule.paragraphMinTextCount=2,Z.rule.paragraphMinWordCount=1),Z.state.translationArea==="body"&&Z.rule.excludeTags&&(Z.rule.excludeTags=Z.rule.excludeTags.filter(ae=>!Z.rule.bodyTranslateTags.includes(ae)&&!Z.rule.forceTranslateTags.includes(ae))),Z.rule.mainFrameSelector){let ae=document.querySelector(Z.rule.mainFrameSelector);ae&&(Z.mainFrame=ae)}return Z}function Gi(t,e){if(!e)return!1;let{matches:n,excludeMatches:r,selectorMatches:a,excludeSelectorMatches:i}=e;return r&&r.length>0&&wt(t,r)?!1:n&&n.length>0&&wt(t,n)?!0:i&&i.length>0&&Fl(i)?!1:!!(a&&a.length>0&&Fl(a))}function x1(t,e){if(!e)return!1;let{excludeMatches:n,excludeSelectorMatches:r}=e;return!!(n&&n.length>0&&wt(t,n)||r&&r.length>0&&Fl(r))}function Gw(t){return typeof t=="number"}d();d();d();d();d();d();d();var Nq=w1(2),C1=w1(3);function w1(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var Vw=/\s+/g,$w=/[\t\n\v\f\r ]+/g;function D1(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?Yw:Qw;return String(t).replace(e.style==="html"?$w:Vw,e.trim?Zw(n):n)}function Yw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function Qw(){return" "}function Zw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var A1={}.hasOwnProperty;function Jw(t){return t==null?"":D1(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function Xw(t){return C1(" "+Jw(t)+" ")}function eD(t){let e=Xw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function sD(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function uD(t,e,n,r){e=cD(e,n,r);let a=[],i;if(e)for(i in e)Rl.call(e,i)&&a.push([i,lD(t,e[i])]);return a.length===0?Dp():a.sort(dD)}function lD(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of SD){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?I1(t)?"zh-TW":"zh-CN":e:"auto"}var O1=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Ap=new Map(O1),xD=new Map(O1.map(([t,e])=>[e,t]));function z1(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>xD.get(s));!e&&e!==0&&(e=25);let a=zl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Ap.keys()]},o=L1(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&g<.95)break;return Ap.get(p)}}let[s,u]=o[0],l=Ap.get(s);if(l&&u>.9)return l}}catch(r){z.error(r)}return"auto"}d();d();function pa(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function ED(t,e){return t<>>32-e}function Ul(t,e,n,r,a,i){return pa(ED(pa(pa(e,t),pa(r,i)),a),n)}function en(t,e,n,r,a,i,o){return Ul(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return Ul(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return Ul(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return Ul(n^(e|~r),t,e,a,i,o)}function Nl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function kp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Nl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Nl(a.concat(kp(e)),512+e.length*8),N1(Nl(i.concat(o),512+128))}function U1(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function Pp(t){return unescape(encodeURIComponent(t))}function q1(t){return CD(Pp(t))}function DD(t){return U1(q1(t))}function j1(t,e){return wD(Pp(t),Pp(e))}function AD(t,e){return U1(j1(t,e))}function kn(t,e,n){return e?n?j1(e,t):AD(e,t):n?q1(t):DD(t)}var Vi=[];async function ql(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function H1(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await LD(e,t)}async function W1(t){let e=kn(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await PD(n,e)}async function PD(t,e){let n=await ql(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function LD(t,e){let n=await ql(t);return(await FD()).includes(t)||await _D(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function _D(t){let e="cache_list",n=await ql(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Vi.push(t)},a.onerror=i=>{n.close()}}async function FD(){if(Vi&&Vi.length>0)return Vi;let t=await ql(Q+"-cacheList","cache_list");return Vi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Vi}d();d();var Lp="Original";function $e(){return Lp}function pn(t){Lp=t,K1(Lp)}d();function Hr(t){return t?.id?.endsWith("pdfWebPage")||!1}function ga(t){try{if(!t||!Hr(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Ye={},ma=async function(t,e){let{method:n,data:r}=t,a=await Ye.updateGlobalContext(),i=Date.now();if(z.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Ze(Kn,i);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Ze(Kn,i);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Ze(Kn,i);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Ze(Kn,i);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Ze(Kn,i);else if(n==="translatePage")await Ye.translatePage(a,r),Ze(Kn,i);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(vu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(_o,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Je()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Je())return JSON.stringify(a)}};function G1(t){Object.assign(Ye,t)}function V1(t){Object.assign(Ye,t)}function $1(t){Object.assign(Ye,t)}var MD=function(t,e){let{method:n,data:r}=t;if(z.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return $e();if(n==="getCurrentPageLanguage"){let a=yt();return Ye.detectCurrentPageLanguage().catch(i=>{z.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return Nn(r),yt();if(n==="getContextString"){let a=Ye.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return ga(a?.rule)}}},jl,Hl;function Y1(){let t=Wl();Je()||BD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Wl(){return jl||(jl=new br("content_script",!1).getConnection("main",ma),jl)}function BD(){return Hl||(Hl=new br("content_script",!1).getConnection("main_sync",MD,{sync:!0}),Hl)}d();var _p=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Kl="https://transmart.qq.com/api/imt",Wr=class t{static langMapReverse=new Map(_p.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await de({url:Kl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function ID(t,e){return Math.floor(Math.random()*(e-t+1))+t}var RD=30,Fp="RATE_LIMITER_TICKS",$i=class t{static strictTicks={};static clearStrictTicks(){bs(Fp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await Pl(Fp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){z.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await bs(Fp,JSON.stringify(this.strictTicks))}catch(a){z.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=ID(4,RD);await Dr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function vt(t){return await Wl().sendMessage("background:main",t)}function de(t){return mu()?wl({method:"request",data:t}):ye()||gu()?(t.fetchPolyfill=globalThis.GM_fetch,Ur(t)):vt({method:"fetch",data:t})}function qn(){return ye()?Xt():vt({method:"getConfig"})}function gn(t){return ye()?hs(t):vt({method:"setUserConfig",data:t})}function mn(){return ye()?qr():vt({method:"getUserConfig"})}function Es(){return ye()?Jt():vt({method:"getLocalConfig"})}function Gl(t){return ye()?Ht(t):vt({method:"setLocalConfig",data:t})}function Q1(t){return ye()?kl(t):vt({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=zl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||it()){if(t.translateService&&!Du.includes(t.translateService))return Promise.resolve("auto");let r=z1(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await vt({method:"detectLanguage",data:t});return Promise.resolve(e)}function Z1(){return vt({method:"detectTabLanguage"})}async function Vl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||it()){let n=t.substring(0,200);e=await Wr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function K1(t){let e=new CustomEvent(Oa,{detail:t});if(document.dispatchEvent(e),ye())return;Wl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function J1(t){return ye()?W1(t):vt({method:"queryParagraphCache",data:t})}async function X1(t){if(ye()){await H1(t);return}return vt({method:"setParagraphCache",data:t})}async function e2(){if(ye())return Promise.resolve();await vt({method:"mockRequest"})}function Yi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):vt({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function $l(t=""){return ye()||it()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function Mp(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Yl(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):vt({method:"openAboutPage"})}function Qi(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):vt({method:"openInTab",data:t})}function t2(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):vt({method:"openEbookViewerPage"})}function n2(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):vt({method:"openEbookBuilderPage"})}function r2(t){it()}function Zi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):vt({method:"openPdfViewerPage",data:{url:e}})}function a2(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):vt({method:"openSubtitleBuilderPage"})}function Ji(t){return ye()?Promise.resolve():vt({method:"setBadge",data:{text:t}})}function i2(){return ye()?(z.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):vt({method:"autoSyncLatestConfig"})}function Ql(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function o2(t,e){return ye()?$i.getDelay(t,e):vt({method:"getDelay",data:{key:t,options:e}})}function s2(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return!!(r&&e.hostname===r)}function Zl(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return r&&e.hostname===r?!0:!(Bp(t)||e.protocol!=="http:"&&e.protocol!=="https:"&&e.protocol!=="file:"&&e.protocol!=="data:")}function Bp(t){try{return new URL(t)?.pathname.toLowerCase().endsWith(".pdf")}catch{return!1}}d();d();d();d();var Ip={get:(t,e,n)=>{let r=e===void 0?t:{[t]:e};return oe.storage[n].get(r)},set:(t,e,n)=>oe.storage[n].set({[t]:e})};function Jl(t,e,n){let[r]=re(()=>typeof e=="function"?e():e),[a]=re(n),[i,o]=re(r),[s,u]=re(!1),[l,c]=re("");Ce(()=>{Ip.get(t,r,a).then(g=>{g[t]&&o(g[t]),u(!0),c("")}).catch(g=>{u(!1),c(g)})},[t,r,a]);let p=Ve(g=>{let m=typeof g=="function"?g(i):g;z.debug("new settings",m),Ip.set(t,m,a).then(()=>{o(m),u(!0),c("")}).catch(f=>{o(m),u(!1),c(f)})},[a,t,i]);return[i,p,s,l]}d();function Rp(t,e,n){let r=[];return function(){let[i,o,s,u]=Jl(t,e,n),l=Ve(c=>{for(let p of r)p(c)},[]);return Ce(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function u2(t,e){return Rp(t,e,"sync")}var OD="userConfig",zD=null,ND=u2(OD,zD);function rr(t){let[e,n,r,a]=ND(),i=Ve(o=>{let s=typeof o=="function"?o(e):o;s&&(s.updatedAt=new Date().toISOString()),n(s),t&&t(s)},[e]);return[e,i,r,a,n]}d();d();d();var Xi={},UD={root:"",lang:"en",fallbackLang:"en"};function Op(t,e){let n=Object.assign({},UD,t);Xi=e||Xi;let[r,a]=re(n.lang),[i,o]=re(Xi),[s,u]=re(!1),l=p=>{if(i.hasOwnProperty(p))return;u(!1);let g=H3(n.root||"",p);n.getUrl&&(g=n.getUrl(n.root||"",p),fetch(g).then(m=>m.json()).then(m=>{Xi[p]=m,o({...Xi}),u(!0)}).catch(m=>{o({...Xi}),u(!0)}))};return Ce(()=>{l(n.fallbackLang||"en"),l(r)},[r]),{lang:r,setLang:a,t:(p,g)=>{if(!i.hasOwnProperty(r))return p;let m=gs(i,r,p);return m===p&&r!==n.fallbackLang&&(m=gs(i,n.fallbackLang,p)),pp(m,g)},isReady:s}}d();d();var qD=0;function w(t,e,n,r,a){var i,o,s={};for(o in e)o=="ref"?i=e[o]:s[o]=e[o];var u={type:t,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--qD,__source:a,__self:r};if(typeof t=="function"&&(i=t.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Fe.vnode&&Fe.vnode(u),u}var Np=hi(null),zp={root:"assets",lang:"en",fallbackLang:"en"},eo=t=>{let{t:e,setLang:n,lang:r,isReady:a}=Op({root:t.root||zp.root,lang:t.lang||zp.lang,fallbackLang:t.fallbackLang||zp.fallbackLang,getUrl:t.getUrl},t.translations);return w(Np.Provider,{value:{t:e,setLang:n,lang:r,isReady:a},children:t.children})};function xe(){return du(Np)}d();var jD=function(t,e){let{method:n,data:r}=t;z.debug(`popup received message: ${n}`,r||" ");let a;e.active&&(a=e.id,globalThis.document.dispatchEvent(new CustomEvent(Mo,{detail:{tabId:a,payload:t}})))},Xl;function l2(){Cs()}function Cs(){return Xl||(Xl=new br("popup",!1).getConnection("main_sync",jD),Xl)}d();d();function c2(t,e=2e3){return n=>{let r,a=0;return i=>{++a==t&&(n(i),a=0),clearTimeout(r),r=setTimeout(()=>a=0,e)}}}d();var ec="DROP_DOWN_DEFAULT_VALUE";function Up(t){let{showArrow:e,onSelected:n,className:r,menus:a,maxWidth:i,style:o}=t;r=r||"",e=e??!0,i=i||80;let s=qe(null);return w("select",{ref:s,autoComplete:"off",class:`min-select ${e?"":"min-select-no-arrow"} ${r||""}`,value:ec,style:{maxWidth:`${i}px`,...o},onChange:u=>{u.preventDefault();let l=u.target.value;if(s.current&&l!==ec){s.current.value=ec,s.current?.dispatchEvent(new Event("change"));let c=a.find(p=>p.value===l);c&&n(c)}},children:[{value:ec,label:t.label}].concat(a).map((u,l)=>w("option",{value:u.value,children:u.label},"option-"+l))})}d();d();function to(t,e){return t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})>=0}var HD=({date:t})=>{let{t:e}=xe(),[n,r]=re(!1);return Ce(()=>{setTimeout(()=>{r(!0)},5e3)},[]),n?null:w("p",{class:"text-sm",children:[e("Successfully synchronized with the latest official rules:")," ",new Date(t).toLocaleString()]})},WD=({minVersion:t})=>{let{t:e}=xe();return w("p",{class:"text-sm",children:e("localVersionIsTooOld",{minVersion:t})})},KD=()=>{let{t}=xe();return w("p",{class:"text-sm",dangerouslySetInnerHTML:{__html:t("badUserscriptBrowser",{1:"https://immersivetranslate.com/docs/installation/"})}})},GD=({message:t,handleSyncing:e,date:n})=>{let{t:r}=xe();return w("p",{class:"text-sm",children:[r("failToSyncRules")," ",w("a",{onClick:e,children:r("retry")}),w("br",{}),r("failedReason"),"\uFF1A",t,w("br",{}),r("currentRuleVersion"),"\uFF1A",n]})};function qp(t){let{isShowError:e,request:n}=t,[r,a]=re(null),{t:i}=xe(),[o,s]=re(null),[u,l]=re(null),[c,p]=re(""),[g,m]=re(!1),[f,T]=re(!1),[b,h]=re(!1),[C,D]=re(null),[M,B]=re(null),S=Sn(),y=async()=>{p("");let _=o;if(o===null)try{let k=await n({url:Bo});k?(s(k),_=k,m(!0)):(p(i("unknownError")),l(null))}catch(k){l(null),p(k.message);return}_!==null?(t.setStorageBuildinConfig(_),l(!1),a(_.buildinConfigUpdatedAt)):(p(i("canNotFetchRemoteRule")),l(null))};return Ce(()=>{Xt().then(_=>{let k=_.buildinConfigUpdatedAt;D(_);let v=new Date(k);if(a(k),S==="0.0.0"){h(!0);return}n({url:Bo}).then(I=>{let F=I,L=F.minVersion,U=S;s(F);let N=F.latestVersion;if(N&&(to(U,N)?B(!0):B(!1)),to(U,L)){let q=F.buildinConfigUpdatedAt;new Date(q)>v?(l(!0),y()):l(!1)}else T(!0),l(null)}).catch(I=>{l(null),p(I.message)})})},[]),Ce(()=>{Xt().then(_=>{D(_)})},[r]),C?w("div",{class:"text-sm mt-2",style:{maxWidth:218},children:b?w(KD,{}):c?e===!1?null:w(GD,{handleSyncing:y,message:c,date:r||""}):f?e===!1?null:w(WD,{minVersion:o.minVersion}):u===null||u===!0?null:g?w(HD,{date:r}):null}):null}d();function VD(){return navigator.userAgent.indexOf("Mac")!==-1}var d2={Alt:"\u2325"};function tc(t=""){return VD()?Object.keys(d2).reduce((e,n)=>e.replace(n,d2[n]),t):t}d();d();var nc='',p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0ZGQzczNiIgZD0iTTMgN2gxN3YxMEgzeiIvPjxwYXRoIGZpbGw9InVybCgjYSkiIGQ9Ik02Ljg5NyA5LjI0MmMuNDE1IDAgLjcyLjExMS45MjguMzQ3LjIwNy4yMzUuMzE4LjUyNy4zMTguODczcy0uMTEuNjIzLS4zMTguODQ1Yy0uMjA4LjIyMi0uNTI3LjMzMy0uOTI4LjMzM2gtMS4zM1Y5LjI0MmgxLjMzWm05Ljg0NiAxLjc4OGMuMzg4IDAgLjY2NS4xNTIuODQ1LjQ1Ny4xNTIuMjY0LjIzNS41ODIuMjYzLjk4NHYuMzE5YzAgLjQ5OS0uMDgzLjg4Ny0uMjYzIDEuMTkyLS4xOC4zMDQtLjQ1Ny40NTctLjgzLjQ1Ny0uMzg5IDAtLjY2Ni0uMTUzLS44NDYtLjQ0NC0uMTUyLS4yNjMtLjIzNS0uNTk1LS4yNjMtMS4wMTF2LS4yOTFjMC0uNDg1LjA4My0uODczLjI2My0xLjE3OC4xOC0uMzA1LjQ0My0uNDg1LjgzMS0uNDg1Wm0tMy40MDctMS4xMzZhMS4xNyAxLjE3IDAgMCAwLS43MDYuMjM1IDEuNDgyIDEuNDgyIDAgMCAwLS40MTUuNWwtLjA4My4xNjUtLjA3LS44MDNoLTEuMzU3djUuNDMyaDEuNDU0di0zLjY1OWEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiA4LjEySDQuMTE0djcuMzE3aDEuNDY4VjEyLjc5aDEuMzNjLjg0NCAwIDEuNDk1LS4yMDggMS45OC0uNjM4LjQ4NS0uNDMuNzItLjk4My43Mi0xLjY5cy0uMjM1LTEuMjYxLS43Mi0xLjY5Yy0uNDQzLS4zODktMS4wMzktLjYxLTEuNzczLS42MzhsLS4yMjEtLjAxNFptOS44NDcgMS43NzRjLS44MDMgMC0xLjQyNi4yNjMtMS44ODMuNzc2LS40MTYuNDctLjYzNyAxLjA2Ny0uNjc5IDEuNzczdi4zMzNjMCAuODE4LjIyMiAxLjQ4My42NzkgMS45OTUuNDU3LjUxMyAxLjA4Ljc3NiAxLjg4My43NzYuODA0IDAgMS40MjctLjI2MyAxLjg4NC0uNzc2LjQxNS0uNDcuNjM3LTEuMDUzLjY3OC0xLjc3M3YtLjMzM2MwLS44MTctLjIyMS0xLjQ4Mi0uNjc4LTEuOTk1LS40NTctLjUxMy0xLjA4LS43NzYtMS44ODQtLjc3NlpNMTguMDAzIDZhNiA2IDAgMCAxIDAgMTJIMFY5LjQyM0EzLjQyIDMuNDIgMCAwIDEgMy40MiA2aDE0LjU4M1oiLz48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSI3LjUiIHgyPSIyMiIgeTE9IjE5IiB5Mj0iNiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyMjIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM2OTY5NjkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=",g2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIxMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzk5OSIgZD0iTTYuODk3IDMuMjQyYy40MTUgMCAuNzIuMTExLjkyOC4zNDcuMjA3LjIzNS4zMTguNTI2LjMxOC44NzMgMCAuMzQ2LS4xMS42MjMtLjMxOC44NDUtLjIwOC4yMjItLjUyNy4zMzMtLjkyOC4zMzNoLTEuMzNWMy4yNDJoMS4zM1ptOS44NDYgMS43ODhjLjM4OCAwIC42NjUuMTUyLjg0NS40NTcuMTUyLjI2NC4yMzUuNTgyLjI2My45ODR2LjMxOWMwIC40OTktLjA4My44ODctLjI2MyAxLjE5Mi0uMTguMzA0LS40NTcuNDU3LS44My40NTctLjM4OSAwLS42NjYtLjE1My0uODQ2LS40NDQtLjE1Mi0uMjYzLS4yMzUtLjU5NS0uMjYzLTEuMDExdi0uMjkxYzAtLjQ4NS4wODMtLjg3My4yNjMtMS4xNzguMTgtLjMwNS40NDMtLjQ4NS44MzEtLjQ4NVptLTMuNDA3LTEuMTM2YTEuMTcgMS4xNyAwIDAgMC0uNzA2LjIzNSAxLjQ4MiAxLjQ4MiAwIDAgMC0uNDE1LjVsLS4wODMuMTY1LS4wNy0uODAzaC0xLjM1N3Y1LjQzMmgxLjQ1NFY1Ljc2NGEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiAyLjEySDQuMTE0djcuMzE3aDEuNDY4VjYuNzloMS4zM2MuODQ0IDAgMS40OTUtLjIwOCAxLjk4LS42MzguNDg1LS40My43Mi0uOTgzLjcyLTEuNjlzLS4yMzUtMS4yNjEtLjcyLTEuNjljLS40NDMtLjM4OS0xLjAzOS0uNjEtMS43NzMtLjYzOGwtLjIyMS0uMDE0Wm05Ljg0NyAxLjc3NGMtLjgwMyAwLTEuNDI2LjI2My0xLjg4My43NzYtLjQxNi40Ny0uNjM3IDEuMDY3LS42NzkgMS43NzN2LjMzM2MwIC44MTguMjIyIDEuNDgzLjY3OSAxLjk5NS40NTcuNTEzIDEuMDguNzc2IDEuODgzLjc3Ni44MDQgMCAxLjQyNy0uMjYzIDEuODg0LS43NzYuNDE1LS40Ny42MzctMS4wNTMuNjc4LTEuNzczdi0uMzMzYzAtLjgxNy0uMjIxLTEuNDgzLS42NzgtMS45OTUtLjQ1Ny0uNTEzLTEuMDgtLjc3Ni0xLjg4NC0uNzc2Wk0xOC4wMDMgMGE2IDYgMCAwIDEgMCAxMkgwVjMuNDIzQTMuNDIgMy40MiAwIDAgMSAzLjQyIDBoMTQuNTgzWiIvPjwvc3ZnPg==";var m2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAn1BMVEUAAADt7vHu7vLu7vLv7+/n5+fFxcXu7vHv7/PHx8eamprt7fLt7fHn5+vGxsbS09Surq6fn5+ZmZmZmZnGxsbGxsbt7/K/v7/Hx8ft7vHGxsaZmZn09vnk5eeqqquenp7p6u3X2NnLy8vU1dbr7O67u7uvr6/o6evh4uPR0dLCwsLAwMDZ2ty9vb6kpaWhoaHe3+HPz8+zs7OkpKTc3d7Gt0R8AAAAGXRSTlMA779wIBDv338gv5+AgHDv7+/v36+gn3BgD0kJmgAAAS1JREFUKM9dkOmSgyAQhNFo7mTvYwYEBa9oorne/9l2hqJSbr4q+NHNdBcjAukyXgBE8SwRU5IYHmwm1iyCCdFMBJbwxDK8B2iKLGjl8VAC+JmEcqzRrmnP5yzrbm93SuOeDQCcpNToGaV8ISGmAfBGPce+qjrsjSxYSbkBGtt1tZGEueLpwsZW8A8snlj2jD0efRZVtxzw4Ia2BFgIch1qOaHCM4lsHHA0WpOpKyk7qX2WWLBhhhxU7grlKlV7I+LyAm+DUplS/sqv2HL5FiDDSio15CQOdHrrl5L6kpqEMOHwTlIiOKu0WIDy5Bfkn3+HJTYXRNdmWXtA1nmJfu1lgRNcQw2encV/2J0I7OdIXM1YIzH/FQ9WX4i1JF4RP1dBDNZ+/S7lx/onDcIfdi8x4pYpSxgAAAAASUVORK5CYII=",f2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAA51BMVEUAAABRT2tSUGpRT2tQUHBQUGjwtcxRT2tRUGtST2tSTmrvsMnvt89QUHDqTIpkXHhST2zQobmfdpPrTYrGVoHqS4nwtszvtMzvtc3vr89RT2vwtczASHb09vnIXYbt4OncqMDqTInGVoBbVnHqp8GqiKJlXHfz2+bsrsfkmrfIm7SggpvScZfKaY/q1uDtgKvRiKaNdY/MY4vy7fLy5Ozxydrxw9bhtcjnobzVlK/diam0j6jYfqHVeJyXfJWcd5TrXJOCb4l5aYNvYn3DUXzxzd3kwNDSorrth6/CjqnAeZnNdJaDb4nDaCDkAAAAGnRSTlMA73C/ICDv37+ff3AgEL+AgO/v7+/fr6BgELJb3PQAAAE/SURBVCjPXZHnUsMwEIRlOySkhw66k+24YScx6b0XOu//PJw0mozh+6Efu6ddzYlpqiWrwLlhmTmW5cLiZ4oZyzR4BsNkmhL/R0nPcx6FR6357ZbPuanyKefT62yjn37/cJwPbjeUJnuKNPeFuAaFjXhNgkUXONHDdR6CJIkh8HArlSo1UIUbx6sTEt4CZlfSaLBLOl2YeaixA2irLKrey4AzA4jpXQVG7hI6mCGBPonSaIF9StMUMe0hzrGjslhBGp7tDIUzfRPTnvhWhiHLQxjYQrwIoQ5nAXtZ3uD8AAkKYTsk0sAocNVSqqpkRaK+MYYNSTkms3wXXodCMZpAKD9FLzF6Bxg/ExMgXS+RluKHkGEZUYOi7sIf3DrTlPNAfOx2XSDyj+xM5QGg2yTIua+wLJVy7abZvKuVn7TwCyKmN+3PjJblAAAAAElFTkSuQmCC",h2="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9IkZyYW1lIj4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTguNzEwMjMgMTMuMzg3NkwxMy4yODkzIDguODA4NkwxNC4wOTc3IDguMDAwMjJMMTMuMjg5NyA3LjE5MjIyTDguNzEwMjMgMi42MTI3OUw3LjkwMjIzIDMuNDIwNzlMMTEuOTA5NSA3LjQyODc5SDEuOTA1NjZWOC41NzE2NUgxMS45MDk1TDcuOTAxODUgMTIuNTc5M0w4LjcxMDIzIDEzLjM4NzZaIiBmaWxsPSIjODM4MzgzIi8+CjwvZz4KPC9zdmc+Cg==";function b2({config:t,isLogin:e,isProUser:n}){let{t:r}=xe();return ml(t)?w("div",{}):w("div",{class:"flex items-center",children:[w("a",{class:"flex items-center text-decoration-none",target:"_blank",href:e?ku:r4,children:[w("img",{src:e?f2:m2}),w("span",{class:"text-xs ml-2 text-label",children:r(e?"loggedIn":"notLogin")})]}),w("a",{title:r(n?"popup.openProForPro":"popup.openPro"),target:"_blank",class:"ml-2",href:n?ku:a4,children:w("img",{src:n?p2:g2})})]})}d();d();var T2={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},y2={...Ot,"zh-CN":{...T2["zh-CN"],...Ot["zh-CN"]},"zh-TW":{...T2["zh-TW"],...Ot["zh-TW"]}},rc=y2;function no(t,e,n){return hr(y2,t,e,lr,n)}var fa=(t,e,n,r)=>{let a=Yh[t]||t,i=Qh[t],o=Zh[t],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[t]?s[t]:a;if(s[e]){let u=s[e];return r||t==="auto"||t==="placeholder"?u:`${u} (${a})`}else return a};d();d();d();d();d();function jp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(Vh),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${Fd}-theme-${t}`):a.push(`${_d}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(Fd):a.push(_d),a}function Hp(t){let e=["notranslate",wu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function v2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Za(n,!0),g="afterend",m=p[0],f=p[1],T=`${m}(\\d+)${f}`,b=new RegExp(T,"g"),h=rt.sanitize(u);o.length>0&&(h=h.replace(b,B=>{let S=h.indexOf(B),y=h[S-1]===" ",_=h[S+B.length]===" ",v=B.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),I=Number(v);if(isNaN(I))return B;let F=o[I];if(F&&F.type==="element"){let L=F.value.outerHTML;return y||(L=" "+L),_||(L=L+" "),L}else z.error("variable type not supported",F,B);return B}));let C=jp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&C.push(Gh);let D=Hp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${C.join(" ")}" ${ur}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${ur}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ur}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function ac(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";g&&(T=ca(Wp(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let C=Kp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",B=Ts(C+D+M),S=B[0]+h+B[1];if(C===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=Ts(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Kp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);g&&(b=ca(Wp(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",C=Ts(T+b+h),D=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(T===" ")D=D.trimStart();else{let M=Ts(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Kp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Wp(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}t.targetText=rt.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` +`,wrapperSuffix:"
"},{id:"bing",matches:"https://*.bing.com/search*",extraInlineSelectors:["a","i"],globalStyles:{"[class*='lineclamp'],.b_title":"-webkit-line-clamp:unset;"}},{id:"yahoo",matches:"*.yahoo.*",excludeSelectors:["._ys_jiqava","#ybar-inner-wrap","#Col2-5-Rmp-Proxy"],extraBlockSelectors:[".SIPGg",".sc-kzMCTH.pSZXj"],globalStyles:{"#atomic .Mt\\(20px\\)":"margin-top: 100px;","[class*='LineClamp']":"-webkit-line-clamp:unset;max-height:unset;","a[class*='js-content-viewer']> div[class*='Td\\(n\\)']":"overflow: scroll;","[class*='_ys_24482e']":"-webkit-line-clamp:unset;","#Aside > :first-child":"overflow:scroll;"}},{id:"wsj",matches:"www.wsj.com",excludeSelectors:["header","footer","nav","[aria-label='Markets summary']"]},{id:"businessinsider",matches:"www.businessinsider.com",excludeSelectors:["header","nav","section.live-updates-module "]},{id:"goodreads",matches:"www.goodreads.com",excludeSelectors:[".badgeYear",".gr-mediaBox__desc",".bookVotedRow",".minirating","div[itemprop='aggregateRating']",".wtrButtonContainer",".RatingsHistogram__labelTitle",".FollowButton",".siteHeader__topLevelLink","#books > thead","td[class*='rating']","td[class*='shelves']","td[class*='date_read']","td[class*='date_added']","td[class*='actions']"]},{id:"feeder",matches:"https://feeder.co/*",globalStyles:{".item-summary":"-webkit-line-clamp:unset;"}},{id:"elektrotechnik",matches:"https://www.elektrotechnik.rwth-aachen.de/*",globalAttributes:{"[class='notranslate']":{class:""}}},{id:"nytimes",matches:"www.nytimes.com",excludeSelectors:["#app > div > div > header","#app > div > div > div > div > header","#in-story-masthead"],injectedCss:["a::after {position:relative!important;}"]},{id:"bugsKde",matches:"bugs.kde.org","excludeTags.remove":["svg","PRE"],additionalExcludeSelectors:[".bz_first_comment_head",".bz_comment_head",".related_actions"]},{id:"eastmoney",matches:"guba.eastmoney.com",searchEnhancementConfig:[{id:"eastmoney",urlMatch:"guba.eastmoney.com/news,us\\w+,\\w+.html",delayTime:0,selector:".moneyFlowContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"guba.eastmoney.com/news,us(\\w+?),\\S+.html"}]},showCount:8},{id:"eastmoney",urlMatch:"guba.eastmoney.com/list,us\\w+.*.html",delayTime:0,selector:".qualityContentContainer",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#294688",title:"font-size:14px;color:#294688;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin:0px 0 16px;",more:"color:#294688;margin-top:8px;"},keyword:{value:"[0]$1:[0]$2",matches:[{source:{type:"selector",attribute:"href"},matchRegex:"code=(\\w+)_(\\w+)",match:"a[href*='rank/stock?code=']"}]},showCount:8}]},{id:"xueqiu",matches:"xueqiu.com",searchEnhancementConfig:[{id:"xueqiu",urlMatch:"xueqiu.com/S/[a-zA-Z]+/?$",delayTime:0,selector:".container-side-sm.float-right.stock__side",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;padding:0;",source:"font-size:12px; margin-bottom: 0px;",keyword:"color:#06c",title:"font-size:14px;color:#06c;",enTitle:"margin-top:4px;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;font-weight: bold;",time:"margin:0px 0 16px;",more:"color:#06c;margin-top:8px;"},showCount:8,keyword:{value:"[0]$1",matches:[{source:{type:"selector",attribute:"text"},matchRegex:"\\((.+)\\)",match:".stock-name"}]}}]},{id:"laohu8",matches:"www.laohu8.com",searchEnhancementConfig:[{id:"laohu8",urlMatch:"www.laohu8.com/stock/[a-zA-Z]+/?$",delayTime:0,selector:".hot-stocks-root",selectorAction:"insertBefore",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 0px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 0px 0 16px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)"}]},showCount:8}]},{id:"futunn",matches:"www.futunn.com",searchEnhancementConfig:[{id:"futunn",urlMatch:"www.futunn.com/stock/\\w+-US",delayTime:0,selector:".right",selectorAction:"appendChild",style:{container:"background:white;border:none;border-radius: 4px;box-shadow: 0 2px 4px hsla(216,5%,62%,.14);",source:"font-size:12px; margin-bottom: 4px;",title:"font-size:14px;color: #007bff;",enTitle:"margin-top:4px;color: #4d5156;font-size:12px;",searchTitle:"margin:4px 0 16px;position:relative;padding-right:24px;font-size: 16px;",time:"margin: 4px 0 20px;"},keyword:{value:"[0]$1 stock",matches:[{source:"url",matchRegex:"stock/([a-zA-Z]+)-US"}]},showCount:8}]},{id:"bmvrMarseille",matches:"www.bmvr.marseille.fr",globalStyles:{"a > div":"display:block;","[style*='358px;']":"width: 33.3333%; height: auto; padding: 0px; position: relative; margin: 0px;"},globalAttributes:{"#app":{class:""}}},{id:"piAi",matches:"pi.ai/talk",globalStyles:{"[class*='text-brand-green']":"flex-direction:column;"}},{id:"claudeAi",matches:"claude.ai",excludeSelectors:[".contents *"],"excludeTags.remove":["PRE"],injectedCss:"[data-testid='chat-menu-trigger'] br {display:none;}",aiRule:{messageWrapperSelector:".contents",messageContainerSelector:".ReactMarkdown",messageStreamEndSelector:".contents > button",streamingChange:!0,streamingDeepChild:!1,streamingDelayTime:1e3}},{id:"feishu",matches:["*.feishu.cn","*.larkoffice.com","*.larksuite.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],mutationObserverLimitTargetSelectors:[".maindocbody","div[class*='render']","div[class*='block']"],"excludeSelectors.add":[".catalogue__list"]},{id:"gitbook",selectorMatches:[".gitbook-root"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"],"additionalExcludeSelectors.add":["[spellcheck='false']"]},{id:"mitre",matches:"cwe.mitre.org",globalStyles:{"span.list_entry":"height: unset;"}},{id:"kaggle",matches:"www.kaggle.com",excludeTags:["i","button"]},{id:"ieee",matches:"spectrum.ieee.org",extraBlockSelectors:["small"]},{id:"ieeexplore",matches:"ieeexplore.ieee.org",stayOriginalSelectors:["a[ref-type]",".inline-formula",".display-formula"]},{id:"cnn",matches:"*.cnn.com","excludeSelectors.add":[".ad-slot-header__wrapper","#pageFooter"],"bodyRule.add":{bodySelector:".layout__content-wrapper",articleSelector:".article__content-container"}},{id:"marginalrevolution",matches:"marginalrevolution.com",globalAttributes:{header:{translate:"unset;"}}},{id:"highfrequencyelectronics",matches:"www.highfrequencyelectronics.com",globalStyles:{"#main-content":"overflow:unset;"}},{id:"githubBlog",matches:"github.blog",globalStyles:{".font-mktg":"word-break:normal;"}},{id:"semanticscholar",matches:"www.semanticscholar.org",selectors:[".cl-paper-title",".cl-paper-abstract",".tldr-abstract-replacement",".text-truncator",".paper-detail-title"]},{id:"uni-trier",matches:"dblp.uni-trier.de",selectors:["h1","h2",".title",".external","dd p"],excludeSelectors:[".side-column"]},{id:"bilibili",matches:"www.bilibili.com","excludeSelectors.add":[".bpx-player-subtitle-panel-text"],"subtitleRule.add":{type:"bilibili",subtitleUrlRegExp:"aisubtitle.hdslb.com/bfs",loadingContainerSelector:".bpx-player-subtitle-panel"}},{id:"time",matches:"time.com",excludeSelectors:[".date-and-duration"],globalStyles:{".headline":"-webkit-line-clamp:unset;overflow:unset;height:unset;",h3:"-webkit-line-clamp:unset;overflow:unset;",p:"-webkit-line-clamp:unset;overflow:unset;"}},{id:"docs-swift",matches:"docs.swift.org",selectors:[".content","#menu"]},{id:"uzh",matches:"www.uzh.ch",injectedCss:[".TextImage--inner {overflow:auto !important;}"]},{id:"mail-yandex",matches:"mail.yandex.com",selectors:["article",".Text_color_primary",".mail-MessageSnippet-Item_subject"],globalStyles:{".mail-MessageSnippet":"height: unset; line-height:unset;",".immersive-translate-target-translation-block-wrapper":"margin:unset;"}},{id:"forums.zotero",matches:"forums.zotero.org",selectors:[".page-sidebar",".page-content"]},{id:"pubmed.ncbi.nlm.nih.gov",matches:"pubmed.ncbi.nlm.nih.gov",urlChangeDelay:0,excludeSelectors:[".docsum-journal-citation",".citation-part",".docsum-authors",".top-wrapper",".article-source",".citation-doi",".identifiers",".cite",".share",".arrow-link"],globalAttributes:{"#Scholarscope_HighlightContent":{class:""},"#Scholarscope_HighlightOrigin":{class:"Scholarscope_HighlightContents"}},mutationExcludeContainsSelectors:["#Scholarscope_HighlightContent highlight"],mutationExcludeSelectors:["#Scholarscope_HighlightContent","#Scholarscope_HighlightContent span"],injectedCss:["#Scholarscope_HighlightOrigin > p font,#Scholarscope_HighlightContent > p font {display: inline!important;}","#Scholarscope_HighlightOrigin > p font br,#Scholarscope_HighlightContent > p font br {display: none!important;}"]},{id:"chosun",matches:"www.chosun.com",injectedCss:"body {word-break: unset!important;}"},{id:"yna",matches:"*.yna*",injectedCss:["font > br {display:none}"],globalStyles:{"a,strong":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;","div,p,li,.item-box01,.news-con":"height:unset;max-height:unset;-webkit-line-clamp:unset;"},"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"cnet",matches:"www.cnet.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"dolmods",matches:"dolmods.net",globalStyles:{"[class*='max-h']":"max-height:unset!important;"}},{id:"digitimes",matches:"www.digitimes.com",globalStyles:{"a,.title,.abstract,.display-5,.top":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeSelectors.add":[".main-nav-frame",".sub-header-wrapper",".footer",".date"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"vdi-nachrichten",matches:"www.vdi-nachrichten.com","excludeSelectors.add":[".header-menu__item > a",".linkbar__item",".header__button-group"]},{id:"htdp",matches:"htdp.org",excludeTags:["blockquote"],stayOriginalSelectors:[".RktIn"]},{id:"newsletterss",matches:"newsletterss.com",initialGlobalAttributes:{iframe:{scrolling:"auto"}}},{id:"docusaurus",selectorMatches:["#__docusaurus"],"excludeSelectors.add":["aside",".DocSearch-Modal"]},{id:"mercari",matches:"*.mercari.com","excludeTags.remove":["PRE"]},{id:"qqMail",matches:"mail.qq.com",useIframePostMessage:!1},{id:"nikkei",matches:"www.nikkei.com",globalStyles:{"h3,div,span,p":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"}},{id:"pubs.rsc.org",matches:"pubs.rsc.org",excludeSelectors:[".eqn"]},{id:"indeed",matches:"*.indeed.com",globalStyles:{"span,.css-19rjr9w.e1wnkr790":"max-height:unset;-webkit-line-clamp:unset;height:unset;white-space:unset;"},"excludeTags.remove":["BUTTON"]},{id:"brutalist",matches:"brutalist.report",selectors:["li > a:first-child","aside","nav > a","h1 > a","h3 > a","h2 >a"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"maxroll",matches:["maxroll.gg"],extraInlineSelectors:[".d4t-sprite-icon",".d4t-icon"],injectedCss:["font {font-family: sans-serif !important;}"]},{id:"microsoftTeams",matches:["teams.live.com"],"stayOriginalSelectors.add":["span[title][style='min-width: 20px; height: 20px;']"]},{id:"gradioappdocs",matches:"www.gradio.app/docs/*",selectors:["div.obj"],excludeSelectors:["div#examples"]},{id:"arca",matches:"arca.live","excludeTags.remove":["PRE"]},{id:"chatpdf",matches:["www.chatpdf.com"],"additionalExcludeSelectors.remove":[".notranslate"],excludeSelectors:[".chat-message-row.ai *",".pdf-viewer"],aiRule:{streamingSelector:"",messageWrapperSelector:".chat-message-row.ai",streamingChange:!1,streamingDeepChild:!0,streamingDelayTime:1e3}},{id:"inciteful",matches:["inciteful.xyz"],"excludeTags.remove":["BUTTON"]},{id:"app.element.io",matches:["app.element.io"],"additionalExcludeSelectors.remove":[".notranslate"],"excludeSelectors.add":[".mx_DisambiguatedProfile",".mx_ReplyChain_wrapper",".mx_ThreadSummary_replies_amount"]},{id:"fastapi.tiangolo.com",matches:"fastapi.tiangolo.com",selectors:["article"]},{id:"termynal",selectorMatches:["link[href*='termynal.css']"],"stayOriginalSelectors.add":[".termy"]},{id:"cpb-nl",matches:["www.cpb.nl"],"bodyRule.add":{enable:!1}},{id:"hub.logseq",matches:["hub.logseq.com"],globalStyles:{"[class*=':h-[']":"height:unset;"}},{id:"chat.zalo",matches:["chat.zalo.me"],"additionalExcludeSelectors.remove":[".notranslate"],inputExecCommandDeleteEnable:!0,"inputConfig.add":{execCommandDeleteEnable:!0}},{id:"epam",matches:"*.epam.com",globalStyles:{"[class*='ContentAnchorLinkList']":"word-break:unset;"},"excludeSelectors.add":["#blog-page-sidebar-wrapper"],"excludeTags.remove":["BUTTON"]},{id:"discussions.apple",matches:"discussions.apple.com","excludeSelectors.add":[".page-number"]},{id:"www.sixthtone.com",matches:["www.sixthtone.com"],"excludeSelectors.add":["#footer","[class^=index_time]","[class^=index_anthorList]","[class^=index_node]","[class^=index_popupWrapper]"]},{id:"forum.unity",matches:["forum.unity.com"],"excludeSelectors.add":[".bbCodeCode"]},{id:"wattpad",matches:["www.wattpad.com"],"excludeTags.remove":["PRE"],globalAttributes:{header:{translate:"unset;"}},globalStyles:{".story-info .item-description":"overflow: scroll;"}},{id:"netflix",matches:["www.netflix.com"],"excludeSelectors.add":[".player-timedtext"],"mutationExcludeSelectors.add":[".player-timedtext *"],"subtitleRule.add":{type:"netflix",loadingContainerSelector:".watch-video",subtitleUrlRegExp:"^https://.+?.oca.nflxvideo.net/\\?([ovet]=[^=]+){4}$",loadingStyle:"bottom: 15%;",quickButtonRule:{appendSelector:'[data-uia="control-next"]',insertBeforeSelector:'[data-uia="control-next"]',injectCSS:".imt-quick-subtitle-button {height: 60%; margin-right: 50px; font-size: 20px; } .logo,.logo svg { height: 36px; width: 36px} .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(50%); right: 0}"},videoSelector:"video",attachRule:{appendSelector:".watch-video",injectedCSS:[".imt-caption-window {margin-bottom: 0px; bottom: 10vw;}"],injectedGlobalCSS:[".player-timedtext {display: none !important; }"]}}},{id:"udemy",matches:["www.udemy.com"],"excludeSelectors.add":["[data-purpose='captions-cue-text']",".shaka-text-container"],"mutationExcludeSelectors.add":["[data-purpose='captions-cue-text'] *",".shaka-text-container *"],"subtitleRule.add":{type:"udemy",subtitleUrlRegExp:"^https://vtt.*\\.udemycdn\\.com/.*\\.vtt",videoPlayerSelector:"video.shaka-video",humanTrust:85,loadingContainerSelector:".shaka-video-container",loadingStyle:"bottom: 15%;",injectedCss:["[class^='well--text'] {white-space: pre;}"],quickButtonRule:{appendSelector:'[data-purpose="video-controls"]'}},"subtitleRule.add_v.[1.4.1]":{hookType:"fetch|xhr"}},{id:"iview",matches:"iview.abc.net.au",excludeSelectors:[".jwplayer"],"mutationExcludeSelectors.add":[".jwplayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/cc/.*\\.(vtt|webvtt)$",loadingContainerSelector:".jwplayer",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:".jw-settings-submenu-button",injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"nmaart",matches:"www.nma.art",excludeSelectors:[".video-container"],"mutationExcludeSelectors.add":[".video-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"/texttrack/.*\\.(vtt|webvtt)",loadingContainerSelector:".video-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"apple",matches:"developer.apple.com",excludeSelectors:[".developer-video-player"],"mutationExcludeSelectors.add":[".developer-video-player *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.(vtt|webvtt)"}},{id:"khanacademy",matches:["www.khanacademy.org"],"subtitleRule.add":{type:"khanacademy",subtitleUrlRegExp:"GetSubtitles",hookType:"fetch"},"stayOriginalSelectors.add":[".mathjax-wrapper"]},{id:"nebula",matches:["nebula.tv"],"excludeSelectors.add":["[data-subtitles-container='true']"],"mutationExcludeSelectors.add":["[data-subtitles-container='true'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:".video-poster",quickButtonRule:{appendSelector:".icon-spacing.css-4yh7a0",insertBeforeSelector:"#subtitles-toggle-button",ccEnableSelector:"#subtitles-toggle-button"}}},{id:"frontendmasters",matches:["frontendmasters.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 2} .imt-quick-subtitle-pop-content {z-index: 2147483647}"],quickButtonRule:{appendSelector:".vjs-control-bar"},videoSelector:".PromoPlayer video",attachRule:{appendSelector:".video-js",injectedGlobalCSS:".vjs-text-track-display {display: none;}"}}},{id:"udacity",matches:["*.udacity.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".vtt$",loadingContainerSelector:".vjs-text-track-display"}},{id:"skillshare",matches:["www.skillshare.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt\\?",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 13}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-volume-panel",injectCSS:" .label { display: none; } .imt-quick-subtitle-pop-content {transform: translateX(43%); right: 0; z-index: 2147483647 } "}}},{id:"domestika",matches:["www.domestika.org"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*subtitles.*\\.vtt",quickButtonRule:{appendSelector:".controlBar-wrapper .right-wrapper",insertBeforeSelector:".vjs-volume-panel"}}},{id:"hbomax",matches:["play.max.com","play.hbomax.com"],"excludeSelectors.add":["[data-testid='playerContainer']","[data-testid='CueBoxContainer']"],"mutationExcludeSelectors.add":["[data-testid='playerContainer'] *","[data-testid='CueBoxContainer'] *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"[data-testid='playerContainer']"}},{id:"mindvalley",matches:["home.mindvalley.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.webvtt$",loadingContainerSelector:".vjs-text-track-display",injectedCss:["#immersive-translate-quick-button-container {order: 6}"],quickButtonRule:{appendSelector:'[data-testid="video-section"] .vjs-control-bar',insertBeforeSelector:'[data-testid="video-section"] .vjs-volume-panel',injectCSS:".imt-quick-subtitle-pop-content {z-index: 999999;}"}}},{id:"masterclass",matches:["www.masterclass.com","learn.microsoft.com"],"excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",loadingContainerSelector:".vjs-text-track-display",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-playback-rate"}}},{id:"viu",matches:["www.viu.com"],"excludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay"],"mutationExcludeSelectors.add":[".bmpui-ui-viu-subtitle-overlay *"],"subtitleRule.add":{type:"webvtt",hookType:"xhr",subtitleUrlRegExp:"https?://[^/]+\\.cloudfront\\.net/[^/]+/[^/]+$",loadingContainerSelector:".bmpui-container-wrapper",loadingStyle:"bottom: 20%;",injectedCss:[".bmpui-controls-hidden #immersive-translate-quick-button-container {display: none;}"],quickButtonRule:{appendSelector:".bmpui-ui-container.bmpui-ui-viu-subtitle > .bmpui-container-wrapper",injectCSS:".imt-quick-subtitle-button {margin-bottom: 8px}"}}},{id:"linkin",matches:"*.linkedin.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*ambry/\\?x-li-ambry-ep=.*",hookType:"xhr",loadingContainerSelector:".video-player-container",quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-toggle"}}},{id:"kanopy",matches:"*.kanopy.com","excludeSelectors.add":[".vjs-text-track-display"],"mutationExcludeSelectors.add":[".vjs-text-track-display *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:".*captioncache/webvtt.*",hookType:"xhr",loadingContainerSelector:".video-player-container",injectedCss:["#immersive-translate-quick-button-container{height: 40px;display: flex;align-items: center;align-self: flex-end;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-caption-control"}}},{id:"iflix",matches:["www.iflix.com","wetv.vip"],"excludeSelectors.add":[".text-track"],"mutationExcludeSelectors.add":[".player-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt",hookType:"xhr",loadingContainerSelector:"#player-wrapper",loadingStyle:"bottom: 18%;",quickButtonRule:{appendSelector:'[data-role="wetv-ctrlbar-right"]',insertBeforeSelector:'[data-role="wetv-player-definition"]'}}},{id:"imdb",matches:"www.imdb.com","excludeSelectors.add":[".jw-text-track-container"],"mutationExcludeSelectors.add":[".jw-text-track-container *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#imdbnext-vp-jw-single",quickButtonRule:{appendSelector:".jw-reset.jw-button-container",insertBeforeSelector:'[button="ttt-button"]'}}},{id:"itv",matches:["www.itv.com"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".genie-video",loadingContainerSelector:".genie-container",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".control-bar_right-child-container",insertBeforeSelector:".controls-toggle_button--fullscreen"}}},{id:"egghead",matches:["egghead.io"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".cueplayer-react-video",loadingContainerSelector:".cueplayer-react-video-holder",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:".cueplayer-react-control-bar-right-part",insertBeforeSelector:".cueplayer-react-closed-caption"}}},{id:"coursera",matches:["www.coursera.org"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:".vjs-tech",loadingContainerSelector:".rc-VideoControlsContainer",loadingStyle:"bottom: unset; top: 5%;",quickButtonRule:{appendSelector:'[role="presentation"] > .rc-ControlBar > .icon-container'}}},{id:"ocrtraining",matches:["ocrtraining.cit.nih.gov","videocast.nih.gov"],"excludeSelectors.add":["#videocastPlayer"],"mutationExcludeSelectors.add":["#videocastPlayer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.srt$",loadingContainerSelector:"#videocastPlayer"}},{id:"espn",matches:["*.espn.com"],mainFrameMinTextCount:0,"excludeSelectors.add":["#fittPageContainer"],"mutationExcludeSelectors.add":["#fittPageContainer *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",injectedCss:["#immersive-translate-quick-button-container{margin-top:16px;}",".vjs-text-track-display > div >div {font:unset!important;}"],quickButtonRule:{appendSelector:".vjs-control-bar",insertBeforeSelector:".vjs-captions-button"}}},{id:"fmoviesz",matches:["fmoviesz.to","vidplay.online","c8365730d4.nl"],"excludeSelectors.add":["#player"],"mutationExcludeSelectors.add":["#player *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"subtitle/.*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:"#player",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"aniwatch",matches:["megacloud.tv","aniwatch.to"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"multi_attach_vtt",subtitleUrlRegExp:"^(?!.*sprite\\.vtt$).*\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"},activeLangSelector:"#jw-player-settings-submenu-captions .jw-settings-submenu-items .jw-settings-item-active",videoSelector:"video",attachRule:{appendSelector:".jw-wrapper",injectedGlobalCSS:[".jw-text-track-container {display: none;}","@media (min-width: 576px) { video::cue {opacity: 0} }"]}}},{id:"rottentomatoes",matches:["*.rottentomatoes.com"],"excludeSelectors.add":[".jw-wrapper"],"mutationExcludeSelectors.add":[".jw-wrapper *"],"subtitleRule.add":{type:"webvtt",subtitleUrlRegExp:"\\.vtt$",quickButtonRule:{appendSelector:".jw-button-container",insertBeforeSelector:".jw-icon-cc"}}},{id:"dailymotion",matches:["*.dailymotion.com"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"subsrt",subsrtFormat:"srt",loadingContainerSelector:".player",subtitleUrlRegExp:"/video/.*\\.srt",quickButtonRule:{appendSelector:".controls_bottom_right",insertBeforeSelector:".subtitles_toggle_button"}}},{id:"movie-web",matches:["movie-web.app/media*"],"excludeSelectors.add":["#root"],"mutationExcludeSelectors.add":["#root *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",subsrtFormat:"vtt",loadingContainerSelector:".relative.h-screen.overflow-hidden",subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".hidden.justify-between .flex.items-center.space-x-3"}}},{id:"deeplearning",matches:["learn.deeplearning.ai"],"excludeSelectors.add":['[data-layout="video"]'],"mutationExcludeSelectors.add":['[data-layout="video"] *'],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",loadingContainerSelector:'[data-layout="video"]',subtitleUrlRegExp:".*\\.vtt",quickButtonRule:{appendSelector:".vds-controls-group:last-child",insertBeforeSelector:".vds-caption-button"}}},{id:"paramountplus",matches:["*.paramountplus.com"],"excludeSelectors.add":[".aa-player-skin"],"mutationExcludeSelectors.add":[".aa-player-skin *"],"subtitleRule.add":{type:"text_track_dynamic",injectedCss:[".tt-container {white-space: pre-line;}",".timed-text-css-box-inner {display: none!important;}",".timed-text-css-box-inner:last-child {display: block!important;}"],videoPlayerSelector:"video",quickButtonRule:{appendSelector:".top-menu-container"}}},{id:"pluto",matches:["pluto.tv"],"excludeSelectors.add":[".video-player-layout"],"mutationExcludeSelectors.add":[".video-player-layout *"],"subtitleRule.add":{type:"text_track_dynamic",videoPlayerSelector:"video",quickButtonRule:{appendSelector:".endControls-0-2-85"}}},{id:"vimeo",matches:["vimeo.com"],"excludeSelectors.add":[".vp-captions"],"mutationExcludeSelectors.add":[".vp-captions *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".player_container",loadingStyle:"bottom: unset; top: 5%;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"ted",matches:["www.ted.com"],"excludeSelectors.add":["#video"],"mutationExcludeSelectors.add":["#video *"],"subtitleRule.add":{type:"webvtt",hookType:"fetch",subtitleUrlRegExp:"\\.vtt",videoPlayerSelector:"video",loadingContainerSelector:"media-controller",quickButtonRule:{appendSelector:".pointer-events-none #media-control-bar",insertBeforeSelector:".pointer-events-none .media-volume-wrapper"}}},{id:"player.vimeo",matches:["https://player.vimeo.com/video/*","laracasts.com"],selectorMatches:["iframe[src*='player.vimeo.com']"],extraBlockSelectors:["span.vp-captions-line","span[class^=CaptionsRenderer_]"],"excludeSelectors.add":[".vp-captions-line"],"mutationExcludeSelectors.add":[".vp-captions *",".vp-captions-line *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".vp-telecine",loadingStyle:"bottom: unset; top: 5%; font-size: 12px;",injectedCss:["#immersive-translateQuickButton {visibility: inherit!important;}"],quickButtonRule:{appendSelector:'[data-control-bar="true"] > div',insertBeforeSelector:'[data-volume-control-container="true"]',ccEnableSelector:'[data-cc-button="true"]',injectCSS:".imt-quick-subtitle-button {margin-right: 0px; font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 28px !important;}"}}},{id:"tv.adobe",matches:"https://*.tv.adobe.com","excludeSelectors.add":[".mpc-player"],"mutationExcludeSelectors.add":[".mpc-player *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".mpc-player",quickButtonRule:{appendSelector:".mpc-controls__container"}}},{id:"threejs-journey",matches:"threejs-journey.com","excludeSelectors.add":[".video-area"],"mutationExcludeSelectors.add":[".video-area *"],"subtitleRule.add":{type:"text_track",videoPlayerSelector:"video",loadingContainerSelector:".video-area",injectedCss:[".js-tracks-text.tracks-text {white-space: pre;}"],quickButtonRule:{appendSelector:".js-controls .right",insertBeforeSelector:".js-subtitles",injectCSS:".imt-quick-subtitle-button { font-size: 12px;} .logo,.logo svg { height: 18px !important; width: 18px !important;} .imt-quick-subtitle-pop-content {bottom: 38px !important;}"}}},{id:"codewithchris",matches:["learn.codewithchris.com","*.rachelsenglishacademy.com","www.unrealsenseiacademy.com"],"excludeSelectors.add":[".w-captions",".w-captions-line > div > span"],"mutationExcludeSelectors.add":[".w-captions *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/embed/captions/",loadingContainerSelector:".w-ui-container",hookType:"fetch",generalSetting:{captionsPath:"captions",itemsPath:"hash.lines",textKey:"text"}}},{id:"panopto",matches:["southampton.cloud.panopto.eu"],"excludeSelectors.add":[".primaryPlayer"],"mutationExcludeSelectors.add":[".primaryPlayer *"],"subtitleRule.add":{type:"general",subtitleUrlRegExp:"DeliveryInfo.aspx",disableSubsCache:!0,loadingContainerSelector:"#primaryPlayer",hookType:"fetch",generalSetting:{textKey:"Caption"},quickButtonRule:{appendSelector:"#transportControls",insertBeforeSelector:"#captionsButton"}}},{id:"edx",matches:["*.edx.org"],"excludeSelectors.add":[".closed-captions",".subtitles-menu"],mainFrameMinTextCount:0,"subtitleRule.add":{type:"general",subtitleUrlRegExp:"/transcript/translation/",loadingContainerSelector:".tc-wrapper",generalSetting:{itemsPath:"text"},injectedCss:[".subtitles-menu span,.closed-captions {white-space: pre-line;}","#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],quickButtonRule:{appendSelector:".secondary-controls",insertBeforeSelector:".speeds.menu-container"}}},{id:"ardmediathek",matches:["www.ardmediathek.*"],"excludeSelectors.add":[".ardplayer-viewport-addon-overlays"],"mutationExcludeSelectors.add":[".ardplayer-viewport-addon-overlays *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"subtitle/ebutt",loadingContainerSelector:".ardplayer-viewport-addon-overlays",quickButtonRule:{appendSelector:".ardplayer-footer .ardplayer-addons-container",insertBeforeSelector:".ardplayer-footer .ardplayer-button-sharing",injectCSS:".imt-quick-subtitle-button {font-size: 20px; } .logo,.logo svg { height: 36px !important; width: 36px !important;} .imt-quick-subtitle-pop-content {z-index: 2147483647;} "}}},{id:"bbc-iplayer",matches:["https://www.bbc.*/iplayer*"],"excludeSelectors.add":[".player"],"mutationExcludeSelectors.add":[".player *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".player__container"}},{id:"bbc",matches:["*.bbc.*"],"excludeSelectors.add":["section.module--languages",".drop-capped",".smp-toucan-player","smp-subtitles","#subtitle_subtitle2"],"mutationExcludeSelectors.add":["[data-testid='media-player-container-landscape'] *"],"subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"iplayer/subtitles/.*.xml",loadingContainerSelector:".smp-toucan-player"}},{id:"zdf.de",matches:["www.zdf.de"],"excludeSelectors.add":[".zdfplayer-cue-region"],"subtitleRule.add":{type:"ebutt",subtitleUrlRegExp:"mtt/.*.xml",loadingContainerSelector:".zdfplayer-video-container",responseType:"document",injectedCss:["#immersive-translate-quick-button-container {display:inline-block;vertical-align:middle;margin-right:-16px;}"],quickButtonRule:{appendSelector:".right-controls-1FfJUp.svelte-inzdbf",insertBeforeSelector:".right-controls-1FfJUp.svelte-inzdbf button"}}},{id:"piped.video",matches:"piped.video","subtitleRule.add":{type:"ebutt",hookType:"fetch",subtitleUrlRegExp:"api/timedtext",loadingContainerSelector:".shaka-video-container",responseType:"document",quickButtonRule:{appendSelector:".shaka-controls-button-panel",insertBeforeSelector:".shaka-mute-button"}}},{id:"disneyplus",matches:["www.disneyplus.com"],"excludeSelectors.add":[".dss-hls-subtitle-overlay"],"mutationExcludeSelectors.add":[".dss-hls-subtitle-overlay *"],"subtitleRule.add":{type:"disneyplus",subtitleUrlRegExp:"\\.vtt$"}},{id:"mubi",matches:["https://mubi.com","https://mubi.de"],"subtitleRule.add":{type:"fmp4.xml",subtitleUrlRegExp:"textstream",hookType:"fetch",quickButtonRule:{appendSelector:".css-1k6yql2.e1b63bld4",insertBeforeSelector:".css-1ce7rqp.e7f2hfl0"}}},{id:"hulu",matches:"https://*.hulu.com","subtitleRule.add":{type:"hulu",hookType:"fetch",injectedCss:[".ClosedCaption {display:none!important;}"],videoSelector:"#content-video-player",subtitleUrlRegExp:"play.hulu.com/.*/playlist",loadingContainerSelector:"#web-player-app",quickButtonRule:{appendSelector:".PlayerSettingsGroup",insertBeforeSelector:".PlayerSettingsGroup .PlayerControlsButton"}}},{id:"youku.tv",matches:"www.youku.tv","excludeSelectors.add":["#subtitle"],"mutationExcludeSelectors.add":["#subtitle *"],"subtitleRule.add":{type:"subsrt",hookType:"fetch",injectedCss:["#immersive-translate-quick-button-container {display: inline-block; vertical-align: middle;}"],subtitleUrlRegExp:"\\.ass$",subsrtFormat:"ass",loadingContainerSelector:"#youku-dashboard",loadingStyle:"bottom: 10%;",quickButtonRule:{appendSelector:".kui-dashboard-dashboard-panel .kui-dashboard-rear-ctn",insertBeforeSelector:".kui-rate-control-0"}}},{id:"starz",matches:"www.starz.com","excludeSelectors.add":["starz-player"],"mutationExcludeSelectors.add":["starz-player *"],"subtitleRule.add":{type:"subsrt",subsrtFormat:"vtt",subtitleUrlRegExp:"\\.vtt$",loadingContainerSelector:"starz-player",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {display: inline-block;}"],quickButtonRule:{appendSelector:"starz-player .button-group",insertBeforeSelector:"starz-player .button-group .video-player-icon-md"}}},{id:"www.iq.com",matches:"www.iq.com","excludeSelectors.add":[".iqp-subtitle"],"mutationExcludeSelectors.add":[".iqp-subtitle *"],"subtitleRule.add":{type:"xml",subtitleUrlRegExp:"\\.xml\\?",loadingContainerSelector:".intl-video-area",xmlTextSelector:"sub",loadingStyle:"bottom: 10%;",injectedCss:["#immersive-translate-quick-button-container {float: right; height: 100%;}"],quickButtonRule:{appendSelector:".iqp-contrls-right"}}},{id:"archiveToday",matches:["archive.today","archive.ph","archive.is","archive.md"],"excludeSelectors.add":["#HEADER"]},{id:"arxiv-vanity.com",matches:["www.arxiv-vanity.com"],"excludeSelectors.add":[".arxiv-vanity-wrapper"]},{id:"fibery",matches:["the.fibery.io"],"additionalExcludeSelectors.remove":["[translate=no]"],"additionalStayOriginalSelectors.add":[".entity-node-view-container"]},{id:"makersuite.google",matches:"makersuite.google.com","excludeSelectors.add":[".material-symbols-outlined"]},{id:"etymonline",matches:"www.etymonline.com",globalAttributes:{".crossreference.notranslate":{class:"crossreference"},".foreign.notranslate":{class:"foreign"}}},{id:"https://browse.arxiv.org/",matches:["https://browse.arxiv.org","https://arxiv.org/html/*"],"excludeSelectors.add":[".desktop_header","[class*='ltx_lst_language_']","div.package-alerts"]},{id:"jstor",matches:"www.jstor.org","excludeSelectors.add":[".audio-duration","[data-qa='card-item-count']"],globalStyles:{".card__heading":"-webkit-line-clamp:unset;","search-results-vue-pharos-image-card,search-ui-pharos-image-card":"display:flex;","search-results-vue-pharos-link":"display:inline;"}},{id:"tandfonline",matches:"*.tandfonline.com","extraInlineSelectors.add":["span.off-screen"]},{id:"boringreport",matches:["www.boringreport.org"],"excludeTags.remove":["BUTTON"]},{id:"bsky.app",matches:"https://bsky.app",selectors:["[data-testid=postText]"],isTranslateTitle:!1},{id:"peacocktv",matches:["*.peacocktv.com"],injectedCss:[".video-player__subtitles__line > font,.video-player__subtitles__line:only-child{display:block;}"]},{id:"noTranslate",matches:["*.tiktok.com","altis.world","*.newthingsunderthesun.com","*.gumroad.com","edstem.org","actions.tldrnewsletter.com","community.linkingyourthinking.com","doc.qt.io","winaero.com"],"additionalExcludeSelectors.remove":[".notranslate","[translate=no]"]},{id:"jmir",matches:["*.jmir.org"],"additionalInlineSelectors.add":[".tooltiptext"]},{id:"smzdm",matches:["www.smzdm.com"],"excludeSelectors.add":[".z-highlight",".feed-block-info",".z-feed-foot",".feed-block-descripe","#J_column_tab_box",".crumbs"],globalStyles:{".feed-block-title":"height:unset"}},{id:"xiaohongshu.com",matches:["www.xiaohongshu.com"],"excludeSelectors.add":[".author-wrapper",".info",".side-bar"],globalStyles:{"a.title":"-webkit-line-clamp:3"}},{id:"learnopengl",matches:["learnopengl.com"],globalStyles:{function:"position:relative;z-index:1000;"}},{id:"notateslaapp",matches:["www.notateslaapp.com"],"extraBlockSelectors.add":[".nav > *"]},{id:"eightfold",matches:["*.eightfold.ai"],injectedCss:[".flexbox{width:100%}"]},{id:"deno",matches:["deno.com"],injectedCss:[":root {font-feature-settings:unset}"]},{id:"soundcloud",matches:"soundcloud.com",injectedCss:[".compactTrackListItem {height: unset !important;}"],"excludeSelectors.add":[".searchTitle__textContent",".searchOptions__container",".compactTrackListItem__additional",".soundTitle__tagContainer",".searchResultGroupHeading",".sc-ministats-group",".compactTrackList__moreLink",".sound__soundActions"]},{id:"section.blog.naver.com",matches:"section.blog.naver.com",globalStyles:{".text,.title_post,.text_post,p,strong,div":"-webkit-line-clamp:unset;max-height:unset;height:unset;"},"extraBlockSelectors.add":[".item",".heading a",".info_find a"],"excludeSelectors.add":[".comments",".time"]},{id:"gradio-app",selectorMatches:"gradio-app","excludeTags.remove":["BUTTON"],"excludeSelectors.add":['[data-testid="block-label"]'],"mutationConfig.add":{buildTimeout:1e3,consumeTimeout:1e3}}]};function Q3(){if(we.PROD==="1")return{};let t={};if(we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID&&we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY){let n={secretId:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_ID,secretKey:we.IMMERSIVE_TRANSLATE_SECRET_TENCENT_SECRET_KEY};t.translationServices={},t.translationServices.tencent=n}if(we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID&&we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY){let n={appid:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_APPID,key:we.IMMERSIVE_TRANSLATE_SECRET_BAIDU_KEY};t.translationServices||(t.translationServices={}),t.translationServices.baidu=n}if(we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN){let n={token:we.IMMERSIVE_TRANSLATE_SECRET_CAIYUN_TOKEN};t.translationServices||(t.translationServices={}),t.translationServices.caiyun=n}if(we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY){let n={apikey:we.IMMERSIVE_TRANSLATE_SECRET_OPENL_APIKEY};t.translationServices||(t.translationServices={}),t.translationServices.openl=n}if(we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID&&we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET){let n={appId:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_ID,appSecret:we.IMMERSIVE_TRANSLATE_SECRET_YOUDAO_APP_SECRET};t.translationServices||(t.translationServices={}),t.translationServices.youdao=n}if(we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID&&we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY){let n={accessKeyId:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_ACCESS_KEY_ID,secretAccessKey:we.IMMERSIVE_TRANSLATE_SECRET_VOLC_SECRET_ACCESS_KEY};t.translationServices||(t.translationServices={}),t.translationServices.volc=n}if(we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY){let n={authKey:we.IMMERSIVE_TRANSLATE_SECRET_DEEPL_AUTH_KEY};t.translationServices||(t.translationServices={}),t.translationServices.deepl=n}if(we.DEEPL_PROXY_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateApiUrl=we.DEEPL_PROXY_ENDPOINT),we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT&&(t.translationServices||(t.translationServices={}),t.translationServices.deepl||(t.translationServices.deepl={}),t.translationServices.deepl.immersiveTranslateDeeplTokenUrl=we.IMMERSIVE_TRANSLATE_DEEPL_ENDPOINT),we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY){let n={APIKEY:we.IMMERSIVE_TRANSLATE_SECRET_OPENAI_API_KEY};t.translationServices||(t.translationServices={}),t.translationServices.openai=n}we.IMMERSIVE_TRANSLATE_SERVICE&&(t.translationService=we.IMMERSIVE_TRANSLATE_SERVICE);let e={};return we.DEBUG==="1"&&(e.debug=!0,e.cache=!1),we.MOCK==="1"&&(e.translationService="mock"),e}async function Jt(){let t=await oe.storage.local.get(Fo);if(t[Fo]){let e=t[Fo],n=e.tempTranslationUrlMatches||[],r=n.filter(o=>o.expiredAt>Date.now()),a=!1;r.length!==n.length&&(n=r,a=!0);let i={...e,tempTranslationUrlMatches:[...n]};return a&&await Ht(i),i}else return{}}async function Ht(t){await oe.storage.local.set({[Fo]:t})}async function kl(t){await oe.storage.local.set({[Yr]:t})}async function Z3(){let t=await oe.storage.local.get(Yr),n={...await fp(),...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let r=t[Yr];if(r&&r.buildinConfigUpdatedAt){let a=new Date(r.buildinConfigUpdatedAt),i=new Date(n.buildinConfigUpdatedAt);a>i&&(n=r)}}return n}async function Xt(){let t=await oe.storage.local.get(Yr),e={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};if(t[Yr]){let E=t[Yr];if(E&&E.buildinConfigUpdatedAt){let P=new Date(E.buildinConfigUpdatedAt),O=new Date(e.buildinConfigUpdatedAt);P>O&&(e=E)}}let n=await zw(e);e.targetLanguage=n;let r=await Mt.get(Ft,null),a={};if(!ye()&&oe.commands&&oe.commands.getAll){let E=await oe.commands.getAll();for(let P of E)P.name&&P.shortcut&&(a[P.name]=P.shortcut)}let i=await fp(),o=Q3(),s=await qr(),u=globalThis.IMMERSIVE_TRANSLATE_CONFIG||{},l=await Jt(),c=new Date,p=Object.assign({},u,o,s);if(!p.interfaceLanguage){let E=await Rw();p.interfaceLanguage=E}let g=p.interfaceLanguage==="en",m=p.targetLanguage==="en",f=e&&e.translationLanguagePattern&&e.translationLanguagePattern.matches&&e.translationLanguagePattern.matches.length===0,T=["bing","google","transmart","mock"].includes(p.translationService)||!p.translationService;!g&&!m&&!f&&T?e.translationLanguagePattern||(e.translationLanguagePattern={matches:["en"],excludeMatches:[]}):e.translationLanguagePattern={matches:[],excludeMatches:[]};let b=e&&e.enableDefaultAlwaysTranslatedUrls;p.enableDefaultAlwaysTranslatedUrls===!1&&(b=!1);let h=p&&p.isChangedAlwaysTranslatedUrls,C=[];p.translationUrlPattern&&p.translationUrlPattern.matches&&(C=p.translationUrlPattern.matches||[]);let D=!1;h===void 0&&(C.length>0?h=!0:h=!1,p.isChangedAlwaysTranslatedUrls=h,s.isChangedAlwaysTranslatedUrls=h,D=!0);let M=(p?.translationLanguagePattern?.matches?.length||0)>0,B=await At("installedAt",""),S=Number(await Nr("translage_page_daily",0)),y=Number(await At(Kn,0)),_;y>0&&(Date.now()-y0&&(Date.now()-S0){let E=l.tempTranslationUrlMatches.filter(P=>new Date(P.expiredAt)>c);if(E.length>0){let P=p.translationUrlPattern?p.translationUrlPattern?.matches||[]:[],O=Array.isArray(P)?P:[P],H=Array.from(new Set(O.concat(E.map(j=>j.match))));p.translationUrlPattern={...p.translationUrlPattern,matches:H}}}let F=Object.assign(i,e);Ya({rule:e,valueIsArray:E=>Array.isArray(i[E]),getMergedValue:E=>i[E],onMergedResult:(E,P)=>{E!="generalRule"&&(F[E]=P)}});let L=Zt(r),U={};p.translationServices&&p.translationServices.deepl&&(U=p.translationServices.deepl);let N={};p.translationServices&&p.translationServices.openai&&(N=p.translationServices.openai),!L&&U.authKey&&!U.provider?(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="custom"):U&&U.provider||(F.translationServices.deepl||(F.translationServices.deepl={}),F.translationServices.deepl.provider="pro"),!L&&N.APIKEY&&!N.provider?(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="custom"):N&&N.provider||(F.translationServices.openai||(F.translationServices.openai={}),F.translationServices.openai.provider="pro");let q=Object.keys(F),A=["translationUrlPattern","translationLanguagePattern","immediateTranslationPattern","translationBodyAreaPattern","translationParagraphLanguagePattern","translationThemePatterns","translationGeneralConfig","shortcuts","inputTranslationUrlPattern","inputLanguageCodeAlias"];for(let E of q){let P=E;if(P==="generalRule")typeof p[P]=="object"&&(F[P]=Tl(i[P],p[P]));else if(P==="translationServices")Nw(p,F);else if(typeof p[P]!="string"&&typeof p[P]!="boolean"&&typeof p[P]!="number"&&A.includes(P))p[P]&&(F[P]=Object.assign(F[P],p[P])),P==="shortcuts"&&(ye()||it()?F[P]={...F[P],...a}:F[P]={...a});else if(P==="rules"){if(Array.isArray(p[P])){let O=F.rules||[],H={};for(let W of O)W.id&&(H[W.id]=W);let j=p[P].map(W=>W.id&&H[W.id]?k3(e.generalRule,H[W.id],W):W);F[P]=[...j,...F[P]]}if(we.PROD==="0"&&we.DEV_RULES){let O=JSON.parse(we.DEV_RULES);F[P]=[...O,...F[P]]}}else p[P]!==void 0&&(F[P]=p[P])}return F.donateUrl=e.donateUrl,F.minVersion=e.minVersion,F.feedbackUrl=e.feedbackUrl,F.rawUserConfig=s,F}async function qr(){return(await oe.storage.sync.get("userConfig")||{}).userConfig||{}}async function hs(t){await oe.storage.sync.set({userConfig:t})}async function bs(t,e){await oe.storage.local.set({[t]:e})}async function Pl(t){return(await oe.storage.local.get(t))[t]||""}var Rw=async()=>{let t=["zh-CN"];try{t=await oe.i18n.getAcceptLanguages()}catch(r){z.warn("get browser language error:",r)}let n=t.map(r=>Te(r)).find(r=>Ot[r]);return n||"en"},fp=async()=>{let t={...Ni,buildinConfigUpdatedAt:we.BUILD_TIME};return{...t,targetLanguage:lr,interfaceLanguage:"en",translationMode:"dual",debug:!1,alpha:!1,translationUrlPattern:{matches:[],excludeMatches:[]},translationLanguagePattern:{matches:[],excludeMatches:[]},translationThemePatterns:{},translationParagraphLanguagePattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationBodyAreaPattern:{matches:[],excludeMatches:[],selectorMatches:[],excludeSelectorMatches:[]},translationTheme:"none",translationService:"bing",inputTranslationService:"inherit",mouseHoverTranslationService:"inherit",subtitleTranslateService:"inherit",translationArea:"main",translationStartMode:"dynamic",translationServices:{},monkeyH5FloatBall:{...t.monkeyH5FloatBall},pcFloatBall:{...t.pcFloatBall},generalRule:{...t.generalRule},translationGeneralConfig:{engine:"bing",_systemExcludeWordRegex:"\\b({word})\\b"},rules:[]}};function Ow(t,e){return t=t||[],e=e||[],t.length!==e.length?!0:e.filter(r=>!t.includes(r)).length>0}async function zw(t){try{let e=t?.autoSelectTargetLanguageAfterInstalledAt;if(!e)return lr;let n=await At("installedAt","");if(n&&new Date(n){let l=a[u],c=a[l.extends];!c||l.extends==u||(a[u]={...c,...a[u]})}),Ya({rule:{...a},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),Ya({rule:{...r},valueIsArray:u=>Array.isArray(a[u]),getMergedValue:u=>a[u],onMergedResult:(u,l)=>{a[u]={...a[u],...l}}}),new Date(t.updatedAt)<=new Date("2024.4.2")&&Object.keys(r).forEach(u=>{["openai","gemini"].includes(u)&&r[u].prompt!=null&&(r[u].maxTextGroupLengthPerRequest==null&&(a[u].maxTextGroupLengthPerRequest=1),r[u].multiplePrompt==null&&(a[u].multiplePrompt=r[u].prompt))});let o=["imt_source_field","imt_trans_field","imt_sub_source_field","imt_sub_trans_field"],s=(u,l)=>{!u||!u[l]||!u?.env||(u[l]=u[l].replace(/{{(.+?)}}/g,(c,p)=>o.includes(p)?c:u?.env[p]||c))};Object.values(a).forEach(u=>{s(u,"prompt"),s(u,"multiplePrompt"),s(u,"subtitlePrompt")})}var Uw=["block","grid","flex","table","table-row","table-cell","list-item","-webkit-box","box","contents"];function xn(t,e){if(e.length===0)return!1;let n=e.join(",");return t.matches&&t.matches(n)||!1}function la(t,e,n){let{blockSelectors:r,extraBlockSelectors:a,extraInlineSelectors:i,atomicBlockSelectors:o}=e;if(xn(t,i))return!1;if(xn(t,a)||["br","input"].includes(t.nodeName.toLowerCase()))return!0;let l=null;if(t.parentNode&&t.parentNode.immersiveTranslateComputedStyle&&(l=t.parentNode.immersiveTranslateComputedStyle),l&&l.display&&l.display==="inline-flex")return!1;let c=p();return c&&(c=!xn(t,o)),c;function p(){return n&&n.display?!!Uw.includes(n.display):xn(t,r)}}var Kt=xn;function Qa(t){return!!t.shadowRoot}function ca(t){if(!t||typeof t!="string"&&(t=t.textContent,!t))return"";let e="";return t!==t.trimStart()&&(e+=" "),e+=t.trim(),e===" "||t!==t.trimEnd()&&(e+=" "),e}function Ts(t){if(!t)return["",""];if(typeof t!="string"&&(t=t.textContent,!t))return["",""];let e=[];return t!==t.trimStart()?e.push(" "):e.push(""),!t.trim()&&e.length===1?[" ",""]:(t!==t.trimEnd()?e.push(" "):e.push(""),e)}function Tr(t,e=!1){let n=Io;return e&&t?.translatedPlaceholderDelimiters?n=t.translatedPlaceholderDelimiters:t?.placeholderDelimiters&&(n=t.placeholderDelimiters),n}function Za(t,e=!1){let n=t.config?.translationServices?.[t.translationService];return Tr(n,e)}function Ui(t,e){return ua(e,t.targetLanguage,{ignoreZhCNandZhTW:t.rule.ignoreZhCNandZhTW})}function hp(t){let{rule:e}=t,n=qw(t);return` <${e.targetWrapperTag} class="${n} notranslate">`}function qw(t){let e=t.config.loadingTheme;return`${Q}-loading-${e}`}function ys(t,e){let n=t.rule,r=document.createElement(n.targetWrapperTag);r.classList.add("notranslate",bt),r.setAttribute("translate","no"),r.setAttribute("lang",t.targetLanguage),ut(r,Uh,e.toString());let a=hp(t);return r.append(rt.sanitize(a,{RETURN_DOM_FRAGMENT:!0})),r}function qi(t,e){return t.querySelector(`[${Ld}='${e}']`)}function J3(){document.querySelectorAll(`[${Ld}]`).forEach(e=>{e.remove()})}function X3(){document.querySelectorAll(`.${bt}-error`).forEach(e=>{e.remove()})}function e1(){let t=document.querySelectorAll("iframe"),e=[];return t.forEach(n=>{Hi(n)&&e.push(n)}),e}function bp(t){let e={},{glossaries:r,_systemExcludeWordRegex:a,text:i,delimiters:o,excludeRegexps:s,targetLanguage:u}=t,l=i,c=1001;try{if(r&&r.length>0){let p={},g=r.filter(f=>f.tl&&f.tl!==u?!1:f.k?(p[f.k]=f.v||"",!0):!1).sort((f,T)=>f.tl&&!T.tl?1:!f.tl&&T.tl?-1:0),m=new RegExp(a.replace("{word}",g.map(f=>f.k).join("|")),"g");l=l.replace(m,(f,T)=>{let b=c++;return e[`${b}`]=p[T]||T,o.length>2?f.replace(T,`<${o[2]}${b}>`):f.replace(T,`${o[0]}${b}${o[1]}`)})}s&&s.length>0&&s.forEach(p=>{let g=new RegExp(p,"gi");l=l.replace(g,(m,f)=>{let T=c++;return e[`${T}`]=O3(f),o.length>2?m.replace(f,`<${o[2]}${T}>`):m.replace(f,`${o[0]}${T}${o[1]}`)})})}catch(p){z.debug(`format source text error: ${p.message}`)}return{text:l,variables:e}}function vs(t){let{noTranslateRegexp:e,minTextCount:n,minWordCount:r,delimiters:a,text:i}=t,o=new RegExp(`${a[0]}(\\d+)${a[1]}`,"gi");if(a.length>2){let u=a[2];o=new RegExp(`<${u}(\\d+)>(.*?)`,"gi")}let s=i.trim();return s=s.replace(o,""),s=s.trim(),s===""||s.length===1&&s.charCodeAt(0)===8203||/^[0-9.,\/#!$%\^&\*;:{}=\-_`~()\s]+$/.test(i)||s.includes("")||s.includes("< styles>")||d1(s)||s1(s)||c1(s)||u1(s)||l1(s)||Hw(s)||o.test(s)||e&&e.length>0&&new RegExp(e.join("|"),"gi").test(s)?!1:Ll(i,n,r)}function jr(t){return t.nodeType===Node.ELEMENT_NODE}function t1(t,e){return t.paragraphs?t.paragraphs[0]?.ctxId!==e?(t.paragraphs=[],!1):!0:!1}async function Tp(){return await At("fakeUserId","")}async function jw(){return await At("installedAt","")}async function n1(t){let n=Me().INSTALL_FROM,r=Sn(),a=await jw(),i=await Tp(),o=await Xt(),s=!1,u=await Mt.get(Ft,null),l=!1;return u&&Zt(u)&&(s=!0,u.subscription&&u.subscription.isTrial&&(l=!0)),{installFrom:n,version:r,installedAt:a,interfaceLang:t,optionInterfaceLang:o.interfaceLanguage,deviceId:i,isProUser:s,isTrial:l}}function r1(t,e,n,r){if(!e||!r||!t)return"";let a=t.xpathRule,i=0,o=n;for(;o&&o!==r;)i++,o=o.parentNode;let s=i+"";for(let u=0;u{!t||!e||(async()=>{let a=await vp(t,e);r(a)})()},[t,e,r]),n}async function vp(t,e){if(!t||!e)return;let n=!1,r,a=!0;!it()&&ye()||et().any?(a=!1,r=e.monkeyH5FloatBall,!r&&t.rule.isShowUserscriptPagePopup==!1&&(r=t.config.monkeyH5FloatBall,r.enable=!1),r||(r=t.config.monkeyH5FloatBall),n=!e.monkeyH5FloatBall):(r=t.config.pcFloatBall,n=!e.pcFloatBall);try{if(r?.afterInstalledAt&&n){let i=await At("installedAt","");new Date(i).getTime()s==n),a=t.config.translationModeLanguagePattern.translationMatches.find(s=>s==n),i=t.config.translationModeUrlPattern.dualMatches.find(s=>wt(t.url,s));return t.config.translationModeUrlPattern.translationMatches.find(s=>wt(t.url,s))?"translation":i?"dual":a?"translation":r?"dual":null}var _l=!1,Ww=ye();function p1(t,e){let n=[];for(let r of e){let a=t.querySelectorAll(r);for(let i of a)n.push(i)}return n}function Kw(t,e){let n=function(i){return i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE?i.nodeType===Node.ELEMENT_NODE&&g1(i,e,!0)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT},r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,n),a=!0;for(;r.nextNode();){let i=r.currentNode;if(i.nodeType===Node.ELEMENT_NODE){if(da(i,Eu)){if(a===!0)return!0;continue}if(Ss(i.nodeName,e.inlineTags))return!0;if(!Sp(i,e))return!1}}return!0}function xp(t,e){let n=e.inlineTags;if(t.nodeType===Node.ELEMENT_NODE)if(Ss(t.nodeName,n)||Sp(t,e)){if(da(t,Hh)||Ss(t.nodeName,["BR"]))return!1;if(da(t,Eu))return!0;if(Sp(t,e)){let r=globalThis.getComputedStyle(t);if(r.display==="block"||r.display==="flex")return!1}return Kw(t,e)}else return da(t,Eu);return!1}function g1(t,e,n){if(!(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE)||t.nodeType===Node.ELEMENT_NODE&&da(t,jh,!0))return!0;if(t.nodeType===Node.ELEMENT_NODE&&da(t,Bh))return!1;let{stayOriginalTags:r,excludeTags:a}=e,i=[];return n&&a&&a.length>0?i=a||[]:i=a.filter(o=>!r.includes(o)),!!(t.nodeType===Node.ELEMENT_NODE&&(t.getAttribute("translate")==="no"||t.classList.contains("notranslate"))||Ss(t.nodeName,i))}function Ll(t,e,n){let r=t.trim();return r.length>=e||r.split(" ").filter(o=>o.trim()!=="").length>=n||!f1(r)&&r.length>=n}function m1(t,e,n){let r=t.trim();if(r.length<=e)return!0;if(f1(r)){if(r.split(" ").length<=n)return!0}else if(r.length<=n)return!0;return!1}function f1(t){for(let e=0;e127)return!1;return!0}function s1(t){if(t&&t.includes("://")&&!t.includes(" ")&&t.length<512)try{return new URL(t),!0}catch{return!1}else return!1}function u1(t){return t?/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(t):!1}function l1(t){return t?/^[_\d:\-+\.。,,% ]+$/.test(t):!1}function c1(t){if(t&&t.startsWith("#")){if(t.split("#").length>2)return!1;if(t.indexOf(" ")===-1)return!0}return!1}function d1(t){return!!(t&&t.startsWith("@")&&t.indexOf(" ")===-1)}function da(t,e,n=!1){return Ep(t,e,"1",n)}function Ep(t,e,n,r=!1){return _l&&!r?t[Tn]?!!(t[Tn]&&t[Tn][e]===n):!1:t.dataset[e]===n}function Wi(t){return(t.innerText||t.textContent||"").trim()}function Cp(t){let e=t.querySelectorAll("iframe"),n="";for(let r=0;r2e3))break}return n}function Fl(t){return t?typeof t=="string"?document.querySelector(t)!==null:t.some(e=>document.querySelector(e)):!1}function ut(t,e,n,r=!1,a=!1){t.isContentEditable&&!a||(_l&&!r?(t[Tn]||(t[Tn]={}),t[Tn][e]||(t[Tn][e]=n)):t.dataset[e]!==n&&(t.dataset[e]=n))}function Ml(t,e,n=!1){if(_l&&!n){if(!t[Tn]||!t[Tn][e])return;delete t[Tn][e]}else delete t.dataset[e]}function Ki(t,e,n=!1){return _l&&!n?!t[Tn]||!t[Tn][e]?void 0:t[Tn][e]:t.dataset[e]}function Sp(t,e){let n=e.allBlockTags.concat(e.inlineTags).concat(e.excludeTags);return!Ss(t.nodeName,n)}function Ae(){if(!globalThis||!globalThis.location)return"https://example.com";if(!Je())return globalThis.location.href;try{let e=globalThis.location.href,n=new URL(e);if(n.protocol==="about:"||n.protocol==="blob:"){if(globalThis.location.ancestorOrigins&&globalThis.location.ancestorOrigins.length>0)return globalThis.location.ancestorOrigins[0];let r="";try{r=globalThis.parent.location.href}catch{}return r||(globalThis.location!=globalThis.parent.location?document.referrer:document.location.href)}else return e}catch{}return globalThis.location.href}function An(t,e,n){if(t instanceof ShadowRoot){try{t.appendChild(document.createElement("style")).textContent=e}catch(r){z.warn("injectCSS failed, rootDocument"+r?.message,t)}return}if(t&&t.head&&t.head.appendChild){let r=t.createElement("style");if(n){let a=t.querySelector(`style[data-id="${n}"]`);a&&a.remove(),r.dataset.id=n}r.textContent=e,t.head.appendChild(r)}else if(t){let r=document.createElement("head"),a=document.createElement("style");a.textContent=e,r.appendChild(a),t.appendChild(r)}else z.warn("injectCSS failed, rootDocument does not have head node",t)}function Hi(t){let e=t.getAttribute("src");if(e){if(e==="about:blank")return!0;if(Ww){if(e.startsWith("blob:"))return!0}else if(e.startsWith("blob:"))return!!document.querySelector("meta[name='immersive-translate-ebook-viewer']")||!e.startsWith("blob:http");return!1}try{if(t.contentDocument&&t.contentDocument.body)return!0}catch{}return!1}function Ss(t,e){if(!t||!e)return!1;Array.isArray(e)||(e=[e]),t=t.toUpperCase();for(let n of e)if(t===n)return!0;return!1}function h1(t){let e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),a=parseInt(e.substring(4,6),16);return{r:n,g:r,b:a}}function b1(t,e,n,r){if(r.document.caretPositionFromPoint){let a=r.document.caretPositionFromPoint(t,e);if(a){let i=r.document.createRange(),o=a.offsetNode;if(!o||o.nodeType!==Node.TEXT_NODE||g1(o,n,!0))return null;try{i.setStart(o,a.offset),i.setEnd(o,a.offset)}catch(s){return z.warn("getRangeFromPoint error",s),null}return i}return null}else return r.document.caretRangeFromPoint?r.document.caretRangeFromPoint(t,e):null}function T1(t,e,n){let r=0,a=(i,o,s,u)=>{if(++r>100||u===i)return i;let l=i.shadowRoot;if(!l||typeof l.elementFromPoint!="function")return i;let c=l.elementFromPoint(o,s);return c?a(c,o,s,i):i};return a(t,e,n)}d();var v1="auto",Bl="auto",y1="auto";function S1(t){v1=t}function Nn(t){Bl=t}function yt(){return Bl!=="auto"?Bl:y1!=="auto"?y1:v1}function Il(){return Bl}function E1(t,e){let n=Object.assign({},t),r=new Map;(n.langOverrides||[]).forEach(i=>{r.set(i.id,i)});for(let i of r.keys()){let[o,s]=i.split("2");if(["auto",e.sourceLanguage].includes(o)&&["auto",e.targetLanguage].includes(s)){let u=r.get(i);if(!u)continue;if(u.extends){let l=r.get(u.extends);l&&(n=Object.assign({},n,l))}n=Object.assign({},n,u)}}return n}async function Un(t){let{url:e,config:n,state:r}=t,a=new URL(e),i="auto",{translationParagraphLanguagePattern:o,translationService:s,translationServices:u,translationTheme:l,translationThemePatterns:c,translationUrlPattern:p,targetLanguage:g,sourceLanguageUrlPattern:m,immediateTranslationPattern:f}=n,T=g||"zh-CN",b=Gi(e,o),h=Gi(e,f),C=s,D=Object.keys(u);for(let ae of D){let ie=u[ae];if(Gi(e,ie)){C=ae;break}}let M=l,B=Object.keys(c);for(let ae of B){let ie=c[ae];if(ie&&Gi(e,ie)){M=ae;break}}let S=Gi(e,p),y=x1(e,p);y||(y=wt(e,Xh)),y||(y=wt(e,n.blockUrls));let _=x1(e,n.inputTranslationUrlPattern);_||(_=wt(e,n.inputTranslationBlockUrls));let k=wt(e,n.mutationBlockUrls),v=Object.keys(m),I={};for(let ae of v){let ie=m[ae];if(ie&&ie.matches)for(let Ee of ie.matches)I[Ee]=ae}let F=Object.keys(I),L=ip(e,F);L&&(i=I[L]??"auto",I[L]&&I[L]!=="auto"&&Nn(I[L]));let U=a.hostname,N=await nr(U),q=a.pathname+a.search+a.hash,A=await nr(q),E=`https://${N}.com/${A}`,P=await Jt(),O=await Z3(),H=n.translationStartMode;H==="dynamic"&&h&&(H="immediate");let j=C;n.inputTranslationService&&n.inputTranslationService!=="inherit"&&(j=n.inputTranslationService);let W=C;n.mouseHoverTranslationService&&n.mouseHoverTranslationService!=="inherit"&&(W=n.mouseHoverTranslationService);let V=C;n.subtitleTranslateService&&n.subtitleTranslateService!=="inherit"&&(V=n.subtitleTranslateService);let se=await Mt.get(Ft,null),X=!1;se&&(X=Zt(se));let Z={targetLanguage:T,config:n,translationService:C,inputTranslationService:j,mouseHoverTranslationService:W,subtitleTranslateService:V,isTranslateUrl:S,sourceLanguage:i,mainFrame:document.body,isTranslateExcludeUrl:y,isMutationTranslationExcludeUrl:k,isInputTranslationExcludeUrl:_,rule:n.generalRule,url:e,encryptedUrl:E,state:r?Object.assign({translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},r):{translationMode:n.translationMode,translationArea:n.translationArea,translationStartMode:H,immediateTranslationTextCount:n.immediateTranslationTextCount,isAutoTranslate:!1,translationDebounce:300,isNeedClean:!1,isDetectParagraphLanguage:b,cache:n.cache,translationTheme:M,isTranslateDirectlyOnHover:!1},localConfig:P};se&&(Z.user=se,X?Z.isPro=!0:Z.isPro=!1),Z.state.translationArea==="body"&&(Z.config.generalRule.excludeTags=Z.config.generalRule.excludeTags.filter(ae=>!Z.config.generalRule.bodyTranslateTags.includes(ae)),Z.config.generalRule.additionalExcludeSelectors=Z.config.generalRule.additionalExcludeSelectors.filter(ae=>ae!==".btn"));let ue=n.translationServices[Z.translationService]||{};ue.immediateTranslationTextCount!==void 0&&Gw(ue.immediateTranslationTextCount)&&ue.immediateTranslationTextCount>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCount),Z.translationService==="deepl"&&(ue&&ue.authKey&&ue.authKey.startsWith("immersive_")||ue&&ue.provider==="pro"&&Z.user?.token)&&ue.immediateTranslationTextCountForImmersiveDeepl!==void 0&&ue.immediateTranslationTextCountForImmersiveDeepl>=0&&(Z.state.immediateTranslationTextCount=ue.immediateTranslationTextCountForImmersiveDeepl),ue&&ue.translationDebounce&&typeof ue.translationDebounce=="number"&&(Z.state.translationDebounce=ue.translationDebounce);let ge=O.immediateTranslationTextCount;n.immediateTranslationTextCount!==ge&&(Z.state.immediateTranslationTextCount=n.immediateTranslationTextCount);let te=n.rules,Y;globalThis.PDFViewerApplication?Y=te.find(ae=>ae.pageType=="pdfReader"):globalThis.immersiveTranslateEbookViewer?Y=te.find(ae=>ae.pageType=="ebookReader"):globalThis.immersiveTranslateEbookBuilder?Y=te.find(ae=>ae.pageType=="ebookBuilder"):Y=te.find(ae=>Gi(e,ae)),Z.state.translationArea==="body"&&(Z.rule.paragraphMinTextCount=1,Z.rule.paragraphMinWordCount=1),Y&&Y.pageType==="ebookBuilder"&&(Z.state.translationStartMode="immediate");let be=n.generalRule;if(Y&&(Z.rule=Tl(be,Y)),Z.rule.selectors.length>0&&(Z.rule.paragraphMinTextCount=2,Z.rule.paragraphMinWordCount=1),Z.state.translationArea==="body"&&Z.rule.excludeTags&&(Z.rule.excludeTags=Z.rule.excludeTags.filter(ae=>!Z.rule.bodyTranslateTags.includes(ae)&&!Z.rule.forceTranslateTags.includes(ae))),Z.rule.mainFrameSelector){let ae=document.querySelector(Z.rule.mainFrameSelector);ae&&(Z.mainFrame=ae)}return Z}function Gi(t,e){if(!e)return!1;let{matches:n,excludeMatches:r,selectorMatches:a,excludeSelectorMatches:i}=e;return r&&r.length>0&&wt(t,r)?!1:n&&n.length>0&&wt(t,n)?!0:i&&i.length>0&&Fl(i)?!1:!!(a&&a.length>0&&Fl(a))}function x1(t,e){if(!e)return!1;let{excludeMatches:n,excludeSelectorMatches:r}=e;return!!(n&&n.length>0&&wt(t,n)||r&&r.length>0&&Fl(r))}function Gw(t){return typeof t=="number"}d();d();d();d();d();d();d();var Nq=w1(2),C1=w1(3);function w1(t){if(typeof t!="number"||Number.isNaN(t)||t<1||t===Number.POSITIVE_INFINITY)throw new Error("`"+t+"` is not a valid argument for `n-gram`");return e;function e(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),i=a.length-t+1;if(i<1)return r;for(;i--;)r[i]=a.slice(i,i+t);return r}}d();var Vw=/\s+/g,$w=/[\t\n\v\f\r ]+/g;function D1(t,e){e?typeof e=="string"&&(e={style:e}):e={};let n=e.preserveLineEndings?Yw:Qw;return String(t).replace(e.style==="html"?$w:Vw,e.trim?Zw(n):n)}function Yw(t){let e=/\r?\n|\r/.exec(t);return e?e[0]:" "}function Qw(){return" "}function Zw(t){return e;function e(n,r,a){return r===0||r+n.length===a.length?"":t(n)}}var A1={}.hasOwnProperty;function Jw(t){return t==null?"":D1(String(t).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function Xw(t){return C1(" "+Jw(t)+" ")}function eD(t){let e=Xw(t),n={},r=-1;for(;++rn&&(n=i,r=a)}return[r,n]}function sD(t,e){let n=t.match(e);return(n?n.length:0)/t.length||0}function uD(t,e,n,r){e=cD(e,n,r);let a=[],i;if(e)for(i in e)Rl.call(e,i)&&a.push([i,lD(t,e[i])]);return a.length===0?Dp():a.sort(dD)}function lD(t,e){let n=0,r=-1;for(;++re.traditionalCharacters?(e.detectedCharacters="simplified",e.detectionRate=e.simplifiedCharacters/e.traditionalCharacters|1):e.simplifiedCharacterso+s.length,0));let i=t.length-r;for(let o of SD){let s=o[1],u=o[0],l=t.match(s),c=l?l.length:0;c>n&&(n=c,e=u)}return n*2.5/i>.5?e==="zh-CN"?I1(t)?"zh-TW":"zh-CN":e:"auto"}var O1=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Ap=new Map(O1),xD=new Map(O1.map(([t,e])=>[e,t]));function z1(t,e,n=["en"]){if(!t)return"auto";try{let r=n.map(s=>xD.get(s));!e&&e!==0&&(e=25);let a=zl(t);if(a!=="auto")return a;let i={minLength:e,whitelist:[...Ap.keys()]},o=L1(t,i);if(o&&o.length>0){if(o.length>1&&o[0][1]-o[1][1]<=.3)for(let c=0;c.5&&c/o.length<=.25){if(p=="eng"&&g<.95)break;return Ap.get(p)}}let[s,u]=o[0],l=Ap.get(s);if(l&&u>.9)return l}}catch(r){z.error(r)}return"auto"}d();d();function pa(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function ED(t,e){return t<>>32-e}function Ul(t,e,n,r,a,i){return pa(ED(pa(pa(e,t),pa(r,i)),a),n)}function en(t,e,n,r,a,i,o){return Ul(e&n|~e&r,t,e,a,i,o)}function tn(t,e,n,r,a,i,o){return Ul(e&r|n&~r,t,e,a,i,o)}function nn(t,e,n,r,a,i,o){return Ul(e^n^r,t,e,a,i,o)}function rn(t,e,n,r,a,i,o){return Ul(n^(e|~r),t,e,a,i,o)}function Nl(t,e){t[e>>5]|=128<>>9<<4)+14]=e;var n,r,a,i,o,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>e%32&255);return n}function kp(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(t.charCodeAt(e/8)&255)<16&&(r=Nl(r,t.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,i[n]=r[n]^1549556828;return o=Nl(a.concat(kp(e)),512+e.length*8),N1(Nl(i.concat(o),512+128))}function U1(t){var e="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+e.charAt(r&15);return n}function Pp(t){return unescape(encodeURIComponent(t))}function q1(t){return CD(Pp(t))}function DD(t){return U1(q1(t))}function j1(t,e){return wD(Pp(t),Pp(e))}function AD(t,e){return U1(j1(t,e))}function kn(t,e,n){return e?n?j1(e,t):AD(e,t):n?q1(t):DD(t)}var Vi=[];async function ql(t,e){return await new Promise((n,r)=>{let a=t,i=1,o=indexedDB.open(a,i);o.onsuccess=s=>{n(o.result)},o.onerror=s=>{r()},o.onupgradeneeded=s=>{let u=o.result,l=e||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function H1(t){let e=`${Q}-${t.service}@${t.from}->${t.to}`;return await LD(e,t)}async function W1(t){let e=kn(t.originalText),n=`${Q}-${t.service}@${t.from}->${t.to}`;return await PD(n,e)}async function PD(t,e){let n=await ql(t);return await new Promise((r,a)=>{if(!n)return a();let i="cache",s=n.transaction([i],"readonly").objectStore(i).get(e);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function LD(t,e){let n=await ql(t);return(await FD()).includes(t)||await _D(t),await new Promise(a=>{if(!n)return a(!1);let i="cache",s=n.transaction([i],"readwrite").objectStore(i).put(e);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function _D(t){let e="cache_list",n=await ql(Q+"-cacheList",e),a=n.transaction([e],"readwrite").objectStore(e).put({key:t});a.onsuccess=i=>{n.close(),Vi.push(t)},a.onerror=i=>{n.close()}}async function FD(){if(Vi&&Vi.length>0)return Vi;let t=await ql(Q+"-cacheList","cache_list");return Vi=await new Promise(e=>{let n="cache_list",a=t.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=i=>{t.close(),e(a.result)},a.onerror=i=>{t.close(),e([])}}),Vi}d();d();var Lp="Original";function $e(){return Lp}function pn(t){Lp=t,K1(Lp)}d();function Hr(t){return t?.id?.endsWith("pdfWebPage")||!1}function ga(t){try{if(!t||!Hr(t))return"";let e="";if(t.pdfUrlExtractRule.attribute&&t.pdfUrlExtractRule.selector){let r=t.pdfUrlExtractRule,{selector:a,attribute:i}=r;if(a&&i){let o=document.querySelector(a);if(!o)return"";e=o.getAttribute(i)||""}}else e=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(e.startsWith("about"))return"";if(!e.startsWith("/"))return e;let n=new URL(location.href);return e.startsWith("//")?n.protocol+e:n.protocol+"//"+n.host+e}catch{return""}}var Ye={},ma=async function(t,e){let{method:n,data:r}=t,a=await Ye.updateGlobalContext(),i=Date.now();if(z.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Ze(Kn,i);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Ze(Kn,i);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Ze(Kn,i);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Ze(Kn,i);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Ze(Kn,i);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Ze(Kn,i);else if(n==="translatePage")await Ye.translatePage(a,r),Ze(Kn,i);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(vu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(_o,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Je()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Je())return JSON.stringify(a)}};function G1(t){Object.assign(Ye,t)}function V1(t){Object.assign(Ye,t)}function $1(t){Object.assign(Ye,t)}var MD=function(t,e){let{method:n,data:r}=t;if(z.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return $e();if(n==="getCurrentPageLanguage"){let a=yt();return Ye.detectCurrentPageLanguage().catch(i=>{z.warn("detectCurrentPageLanguage failed",i)}),a}else{if(n==="setCurrentPageLanguageByClient")return Nn(r),yt();if(n==="getContextString"){let a=Ye.getPureGlobalContext(),{articleNode:i,bodyNode:o,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return ga(a?.rule)}}},jl,Hl;function Y1(){let t=Wl();Je()||BD(),t.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function Wl(){return jl||(jl=new br("content_script",!1).getConnection("main",ma),jl)}function BD(){return Hl||(Hl=new br("content_script",!1).getConnection("main_sync",MD,{sync:!0}),Hl)}d();var _p=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],Kl="https://transmart.qq.com/api/imt",Wr=class t{static langMapReverse=new Map(_p.map(([e,n])=>[n,e]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(e){let n={header:{fn:"text_analysis",client_key:t.getClientKey()},text:e.slice(0,280)},r=await de({url:Kl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,i=t.langMapReverse.get(a);return i||a}};d();function ID(t,e){return Math.floor(Math.random()*(e-t+1))+t}var RD=30,Fp="RATE_LIMITER_TICKS",$i=class t{static strictTicks={};static clearStrictTicks(){bs(Fp,"{}")}static async getStrictTicks(e,n){if(n)return this.strictTicks[e]||[];try{let r=await Pl(Fp);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){z.debug("Error setting rate limiter ticks",r),this.strictTicks[e]=[]}finally{return this.strictTicks[e]||[]}}static wait(e,n){return new Promise((r,a)=>{t.getDelay(e,n).then(i=>{setTimeout(()=>{r(i)},i)})})}static async setStrictTicks(e,n,r){try{if(this.strictTicks[e]=n,r)return;await bs(Fp,JSON.stringify(this.strictTicks))}catch(a){z.debug("Error setting rate limiter ticks",a)}}static async getDelay(e,n,r=!1){if(!r){let l=ID(4,RD);await Dr(l)}let a=await this.getStrictTicks(e,r)||[],{limit:i,interval:o}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(e,a,r),0):(a.push(u),await this.setStrictTicks(e,a,r),u-s)}};async function vt(t){return await Wl().sendMessage("background:main",t)}function de(t){return mu()?wl({method:"request",data:t}):ye()||gu()?(t.fetchPolyfill=globalThis.GM_fetch,Ur(t)):vt({method:"fetch",data:t})}function qn(){return ye()?Xt():vt({method:"getConfig"})}function gn(t){return ye()?hs(t):vt({method:"setUserConfig",data:t})}function mn(){return ye()?qr():vt({method:"getUserConfig"})}function Es(){return ye()?Jt():vt({method:"getLocalConfig"})}function Gl(t){return ye()?Ht(t):vt({method:"setLocalConfig",data:t})}function Q1(t){return ye()?kl(t):vt({method:"setBuildinConfig",data:t})}async function Ie(t){if(t.text){let n=zl(t.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(ye()||it()){if(t.translateService&&!Du.includes(t.translateService))return Promise.resolve("auto");let r=z1(t.text,t.minLength,t.pageLangs);return Promise.resolve(r)}let e=await vt({method:"detectLanguage",data:t});return Promise.resolve(e)}function Z1(){return vt({method:"detectTabLanguage"})}async function Vl(t){let e=await Ie({text:t,pageLangs:["en"]});try{if(ye()||it()){let n=t.substring(0,200);e=await Wr.detectLanguageRemotelyByTransmart(n)}}catch{}return e}function K1(t){let e=new CustomEvent(Oa,{detail:t});if(document.dispatchEvent(e),ye())return;Wl().sendMessage("popup:main_sync",{method:"setPageStatus",data:t}).catch(r=>{})}function J1(t){return ye()?W1(t):vt({method:"queryParagraphCache",data:t})}async function X1(t){if(ye()){await H1(t);return}return vt({method:"setParagraphCache",data:t})}async function e2(){if(ye())return Promise.resolve();await vt({method:"mockRequest"})}function Yi(t=!1,e=""){return ye()?(oe.runtime.openOptionsPage(t,e),Promise.resolve()):vt({method:"openOptionsPage",data:{newTab:t,pageRoute:e}})}function $l(t=""){return ye()||it()?Me().OPTIONS_URL:oe.runtime.getURL("options.html")}function Mp(t=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function Yl(t=!1){return ye()?(oe.extra.openAboutPage(t),Promise.resolve()):vt({method:"openAboutPage"})}function Qi(t){return ye()?(oe.extra.openInTab(t),Promise.resolve()):vt({method:"openInTab",data:t})}function t2(t=!1){return ye()?(oe.extra.openEbookViewerPage(t),Promise.resolve()):vt({method:"openEbookViewerPage"})}function n2(t=!1){return ye()?(oe.extra.openEbookBuilderPage(t),Promise.resolve()):vt({method:"openEbookBuilderPage"})}function r2(t){it()}function Zi(t=!1,e){return ye()?(oe.extra.openPdfViewerPage(t),Promise.resolve()):vt({method:"openPdfViewerPage",data:{url:e}})}function a2(t=!1){return ye()?(oe.extra.openSubtitleBuilderPage(t),Promise.resolve()):vt({method:"openSubtitleBuilderPage"})}function Ji(t){return ye()?Promise.resolve():vt({method:"setBadge",data:{text:t}})}function i2(){return ye()?(z.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):vt({method:"autoSyncLatestConfig"})}function Ql(t,e=!1){return ye()?oe.extra.openInTab(t,e):globalThis.open(t,e?"_blank":"_self"),Promise.resolve()}function o2(t,e){return ye()?$i.getDelay(t,e):vt({method:"getDelay",data:{key:t,options:e}})}function s2(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return!!(r&&e.hostname===r)}function Zl(t){let e;try{e=new URL(t)}catch{return!1}let n=Mp(),r="";try{r=new URL(n).hostname}catch{}return r&&e.hostname===r?!0:!(Bp(t)||e.protocol!=="http:"&&e.protocol!=="https:"&&e.protocol!=="file:"&&e.protocol!=="data:")}function Bp(t){try{return new URL(t)?.pathname.toLowerCase().endsWith(".pdf")}catch{return!1}}d();d();d();d();var Ip={get:(t,e,n)=>{let r=e===void 0?t:{[t]:e};return oe.storage[n].get(r)},set:(t,e,n)=>oe.storage[n].set({[t]:e})};function Jl(t,e,n){let[r]=re(()=>typeof e=="function"?e():e),[a]=re(n),[i,o]=re(r),[s,u]=re(!1),[l,c]=re("");Ce(()=>{Ip.get(t,r,a).then(g=>{g[t]&&o(g[t]),u(!0),c("")}).catch(g=>{u(!1),c(g)})},[t,r,a]);let p=Ve(g=>{let m=typeof g=="function"?g(i):g;z.debug("new settings",m),Ip.set(t,m,a).then(()=>{o(m),u(!0),c("")}).catch(f=>{o(m),u(!1),c(f)})},[a,t,i]);return[i,p,s,l]}d();function Rp(t,e,n){let r=[];return function(){let[i,o,s,u]=Jl(t,e,n),l=Ve(c=>{for(let p of r)p(c)},[]);return Ce(()=>(r.push(o),()=>{r.splice(r.indexOf(o),1)}),[o]),[i,l,s,u]}}function u2(t,e){return Rp(t,e,"sync")}var OD="userConfig",zD=null,ND=u2(OD,zD);function rr(t){let[e,n,r,a]=ND(),i=Ve(o=>{let s=typeof o=="function"?o(e):o;s&&(s.updatedAt=new Date().toISOString()),n(s),t&&t(s)},[e]);return[e,i,r,a,n]}d();d();d();var Xi={},UD={root:"",lang:"en",fallbackLang:"en"};function Op(t,e){let n=Object.assign({},UD,t);Xi=e||Xi;let[r,a]=re(n.lang),[i,o]=re(Xi),[s,u]=re(!1),l=p=>{if(i.hasOwnProperty(p))return;u(!1);let g=H3(n.root||"",p);n.getUrl&&(g=n.getUrl(n.root||"",p),fetch(g).then(m=>m.json()).then(m=>{Xi[p]=m,o({...Xi}),u(!0)}).catch(m=>{o({...Xi}),u(!0)}))};return Ce(()=>{l(n.fallbackLang||"en"),l(r)},[r]),{lang:r,setLang:a,t:(p,g)=>{if(!i.hasOwnProperty(r))return p;let m=gs(i,r,p);return m===p&&r!==n.fallbackLang&&(m=gs(i,n.fallbackLang,p)),pp(m,g)},isReady:s}}d();d();var qD=0;function w(t,e,n,r,a){var i,o,s={};for(o in e)o=="ref"?i=e[o]:s[o]=e[o];var u={type:t,props:s,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--qD,__source:a,__self:r};if(typeof t=="function"&&(i=t.defaultProps))for(o in i)s[o]===void 0&&(s[o]=i[o]);return Fe.vnode&&Fe.vnode(u),u}var Np=hi(null),zp={root:"assets",lang:"en",fallbackLang:"en"},eo=t=>{let{t:e,setLang:n,lang:r,isReady:a}=Op({root:t.root||zp.root,lang:t.lang||zp.lang,fallbackLang:t.fallbackLang||zp.fallbackLang,getUrl:t.getUrl},t.translations);return w(Np.Provider,{value:{t:e,setLang:n,lang:r,isReady:a},children:t.children})};function xe(){return du(Np)}d();var jD=function(t,e){let{method:n,data:r}=t;z.debug(`popup received message: ${n}`,r||" ");let a;e.active&&(a=e.id,globalThis.document.dispatchEvent(new CustomEvent(Mo,{detail:{tabId:a,payload:t}})))},Xl;function l2(){Cs()}function Cs(){return Xl||(Xl=new br("popup",!1).getConnection("main_sync",jD),Xl)}d();d();function c2(t,e=2e3){return n=>{let r,a=0;return i=>{++a==t&&(n(i),a=0),clearTimeout(r),r=setTimeout(()=>a=0,e)}}}d();var ec="DROP_DOWN_DEFAULT_VALUE";function Up(t){let{showArrow:e,onSelected:n,className:r,menus:a,maxWidth:i,style:o}=t;r=r||"",e=e??!0,i=i||80;let s=qe(null);return w("select",{ref:s,autoComplete:"off",class:`min-select ${e?"":"min-select-no-arrow"} ${r||""}`,value:ec,style:{maxWidth:`${i}px`,...o},onChange:u=>{u.preventDefault();let l=u.target.value;if(s.current&&l!==ec){s.current.value=ec,s.current?.dispatchEvent(new Event("change"));let c=a.find(p=>p.value===l);c&&n(c)}},children:[{value:ec,label:t.label}].concat(a).map((u,l)=>w("option",{value:u.value,children:u.label},"option-"+l))})}d();d();function to(t,e){return t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})>=0}var HD=({date:t})=>{let{t:e}=xe(),[n,r]=re(!1);return Ce(()=>{setTimeout(()=>{r(!0)},5e3)},[]),n?null:w("p",{class:"text-sm",children:[e("Successfully synchronized with the latest official rules:")," ",new Date(t).toLocaleString()]})},WD=({minVersion:t})=>{let{t:e}=xe();return w("p",{class:"text-sm",children:e("localVersionIsTooOld",{minVersion:t})})},KD=()=>{let{t}=xe();return w("p",{class:"text-sm",dangerouslySetInnerHTML:{__html:t("badUserscriptBrowser",{1:"https://immersivetranslate.com/docs/installation/"})}})},GD=({message:t,handleSyncing:e,date:n})=>{let{t:r}=xe();return w("p",{class:"text-sm",children:[r("failToSyncRules")," ",w("a",{onClick:e,children:r("retry")}),w("br",{}),r("failedReason"),"\uFF1A",t,w("br",{}),r("currentRuleVersion"),"\uFF1A",n]})};function qp(t){let{isShowError:e,request:n}=t,[r,a]=re(null),{t:i}=xe(),[o,s]=re(null),[u,l]=re(null),[c,p]=re(""),[g,m]=re(!1),[f,T]=re(!1),[b,h]=re(!1),[C,D]=re(null),[M,B]=re(null),S=Sn(),y=async()=>{p("");let _=o;if(o===null)try{let k=await n({url:Bo});k?(s(k),_=k,m(!0)):(p(i("unknownError")),l(null))}catch(k){l(null),p(k.message);return}_!==null?(t.setStorageBuildinConfig(_),l(!1),a(_.buildinConfigUpdatedAt)):(p(i("canNotFetchRemoteRule")),l(null))};return Ce(()=>{Xt().then(_=>{let k=_.buildinConfigUpdatedAt;D(_);let v=new Date(k);if(a(k),S==="0.0.0"){h(!0);return}n({url:Bo}).then(I=>{let F=I,L=F.minVersion,U=S;s(F);let N=F.latestVersion;if(N&&(to(U,N)?B(!0):B(!1)),to(U,L)){let q=F.buildinConfigUpdatedAt;new Date(q)>v?(l(!0),y()):l(!1)}else T(!0),l(null)}).catch(I=>{l(null),p(I.message)})})},[]),Ce(()=>{Xt().then(_=>{D(_)})},[r]),C?w("div",{class:"text-sm mt-2",style:{maxWidth:218},children:b?w(KD,{}):c?e===!1?null:w(GD,{handleSyncing:y,message:c,date:r||""}):f?e===!1?null:w(WD,{minVersion:o.minVersion}):u===null||u===!0?null:g?w(HD,{date:r}):null}):null}d();function VD(){return navigator.userAgent.indexOf("Mac")!==-1}var d2={Alt:"\u2325"};function tc(t=""){return VD()?Object.keys(d2).reduce((e,n)=>e.replace(n,d2[n]),t):t}d();d();var nc='',p2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0ZGQzczNiIgZD0iTTMgN2gxN3YxMEgzeiIvPjxwYXRoIGZpbGw9InVybCgjYSkiIGQ9Ik02Ljg5NyA5LjI0MmMuNDE1IDAgLjcyLjExMS45MjguMzQ3LjIwNy4yMzUuMzE4LjUyNy4zMTguODczcy0uMTEuNjIzLS4zMTguODQ1Yy0uMjA4LjIyMi0uNTI3LjMzMy0uOTI4LjMzM2gtMS4zM1Y5LjI0MmgxLjMzWm05Ljg0NiAxLjc4OGMuMzg4IDAgLjY2NS4xNTIuODQ1LjQ1Ny4xNTIuMjY0LjIzNS41ODIuMjYzLjk4NHYuMzE5YzAgLjQ5OS0uMDgzLjg4Ny0uMjYzIDEuMTkyLS4xOC4zMDQtLjQ1Ny40NTctLjgzLjQ1Ny0uMzg5IDAtLjY2Ni0uMTUzLS44NDYtLjQ0NC0uMTUyLS4yNjMtLjIzNS0uNTk1LS4yNjMtMS4wMTF2LS4yOTFjMC0uNDg1LjA4My0uODczLjI2My0xLjE3OC4xOC0uMzA1LjQ0My0uNDg1LjgzMS0uNDg1Wm0tMy40MDctMS4xMzZhMS4xNyAxLjE3IDAgMCAwLS43MDYuMjM1IDEuNDgyIDEuNDgyIDAgMCAwLS40MTUuNWwtLjA4My4xNjUtLjA3LS44MDNoLTEuMzU3djUuNDMyaDEuNDU0di0zLjY1OWEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiA4LjEySDQuMTE0djcuMzE3aDEuNDY4VjEyLjc5aDEuMzNjLjg0NCAwIDEuNDk1LS4yMDggMS45OC0uNjM4LjQ4NS0uNDMuNzItLjk4My43Mi0xLjY5cy0uMjM1LTEuMjYxLS43Mi0xLjY5Yy0uNDQzLS4zODktMS4wMzktLjYxLTEuNzczLS42MzhsLS4yMjEtLjAxNFptOS44NDcgMS43NzRjLS44MDMgMC0xLjQyNi4yNjMtMS44ODMuNzc2LS40MTYuNDctLjYzNyAxLjA2Ny0uNjc5IDEuNzczdi4zMzNjMCAuODE4LjIyMiAxLjQ4My42NzkgMS45OTUuNDU3LjUxMyAxLjA4Ljc3NiAxLjg4My43NzYuODA0IDAgMS40MjctLjI2MyAxLjg4NC0uNzc2LjQxNS0uNDcuNjM3LTEuMDUzLjY3OC0xLjc3M3YtLjMzM2MwLS44MTctLjIyMS0xLjQ4Mi0uNjc4LTEuOTk1LS40NTctLjUxMy0xLjA4LS43NzYtMS44ODQtLjc3NlpNMTguMDAzIDZhNiA2IDAgMCAxIDAgMTJIMFY5LjQyM0EzLjQyIDMuNDIgMCAwIDEgMy40MiA2aDE0LjU4M1oiLz48ZGVmcz48bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSI3LjUiIHgyPSIyMiIgeTE9IjE5IiB5Mj0iNiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPjxzdG9wIHN0b3AtY29sb3I9IiMyMjIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM2OTY5NjkiLz48L2xpbmVhckdyYWRpZW50PjwvZGVmcz48L3N2Zz4=",g2="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIxMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzk5OSIgZD0iTTYuODk3IDMuMjQyYy40MTUgMCAuNzIuMTExLjkyOC4zNDcuMjA3LjIzNS4zMTguNTI2LjMxOC44NzMgMCAuMzQ2LS4xMS42MjMtLjMxOC44NDUtLjIwOC4yMjItLjUyNy4zMzMtLjkyOC4zMzNoLTEuMzNWMy4yNDJoMS4zM1ptOS44NDYgMS43ODhjLjM4OCAwIC42NjUuMTUyLjg0NS40NTcuMTUyLjI2NC4yMzUuNTgyLjI2My45ODR2LjMxOWMwIC40OTktLjA4My44ODctLjI2MyAxLjE5Mi0uMTguMzA0LS40NTcuNDU3LS44My40NTctLjM4OSAwLS42NjYtLjE1My0uODQ2LS40NDQtLjE1Mi0uMjYzLS4yMzUtLjU5NS0uMjYzLTEuMDExdi0uMjkxYzAtLjQ4NS4wODMtLjg3My4yNjMtMS4xNzguMTgtLjMwNS40NDMtLjQ4NS44MzEtLjQ4NVptLTMuNDA3LTEuMTM2YTEuMTcgMS4xNyAwIDAgMC0uNzA2LjIzNSAxLjQ4MiAxLjQ4MiAwIDAgMC0uNDE1LjVsLS4wODMuMTY1LS4wNy0uODAzaC0xLjM1N3Y1LjQzMmgxLjQ1NFY1Ljc2NGEuODguODggMCAwIDEgLjMxOS0uMzg4Yy4xMS0uMDY5LjI1LS4xMS40MTUtLjEyNGguMTI1bC41NC4wMTQuMTY2LTEuMzE3Yy0uMDctLjAxNC0uMTI0LS4wMjgtLjE5NC0uMDQxLS4wNTUtLjAxNC0uMTI0LS4wMTQtLjE5NC0uMDE0Wk02Ljg5NiAyLjEySDQuMTE0djcuMzE3aDEuNDY4VjYuNzloMS4zM2MuODQ0IDAgMS40OTUtLjIwOCAxLjk4LS42MzguNDg1LS40My43Mi0uOTgzLjcyLTEuNjlzLS4yMzUtMS4yNjEtLjcyLTEuNjljLS40NDMtLjM4OS0xLjAzOS0uNjEtMS43NzMtLjYzOGwtLjIyMS0uMDE0Wm05Ljg0NyAxLjc3NGMtLjgwMyAwLTEuNDI2LjI2My0xLjg4My43NzYtLjQxNi40Ny0uNjM3IDEuMDY3LS42NzkgMS43NzN2LjMzM2MwIC44MTguMjIyIDEuNDgzLjY3OSAxLjk5NS40NTcuNTEzIDEuMDguNzc2IDEuODgzLjc3Ni44MDQgMCAxLjQyNy0uMjYzIDEuODg0LS43NzYuNDE1LS40Ny42MzctMS4wNTMuNjc4LTEuNzczdi0uMzMzYzAtLjgxNy0uMjIxLTEuNDgzLS42NzgtMS45OTUtLjQ1Ny0uNTEzLTEuMDgtLjc3Ni0xLjg4NC0uNzc2Wk0xOC4wMDMgMGE2IDYgMCAwIDEgMCAxMkgwVjMuNDIzQTMuNDIgMy40MiAwIDAgMSAzLjQyIDBoMTQuNTgzWiIvPjwvc3ZnPg==";var m2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAn1BMVEUAAADt7vHu7vLu7vLv7+/n5+fFxcXu7vHv7/PHx8eamprt7fLt7fHn5+vGxsbS09Surq6fn5+ZmZmZmZnGxsbGxsbt7/K/v7/Hx8ft7vHGxsaZmZn09vnk5eeqqquenp7p6u3X2NnLy8vU1dbr7O67u7uvr6/o6evh4uPR0dLCwsLAwMDZ2ty9vb6kpaWhoaHe3+HPz8+zs7OkpKTc3d7Gt0R8AAAAGXRSTlMA779wIBDv338gv5+AgHDv7+/v36+gn3BgD0kJmgAAAS1JREFUKM9dkOmSgyAQhNFo7mTvYwYEBa9oorne/9l2hqJSbr4q+NHNdBcjAukyXgBE8SwRU5IYHmwm1iyCCdFMBJbwxDK8B2iKLGjl8VAC+JmEcqzRrmnP5yzrbm93SuOeDQCcpNToGaV8ISGmAfBGPce+qjrsjSxYSbkBGtt1tZGEueLpwsZW8A8snlj2jD0efRZVtxzw4Ia2BFgIch1qOaHCM4lsHHA0WpOpKyk7qX2WWLBhhhxU7grlKlV7I+LyAm+DUplS/sqv2HL5FiDDSio15CQOdHrrl5L6kpqEMOHwTlIiOKu0WIDy5Bfkn3+HJTYXRNdmWXtA1nmJfu1lgRNcQw2encV/2J0I7OdIXM1YIzH/FQ9WX4i1JF4RP1dBDNZ+/S7lx/onDcIfdi8x4pYpSxgAAAAASUVORK5CYII=",f2="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAA51BMVEUAAABRT2tSUGpRT2tQUHBQUGjwtcxRT2tRUGtST2tSTmrvsMnvt89QUHDqTIpkXHhST2zQobmfdpPrTYrGVoHqS4nwtszvtMzvtc3vr89RT2vwtczASHb09vnIXYbt4OncqMDqTInGVoBbVnHqp8GqiKJlXHfz2+bsrsfkmrfIm7SggpvScZfKaY/q1uDtgKvRiKaNdY/MY4vy7fLy5Ozxydrxw9bhtcjnobzVlK/diam0j6jYfqHVeJyXfJWcd5TrXJOCb4l5aYNvYn3DUXzxzd3kwNDSorrth6/CjqnAeZnNdJaDb4nDaCDkAAAAGnRSTlMA73C/ICDv37+ff3AgEL+AgO/v7+/fr6BgELJb3PQAAAE/SURBVCjPXZHnUsMwEIRlOySkhw66k+24YScx6b0XOu//PJw0mozh+6Efu6ddzYlpqiWrwLlhmTmW5cLiZ4oZyzR4BsNkmhL/R0nPcx6FR6357ZbPuanyKefT62yjn37/cJwPbjeUJnuKNPeFuAaFjXhNgkUXONHDdR6CJIkh8HArlSo1UIUbx6sTEt4CZlfSaLBLOl2YeaixA2irLKrey4AzA4jpXQVG7hI6mCGBPonSaIF9StMUMe0hzrGjslhBGp7tDIUzfRPTnvhWhiHLQxjYQrwIoQ5nAXtZ3uD8AAkKYTsk0sAocNVSqqpkRaK+MYYNSTkms3wXXodCMZpAKD9FLzF6Bxg/ExMgXS+RluKHkGEZUYOi7sIf3DrTlPNAfOx2XSDyj+xM5QGg2yTIua+wLJVy7abZvKuVn7TwCyKmN+3PjJblAAAAAElFTkSuQmCC",h2="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgaWQ9IkZyYW1lIj4KPHBhdGggaWQ9IlZlY3RvciIgZD0iTTguNzEwMjMgMTMuMzg3NkwxMy4yODkzIDguODA4NkwxNC4wOTc3IDguMDAwMjJMMTMuMjg5NyA3LjE5MjIyTDguNzEwMjMgMi42MTI3OUw3LjkwMjIzIDMuNDIwNzlMMTEuOTA5NSA3LjQyODc5SDEuOTA1NjZWOC41NzE2NUgxMS45MDk1TDcuOTAxODUgMTIuNTc5M0w4LjcxMDIzIDEzLjM4NzZaIiBmaWxsPSIjODM4MzgzIi8+CjwvZz4KPC9zdmc+Cg==";function b2({config:t,isLogin:e,isProUser:n}){let{t:r}=xe();return ml(t)?w("div",{}):w("div",{class:"flex items-center",children:[w("a",{class:"flex items-center text-decoration-none",target:"_blank",href:e?ku:r4,children:[w("img",{src:e?f2:m2}),w("span",{class:"text-xs ml-2 text-label",children:r(e?"loggedIn":"notLogin")})]}),w("a",{title:r(n?"popup.openProForPro":"popup.openPro"),target:"_blank",class:"ml-2",href:n?ku:a4,children:w("img",{src:n?p2:g2})})]})}d();d();var T2={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},y2={...Ot,"zh-CN":{...T2["zh-CN"],...Ot["zh-CN"]},"zh-TW":{...T2["zh-TW"],...Ot["zh-TW"]}},rc=y2;function no(t,e,n){return hr(y2,t,e,lr,n)}var fa=(t,e,n,r)=>{let a=Yh[t]||t,i=Qh[t],o=Zh[t],s={"zh-CN":i,"zh-TW":o,en:a};if(n)return s[t]?s[t]:a;if(s[e]){let u=s[e];return r||t==="auto"||t==="placeholder"?u:`${u} (${a})`}else return a};d();d();d();d();d();function jp(t,e,n=[],r){let a=["notranslate"];return r&&a.push(Vh),t&&(a.push(`${Q}-target-translation-theme-${t}`),e?a.push(`${Fd}-theme-${t}`):a.push(`${_d}-theme-${t}`)),n.length>0&&a.push(...n),e?a.push(Fd):a.push(_d),a}function Hp(t){let e=["notranslate",wu];return t&&e.push(`${Q}-target-translation-theme-${t}-inner`),e}function v2(t,e,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=t;o=o||[];let{text:u}=e,{wrapperPrefix:l,wrapperSuffix:c}=r,p=Za(n,!0),g="afterend",m=p[0],f=p[1],T=`${m}(\\d+)${f}`,b=new RegExp(T,"g"),h=rt.sanitize(u);o.length>0&&(h=h.replace(b,B=>{let S=h.indexOf(B),y=h[S-1]===" ",_=h[S+B.length]===" ",v=B.replace(new RegExp(p[0],"g"),"").replace(new RegExp(p[1],"g"),""),I=Number(v);if(isNaN(I))return B;let F=o[I];if(F&&F.type==="element"){let L=F.value.outerHTML;return y||(L=" "+L),_||(L=L+" "),L}else z.error("variable type not supported",F,B);return B}));let C=jp(i,t.inline,r.translationClasses||[],t.preWhitespace);s&&C.push(Gh);let D=Hp(i),M="";return r.translationBlockStyle&&(M=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${M} class="${C.join(" ")}" ${ur}="1"><${r.targetWrapperTag} class="${D.join(" ")}" ${ur}="1">${h}`,t.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),t.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ur}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function ac(t,e){let n=t.original||t,r=null,{stayOriginalSelectors:a,delimiters:i,isPreWhitespace:o}=e,s=[],u={};for(let l=0;l2&&(h=`<${i[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let T=c.textContent||"";g&&(T=ca(Wp(c))),s.push({text:T,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Kt(c,a)){let b=Object.keys(u).length,h=`${i[0]}${b}${i[1]}`;i.length>2&&(h=`<${i[2]}${b}>`),u[b]=c;let C=Kp(s).endsWith(" ")?" ":"",D=ca(c.innerText||c.textContent),M=ca(c.nextSibling).startsWith(" ")?" ":"",B=Ts(C+D+M),S=B[0]+h+B[1];if(C===" ")S=S.trimStart();else if(!S.startsWith(" ")){let y=Ts(c.previousSibling)[1];y===""&&(y=" "),S=y+S}s.push({text:S,type:"variable"})}else{let T=Kp(s).endsWith(" ")?" ":"",b=ca(c.innerText||c.textContent);g&&(b=ca(Wp(c)));let h=ca(c.nextSibling).startsWith(" ")?" ":"",C=Ts(T+b+h),D=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(T===" ")D=D.trimStart();else{let M=Ts(c.previousSibling)[1];M===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(M=" "),D=M+D}s.push({text:D,type:"text"})}else{let T=Kp(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=ca(Wp(c))),T===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}t.targetText=rt.sanitize(t.targetText);let a=!1,i=t.text,o=i.split(" ").length,s=i.split(` `).length;o<=n.blockMinWordCount&&i.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(t.id),elements:[],isVertical:!1,rootFrame:t.commonAncestorContainer,text:t.text,variables:r,inline:a,preWhitespace:t.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Za(e);if(l.length>2){let c=l[2];return $D({delimiterTag:c,targetText:t.targetText,inline:a,preWhitespace:t.isPreWhitespace||!1,wrapperPrefix:e.rule.wrapperPrefix,wrapperSuffix:e.rule.wrapperSuffix,targetWrapperTag:e.rule.targetWrapperTag,translationTheme:e.state.translationTheme,translationBlockStyle:e.rule.translationBlockStyle,translationClasses:e.rule.translationClasses,variables:r}).html}else{let c=v2(u,{id:Number(t.id),url:"https://google.com",text:t.targetText,from:"auto",to:"auto",fromByClient:"auto"},e);return c.html}}function Wp(t){return(t?.innerText||t.textContent||"").replace(/\s+/g," ")||""}function $D(t){let{delimiterTag:e,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=t;o=o||[];let p=t.targetText;p=rt.sanitize(p);let g=p,m=new RegExp(`<${e}(\\d+)>(.*?)`,"g"),f=new RegExp(`<${e}(\\d+)>`);o.length>0&&(g=g.replace(m,C=>{let D=g.indexOf(C),M=g[D-1]===" ",B=g[D+C.length]===" ",S=C.match(f);if(!S)return C;let y=S[1],_=Number(y);if(isNaN(_))return C;let k=o[Number(_)];if(k&&k.type==="element"){let v=k.value.outerHTML;return M||(v=" "+v),B||(v=v+" "),v}else if(k&&k.type==="text"){let v=k.value;return M||(v=" "+v),B||(v=v+" "),v}else z.error("variable type not supported",k,C);return C}));let T=jp(l,n,r||[],s),b=Hp(l),h="";return c&&(h=`style="${c}"`),g=`<${a} ${h} class="${T.join(" ")}" ${ur}="1"><${a} class="${b.join(" ")}" ${ur}="1">${g}`,n||(i==="smart"?g=`
${g}`:g=`${i}${g}`),n&&(i!=="smart"?g=`${i}${g}`:g=`<${a} class="notranslate" ${ur}="1"> ${g}`),u==="smart"?g=`${g}`:g=`${g}${u}`,{html:g,position:"afterend"}}function Kp(t){let e=t[t.length-1];return e?e.text:""}function Gp(t){let{text:e,delimiters:n,variables:r}=t,a=e;if(n.length>2){let i=n[2],o=new RegExp(`<${i}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${i}(\\d+)>`),u=e;return Object.keys(r).length>0&&(u=u.replace(o,c=>{let p=c.match(s);if(!p)return c;let g=p[1],m=Number(g);if(isNaN(m))return c;let f=r[g];return f||c})),u}else{let i=`${n[0]}(\\d+)${n[1]}`,o=new RegExp(i,"g");a=a.replace(o,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}var De=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(e,n,r){this.serviceConfig=e,this.generalConfig=n,this.translationOptions=r,e?.retry&&(this.retry=e.retry),e?.requestTimeout&&(this.requestTimeout=Number(e.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let e=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(e.limit=Number(n.limit)),n?.interval&&(e.interval=Number(n.interval)),e}formatRateLimit(e){return e.limit<1&&(e.interval=Math.round(1e3/e.limit),e.limit=1),e}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(e){throw new Error("Not implemented")}translateList(e){throw new Error("Not implemented")}async multipleTranslate(e,n,r){if(e.sentences.length===0)return{sentences:[]};let{sentences:a}=e,i=!1,o=!1,s=[],u=null,l=new Set;for(let b of a)b.from&&b.from!=="auto"&&l.add(b.from),b.refresh&&(i=!0),b.debug&&(o=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let p=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(p=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(p=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=z3(a,c,p)}catch(b){if(r)for(let h=0;hb));let g=[],m=[],f=(b,h,C)=>{let D="";if(h.translatedTexts&&h.translatedTexts[0]&&(D=h.translatedTexts[0]),m[b]||(m[b]=h,m[b].translatedTexts=Array(h.sentenceTotalParts).fill(null)),m[b].hasError)return;if(C){let S=C instanceof $?new $(C.name,C.message).initNetWork(C.status).initData(C.data):C;m[b].hasError=!0,h.callback&&h.callback(S,null,h.sentence);return}m[b].translatedTexts[h.partIndex]=D;let M=m[b],B=0;for(let S=0;S{let B=h.from;if(h.fromByClient&&h.fromByClient!=="auto"&&(B=h.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:h.tempSentences.map(y=>y.text),forces:h.tempSentences.map(y=>y.force),xpaths:h.tempSentences.map(y=>y.xpath||""),from:B,to:h.to,url:C,options:n,refresh:i,debug:o}),sourceTempSentences:h.tempSentences};{let S=Kh;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(S=this.serviceConfig.translationTextSeparator);let y=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(y=this.serviceConfig.newlinePlaceholderDelimiters);let _=[],k=Tr(this.serviceConfig);if(h.tempSentences.forEach((q,A)=>{let E=bp({text:q.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:k,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:h.to});q.force!==!0&&(E&&E.text&&E.text.trim().lengthA.text);return Promise.resolve({sourceTempSentences:h.tempSentences,text:q,from:B,to:h.to})}let v="";y&&y.length>=2?v=_.map((q,A)=>{let{item:E}=q;return A===_.length-1?E.text:E.text+y[0]+(A+1)+y[1]}).join(""):v=_.map(({item:q})=>q.text).join(S);let I=await this.translate({text:v,from:B,to:h.to,url:C,options:{...n,rawTextArrayLength:_.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:i,debug:o}),{text:F}=I,L=[];if(y&&y.length>=2){let q=`${y[0]}\\d+${y[1]}`;y&&y.length>=3&&(q=y[2]);let A=new RegExp(q,"g");L=F.split(A)}else L=F.split(S);let U=[];if(L.length>_.length){for(let q=0;q<_.length-1;q++)U[q]=L[q];U[_.length-1]=L.slice(_.length-1).join(S)}else if(L.length<_.length)for(let q=L.length;q<_.length;q++)L[q]="";else U=[...L];let N=h.tempSentences.map(q=>q.text);return k=Tr(this.serviceConfig,!0),U.forEach((q,A)=>{let E=_[A],P=E.index,O=E.variables||{};Object.keys(O).length>0&&(q=Gp({text:q,delimiters:k,variables:O})),N[P]=q}),{sourceTempSentences:h.tempSentences,text:N,from:I.from,to:I.to}}};g.push(M().then(B=>{let{text:S,sourceTempSentences:y}=B;for(let _=0;_{if(B instanceof $&&B.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let S=0;S{let h=b.sentence.text;return b.translatedTexts&&b.translatedTexts.length>0&&(h=b.translatedTexts.join("")),{...b.sentence,text:h}})}}async formatAndTranslateList(e){let n={...e},{forces:r}=e,a=[],i=Tr(this.serviceConfig);if(this.serviceConfig&&i.length>0)try{let{text:l,xpaths:c}=e;if(l.forEach((p,g)=>{let m=bp({text:p,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:i,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:e.to});r&&r[g]!==!0&&(m&&m.text&&m.text.trim().lengthp.text),n.xpaths=a.map(p=>p.xpath)}catch(l){z.debug("formatAndTranslateList error",e,l)}let o=await this.translateList(n),{text:s}=o,u=e.text.map(l=>l);return i=Tr(this.serviceConfig,!0),s.forEach((l,c)=>{let p=a[c];if(p){let g=p.index,m=p.variables,f=Object.keys(m);u[g]=l,f.length>0&&(u[g]=Gp({text:l,delimiters:i,variables:m}))}}),{...o,text:u}}detectLanguageLocally(e){return Ie({text:e,minLength:18,pageLangs:[yt(),"en"]})}detectLanguageRemotely(e){return Promise.resolve("auto")}detectLanguage(e){return e.length>=50?this.detectLanguageLocally(e):this.detectLanguageRemotely(e)}};var x2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ws=class t extends De{static langMap=new Map(x2);maxTextGroupLength=50;static langMapReverse=new Map(x2.map(([e,n])=>[n,e]));static getUTCDate(e){let n=e.getUTCFullYear(),r=`${e.getUTCMonth()+1}`.padStart(2,"0"),a=`${e.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(e,n,r){if(super(e,n,r),!e||!e.secretId||!e.secretKey)throw new $("secretId and secretKey are required");this.secretId=e.secretId?.trim(),this.secretKey=e.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceText:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetText,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async translateList(e){let{text:n,from:r,to:a}=e,i=JSON.stringify({ProjectId:0,Source:t.langMap.get(r)||"auto",SourceTextList:n,Target:t.langMap.get(a)||a}),o=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:i,service:"tmt",version:"2018-03-21"});return{text:o.Response.TargetTextList,from:t.langMapReverse.get(o.Response.Source)||r,to:t.langMapReverse.get(o.Response.Target)||a}}async signedRequest({secretId:e,secretKey:n,action:r,payload:a,service:i,version:o}){let s=`${i}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await nr(a)].join(` `),p=t.getUTCDate(u),g=["TC3-HMAC-SHA256",l,`${p}/${i}/tc3_request`,await nr(c)].join(` `),m=await R3(p,`TC3${n}`),f=await El(i,m),T=await El("tc3_request",f),b=await El(g,T),h=await de({retry:this.retry,url:`https://${i}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":o,Authorization:`TC3-HMAC-SHA256 Credential=${e}/${p}/${i}/tc3_request, SignedHeaders=content-type;host, Signature=${b}`},body:a,timeout:this.requestTimeout});if(h instanceof Error)throw h;if(h.Response&&h.Response.Error&&h.Response.Error.Message)throw new $(h.Response.Error.Message);return h}};d();var E2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],YD={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},Ds=class t extends De{static langMap=new Map(E2);static langMapReverse=new Map(E2.map(([e,n])=>[n,e]));isSupportList=!1;constructor(e,n,r){super(e,n,r)}async translate(e){let{text:n,from:r,to:a}=e,i=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),o=await de({url:`https://wxapp.translator.qq.com/api/translate?${i}`,retry:this.retry,method:"GET",headers:YD,timeout:this.requestTimeout});return{text:o.targetText,from:t.langMapReverse.get(o.source)||r,to:t.langMapReverse.get(o.target)||a}}};d();var C2=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Ja=class t extends De{static langMap=new Map(C2);static langMapReverse=new Map(C2.map(([e,n])=>[n,e]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(e,n,r){super(e,n,r),e?.apiUrl&&(this.apiUrl=jt(this.apiUrl,e.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(e){let{text:n,from:r,to:a}=e;if(!n)return{...e};let i=t.langMap.get(r)||"auto",o=t.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,i,o);if(!s)throw new $("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new $("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:t.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(e,n,r){let i="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}).toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}async fetchWithoutToken(e,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:e}),i=this.apiUrl+"?"+a.toString();return{data:await de({retry:this.retry,url:i,timeout:this.requestTimeout})}}};d();d();d();function QD(t,e){return e?t+(e-t%e):t}function ZD(t,e){return t.split(e).length-1}function Vp(t){let e=Date.now(),n=1;for(let r of t)n+=ZD(r,"i");return QD(e,n)}function JD(t,e){return Math.floor(Math.random()*(e-t+1))+t}function $p(){return JD(1e6,1e8)}d();d();d();var Yp="https://www2.deepl.com/jsonrpc",Qp="auto",w2=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];d();function XD(t=w2){return t.reduce((e,n)=>(e[n.code.toLowerCase()]=n.code,e[n.language.toLowerCase()]=n.code,e),{})}function Zp(t){return XD()[t.toLowerCase()]}var eA={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function tA(t){return JSON.stringify(t).replace('"method":"',()=>{let e=t;return(e.id+3)%13===0||(e.id+5)%29===0?'"method" : "':'"method": "'})}function nA(t,e){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:t,target_lang:e}}}}async function rA(t,e,n,r,a,i,o){let s=$p(),u=nA(r,n),l=[];e.forEach(g=>{l.push({text:g,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Vp(e);let c=await de({retry:2,method:"POST",url:t,body:tA(u),headers:eA}),p={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(g=>{p.text.push(g.text)}),p}async function D2(t,e,n,r=Qp,a,i,o){return e?e&&e.length===1&&e[0]===""?{text:[""],from:r,to:n}:rA(t,e,Zp(n),Zp(r)??"auto",a,i,o):{text:[],from:r,to:n}}var A2=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],ro=class t extends De{static langMap=new Map(A2);static langMapReverse=new Map(A2.map(([e,n])=>[n,e]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Yp;constructor(e,n,r){super(e,n,r),e&&e.apiUrl&&(this.API_URL=jt(Yp,e.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(e){let{text:n,to:r,from:a}=e,i=await D2(this.API_URL,n,t.langMap.get(r)||r,t.langMap.get(a)||"auto");return{text:i.text,from:t.langMapReverse.get(i.from),to:t.langMapReverse.get(i.to)}}};d();var As=class t extends De{static langMap=new Map(_p);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(e,n,r){super(e,n,r),this.clientKey=Wr.getClientKey()}async translate(e){let{text:n,to:r}=e,a=await this.detectLanguage(n),i=t.langMap.get(a)||a,o=t.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Me(),u=e.url;s.INSTALL_FROM==="firefox_store"&&(u=k2());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:i,orig_url:u},target:{lang:o}}),p=await de({url:Kl,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(p.header.ret_code!=="succ")throw new $(p.message||p.header.ret_code);return{text:p.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(e){let{from:n,text:r,to:a}=e,i=Me(),o=e.url;if(i.INSTALL_FROM==="firefox_store"&&(o=k2()),r.length===1){let m=await this.translate({from:n,text:r[0],to:a,url:o,options:e.options});return{text:[m.text],from:m.from,to:m.to}}let u=await this.detectLanguage(r.join(` diff --git a/dist/userscript/immersive-translate.user.js b/dist/userscript/immersive-translate.user.js index 6c85896..e2bc83c 100644 --- a/dist/userscript/immersive-translate.user.js +++ b/dist/userscript/immersive-translate.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Immersive Translate - Translate Website & PDF // @description Free Translate Website, Translate PDF & Epub eBook, Translate Video Subtitles in Bilingual -// @version 1.4.3 +// @version 1.4.4 // @namespace https://immersive-translate.owenyoung.com/ // @author Owen Young // @homepageURL https://immersivetranslate.com/ @@ -102,7 +102,7 @@ // @name:es Immersion Translation: Traducción bilingüe de páginas web y documentos PDF // @description:es Bilingual web page translation, also supports PDF translation, bilingual Epub eBook translation, free to use. // ==/UserScript== -(()=>{var B6=Object.create;var B0=Object.defineProperty;var R6=Object.getOwnPropertyDescriptor;var I6=Object.getOwnPropertyNames;var O6=Object.getPrototypeOf,N6=Object.prototype.hasOwnProperty;var j6=(e,t)=>()=>(e&&(t=e(e=0)),t);var U6=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),R0=(e,t)=>{for(var n in t)B0(e,n,{get:t[n],enumerable:!0})},H6=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of I6(t))!N6.call(e,a)&&a!==n&&B0(e,a,{get:()=>t[a],enumerable:!(r=R6(t,a))||r.enumerable});return e};var z6=(e,t,n)=>(n=e!=null?B6(O6(e)):{},H6(t||!e||!e.__esModule?B0(n,"default",{value:e,enumerable:!0}):n,e));var T,d=j6(()=>{T={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var B6=Object.create;var B0=Object.defineProperty;var R6=Object.getOwnPropertyDescriptor;var I6=Object.getOwnPropertyNames;var O6=Object.getPrototypeOf,N6=Object.prototype.hasOwnProperty;var j6=(e,t)=>()=>(e&&(t=e(e=0)),t);var U6=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),R0=(e,t)=>{for(var n in t)B0(e,n,{get:t[n],enumerable:!0})},H6=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of I6(t))!N6.call(e,a)&&a!==n&&B0(e,a,{get:()=>t[a],enumerable:!(r=R6(t,a))||r.enumerable});return e};var z6=(e,t,n)=>(n=e!=null?B6(O6(e)):{},H6(t||!e||!e.__esModule?B0(n,"default",{value:e,enumerable:!0}):n,e));var T,d=j6(()=>{T={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5121,7 +5121,7 @@ ass, HTML, TXT files.`,"description.multiplePrompt":`When the number of paragrap `);y.forEach(function(h){var C=h.trim().split(":"),w=C.shift().trim(),k=C.join(":").trim();f.append(w,k)})}else if(typeof p=="object")for(var b in p)Array.isArray(p[b])&&p[b].forEach(function(h){f.append(b,h)});return f}self.Headers=Headers,self.Request=Request,self.Response=Response,self.GM_fetch=function(p,f){var y,b;return f||(typeof p=="string"?f={}:p=f.url),Request&&Request.prototype&&Request.prototype.isPrototypeOf&&Request.prototype.isPrototypeOf(f)?y=f:(f.body&&(b=f.body),y=new Request(p,f)),new e(function(h,C){var w={};f&&f.extra&&(w=f.extra);var k;function R(v,x){if(v)return v;if(x.get("X-Request-URL"))return x.get("X-Request-URL")}w.method=y.method||"GET",w.timeout=6e4,y.timeout&&(w.timeout=y.timeout),w.url=y.url,w.synchronous=!1,w.onload=function(v){var x=v.status;if(x<100||x>599){C(new TypeError("Network request failed"));return}var B=v.responseHeaders;k=g(B);var _=R(v.finalUrl||v.responseURL,k);k.set("X-Final-URL",_);var E={status:x,statusText:v.statusText,headers:k,url:_},O=v.responseText;let F=new Response(O,E);h(F)},w.onerror=function(v){C(new TypeError("Network request failed"))},w.ontimeout=function(v){C(new TypeError("Network request timeout"))},w.onabort=function(v){C(new TypeError("Network request abort"))},w.headers={},y.headers.forEach(function(v,x){w.headers[x]=v}),b&&(w.data=b),t(w)})},self.GM_fetch.polyfill=!0})();d();d();d();var td=/iPhone/i,Dh=/iPod/i,Ah=/iPad/i,kh=/\biOS-universal(?:.+)Mac\b/i,nd=/\bAndroid(?:.+)Mobile\b/i,_h=/Android/i,ho=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ku=/Silk/i,Sr=/Windows Phone/i,Lh=/\bWindows(?:.+)ARM\b/i,Fh=/BlackBerry/i,Ph=/BB10/i,Mh=/Opera Mini/i,Bh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Rh=/Mobile(?:.+)Firefox\b/i,Ih=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function qC(e){return t=>t.test(e)}function st(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=qC(n),o={apple:{phone:a(td)&&!a(Sr),ipod:a(Dh),tablet:!a(td)&&(a(Ah)||Ih(t))&&!a(Sr),universal:a(kh),device:(a(td)||a(Dh)||a(Ah)||a(kh)||Ih(t))&&!a(Sr)},amazon:{phone:a(ho),tablet:!a(ho)&&a(ku),device:a(ho)||a(ku)},android:{phone:!a(Sr)&&a(ho)||!a(Sr)&&a(nd),tablet:!a(Sr)&&!a(ho)&&!a(nd)&&(a(ku)||a(_h)),device:!a(Sr)&&(a(ho)||a(ku)||a(nd)||a(_h))||a(/\bokhttp\b/i)},windows:{phone:a(Sr),tablet:a(Lh),device:a(Sr)||a(Lh)},other:{blackberry:a(Fh),blackberry10:a(Ph),opera:a(Mh),firefox:a(Rh),chrome:a(Bh),device:a(Fh)||a(Ph)||a(Mh)||a(Rh)||a(Bh)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}var rd="DENO",ad="CHROME",_u="FIREFOX";function WC(e){let t=ad;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=_u:/deno/i.test(n)&&(t=rd)}catch{}return e===ad&&t===ad||e===_u&&t===_u||e===rd&&t===rd}function Oh(){return typeof Deno<"u"}function bo(){return WC(_u)}function Lu(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function Wi(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}d();var Nh={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},jh={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:Nh,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:Nh,query:()=>{},sendMessage:()=>{}}};var oe;Oh()?oe=jh:oe=globalThis.immersiveTranslateBrowserAPI;d();d();function ye(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=An.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":An[a]}else return"auto";else return An[r]}function ht(){return ye(document?.documentElement?.lang||"en")}d();function Jt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function Uh(e){if(e){let t=new Date(e.createTime),n=$C(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function $C(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,o]=n.split("/");return n=`${o}-${r}-${a}`,n}catch{return"unknown"}}d();var Hh=ge+"SyncStoreKey_";function Dt(e,t){let n=Hh+e;return oe.storage.sync.get(n).then(r=>r[n]===void 0?t:r[n])}function Qe(e,t){let n=Hh+e;return oe.storage.sync.set({[n]:t})}d();var zh=ge+"StoreKey_";function wr(e,t){let n=zh+e;return oe.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function qh(e,t){let n=zh+e;return oe.storage.local.set({[n]:t})}d();var Fa=ge+"CacheKey_";function od(e,t){let n=Fa+e;return oe.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function GC(){let e=oe.storage.local.refresh;e&&e()}function id(e,t){let n=Fa+e;return oe.storage.local.get(n).then(r=>{if(r[n]===void 0)return t;let{value:a,expired:o}=r[n];return o&&or.startsWith(Fa)).filter(r=>r!==Fa+zt);if(n.length>0)return oe.storage.local.remove(n)}}var qt={get:od,set:ud,getExpired:id,setExpired:sd,remove:ld,clear:Wh,refresh:GC};d();d();d();d();function $h(e,t){return[e,!e||e.endsWith("/")?"":"/",t,".json"].join("")}function cd(e,t){let n=e;return t&&Object.keys(t).forEach(r=>{let a=t[r];if(a===void 0)return;let o=VC(r);if(typeof a=="object"||o){let i=a;o&&typeof i=="string"&&(i={tag:"a",href:i,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=i.tag||"a",c=n.indexOf(``);if(c!==-1){let m=n.substring(u+s.length,c),g=Object.keys(i).filter(p=>p!=="tag").map(p=>`${p}="${i[p]}"`).join(" ");n=n.replace(`${s}${m}`,`<${l} ${g}>${m}`)}}}else if(a){let i=new RegExp("{"+r+"}","gm");n=n.replace(i,a.toString())}}),n}function $i(e,t,n){let r=e[t];if(!r)return n;if(!n)return"";let a=n.split("."),o="";do{o+=a.shift();let i=r[o];i!==void 0&&(typeof i=="object"||!a.length)?(r=i,o=""):a.length?o+=".":r=n}while(a.length);return r}function sr(e,t,n,r,a){if(!e.hasOwnProperty(n))return t;let o=$i(e,n,t);return o===t&&n!==r&&(o=$i(e,r,t)),cd(o,a)}function VC(e){if(typeof e=="number")return!0;if(e){let t=parseInt(e);return!isNaN(t)}else return!1}function At(e,t,n){return sr(Rt,t,e.config.interfaceLanguage,"en",n)}d();function Gh(e,t){let n=new Date(e),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),o=n.getDate().toString().padStart(2,"0"),i=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return t.replace("YYYY",r).replace("MM",a).replace("DD",o).replace("HH",i).replace("mm",s).replace("ss",u)}function Vh(e){return new Date(e).getTime()}var K=class extends Error{status;constructor(t,n){if(t&&n){super(n),this.name=t;return}super(t)}initNetWork(t){return t&&(this.status=t),this}initStack(t){return t&&(this.stack=t),this}initData(t){return this.data=t,this}data;uiConfig(t){if(!this.message)return{};let n=null;if(n=this.handleProQuota(t)||this.handleUnavailableError(t)||this.handleProUser(t)||this.handleServiceMissingConfig(t)||this.handleNetwork(t)||this.handleFetchError(t),!n){let r=At.bind(null,t),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(t){let n=At.bind(null,t),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(t){let n=At.bind(null,t);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(t){let n=At.bind(null,t),r="retry",a="network",o=n("networkError");if(!this.status||this.status<0)return;let i=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?i=`${n("error.googleLimitIp")}

${i}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?i=`${n("error.openAIFreeLimit")}

${i}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?i=`${n("error.openAIExceededQuota")}

${i}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?i=`${n("error.gemini.429")}

${i}`:i=`${n("error.429")}

${i}`:this.status===403?this.data?.translationService=="claude"?i=`${n("error.claude.403")}

${i}`:i=`${n("error.403")}

${i}`:this.status===400?i=`${n("error.400")}

${i}`:this.status===502?i=`${n("error.502")}

${i}`:this.status===404&&i.includes("User subscription not found")&&(i=`${n("error.subscriptionExpired")}

${i}`,r="setting",a="configError",o=n("error.subscriptionExpiredTitle")),{type:a,title:o,errMsg:i,action:r}}handleFetchError(t){let n=At.bind(null,t);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(t){let n=At.bind(null,t);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return t.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(t){if(!this.message.startsWith("ProQuota:")||!t.user?.subscription)return;let n=At.bind(null,t);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=t.user.subscription,{subscriptionType:o,isTrial:i,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let m=this.data?.translationService=="deepl"?"OpenAI":"Deepl",g=this.data?.translationService=="deepl"?"Deepl":"OpenAI",p=n("errorReason",{message:r});if(o=="onetime_7day")p+=n("proQuotaExceededError.onetime7day",{anotherService:m,brandId:J,href:Au});else{let f="";g=="OpenAI"?f=yh:f=Eh,i?p+=n("proQuotaExceededError.trial",{anotherService:m,brandId:J,href:xh}):p+=n("proQuotaExceededError.nonTrial",{anotherService:m,brandId:J,href:f,translationService:g}),!i&&(a.cancelAtPeriodEnd==="false"||Vh(u)>s)&&(p+=n("proQuotaExceededError.resetTime",{resetTime:Gh(s,"YYYY-MM-DD HH:mm:ss")}))}return p}}};async function Pa(e){let t;if(e&&e.retry&&e.retry>0)try{t=await H0(Kh.bind(null,e),{multiplier:2,maxAttempts:e.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else t=await Kh(e);return t}async function Kh(e){e.body;let{url:t,responseType:n,...r}=e;n||(n="json"),r={mode:"cors",...r};let a=!0;e.fetchPolyfill&&(a=!1);let o=e.fetchPolyfill||fetch,i=3e4;if(e.timeout&&(i=e.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},i),r.signal=l}let s;try{s=await o(t,r)}catch(u){P.debug("fetch error",t,u);let l=u.message||"Unknown Error";throw new K("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=t),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of KC(s.body)){let m=new TextDecoder().decode(c);u+=m;let g;for(;(g=u.indexOf(` -`))>=0;){let p=u.slice(0,g).trim();if(u=u.slice(g+1),p.startsWith("event:")||p==="")continue;let f="";if(p.startsWith("data:")&&(f=p.slice(5).trim()),f==="[DONE]")break;let y;try{y=JSON.parse(f??"")}catch(b){P.debug("json error",b);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(p){P.error("parse response failed",p)}u&&P.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new K("fetchError",c).initNetWork(s.status)}}async function*KC(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}d();var YC=new Map;function Fu(e){let t=JC(64),n=new CustomEvent(hu,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{YC.set(t,(o,i)=>{o?a(o):r(i)})})}function JC(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var QC="";function Xt(){return QC||Pu.version}function dd(){return oe.runtime.getManifest().version}d();function Ue(){try{let e=[Ce().EBOOK_BUILDER_URL,Ce().EBOOK_VIEWER_URL,Ce().SUBTITLE_BUILDER_URL,Ce().HTML_VIEWER_URL,Ce().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];Yt()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let o=new URL(a);return n.startsWith(o.pathname)&&t.includes(o.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var Gi=new Map,qr=class{fromType;logger;constructor(t,n=!1){this.logger=new zi,n&&this.logger.setLevel("debug"),this.fromType=t,Gi.has(t)||(Gi.set(t,new Map),oe.runtime.onMessage.addListener((r,a,o)=>{let i=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,i=`${i}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let m=pd(s),{type:g,name:p}=m;if(g!==t)return!1;let f=pd(i),b=Gi.get(g).get(p);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,w={type:t,name:f.name,id:u,url:l,active:c};if(C){try{let k=h(r.payload,w);o({ok:!0,data:k})}catch(k){o({ok:!1,errorName:k.name,errorMessage:k.message,errorDetails:k.details,errorStatus:k.status})}return!1}else return h(r.payload,w).then(k=>{o({ok:!0,data:k})}).catch(k=>{o({ok:!1,errorName:k.name,errorMessage:k.message,errorDetails:k.message,errorStatus:k.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let o=this.fromType,i=Gi.get(o);if(i.has(t))return i.get(t).connectionInstance;{let s=new md(`${o}:${t}`,this.logger);return Gi.get(o).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},md=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=pd(t),{type:a,id:o}=r;if(a!=="content_script"){let i={to:t,from:this.from,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");try{let s=await oe.runtime.sendMessage(i);return Yh(i,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let i={from:this.from,to:t,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");let s=await oe.tabs.sendMessage(o,i);return Yh(i,s,this.logger)}}};function Yh(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new K(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new K("noResponse","Unknown error")}function pd(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var ZC="";function yo(){return ZC||globalThis.navigator.userAgent}function gd(){return yo().includes("ImtFxiOS")}function Jh(){let t=yo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function eS(){return yo().includes("ImtFxAndroid")}function Xh(){let e=yo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Qh(){let t=yo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function Vi(){let e=yo();if(gd()||eS()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Mu;function fd(){return Mu||(Mu=new qr("content_script",!1).getConnection("pure_main",()=>{}),Mu)}var Zh="G-MKMD9LWFTR";async function Ki(e){try{let t=Ce(),n=t.INSTALL_FROM==="firefox_store";if(Vi()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=Ee(),o=Ue(),i=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await Dt("fakeUserId","");u||(u=await wr("fakeUserId",""),u&&await Qe("fakeUserId",u));let l=Xt(),c=new Date,m=await Dt("installedAt","");m||(m=await wr("installedAt",""),m&&await Qe("installedAt",m)),u?m||(m=new Date(0).toISOString(),await Qe("installedAt",m)):(u=tS(32),await Qe("fakeUserId",u)),m||(m=c.toISOString(),await Qe("installedAt",m));let g=new Date(m),p=e3(g),f=e3(c),y=p===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${Zh}&api_secret=${s}`;i||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Zh}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let w=no.parse(C),k=e.map(v=>{let x=v.params||{};if(w.os&&(x.os_name=w.os.name||"unknown",x.os_version=w.os.version||"unknown",x.os_version_name=w.os.versionName||"unknown"),w.browser){x.browser_name=w.browser.name||"unknown",x.browser_version=w.browser.version||"unknown";let B=Vi();B&&(x.browser_name=B.name,x.browser_version=B.version)}return w.platform&&(x.platform_type=w.platform.type||"unknown"),w.engine&&(x.engine_name=w.engine.name||"unknown",x.engine_version=w.engine.version||"unknown"),l&&(x.version=l),t.INSTALL_FROM&&(x.install_from=t.INSTALL_FROM),p&&(x.install_day=nS(g)),x.userscript=a.toString(),y?x.is_new_user_today="1":x.is_new_user_today="0",b?x.is_new_user_this_week="1":x.is_new_user_this_week="0",o?x.main_frame=0:x.main_frame=1,{...v,params:x}}),R=await Bu({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:k})})}catch{}}function tS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let p=u.slice(0,g).trim();if(u=u.slice(g+1),p.startsWith("event:")||p==="")continue;let f="";if(p.startsWith("data:")&&(f=p.slice(5).trim()),f==="[DONE]")break;let y;try{y=JSON.parse(f??"")}catch(b){P.debug("json error",b);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(p){P.error("parse response failed",p)}u&&P.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,g=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),g&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new K("fetchError",c).initNetWork(s.status)}}async function*KC(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}d();var YC=new Map;function Fu(e){let t=JC(64),n=new CustomEvent(hu,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{YC.set(t,(o,i)=>{o?a(o):r(i)})})}function JC(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};var QC="";function Xt(){return QC||Pu.version}function dd(){return oe.runtime.getManifest().version}d();function Ue(){try{let e=[Ce().EBOOK_BUILDER_URL,Ce().EBOOK_VIEWER_URL,Ce().SUBTITLE_BUILDER_URL,Ce().HTML_VIEWER_URL,Ce().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];Yt()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let o=new URL(a);return n.startsWith(o.pathname)&&t.includes(o.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}d();var Gi=new Map,qr=class{fromType;logger;constructor(t,n=!1){this.logger=new zi,n&&this.logger.setLevel("debug"),this.fromType=t,Gi.has(t)||(Gi.set(t,new Map),oe.runtime.onMessage.addListener((r,a,o)=>{let i=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,i=`${i}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let m=pd(s),{type:g,name:p}=m;if(g!==t)return!1;let f=pd(i),b=Gi.get(g).get(p);if(!b)return this.logger.debug(`no message handler for ${g}:${s}, but it's ok`),!1;let{messageHandler:h,sync:C}=b,w={type:t,name:f.name,id:u,url:l,active:c};if(C){try{let k=h(r.payload,w);o({ok:!0,data:k})}catch(k){o({ok:!1,errorName:k.name,errorMessage:k.message,errorDetails:k.details,errorStatus:k.status})}return!1}else return h(r.payload,w).then(k=>{o({ok:!0,data:k})}).catch(k=>{o({ok:!1,errorName:k.name,errorMessage:k.message,errorDetails:k.message,errorStatus:k.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let o=this.fromType,i=Gi.get(o);if(i.has(t))return i.get(t).connectionInstance;{let s=new md(`${o}:${t}`,this.logger);return Gi.get(o).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},md=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=pd(t),{type:a,id:o}=r;if(a!=="content_script"){let i={to:t,from:this.from,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");try{let s=await oe.runtime.sendMessage(i);return Yh(i,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let i={from:this.from,to:t,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");let s=await oe.tabs.sendMessage(o,i);return Yh(i,s,this.logger)}}};function Yh(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new K(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new K("noResponse","Unknown error")}function pd(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}d();var ZC="";function yo(){return ZC||globalThis.navigator.userAgent}function gd(){return yo().includes("ImtFxiOS")}function Jh(){let t=yo().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function eS(){return yo().includes("ImtFxAndroid")}function Xh(){let e=yo();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function Qh(){let t=yo().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function Vi(){let e=yo();if(gd()||eS()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Mu;function fd(){return Mu||(Mu=new qr("content_script",!1).getConnection("pure_main",()=>{}),Mu)}var Zh="G-MKMD9LWFTR";async function Ki(e){try{let t=Ce(),n=t.INSTALL_FROM==="firefox_store";if(Vi()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=Ee(),o=Ue(),i=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await Dt("fakeUserId","");u||(u=await wr("fakeUserId",""),u&&await Qe("fakeUserId",u));let l=Xt(),c=new Date,m=await Dt("installedAt","");m||(m=await wr("installedAt",""),m&&await Qe("installedAt",m)),u?m||(m=new Date(0).toISOString(),await Qe("installedAt",m)):(u=tS(32),await Qe("fakeUserId",u)),m||(m=c.toISOString(),await Qe("installedAt",m));let g=new Date(m),p=e3(g),f=e3(c),y=p===f,b=c.getTime()-g.getTime()<7*24*60*60*1e3,h=`https://www.google-analytics.com/mp/collect?measurement_id=${Zh}&api_secret=${s}`;i||(h=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${Zh}&api_secret=${s}`);let C="";typeof navigator<"u"&&(C=window.navigator.userAgent);let w=no.parse(C),k=e.map(v=>{let x=v.params||{};if(w.os&&(x.os_name=w.os.name||"unknown",x.os_version=w.os.version||"unknown",x.os_version_name=w.os.versionName||"unknown"),w.browser){x.browser_name=w.browser.name||"unknown",x.browser_version=w.browser.version||"unknown";let B=Vi();B&&(x.browser_name=B.name,x.browser_version=B.version)}return w.platform&&(x.platform_type=w.platform.type||"unknown"),w.engine&&(x.engine_name=w.engine.name||"unknown",x.engine_version=w.engine.version||"unknown"),l&&(x.version=l),t.INSTALL_FROM&&(x.install_from=t.INSTALL_FROM),p&&(x.install_day=nS(g)),x.userscript=a.toString(),y?x.is_new_user_today="1":x.is_new_user_today="0",b?x.is_new_user_this_week="1":x.is_new_user_this_week="0",o?x.main_frame=0:x.main_frame=1,{...v,params:x}}),R=await Bu({responseType:"text",url:h,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:k})})}catch{}}function tS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5363,7 +5363,7 @@ Translate the content to {{to}} Language: max-width: fit-content; } } -`,Id="immersive-translate-toastify-shadow-root",Od=class{defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,ariaLive:"polite",style:{background:""}};constructor(t){this.version="1.12.0",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(t)}showToast(){if(this.toastElement=this._buildToast(),typeof this.options.selector=="string")this._rootElement=document.getElementById(this.options.selector);else if(this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot)this._rootElement=this.options.selector;else if(document.getElementById(Id)){let t=document.getElementById(Id);this._rootElement=t.shadowRoot}else{let t=document.createElement("div");t.setAttribute("translate","no"),t.className="no-translate immersive-translate-toastify-shadow-root",t.id=Id,t.style.all="initial",t.style.zIndex="2147483647",document.body.appendChild(t);let n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=US,n.appendChild(r),this._rootElement=n}if(!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(()=>{this._removeElement(this.toastElement)},this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(t){this.options=Object.assign(this.defaults,t),this.options.backgroundColor,this.toastElement=null,this.options.gravity=t.gravity==="bottom"?"toastify-bottom":"toastify-top",this.options.stopOnFocus=t.stopOnFocus===void 0?!0:t.stopOnFocus,t.backgroundColor&&(this.options.style.background=t.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let t=document.createElement("div");t.className=`toastify on ${this.options.className}`,t.className+=` toastify-${this.options.position}`,t.className+=` ${this.options.gravity}`;for(let n in this.options.style)t.style[n]=this.options.style[n];if(this.options.ariaLive&&t.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)t.appendChild(this.options.node);else if(this.options.escapeMarkup?t.innerText=this.options.text:t.innerHTML=this.options.text,this.options.avatar!==""){let n=document.createElement("img");n.src=this.options.avatar,n.className="toastify-avatar",this.options.position=="left"?t.appendChild(n):t.insertAdjacentElement("afterbegin",n)}if(this.options.close===!0){let n=document.createElement("button");n.type="button",n.setAttribute("aria-label","Close"),n.className="toast-close",n.innerHTML="✖",n.addEventListener("click",a=>{a.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)});let r=window.innerWidth>0?window.innerWidth:screen.width;this.options.position=="left"&&r>360?t.insertAdjacentElement("afterbegin",n):t.appendChild(n)}if(this.options.stopOnFocus&&this.options.duration>0&&(t.addEventListener("mouseover",n=>{window.clearTimeout(t.timeOutValue)}),t.addEventListener("mouseleave",()=>{t.timeOutValue=window.setTimeout(()=>{this._removeElement(t)},this.options.duration)})),typeof this.options.destination<"u"&&t.addEventListener("click",n=>{n.stopPropagation(),this.options.newWindow===!0?window.open(this.options.destination,"_blank"):window.location=this.options.destination}),typeof this.options.onClick=="function"&&typeof this.options.destination>"u"&&t.addEventListener("click",n=>{n.stopPropagation(),this.options.onClick()}),typeof this.options.offset=="object"){let n=this._getAxisOffsetAValue("x",this.options),r=this._getAxisOffsetAValue("y",this.options),a=this.options.position=="left"?n:`-${n}`,o=this.options.gravity=="toastify-top"?r:`-${r}`;t.style.transform=`translate(${a},${o})`}return t}_removeElement(t){t.className=t.className.replace(" on",""),window.setTimeout(()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),t.parentNode&&t.parentNode.removeChild(t),this.options.callback.call(t),this._reposition()},400)}_reposition(){let t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify"),o;for(let i=0;i0?window.innerWidth:screen.width)<=360?(a[i].style[o]=`${r[o]}px`,r[o]+=s+u):a[i].classList.contains("toastify-left")===!0?(a[i].style[o]=`${t[o]}px`,t[o]+=s+u):(a[i].style[o]=`${n[o]}px`,n[o]+=s+u)}}_getAxisOffsetAValue(t,n){return n.offset[t]?isNaN(n.offset[t])?n.offset[t]:`${n.offset[t]}px`:"0px"}};function ll(e){e=e||{},new Od({gravity:"bottom",duration:1500,style:{background:"#222",color:"#f2f2f2"},...e}).showToast()}d();d();d();d();function Xr(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function HS(e,t){return e<>>32-t}function dl(e,t,n,r,a,o){return Xr(HS(Xr(Xr(t,e),Xr(r,o)),a),n)}function en(e,t,n,r,a,o,i){return dl(t&n|~t&r,e,t,a,o,i)}function tn(e,t,n,r,a,o,i){return dl(t&r|n&~r,e,t,a,o,i)}function nn(e,t,n,r,a,o,i){return dl(t^n^r,e,t,a,o,i)}function rn(e,t,n,r,a,o,i){return dl(n^(t|~r),e,t,a,o,i)}function cl(e,t){e[t>>5]|=128<>>9<<4)+14]=t;var n,r,a,o,i,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>t%32&255);return n}function Nd(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(e.charCodeAt(t/8)&255)<16&&(r=cl(r,e.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,o[n]=r[n]^1549556828;return i=cl(a.concat(Nd(t)),512+t.length*8),E2(cl(o.concat(i),512+128))}function x2(e){var t="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+t.charAt(r&15);return n}function jd(e){return unescape(encodeURIComponent(e))}function T2(e){return zS(jd(e))}function WS(e){return x2(T2(e))}function v2(e,t){return qS(jd(e),jd(t))}function $S(e,t){return x2(v2(e,t))}function kn(e,t,n){return t?n?v2(t,e):$S(t,e):n?T2(e):WS(e)}var Io=[];async function ml(e,t){return await new Promise((n,r)=>{let a=e,o=1,i=indexedDB.open(a,o);i.onsuccess=s=>{n(i.result)},i.onerror=s=>{r()},i.onupgradeneeded=s=>{let u=i.result,l=t||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function C2(e){let t=`${J}-${e.service}@${e.from}->${e.to}`;return await KS(t,e)}async function S2(e){let t=kn(e.originalText),n=`${J}-${e.service}@${e.from}->${e.to}`;return await VS(n,t)}async function VS(e,t){let n=await ml(e);return await new Promise((r,a)=>{if(!n)return a();let o="cache",s=n.transaction([o],"readonly").objectStore(o).get(t);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function KS(e,t){let n=await ml(e);return(await JS()).includes(e)||await YS(e),await new Promise(a=>{if(!n)return a(!1);let o="cache",s=n.transaction([o],"readwrite").objectStore(o).put(t);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function YS(e){let t="cache_list",n=await ml(J+"-cacheList",t),a=n.transaction([t],"readwrite").objectStore(t).put({key:e});a.onsuccess=o=>{n.close(),Io.push(e)},a.onerror=o=>{n.close()}}async function JS(){if(Io&&Io.length>0)return Io;let e=await ml(J+"-cacheList","cache_list");return Io=await new Promise(t=>{let n="cache_list",a=e.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=o=>{e.close(),t(a.result)},a.onerror=o=>{e.close(),t([])}}),Io}d();d();var Ud="Original";function Ke(){return Ud}function gn(e){Ud=e,w2(Ud)}d();function Oa(e){return e?.id?.endsWith("pdfWebPage")||!1}function Qr(e){try{if(!e||!Oa(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:o}=r;if(a&&o){let i=document.querySelector(a);if(!i)return"";t=i.getAttribute(o)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var Ye={},Zr=async function(e,t){let{method:n,data:r}=e,a=await Ye.updateGlobalContext(),o=Date.now();if(P.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Qe(Kn,o);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Qe(Kn,o);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Qe(Kn,o);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Qe(Kn,o);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Qe(Kn,o);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Qe(Kn,o);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Qe(Kn,o);else if(n==="translatePage")await Ye.translatePage(a,r),Qe(Kn,o);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(yu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Ri,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Ue()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Ue())return JSON.stringify(a)}};function D2(e){Object.assign(Ye,e)}function A2(e){Object.assign(Ye,e)}function k2(e){Object.assign(Ye,e)}var XS=function(e,t){let{method:n,data:r}=e;if(P.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Ke();if(n==="getCurrentPageLanguage"){let a=Et();return Ye.detectCurrentPageLanguage().catch(o=>{P.warn("detectCurrentPageLanguage failed",o)}),a}else{if(n==="setCurrentPageLanguageByClient")return On(r),Et();if(n==="getContextString"){let a=Ye.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return Qr(a?.rule)}}},pl,gl;function _2(){let e=fl();Ue()||QS(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function fl(){return pl||(pl=new qr("content_script",!1).getConnection("main",Zr),pl)}function QS(){return gl||(gl=new qr("content_script",!1).getConnection("main_sync",XS,{sync:!0}),gl)}d();var Hd=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],hl="https://transmart.qq.com/api/imt",kr=class e{static langMapReverse=new Map(Hd.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await ce({url:hl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,o=e.langMapReverse.get(a);return o||a}};d();function ZS(e,t){return Math.floor(Math.random()*(t-e+1))+e}var e5=30,zd="RATE_LIMITER_TICKS",Oo=class e{static strictTicks={};static clearStrictTicks(){Xi(zd,"{}")}static async getStrictTicks(t,n){if(n)return this.strictTicks[t]||[];try{let r=await Uu(zd);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){P.debug("Error setting rate limiter ticks",r),this.strictTicks[t]=[]}finally{return this.strictTicks[t]||[]}}static wait(t,n){return new Promise((r,a)=>{e.getDelay(t,n).then(o=>{setTimeout(()=>{r(o)},o)})})}static async setStrictTicks(t,n,r){try{if(this.strictTicks[t]=n,r)return;await Xi(zd,JSON.stringify(this.strictTicks))}catch(a){P.debug("Error setting rate limiter ticks",a)}}static async getDelay(t,n,r=!1){if(!r){let l=ZS(4,e5);await pr(l)}let a=await this.getStrictTicks(t,r)||[],{limit:o,interval:i}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(t,a,r),0):(a.push(u),await this.setStrictTicks(t,a,r),u-s)}};async function xt(e){return await fl().sendMessage("background:main",e)}function ce(e){return gu()?Fu({method:"request",data:e}):Ee()||pu()?(e.fetchPolyfill=globalThis.GM_fetch,Pa(e)):xt({method:"fetch",data:e})}function an(){return Ee()?pn():xt({method:"getConfig"})}function fn(e){return Ee()?Ji(e):xt({method:"setUserConfig",data:e})}function hn(){return Ee()?Dr():xt({method:"getUserConfig"})}function us(){return Ee()?Qt():xt({method:"getLocalConfig"})}function bl(e){return Ee()?Zt(e):xt({method:"setLocalConfig",data:e})}function L2(e){return Ee()?i3(e):xt({method:"setBuildinConfig",data:e})}async function Pe(e){if(e.text){let n=Hs(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(Ee()||nt()){if(e.translateService&&!Su.includes(e.translateService))return Promise.resolve("auto");let r=qi(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await xt({method:"detectLanguage",data:e});return Promise.resolve(t)}function F2(){return xt({method:"detectTabLanguage"})}async function yl(e){let t=await Pe({text:e,pageLangs:["en"]});try{if(Ee()||nt()){let n=e.substring(0,200);t=await kr.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function w2(e){let t=new CustomEvent(La,{detail:e});if(document.dispatchEvent(t),Ee())return;fl().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function P2(e){return Ee()?S2(e):xt({method:"queryParagraphCache",data:e})}async function M2(e){if(Ee()){await C2(e);return}return xt({method:"setParagraphCache",data:e})}async function B2(){if(Ee())return Promise.resolve();await xt({method:"mockRequest"})}function No(e=!1,t=""){return Ee()?(oe.runtime.openOptionsPage(e,t),Promise.resolve()):xt({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function jo(e=""){return Ee()||nt()?Ce().OPTIONS_URL:oe.runtime.getURL("options.html")}function R2(e=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function El(e=!1){return Ee()?(oe.extra.openAboutPage(e),Promise.resolve()):xt({method:"openAboutPage"})}function Uo(e){return Ee()?(oe.extra.openInTab(e),Promise.resolve()):xt({method:"openInTab",data:e})}function I2(e=!1){return Ee()?(oe.extra.openEbookViewerPage(e),Promise.resolve()):xt({method:"openEbookViewerPage"})}function O2(e=!1){return Ee()?(oe.extra.openEbookBuilderPage(e),Promise.resolve()):xt({method:"openEbookBuilderPage"})}function xl(e){nt()}function Ho(e=!1,t){return Ee()?(oe.extra.openPdfViewerPage(e),Promise.resolve()):xt({method:"openPdfViewerPage",data:{url:t}})}function N2(e=!1){return Ee()?(oe.extra.openSubtitleBuilderPage(e),Promise.resolve()):xt({method:"openSubtitleBuilderPage"})}function zo(e){return Ee()?Promise.resolve():xt({method:"setBadge",data:{text:e}})}function j2(){return Ee()?(P.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):xt({method:"autoSyncLatestConfig"})}function Tl(e,t=!1){return Ee()?oe.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function U2(e,t){return Ee()?Oo.getDelay(e,t):xt({method:"getDelay",data:{key:e,options:t}})}var H2="G-MKMD9LWFTR";async function rt(e,t,n){try{let r=Vi(),a=Ce(),o=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(o=!1);let i=Ee(),s=Ue(),u=a.PROD==="1",l=`report_${e}`,c=e.endsWith("_daily");if(c){if(s)return;let _=await wr(l,0),E=vl(new Date(_)),O=Date.now(),F=vl(new Date(O));if(E===F)return;await qh(l,O)}else if(!n.config.telemetry)return;let m="sitc4WmvShWYwfU0dANM3Q",g=await Dt("fakeUserId","");g||(g=await wr("fakeUserId",""),g&&await Qe("fakeUserId",g));let p=Xt(),f=new Date,y=await Dt("installedAt","");y||(y=await wr("installedAt",""),y&&await Qe("installedAt",y)),g?y||(y=new Date(0).toISOString(),await Qe("installedAt",y)):(g=t5(32),await Qe("fakeUserId",g)),y||(y=f.toISOString(),await Qe("installedAt",y));let b=new Date(y),h=vl(b),C=vl(f),w=h===C,k=f.getTime()-b.getTime()<7*24*60*60*1e3,R=`https://www.google-analytics.com/mp/collect?measurement_id=${H2}&api_secret=${m}`;u||(R=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${H2}&api_secret=${m}`);let v=no.parse(window.navigator.userAgent),x=t.map(_=>{let E=_.params||{};if(v.os&&(E.os_name=v.os.name||"unknown",E.os_version=v.os.version||"unknown",E.os_version_name=v.os.versionName||"unknown"),v.browser&&(E.browser_name=v.browser.name||"unknown",E.browser_version=v.browser.version||"unknown",r&&(E.browser_name=r.name,E.browser_version=r.version)),v.platform&&(E.platform_type=v.platform.type||"unknown"),v.engine&&(E.engine_name=v.engine.name||"unknown",E.engine_version=v.engine.version||"unknown"),n.translationService&&(E.translation_service||(E.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(E.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?E.openai_is_official="1":E.openai_is_official="0":E.openai_is_official="1"))),n.targetLanguage&&(E.target_language=n.targetLanguage),n.config.interfaceLanguage&&(E.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?E.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":E.enable_default_always_translated_urls="0",p&&(E.version=p),n.config.enableInputTranslation?E.enable_input_translation=n.config.enableInputTranslation?"1":"0":E.enable_input_translation="0",n.config.translationTheme&&(E.translation_theme=n.config.translationTheme),n.config.alpha&&(E.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?E.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):E.always_translate_languages="none",a.INSTALL_FROM&&(E.install_from=a.INSTALL_FROM),n.config.beta&&(E.beta=n.config.alpha.toString()),n.config.translationArea&&(E.translation_area=n.config.translationArea),h&&(E.install_day=n5(b)),n.user){let F=Uh(n.user);F&&Object.keys(F).forEach(M=>{E[M]=F[M]})}else E.user_type="anonymous";n.config.translationMode&&(E.translation_mode=n.config.translationMode),E.userscript=i.toString(),w?E.is_new_user_today="1":E.is_new_user_today="0",k?E.is_new_user_this_week="1":E.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?E.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():E.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),E.page_type=O,s?E.main_frame=0:E.main_frame=1,!c){let F=n.url;try{let M=new URL(F);E.site_host=M.hostname}catch{E.site_host="unknown"}n.sourceLanguage&&(E.source_language=n.sourceLanguage)}return{..._,params:E}});if(o)return;let B=await ce({responseType:"text",url:R,method:"POST",body:JSON.stringify({client_id:g,user_id:g,events:x})})}catch{}}function t5(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;at.removeEventListener("message",n)),e.length=0}function i5(e,t,n,r){return new Promise(a=>{let o=i=>{let s=i.data;a5(t,n,s)&&s.id===r&&(e.removeEventListener("message",o),a(s.response))};e.addEventListener("message",o)})}function s5(e,t,n,r){let a=o=>{let i=o.data;G2(t,"tell",n,i)&&r(i.body)};return e.addEventListener("message",a),[e,a]}function z2(e,t,n,r,a,o){let i=async s=>{let u=s.data;if(G2(n,"ask",r,u)){let l=await o(u.body);t=s.source,t.postMessage(r5(n,r,u.id,l),s.origin)}};return e.addEventListener("message",i),[e,i]}function u5(e,t,n,r,a){let o=Math.random().toString();return e.postMessage($2(t,"tell",n,o,r),a)}async function q2(e,t,n,r,a,o,i){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let m=setTimeout(()=>c(new Error(`Failed to get response within ${i}ms`)),i),g=await i5(e,n,r,s);clearTimeout(m),l(g)});return t.postMessage($2(n,"ask",r,s,a),o),u}var ta=class e{constructor(t,n,r=window,a="*"){this.protocol=t;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;z2(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(t,n=10,r=500){for(let a=0;a<=n;a++)try{return await t.ping({timeout:r}),t}catch{continue}throw new Error(`Could not connect on protocol ${t.protocol.type} after ${n*r}ms`)}static parent(t,n,r="*",a=window){let o=n.contentWindow;if(ea(o))return new e(t,o,a,r);throw new Error("iframe.contentWindow was null")}static iframe(t,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new e(t,a,r,n)}static rootIframe(t,n="*",{thisWindow:r=window}={}){return new e(t,null,r,n)}getSystemProtocol(t){return{type:`system|${t}`}}listeners=[];async ping({timeout:t=1e4}){await q2(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,t)}handleTell(t,n){this.listeners.push(s5(this.thisWindow,this.protocol,t,n))}tell(t,n){u5(this.targetWindow,this.protocol,t,n,this.targetOrigin)}handleAsk(t,n){this.listeners.push(z2(this.thisWindow,this.targetWindow,this.protocol,t,this.targetOrigin,n))}ask(t,n,r=1e4){if(this.targetWindow)return q2(this.thisWindow,this.targetWindow,this.protocol,t,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){o5(this.listeners)}};var V2;async function K2(){if(Ue()){let t=globalThis;for(;t.top!=t.self;)t=t.top;let n=ta.iframe(wu,"*",{targetWindow:t});V2=n,await ta.connect(n).catch(r=>{P.error("connect with parent frame error",r)})}}function Y2(){return V2}d();function J2(e,t){let n=t.matches||[],r=t.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(e)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(e))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(e)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(e))return!0}return!1}d();d();d();d();d();function qd(e,t,n=[],r){let a=["notranslate"];return r&&a.push(ih),e&&(a.push(`${J}-target-translation-theme-${e}`),t?a.push(`${Jc}-theme-${e}`):a.push(`${Yc}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Jc):a.push(Yc),a}function Wd(e){let t=["notranslate",Cu];return e&&t.push(`${J}-target-translation-theme-${e}-inner`),t}function X2(e,t,n){let{rule:r,state:a}=n,{translationTheme:o}=a,{variables:i,isVertical:s}=e;i=i||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,m=Ra(n,!0),g="afterend",p=m[0],f=m[1],y=`${p}(\\d+)${f}`,b=new RegExp(y,"g"),h=Ge.sanitize(u);i.length>0&&(h=h.replace(b,R=>{let v=h.indexOf(R),x=h[v-1]===" ",B=h[v+R.length]===" ",E=R.replace(new RegExp(m[0],"g"),"").replace(new RegExp(m[1],"g"),""),O=Number(E);if(isNaN(O))return R;let F=i[O];if(F&&F.type==="element"){let M=F.value.outerHTML;return x||(M=" "+M),B||(M=M+" "),M}else P.error("variable type not supported",F,R);return R}));let C=qd(o,e.inline,r.translationClasses||[],e.preWhitespace);s&&C.push(oh);let w=Wd(o),k="";return r.translationBlockStyle&&(k=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${k} class="${C.join(" ")}" ${ar}="1"><${r.targetWrapperTag} class="${w.join(" ")}" ${ar}="1">${h}`,e.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),e.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ar}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function Cl(e,t){let n=e.original||e,r=null,{stayOriginalSelectors:a,delimiters:o,isPreWhitespace:i}=t,s=[],u={};for(let l=0;l2&&(h=`<${o[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let y=c.textContent||"";g&&(y=Vr($d(c))),s.push({text:y,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Wt(c,a)){let b=Object.keys(u).length,h=`${o[0]}${b}${o[1]}`;o.length>2&&(h=`<${o[2]}${b}>`),u[b]=c;let C=Gd(s).endsWith(" ")?" ":"",w=Vr(c.innerText||c.textContent),k=Vr(c.nextSibling).startsWith(" ")?" ":"",R=rs(C+w+k),v=R[0]+h+R[1];if(C===" ")v=v.trimStart();else if(!v.startsWith(" ")){let x=rs(c.previousSibling)[1];x===""&&(x=" "),v=x+v}s.push({text:v,type:"variable"})}else{let y=Gd(s).endsWith(" ")?" ":"",b=Vr(c.innerText||c.textContent);g&&(b=Vr($d(c)));let h=Vr(c.nextSibling).startsWith(" ")?" ":"",C=rs(y+b+h),w=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(y===" ")w=w.trimStart();else{let k=rs(c.previousSibling)[1];k===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(k=" "),w=k+w}s.push({text:w,type:"text"})}else{let y=Gd(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=Vr($d(c))),y===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}e.targetText=Ge.sanitize(e.targetText);let a=!1,o=e.text,i=o.split(" ").length,s=o.split(` +`,Id="immersive-translate-toastify-shadow-root",Od=class{defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,ariaLive:"polite",style:{background:""}};constructor(t){this.version="1.12.0",this.options={},this.toastElement=null,this._rootElement=document.body,this._init(t)}showToast(){if(this.toastElement=this._buildToast(),typeof this.options.selector=="string")this._rootElement=document.getElementById(this.options.selector);else if(this.options.selector instanceof HTMLElement||this.options.selector instanceof ShadowRoot)this._rootElement=this.options.selector;else if(document.getElementById(Id)){let t=document.getElementById(Id);this._rootElement=t.shadowRoot}else{let t=document.createElement("div");t.setAttribute("translate","no"),t.className="no-translate immersive-translate-toastify-shadow-root",t.id=Id,t.style.all="initial",t.style.zIndex="2147483647",document.body.appendChild(t);let n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=US,n.appendChild(r),this._rootElement=n}if(!this._rootElement)throw"Root element is not defined";return this._rootElement.insertBefore(this.toastElement,this._rootElement.firstChild),this._reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(()=>{this._removeElement(this.toastElement)},this.options.duration)),this}hideToast(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this._removeElement(this.toastElement)}_init(t){this.options=Object.assign(this.defaults,t),this.options.backgroundColor,this.toastElement=null,this.options.gravity=t.gravity==="bottom"?"toastify-bottom":"toastify-top",this.options.stopOnFocus=t.stopOnFocus===void 0?!0:t.stopOnFocus,t.backgroundColor&&(this.options.style.background=t.backgroundColor)}_buildToast(){if(!this.options)throw"Toastify is not initialized";let t=document.createElement("div");t.className=`toastify on ${this.options.className}`,t.className+=` toastify-${this.options.position}`,t.className+=` ${this.options.gravity}`;for(let n in this.options.style)t.style[n]=this.options.style[n];if(this.options.ariaLive&&t.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)t.appendChild(this.options.node);else if(this.options.escapeMarkup?t.innerText=this.options.text:t.innerHTML=this.options.text,this.options.avatar!==""){let n=document.createElement("img");n.src=this.options.avatar,n.className="toastify-avatar",this.options.position=="left"?t.appendChild(n):t.insertAdjacentElement("afterbegin",n)}if(this.options.close===!0){let n=document.createElement("button");n.type="button",n.setAttribute("aria-label","Close"),n.className="toast-close",n.innerHTML="✖",n.addEventListener("click",a=>{a.stopPropagation(),this._removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)});let r=window.innerWidth>0?window.innerWidth:screen.width;this.options.position=="left"&&r>360?t.insertAdjacentElement("afterbegin",n):t.appendChild(n)}if(this.options.stopOnFocus&&this.options.duration>0&&(t.addEventListener("mouseover",n=>{window.clearTimeout(t.timeOutValue)}),t.addEventListener("mouseleave",()=>{t.timeOutValue=window.setTimeout(()=>{this._removeElement(t)},this.options.duration)})),typeof this.options.destination<"u"&&t.addEventListener("click",n=>{n.stopPropagation(),this.options.newWindow===!0?window.open(this.options.destination,"_blank"):window.location=this.options.destination}),typeof this.options.onClick=="function"&&typeof this.options.destination>"u"&&t.addEventListener("click",n=>{n.stopPropagation(),this.options.onClick()}),typeof this.options.offset=="object"){let n=this._getAxisOffsetAValue("x",this.options),r=this._getAxisOffsetAValue("y",this.options),a=this.options.position=="left"?n:`-${n}`,o=this.options.gravity=="toastify-top"?r:`-${r}`;t.style.transform=`translate(${a},${o})`}return t}_removeElement(t){t.className=t.className.replace(" on",""),window.setTimeout(()=>{this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),t.parentNode&&t.parentNode.removeChild(t),this.options.callback.call(t),this._reposition()},400)}_reposition(){let t={top:15,bottom:15},n={top:15,bottom:15},r={top:15,bottom:15},a=this._rootElement.querySelectorAll(".toastify"),o;for(let i=0;i0?window.innerWidth:screen.width)<=360?(a[i].style[o]=`${r[o]}px`,r[o]+=s+u):a[i].classList.contains("toastify-left")===!0?(a[i].style[o]=`${t[o]}px`,t[o]+=s+u):(a[i].style[o]=`${n[o]}px`,n[o]+=s+u)}}_getAxisOffsetAValue(t,n){return n.offset[t]?isNaN(n.offset[t])?n.offset[t]:`${n.offset[t]}px`:"0px"}};function ll(e){e=e||{},new Od({gravity:"bottom",duration:1500,style:{background:"#222",color:"#f2f2f2"},...e}).showToast()}d();d();d();d();function Xr(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function HS(e,t){return e<>>32-t}function dl(e,t,n,r,a,o){return Xr(HS(Xr(Xr(t,e),Xr(r,o)),a),n)}function en(e,t,n,r,a,o,i){return dl(t&n|~t&r,e,t,a,o,i)}function tn(e,t,n,r,a,o,i){return dl(t&r|n&~r,e,t,a,o,i)}function nn(e,t,n,r,a,o,i){return dl(t^n^r,e,t,a,o,i)}function rn(e,t,n,r,a,o,i){return dl(n^(t|~r),e,t,a,o,i)}function cl(e,t){e[t>>5]|=128<>>9<<4)+14]=t;var n,r,a,o,i,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>t%32&255);return n}function Nd(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(e.charCodeAt(t/8)&255)<16&&(r=cl(r,e.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,o[n]=r[n]^1549556828;return i=cl(a.concat(Nd(t)),512+t.length*8),E2(cl(o.concat(i),512+128))}function x2(e){var t="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+t.charAt(r&15);return n}function jd(e){return unescape(encodeURIComponent(e))}function T2(e){return zS(jd(e))}function WS(e){return x2(T2(e))}function v2(e,t){return qS(jd(e),jd(t))}function $S(e,t){return x2(v2(e,t))}function kn(e,t,n){return t?n?v2(t,e):$S(t,e):n?T2(e):WS(e)}var Io=[];async function ml(e,t){return await new Promise((n,r)=>{let a=e,o=1,i=indexedDB.open(a,o);i.onsuccess=s=>{n(i.result)},i.onerror=s=>{r()},i.onupgradeneeded=s=>{let u=i.result,l=t||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function C2(e){let t=`${J}-${e.service}@${e.from}->${e.to}`;return await KS(t,e)}async function S2(e){let t=kn(e.originalText),n=`${J}-${e.service}@${e.from}->${e.to}`;return await VS(n,t)}async function VS(e,t){let n=await ml(e);return await new Promise((r,a)=>{if(!n)return a();let o="cache",s=n.transaction([o],"readonly").objectStore(o).get(t);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function KS(e,t){let n=await ml(e);return(await JS()).includes(e)||await YS(e),await new Promise(a=>{if(!n)return a(!1);let o="cache",s=n.transaction([o],"readwrite").objectStore(o).put(t);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function YS(e){let t="cache_list",n=await ml(J+"-cacheList",t),a=n.transaction([t],"readwrite").objectStore(t).put({key:e});a.onsuccess=o=>{n.close(),Io.push(e)},a.onerror=o=>{n.close()}}async function JS(){if(Io&&Io.length>0)return Io;let e=await ml(J+"-cacheList","cache_list");return Io=await new Promise(t=>{let n="cache_list",a=e.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=o=>{e.close(),t(a.result)},a.onerror=o=>{e.close(),t([])}}),Io}d();d();var Ud="Original";function Ke(){return Ud}function gn(e){Ud=e,w2(Ud)}d();function Oa(e){return e?.id?.endsWith("pdfWebPage")||!1}function Qr(e){try{if(!e||!Oa(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:o}=r;if(a&&o){let i=document.querySelector(a);if(!i)return"";t=i.getAttribute(o)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var Ye={},Zr=async function(e,t){let{method:n,data:r}=e,a=await Ye.updateGlobalContext(),o=Date.now();if(P.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Ye.translateTheWholePage(r),Qe(Kn,o);else if(n==="translateTheMainPage")await Ye.translateTheMainPage(r),Qe(Kn,o);else if(n==="translateToThePageEndImmediately")await Ye.translateToThePageEndImmediately(r),Qe(Kn,o);else if(n==="toggleTranslatePage")await Ye.toggleTranslatePage(r),Qe(Kn,o);else if(n==="toggleTranslateTheWholePage")await Ye.toggleTranslateTheWholePage(r),Qe(Kn,o);else if(n==="toggleTranslateTheMainPage")await Ye.toggleTranslateTheMainPage(r),Qe(Kn,o);else if(n==="toggleOnlyTransation")await Ye.ensureSwitchTranslationMode(r),Qe(Kn,o);else if(n==="translatePage")await Ye.translatePage(a,r),Qe(Kn,o);else if(n==="toggleTranslationMask")await Ye.toggleTranslationMask(r);else if(n==="restorePage")Ye.restorePage();else if(n==="retryFailedParagraphs")Ye.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Ye.switchTranslationMode(r.mode),await Ye.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Ye.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(yu,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Ye.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Ri,{detail:r}));else if(n==="translateWithOpenAI")await Ye.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Ye.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Ye.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Ye.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Ye.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Ye.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Ye.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")Ue()||await Ye.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!Ue())return JSON.stringify(a)}};function D2(e){Object.assign(Ye,e)}function A2(e){Object.assign(Ye,e)}function k2(e){Object.assign(Ye,e)}var XS=function(e,t){let{method:n,data:r}=e;if(P.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Ke();if(n==="getCurrentPageLanguage"){let a=Et();return Ye.detectCurrentPageLanguage().catch(o=>{P.warn("detectCurrentPageLanguage failed",o)}),a}else{if(n==="setCurrentPageLanguageByClient")return On(r),Et();if(n==="getContextString"){let a=Ye.getPureGlobalContext(),{articleNode:o,bodyNode:i,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Ye.getPureGlobalContext();return Qr(a?.rule)}}},pl,gl;function _2(){let e=fl();Ue()||QS(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function fl(){return pl||(pl=new qr("content_script",!1).getConnection("main",Zr),pl)}function QS(){return gl||(gl=new qr("content_script",!1).getConnection("main_sync",XS,{sync:!0}),gl)}d();var Hd=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],hl="https://transmart.qq.com/api/imt",kr=class e{static langMapReverse=new Map(Hd.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await ce({url:hl,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,o=e.langMapReverse.get(a);return o||a}};d();function ZS(e,t){return Math.floor(Math.random()*(t-e+1))+e}var e5=30,zd="RATE_LIMITER_TICKS",Oo=class e{static strictTicks={};static clearStrictTicks(){Xi(zd,"{}")}static async getStrictTicks(t,n){if(n)return this.strictTicks[t]||[];try{let r=await Uu(zd);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){P.debug("Error setting rate limiter ticks",r),this.strictTicks[t]=[]}finally{return this.strictTicks[t]||[]}}static wait(t,n){return new Promise((r,a)=>{e.getDelay(t,n).then(o=>{setTimeout(()=>{r(o)},o)})})}static async setStrictTicks(t,n,r){try{if(this.strictTicks[t]=n,r)return;await Xi(zd,JSON.stringify(this.strictTicks))}catch(a){P.debug("Error setting rate limiter ticks",a)}}static async getDelay(t,n,r=!1){if(!r){let l=ZS(4,e5);await pr(l)}let a=await this.getStrictTicks(t,r)||[],{limit:o,interval:i}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(t,a,r),0):(a.push(u),await this.setStrictTicks(t,a,r),u-s)}};async function xt(e){return await fl().sendMessage("background:main",e)}function ce(e){return gu()?Fu({method:"request",data:e}):Ee()||pu()?(e.fetchPolyfill=globalThis.GM_fetch,Pa(e)):xt({method:"fetch",data:e})}function an(){return Ee()?pn():xt({method:"getConfig"})}function fn(e){return Ee()?Ji(e):xt({method:"setUserConfig",data:e})}function hn(){return Ee()?Dr():xt({method:"getUserConfig"})}function us(){return Ee()?Qt():xt({method:"getLocalConfig"})}function bl(e){return Ee()?Zt(e):xt({method:"setLocalConfig",data:e})}function L2(e){return Ee()?i3(e):xt({method:"setBuildinConfig",data:e})}async function Pe(e){if(e.text){let n=Hs(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(Ee()||nt()){if(e.translateService&&!Su.includes(e.translateService))return Promise.resolve("auto");let r=qi(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await xt({method:"detectLanguage",data:e});return Promise.resolve(t)}function F2(){return xt({method:"detectTabLanguage"})}async function yl(e){let t=await Pe({text:e,pageLangs:["en"]});try{if(Ee()||nt()){let n=e.substring(0,200);t=await kr.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function w2(e){let t=new CustomEvent(La,{detail:e});if(document.dispatchEvent(t),Ee())return;fl().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function P2(e){return Ee()?S2(e):xt({method:"queryParagraphCache",data:e})}async function M2(e){if(Ee()){await C2(e);return}return xt({method:"setParagraphCache",data:e})}async function B2(){if(Ee())return Promise.resolve();await xt({method:"mockRequest"})}function No(e=!1,t=""){return Ee()?(oe.runtime.openOptionsPage(e,t),Promise.resolve()):xt({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function jo(e=""){return Ee()||nt()?Ce().OPTIONS_URL:oe.runtime.getURL("options.html")}function R2(e=""){return oe&&oe.runtime&&oe.runtime.getURL?oe.runtime.getURL("options.html"):""}function El(e=!1){return Ee()?(oe.extra.openAboutPage(e),Promise.resolve()):xt({method:"openAboutPage"})}function Uo(e){return Ee()?(oe.extra.openInTab(e),Promise.resolve()):xt({method:"openInTab",data:e})}function I2(e=!1){return Ee()?(oe.extra.openEbookViewerPage(e),Promise.resolve()):xt({method:"openEbookViewerPage"})}function O2(e=!1){return Ee()?(oe.extra.openEbookBuilderPage(e),Promise.resolve()):xt({method:"openEbookBuilderPage"})}function xl(e){nt()}function Ho(e=!1,t){return Ee()?(oe.extra.openPdfViewerPage(e),Promise.resolve()):xt({method:"openPdfViewerPage",data:{url:t}})}function N2(e=!1){return Ee()?(oe.extra.openSubtitleBuilderPage(e),Promise.resolve()):xt({method:"openSubtitleBuilderPage"})}function zo(e){return Ee()?Promise.resolve():xt({method:"setBadge",data:{text:e}})}function j2(){return Ee()?(P.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):xt({method:"autoSyncLatestConfig"})}function Tl(e,t=!1){return Ee()?oe.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function U2(e,t){return Ee()?Oo.getDelay(e,t):xt({method:"getDelay",data:{key:e,options:t}})}var H2="G-MKMD9LWFTR";async function rt(e,t,n){try{let r=Vi(),a=Ce(),o=a.INSTALL_FROM==="firefox_store";r?.name?.startsWith("ImtFx")&&(o=!1);let i=Ee(),s=Ue(),u=a.PROD==="1",l=`report_${e}`,c=e.endsWith("_daily");if(c){if(s)return;let _=await wr(l,0),E=vl(new Date(_)),O=Date.now(),F=vl(new Date(O));if(E===F)return;await qh(l,O)}else if(!n.config.telemetry)return;let m="sitc4WmvShWYwfU0dANM3Q",g=await Dt("fakeUserId","");g||(g=await wr("fakeUserId",""),g&&await Qe("fakeUserId",g));let p=Xt(),f=new Date,y=await Dt("installedAt","");y||(y=await wr("installedAt",""),y&&await Qe("installedAt",y)),g?y||(y=new Date(0).toISOString(),await Qe("installedAt",y)):(g=t5(32),await Qe("fakeUserId",g)),y||(y=f.toISOString(),await Qe("installedAt",y));let b=new Date(y),h=vl(b),C=vl(f),w=h===C,k=f.getTime()-b.getTime()<7*24*60*60*1e3,R=`https://www.google-analytics.com/mp/collect?measurement_id=${H2}&api_secret=${m}`;u||(R=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${H2}&api_secret=${m}`);let v=no.parse(window.navigator.userAgent),x=t.map(_=>{let E=_.params||{};if(v.os&&(E.os_name=v.os.name||"unknown",E.os_version=v.os.version||"unknown",E.os_version_name=v.os.versionName||"unknown"),v.browser&&(E.browser_name=v.browser.name||"unknown",E.browser_version=v.browser.version||"unknown",r&&(E.browser_name=r.name,E.browser_version=r.version)),v.platform&&(E.platform_type=v.platform.type||"unknown"),v.engine&&(E.engine_name=v.engine.name||"unknown",E.engine_version=v.engine.version||"unknown"),n.translationService&&(E.translation_service||(E.translation_service=n.translationService),n.config.translationServices&&n.config.translationServices[n.translationService]&&(n.config.translationServices[n.translationService].provider&&(E.translation_service_provider=n.config.translationServices[n.translationService].provider),n.translationService==="openai"&&n.config.translationServices[n.translationService].provider==="custom"&&(n.config.translationServices[n.translationService].apiUrl?n.config.translationServices[n.translationService].apiUrl.startsWith("https://api.openai.com/")?E.openai_is_official="1":E.openai_is_official="0":E.openai_is_official="1"))),n.targetLanguage&&(E.target_language=n.targetLanguage),n.config.interfaceLanguage&&(E.interface_language=n.config.interfaceLanguage),n.config.enableDefaultAlwaysTranslatedUrls?E.enable_default_always_translated_urls=n.config.enableDefaultAlwaysTranslatedUrls?"1":"0":E.enable_default_always_translated_urls="0",p&&(E.version=p),n.config.enableInputTranslation?E.enable_input_translation=n.config.enableInputTranslation?"1":"0":E.enable_input_translation="0",n.config.translationTheme&&(E.translation_theme=n.config.translationTheme),n.config.alpha&&(E.alpha=n.config.alpha.toString()),n.config.translationLanguagePattern&&n.config.translationLanguagePattern.matches?.length>0?E.always_translate_languages=n.config.translationLanguagePattern.matches.join(","):E.always_translate_languages="none",a.INSTALL_FROM&&(E.install_from=a.INSTALL_FROM),n.config.beta&&(E.beta=n.config.alpha.toString()),n.config.translationArea&&(E.translation_area=n.config.translationArea),h&&(E.install_day=n5(b)),n.user){let F=Uh(n.user);F&&Object.keys(F).forEach(M=>{E[M]=F[M]})}else E.user_type="anonymous";n.config.translationMode&&(E.translation_mode=n.config.translationMode),E.userscript=i.toString(),w?E.is_new_user_today="1":E.is_new_user_today="0",k?E.is_new_user_this_week="1":E.is_new_user_this_week="0",n.config.tempTranslateDomainMinutes?E.temp_translate_domain_minutes=n.config.tempTranslateDomainMinutes.toString():E.temp_translate_domain_minutes="0";let O="html";if(n.rule.pageType&&(O=n.rule.pageType),E.page_type=O,s?E.main_frame=0:E.main_frame=1,!c){let F=n.url;try{let M=new URL(F);E.site_host=M.hostname}catch{E.site_host="unknown"}n.sourceLanguage&&(E.source_language=n.sourceLanguage)}return{..._,params:E}});if(o)return;let B=await ce({responseType:"text",url:R,method:"POST",body:JSON.stringify({client_id:g,user_id:g,events:x})})}catch{}}function t5(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;at.removeEventListener("message",n)),e.length=0}function i5(e,t,n,r){return new Promise(a=>{let o=i=>{let s=i.data;a5(t,n,s)&&s.id===r&&(e.removeEventListener("message",o),a(s.response))};e.addEventListener("message",o)})}function s5(e,t,n,r){let a=o=>{let i=o.data;G2(t,"tell",n,i)&&r(i.body)};return e.addEventListener("message",a),[e,a]}function z2(e,t,n,r,a,o){let i=async s=>{let u=s.data;if(G2(n,"ask",r,u)){let l=await o(u.body);t=s.source,t.postMessage(r5(n,r,u.id,l),s.origin)}};return e.addEventListener("message",i),[e,i]}function u5(e,t,n,r,a){let o=Math.random().toString();return e.postMessage($2(t,"tell",n,o,r),a)}async function q2(e,t,n,r,a,o,i){let s=Math.random().toString(),u=new Promise(async(l,c)=>{let m=setTimeout(()=>c(new Error(`Failed to get response within ${i}ms`)),i),g=await i5(e,n,r,s);clearTimeout(m),l(g)});return t.postMessage($2(n,"ask",r,s,a),o),u}var ta=class e{constructor(t,n,r=window,a="*"){this.protocol=t;this.targetWindow=n;this.thisWindow=r;this.targetOrigin=a;z2(r,n,this.getSystemProtocol("ping"),"ping",a,()=>Promise.resolve({}))}static async connect(t,n=10,r=500){for(let a=0;a<=n;a++)try{return await t.ping({timeout:r}),t}catch{continue}throw new Error(`Could not connect on protocol ${t.protocol.type} after ${n*r}ms`)}static parent(t,n,r="*",a=window){let o=n.contentWindow;if(ea(o))return new e(t,o,a,r);throw new Error("iframe.contentWindow was null")}static iframe(t,n="*",{thisWindow:r=window,targetWindow:a=window.parent}={}){return new e(t,a,r,n)}static rootIframe(t,n="*",{thisWindow:r=window}={}){return new e(t,null,r,n)}getSystemProtocol(t){return{type:`system|${t}`}}listeners=[];async ping({timeout:t=1e4}){await q2(this.thisWindow,this.targetWindow,this.getSystemProtocol("ping"),"ping",{data:{},payload:{}},this.targetOrigin,t)}handleTell(t,n){this.listeners.push(s5(this.thisWindow,this.protocol,t,n))}tell(t,n){u5(this.targetWindow,this.protocol,t,n,this.targetOrigin)}handleAsk(t,n){this.listeners.push(z2(this.thisWindow,this.targetWindow,this.protocol,t,this.targetOrigin,n))}ask(t,n,r=1e4){if(this.targetWindow)return q2(this.thisWindow,this.targetWindow,this.protocol,t,n,this.targetOrigin,r);throw new Error("target window is requried")}destroy(){o5(this.listeners)}};var V2;async function K2(){if(Ue()){let t=globalThis;for(;t.top!=t.self;)t=t.top;let n=ta.iframe(wu,"*",{targetWindow:t});V2=n,await ta.connect(n).catch(r=>{P.error("connect with parent frame error",r)})}}function Y2(){return V2}d();function J2(e,t){let n=t.matches||[],r=t.excludeMatches||[];if(r&&!Array.isArray(r)&&(r=[r]),n&&!Array.isArray(n)&&(n=[n]),r.length>0){if(r.includes(e)||r.includes(""))return!1;for(let a of r)if(a.includes("*")&&new RegExp(a).test(e))return!1}if(n.length===0)return!1;if(n.length>0){if(n.includes(e)||n.includes(""))return!0;for(let a of n)if(a.includes("*")&&new RegExp(a).test(e))return!0}return!1}d();d();d();d();d();function qd(e,t,n=[],r){let a=["notranslate"];return r&&a.push(ih),e&&(a.push(`${J}-target-translation-theme-${e}`),t?a.push(`${Jc}-theme-${e}`):a.push(`${Yc}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Jc):a.push(Yc),a}function Wd(e){let t=["notranslate",Cu];return e&&t.push(`${J}-target-translation-theme-${e}-inner`),t}function X2(e,t,n){let{rule:r,state:a}=n,{translationTheme:o}=a,{variables:i,isVertical:s}=e;i=i||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,m=Ra(n,!0),g="afterend",p=m[0],f=m[1],y=`${p}(\\d+)${f}`,b=new RegExp(y,"g"),h=Ge.sanitize(u);i.length>0&&(h=h.replace(b,R=>{let v=h.indexOf(R),x=h[v-1]===" ",B=h[v+R.length]===" ",E=R.replace(new RegExp(m[0],"g"),"").replace(new RegExp(m[1],"g"),""),O=Number(E);if(isNaN(O))return R;let F=i[O];if(F&&F.type==="element"){let M=F.value.outerHTML;return x||(M=" "+M),B||(M=M+" "),M}else P.error("variable type not supported",F,R);return R}));let C=qd(o,e.inline,r.translationClasses||[],e.preWhitespace);s&&C.push(oh);let w=Wd(o),k="";return r.translationBlockStyle&&(k=`style="${r.translationBlockStyle}"`),h=`<${n.rule.targetWrapperTag} ${k} class="${C.join(" ")}" ${ar}="1"><${r.targetWrapperTag} class="${w.join(" ")}" ${ar}="1">${h}`,e.inline||(l==="smart"?h=`
${h}`:h=`${l}${h}`),e.inline&&(l!=="smart"?h=`${l}${h}`:h=`<${r.targetWrapperTag} class="notranslate" ${ar}="1"> ${h}`),c==="smart"?h=`${h}`:h=`${h}${c}`,{html:h,position:g}}function Cl(e,t){let n=e.original||e,r=null,{stayOriginalSelectors:a,delimiters:o,isPreWhitespace:i}=t,s=[],u={};for(let l=0;l2&&(h=`<${o[2]}${b}>`),u[b]=c,s.push({text:h,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let y=c.textContent||"";g&&(y=Vr($d(c))),s.push({text:y,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&Wt(c,a)){let b=Object.keys(u).length,h=`${o[0]}${b}${o[1]}`;o.length>2&&(h=`<${o[2]}${b}>`),u[b]=c;let C=Gd(s).endsWith(" ")?" ":"",w=Vr(c.innerText||c.textContent),k=Vr(c.nextSibling).startsWith(" ")?" ":"",R=rs(C+w+k),v=R[0]+h+R[1];if(C===" ")v=v.trimStart();else if(!v.startsWith(" ")){let x=rs(c.previousSibling)[1];x===""&&(x=" "),v=x+v}s.push({text:v,type:"variable"})}else{let y=Gd(s).endsWith(" ")?" ":"",b=Vr(c.innerText||c.textContent);g&&(b=Vr($d(c)));let h=Vr(c.nextSibling).startsWith(" ")?" ":"",C=rs(y+b+h),w=C[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+C[1];if(y===" ")w=w.trimStart();else{let k=rs(c.previousSibling)[1];k===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(k=" "),w=k+w}s.push({text:w,type:"text"})}else{let y=Gd(s).endsWith(" ")?" ":"",b="";c.textContent&&(b=Vr($d(c))),y===" "&&(b=b.trimStart()),s.push({text:b,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(g=s[c-1].text),c/g,">"))}e.targetText=Ge.sanitize(e.targetText);let a=!1,o=e.text,i=o.split(" ").length,s=o.split(` `).length;i<=n.blockMinWordCount&&o.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ra(t);if(l.length>2){let c=l[2];return l5({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=X2(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function $d(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function l5(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:o,variables:i,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;i=i||[];let m=e.targetText;m=Ge.sanitize(m);let g=m,p=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),f=new RegExp(`<${t}(\\d+)>`);i.length>0&&(g=g.replace(p,C=>{let w=g.indexOf(C),k=g[w-1]===" ",R=g[w+C.length]===" ",v=C.match(f);if(!v)return C;let x=v[1],B=Number(x);if(isNaN(B))return C;let _=i[Number(B)];if(_&&_.type==="element"){let E=_.value.outerHTML;return k||(E=" "+E),R||(E=E+" "),E}else if(_&&_.type==="text"){let E=_.value;return k||(E=" "+E),R||(E=E+" "),E}else P.error("variable type not supported",_,C);return C}));let y=qd(l,n,r||[],s),b=Wd(l),h="";return c&&(h=`style="${c}"`),g=`<${a} ${h} class="${y.join(" ")}" ${ar}="1"><${a} class="${b.join(" ")}" ${ar}="1">${g}`,n||(o==="smart"?g=`
${g}`:g=`${o}${g}`),n&&(o!=="smart"?g=`${o}${g}`:g=`<${a} class="notranslate" ${ar}="1"> ${g}`),u==="smart"?g=`${g}`:g=`${g}${u}`,{html:g,position:"afterend"}}function Gd(e){let t=e[e.length-1];return t?t.text:""}function Vd(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let o=n[2],i=new RegExp(`<${o}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${o}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(i,c=>{let m=c.match(s);if(!m)return c;let g=m[1],p=Number(g);if(isNaN(p))return c;let f=r[g];return f||c})),u}else{let o=`${n[0]}(\\d+)${n[1]}`,i=new RegExp(o,"g");a=a.replace(i,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}var we=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,o=!1,i=!1,s=[],u=null,l=new Set;for(let b of a)b.from&&b.from!=="auto"&&l.add(b.from),b.refresh&&(o=!0),b.debug&&(i=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let m=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(m=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(m=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=l3(a,c,m)}catch(b){if(r)for(let h=0;hb));let g=[],p=[],f=(b,h,C)=>{let w="";if(h.translatedTexts&&h.translatedTexts[0]&&(w=h.translatedTexts[0]),p[b]||(p[b]=h,p[b].translatedTexts=Array(h.sentenceTotalParts).fill(null)),p[b].hasError)return;if(C){let v=C instanceof K?new K(C.name,C.message).initNetWork(C.status).initData(C.data):C;p[b].hasError=!0,h.callback&&h.callback(v,null,h.sentence);return}p[b].translatedTexts[h.partIndex]=w;let k=p[b],R=0;for(let v=0;v{let R=h.from;if(h.fromByClient&&h.fromByClient!=="auto"&&(R=h.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:h.tempSentences.map(x=>x.text),forces:h.tempSentences.map(x=>x.force),xpaths:h.tempSentences.map(x=>x.xpath||""),from:R,to:h.to,url:C,options:n,refresh:o,debug:i}),sourceTempSentences:h.tempSentences};{let v=ah;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(v=this.serviceConfig.translationTextSeparator);let x=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(x=this.serviceConfig.newlinePlaceholderDelimiters);let B=[],_=ur(this.serviceConfig);if(h.tempSentences.forEach((H,L)=>{let S=Ad({text:H.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:_,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:h.to});H.force!==!0&&(S&&S.text&&S.text.trim().lengthL.text);return Promise.resolve({sourceTempSentences:h.tempSentences,text:H,from:R,to:h.to})}let E="";x&&x.length>=2?E=B.map((H,L)=>{let{item:S}=H;return L===B.length-1?S.text:S.text+x[0]+(L+1)+x[1]}).join(""):E=B.map(({item:H})=>H.text).join(v);let O=await this.translate({text:E,from:R,to:h.to,url:C,options:{...n,rawTextArrayLength:B.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:o,debug:i}),{text:F}=O,M=[];if(x&&x.length>=2){let H=`${x[0]}\\d+${x[1]}`;x&&x.length>=3&&(H=x[2]);let L=new RegExp(H,"g");M=F.split(L)}else M=F.split(v);let N=[];if(M.length>B.length){for(let H=0;HH.text);return _=ur(this.serviceConfig,!0),N.forEach((H,L)=>{let S=B[L],A=S.index,j=S.variables||{};Object.keys(j).length>0&&(H=Vd({text:H,delimiters:_,variables:j})),U[A]=H}),{sourceTempSentences:h.tempSentences,text:U,from:O.from,to:O.to}}};g.push(k().then(R=>{let{text:v,sourceTempSentences:x}=R;for(let B=0;B{if(R instanceof K&&R.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let v=0;v{let h=b.sentence.text;return b.translatedTexts&&b.translatedTexts.length>0&&(h=b.translatedTexts.join("")),{...b.sentence,text:h}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],o=ur(this.serviceConfig);if(this.serviceConfig&&o.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((m,g)=>{let p=Ad({text:m,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:o,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[g]!==!0&&(p&&p.text&&p.text.trim().lengthm.text),n.xpaths=a.map(m=>m.xpath)}catch(l){P.debug("formatAndTranslateList error",t,l)}let i=await this.translateList(n),{text:s}=i,u=t.text.map(l=>l);return o=ur(this.serviceConfig,!0),s.forEach((l,c)=>{let m=a[c];if(m){let g=m.index,p=m.variables,f=Object.keys(p);u[g]=l,f.length>0&&(u[g]=Vd({text:l,delimiters:o,variables:p}))}}),{...i,text:u}}detectLanguageLocally(t){return Pe({text:t,minLength:18,pageLangs:[Et(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};var Z2=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],ls=class e extends we{static langMap=new Map(Z2);maxTextGroupLength=50;static langMapReverse=new Map(Z2.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new K("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetText,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetTextList,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:o,version:i}){let s=`${o}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await Jn(a)].join(` `),m=e.getUTCDate(u),g=["TC3-HMAC-SHA256",l,`${m}/${o}/tc3_request`,await Jn(c)].join(` `),p=await d2(m,`TC3${n}`),f=await ol(o,p),y=await ol("tc3_request",f),b=await ol(g,y),h=await ce({retry:this.retry,url:`https://${o}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":i,Authorization:`TC3-HMAC-SHA256 Credential=${t}/${m}/${o}/tc3_request, SignedHeaders=content-type;host, Signature=${b}`},body:a,timeout:this.requestTimeout});if(h instanceof Error)throw h;if(h.Response&&h.Response.Error&&h.Response.Error.Message)throw new K(h.Response.Error.Message);return h}};d();var e1=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],c5={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},cs=class e extends we{static langMap=new Map(e1);static langMapReverse=new Map(e1.map(([t,n])=>[n,t]));isSupportList=!1;constructor(t,n,r){super(t,n,r)}async translate(t){let{text:n,from:r,to:a}=t,o=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),i=await ce({url:`https://wxapp.translator.qq.com/api/translate?${o}`,retry:this.retry,method:"GET",headers:c5,timeout:this.requestTimeout});return{text:i.targetText,from:e.langMapReverse.get(i.source)||r,to:e.langMapReverse.get(i.target)||a}}};d();var t1=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Na=class e extends we{static langMap=new Map(t1);static langMapReverse=new Map(t1.map(([t,n])=>[n,t]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(t,n,r){super(t,n,r),t?.apiUrl&&(this.apiUrl=It(this.apiUrl,t.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let o=e.langMap.get(r)||"auto",i=e.langMap.get(a)||a,s=await this.fetchWithoutToken(n,o,i);if(!s)throw new K("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new K("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let o=e.langMap.get(r)||"auto",i=e.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,o,i);if(!s)throw new K("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new K("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(t,n,r){let o="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}).toString();return{data:await ce({retry:this.retry,url:o,timeout:this.requestTimeout})}}async fetchWithoutToken(t,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}),o=this.apiUrl+"?"+a.toString();return{data:await ce({retry:this.retry,url:o,timeout:this.requestTimeout})}}};d();d();d();function d5(e,t){return t?e+(t-e%t):e}function m5(e,t){return e.split(t).length-1}function Kd(e){let t=Date.now(),n=1;for(let r of e)n+=m5(r,"i");return d5(t,n)}function p5(e,t){return Math.floor(Math.random()*(t-e+1))+e}function Yd(){return p5(1e6,1e8)}d();d();d();var Jd="https://www2.deepl.com/jsonrpc",Xd="auto",n1=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];d();function g5(e=n1){return e.reduce((t,n)=>(t[n.code.toLowerCase()]=n.code,t[n.language.toLowerCase()]=n.code,t),{})}function Qd(e){return g5()[e.toLowerCase()]}var f5={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function h5(e){return JSON.stringify(e).replace('"method":"',()=>{let t=e;return(t.id+3)%13===0||(t.id+5)%29===0?'"method" : "':'"method": "'})}function b5(e,t){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:e,target_lang:t}}}}async function y5(e,t,n,r,a,o,i){let s=Yd(),u=b5(r,n),l=[];t.forEach(g=>{l.push({text:g,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Kd(t);let c=await ce({retry:2,method:"POST",url:e,body:h5(u),headers:f5}),m={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(g=>{m.text.push(g.text)}),m}async function r1(e,t,n,r=Xd,a,o,i){return t?t&&t.length===1&&t[0]===""?{text:[""],from:r,to:n}:y5(e,t,Qd(n),Qd(r)??"auto",a,o,i):{text:[],from:r,to:n}}var a1=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],qo=class e extends we{static langMap=new Map(a1);static langMapReverse=new Map(a1.map(([t,n])=>[n,t]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Jd;constructor(t,n,r){super(t,n,r),t&&t.apiUrl&&(this.API_URL=It(Jd,t.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(t){let{text:n,to:r,from:a}=t,o=await r1(this.API_URL,n,e.langMap.get(r)||r,e.langMap.get(a)||"auto");return{text:o.text,from:e.langMapReverse.get(o.from),to:e.langMapReverse.get(o.to)}}};d();var ds=class e extends we{static langMap=new Map(Hd);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(t,n,r){super(t,n,r),this.clientKey=kr.getClientKey()}async translate(t){let{text:n,to:r}=t,a=await this.detectLanguage(n),o=e.langMap.get(a)||a,i=e.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Ce(),u=t.url;s.INSTALL_FROM==="firefox_store"&&(u=o1());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:o,orig_url:u},target:{lang:i}}),m=await ce({url:hl,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(m.header.ret_code!=="succ")throw new K(m.message||m.header.ret_code);return{text:m.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(t){let{from:n,text:r,to:a}=t,o=Ce(),i=t.url;if(o.INSTALL_FROM==="firefox_store"&&(i=o1()),r.length===1){let p=await this.translate({from:n,text:r[0],to:a,url:i,options:t.options});return{text:[p.text],from:p.from,to:p.to}}let u=await this.detectLanguage(r.join(` diff --git a/docs/options/options.js b/docs/options/options.js index 3679c93..a47fafc 100644 --- a/docs/options/options.js +++ b/docs/options/options.js @@ -1,4 +1,4 @@ -(()=>{var k5=Object.create;var Nc=Object.defineProperty;var A5=Object.getOwnPropertyDescriptor;var L5=Object.getOwnPropertyNames;var _5=Object.getPrototypeOf,M5=Object.prototype.hasOwnProperty;var P5=(e,t)=>()=>(e&&(t=e(e=0)),t);var F5=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Uc=(e,t)=>{for(var n in t)Nc(e,n,{get:t[n],enumerable:!0})},B5=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of L5(t))!M5.call(e,a)&&a!==n&&Nc(e,a,{get:()=>t[a],enumerable:!(r=A5(t,a))||r.enumerable});return e};var R5=(e,t,n)=>(n=e!=null?k5(_5(e)):{},B5(t||!e||!e.__esModule?Nc(n,"default",{value:e,enumerable:!0}):n,e));var E,m=P5(()=>{E={BUILD_TIME:"2024-04-03T13:26:22.000Z",VERSION:"1.4.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var k5=Object.create;var Nc=Object.defineProperty;var A5=Object.getOwnPropertyDescriptor;var L5=Object.getOwnPropertyNames;var _5=Object.getPrototypeOf,M5=Object.prototype.hasOwnProperty;var P5=(e,t)=>()=>(e&&(t=e(e=0)),t);var F5=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Uc=(e,t)=>{for(var n in t)Nc(e,n,{get:t[n],enumerable:!0})},B5=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of L5(t))!M5.call(e,a)&&a!==n&&Nc(e,a,{get:()=>t[a],enumerable:!(r=A5(t,a))||r.enumerable});return e};var R5=(e,t,n)=>(n=e!=null?k5(_5(e)):{},B5(t||!e||!e.__esModule?Nc(n,"default",{value:e,enumerable:!0}):n,e));var E,m=P5(()=>{E={BUILD_TIME:"2024-04-03T14:10:03.000Z",VERSION:"1.4.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; @@ -5013,13 +5013,13 @@ ass, HTML, TXT files.`,"description.multiplePrompt":`When the number of paragrap {env.imt_sub_trans_field}: Translation`,"subtitle.quickButton.black":"Black","subtitle.quickButton.cyan":"Blue","translationServices.claude":"Claude","subtitle.quickButton.backgroundColor":"Background color","subtitle.quickButton.green":"Green","subtitle.quickButton.blue":"Blue","subtitle.quickButton.white":"White","subtitle.quickButton.setting":"Settings","subtitle.quickButton.translationPosition":"Translation location","subtitle.quickButton.backgroundOpacity":"Background Opacity","subtitle.quickButton.sourceFontSize":"Original font size","subtitle.quickButton.sourceTextColor":"Original font color","subtitle.quickButton.yellow":"Yellow","subtitle.quickButton.translationFontSize":"Translation font size","subtitle.quickButton.translationPositionBottom":"Below the original text","subtitle.quickButton.red":"Red","subtitle.quickButton.translationPositionTop":"Above the original text","subtitle.quickButton.translationTextColor":"Translation font color","subtitle.quickButton.magenta":"Magenta",attachSubtitleTranslating:"Translating using {service}...","error.claude.403":"Access to the service is temporarily unavailable, possibly due to regional restrictions related to Claude. You can try changing your IP address, or use other translation services.","browser.brandDescriptionForSafari":"Free Translate Website, Translate PDF & Epub eBook, Translate Video Subtitles in Bilingual","browser.PdfProFile":"AI-Driven PDF Pro Translation","browser.textTranslate":"Text Translation"};var d2=[{code:"zh-CN",messages:u2},{code:"zh-TW",messages:l2},{code:"en",messages:c2}];var m2="immersiveTranslateDeeplGlobalState",xg="immersiveTranslateBingGlobalState",Eg="immersiveTranslateYandexGlobalState",tn={};for(let e of d2)tn[e.code]=e.messages;var fo="Immersive Translate",ee="immersive-translate";var be="immersiveTranslate",Ll="759003177173-mfm15s5nd77vfmo6e7lanof1emnanf0e.apps.googleusercontent.com",Ta=be+"GoogleAccessToken",Os=be+"AuthFlow",_l="immersive-translate-config-latest.json",Sg=be+"AuthState",Ml=be+"IframeMessage",Ej=be+"WaitForRateLimit",p2=be+"DocumentMessageAsk",Gt=be+"DocumentMessageTellThirdParty",ho=be+"showError",f2=be+"DocumentMessageThirdPartyTell",h2=be+"DocumentMessageEventUpload",b2=be+"DocumentMessageHandler",Pl=`${be}Share`,Ns=`${be}ToggleMouseHoverTranslateDirectly`,y2=`${be}ReqDraft`,C2=`${be}ResDraft`,QE=`${be}Container`,T2=`${be}SpecifiedContainer`,Gr="buildinConfig",gi="localConfig",Us="openOptionsPage",wg="openAboutPage",v2="translateLocalPdfFile";var js="openEbookViewer",Hs="openEbookBuilder";var bo=`${be}PageTranslatedStatus`,Sj=`${be}PageUrlChanged`,Yr=`${be}ReceiveCommand`,x2=be+"LastUseMouseHoverTime",Fl=be+"LastUseInputTime",gr=be+"LastUseManualTranslatePageTime",wj=`${be}PopupReceiveMessage`,ZE="immersivetranslate.com",XE="config.immersivetranslate.com",Dj=`https://${ZE}/`,va=`https://${XE}/default_config.json`,kj=`${be}Mark`,Fn=`${be}Root`,E2=`${be}Walked`,Aj=`data-${ee}-walked`,S2=`${be}Paragraph`,w2=`data-${ee}-paragraph`,wr=`data-${ee}-translation-element-mark`,D2=`${be}TranslationElementMark`,Lj=`${be}TranslatedMark`,k2=`${be}LoadingId`,Dg=`data-${ee}-loading-id`,A2=`${be}ErrorId`,Bl=`data-${ee}-error-id`,eS=`${be}AtomicBlockMark`,L2=`${be}ExcludeMark`,_j=`data-${ee}-exclude-mark`,tS=`${be}StayOriginalMark`,Mj=`${be}PreWhitespaceMark`,Rl=`${be}InlineMark`,_2=`${be}BlockMark`,Pj=`${be}Left`,Fj=`${be}Right`,Bj=`${be}Width`,Rj=`${be}Height`,Ij=`${be}Top`,Oj=`${be}FontSize`,M2="lastRunTime",Nj=`${be}GlobalStyleMark`,zs=["@","#"],Il=" --- ",P2=` `,Lt=`${ee}-target-wrapper`,Uj=`${ee}-pdf-target-container`,Ol=`${ee}-target-inner`,jj=`${ee}-source-wrapper`,kg=`${ee}-target-translation-block-wrapper`,Hj=`${ee}-root-translation-theme`,mi=`${be}RootTranslationTheme`,F2=`${ee}-target-translation-vertical-block-wrapper`,zj=`${ee}-target-translation-pdf-block-wrapper`,B2=`${ee}-target-translation-pre-whitespace`,Ag=`${ee}-target-translation-inline-wrapper`,Lg=["none","dashed","underline","dashedBorder","solidBorder","mask","opacity","dotted","dividingLine","highlight","marker","marker2","blockquote","weakening","grey","paper","italic","bold","thinDashed","wavy","nativeDotted","nativeDashed","nativeUnderline"],qs={underline:[{name:"borderColor",required:!1,type:"color"}],nativeUnderline:[{name:"borderColor",required:!1,type:"color"}],nativeDashed:[{name:"borderColor",required:!1,type:"color"}],nativeDotted:[{name:"borderColor",required:!1,type:"color"}],dotted:[{name:"borderColor",required:!1,type:"color"}],dividingLine:[{name:"borderColor",required:!1,type:"color"}],highlight:[{name:"backgroundColor",required:!1,type:"color"}],marker:[{name:"backgroundColor",required:!1,type:"color"}],dashed:[{name:"borderColor",required:!1,type:"color"}],blockquote:[{name:"borderColor",required:!1,type:"color"}],thinDashed:[{name:"borderColor",required:!1,type:"color"}],dashedBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],solidBorder:[{name:"borderRadius",required:!1,type:"number",default:"0"},{name:"borderColor",required:!1,type:"color"}],marker2:[{name:"backgroundColor",required:!1,type:"color"}],wavy:[{name:"borderColor",required:!1,type:"color"}],opacity:[{name:"opacity",required:!1,type:"number",default:10}]},Bn=["auto","zh-CN","zh-TW","en","ja","ko","es","de","fr","pt","pt-br","ru","ar","it","ms","id","vi","af","th","ur","yue","zh-CN-NE","bo","wyw","am","az","be","bg","bn","bs","ca","ceb","co","cs","cy","da","el","eo","et","eu","fa","fi","fil","fj","fy","ga","gd","gl","gu","ha","haw","he","hi","hmn","hr","ht","hu","hy","ig","is","jw","ka","kk","km","kn","ku","ky","la","lb","lo","lt","lv","mg","mi","mk","ml","mn","mr","mt","mww","my","ne","nl","no","ny","otq","pa","pl","ps","ro","sa","sd","si","sk","sl","sm","sn","so","sq","sr","sr-Cyrl","sr-Latn","st","su","sv","sw","ta","te","tg","tlh","tlh-Qaak","to","tr","ty","ug","uk","uz","xh","yi","yo","yua","zu"],R2={af:"Afrikaans",am:"Amharic",ar:"Arabic",auto:"Auto Detect",az:"Azerbaijani",be:"Belarusian",bg:"Bulgarian",tn:"Zana",bn:"Bengali",bs:"Bosnian",bo:"Tibetan",ca:"Catalan",ceb:"Cebuano",co:"Corsican",cs:"Czech",cy:"Welsh",da:"Danish",de:"German",el:"Greek",en:"English",eo:"Esperanto",es:"Spanish",et:"Estonian",eu:"Basque",sa:"Sanskrit",fa:"Persian",fi:"Finnish",fil:"Filipino",fj:"Fijian",fr:"French",fy:"Frisian",ga:"Irish",gd:"Scottish Gaelic",gl:"Galician",gu:"Gujarati",ha:"Hausa",haw:"Hawaiian",he:"Hebrew",hi:"Hindi",hmn:"Hmong",hr:"Croatian",ht:"Haitian Creole",hu:"Hungarian",hy:"Armenian",id:"Indonesian",ig:"Igbo",is:"Icelandic",it:"Italian",ja:"Japanese",jw:"Javanese",ka:"Georgian",kk:"Kazakh",km:"Khmer",kn:"Kannada",ko:"Korean",ku:"Kurdish",ky:"Kyrgyz",la:"Latin",lb:"Luxembourgish",lo:"Lao",lt:"Lithuanian",lv:"Latvian",mg:"Malagasy",mi:"Maori",mk:"Macedonian",ml:"Malayalam",mn:"Mongolian",mr:"Marathi",ms:"Malay",mt:"Maltese",mww:"Hmong Daw",my:"Burmese",ne:"Nepali",nl:"Dutch",no:"Norwegian",ny:"Chichewa",otq:"Quer\xE9taro Otomi",pa:"Punjabi",pl:"Polish",ps:"Pashto",pt:"Portuguese","pt-br":"Portuguese (Brazil)",ro:"Romanian",ru:"Russian",sd:"Sindhi",si:"Sinhala",sk:"Slovak",sl:"Slovenian",sm:"Samoan",sn:"Shona",so:"Somali",sq:"Albanian",sr:"Serbian","sr-Cyrl":"Serbian (Cyrillic)","sr-Latn":"Serbian (Latin)",st:"Sesotho",su:"Sundanese",sv:"Swedish",sw:"Swahili",ta:"Tamil",te:"Telugu",tg:"Tajik",th:"Thai",tlh:"Klingon","tlh-Qaak":"Klingon (piqaD)",to:"Tongan",tr:"Turkish",ty:"Tahitian",ug:"Uyghur",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",vi:"Vietnamese",wyw:"Classical Chinese",xh:"Xhosa",placeholder:"Please Select",yi:"Yiddish",yo:"Yoruba",yua:"Yucatec Maya",yue:"Cantonese (Traditional)","zh-CN":"Simplified Chinese","zh-TW":"Traditional Chinese","zh-CN-NE":"Northeastern Chinese",zu:"Zulu","":"All Languages"},I2={placeholder:"\u8BF7\u9009\u62E9",af:"\u5357\u975E\u8377\u5170\u8BED",am:"\u963F\u59C6\u54C8\u62C9\u8BED",ar:"\u963F\u62C9\u4F2F\u8BED",auto:"\u81EA\u52A8\u68C0\u6D4B",az:"\u963F\u585E\u62DC\u7586\u8BED",be:"\u767D\u4FC4\u7F57\u65AF\u8BED",bg:"\u4FDD\u52A0\u5229\u4E9A\u8BED",tn:"\u8D5E\u7EB3\u8BED",bn:"\u5B5F\u52A0\u62C9\u8BED",bs:"\u6CE2\u65AF\u5C3C\u4E9A\u8BED",bo:"\u85CF\u8BED",ca:"\u52A0\u6CF0\u7F57\u5C3C\u4E9A\u8BED",ceb:"\u5BBF\u52A1\u8BED",co:"\u79D1\u897F\u5609\u8BED",cs:"\u6377\u514B\u8BED",cy:"\u5A01\u5C14\u58EB\u8BED",da:"\u4E39\u9EA6\u8BED",de:"\u5FB7\u8BED",el:"\u5E0C\u814A\u8BED",en:"\u82F1\u8BED",eo:"\u4E16\u754C\u8BED",es:"\u897F\u73ED\u7259\u8BED",et:"\u7231\u6C99\u5C3C\u4E9A\u8BED",eu:"\u5DF4\u65AF\u514B\u8BED",sa:"\u68B5\u8BED",fa:"\u6CE2\u65AF\u8BED",fi:"\u82AC\u5170\u8BED",fil:"\u83F2\u5F8B\u5BBE\u8BED",fj:"\u6590\u6D4E\u8BED",fr:"\u6CD5\u8BED",fy:"\u5F17\u91CC\u65AF\u5170\u8BED",ga:"\u7231\u5C14\u5170\u8BED",gd:"\u82CF\u683C\u5170\u76D6\u5C14\u8BED",gl:"\u52A0\u5229\u897F\u4E9A\u8BED",gu:"\u53E4\u5409\u62C9\u7279\u8BED",ha:"\u8C6A\u8428\u8BED",haw:"\u590F\u5A01\u5937\u8BED",he:"\u5E0C\u4F2F\u6765\u8BED",hi:"\u5370\u5730\u8BED",hmn:"\u82D7\u8BED",hr:"\u514B\u7F57\u5730\u4E9A\u8BED",ht:"\u6D77\u5730\u514B\u91CC\u5965\u5C14\u8BED",hu:"\u5308\u7259\u5229\u8BED",hy:"\u4E9A\u7F8E\u5C3C\u4E9A\u8BED",id:"\u5370\u5EA6\u5C3C\u897F\u4E9A\u8BED",ig:"\u4F0A\u535A\u8BED",is:"\u51B0\u5C9B\u8BED",it:"\u610F\u5927\u5229\u8BED",ja:"\u65E5\u672C\u8BED",jw:"\u722A\u54C7\u8BED",ka:"\u683C\u9C81\u5409\u4E9A\u8BED",kk:"\u54C8\u8428\u514B\u8BED",km:"\u9AD8\u68C9\u8BED",kn:"\u5361\u7EB3\u8FBE\u8BED",ko:"\u97E9\u8BED",ku:"\u5E93\u5C14\u5FB7\u8BED",ky:"\u5409\u5C14\u5409\u65AF\u8BED",la:"\u62C9\u4E01\u8BED",lb:"\u5362\u68EE\u5821\u8BED",lo:"\u8001\u631D\u8BED",lt:"\u7ACB\u9676\u5B9B\u8BED",lv:"\u62C9\u8131\u7EF4\u4E9A\u8BED",mg:"\u9A6C\u62C9\u52A0\u65AF\u8BED",mi:"\u6BDB\u5229\u8BED",mk:"\u9A6C\u5176\u987F\u8BED",ml:"\u9A6C\u62C9\u96C5\u62C9\u59C6\u8BED",mn:"\u8499\u53E4\u8BED",mr:"\u9A6C\u62C9\u5730\u8BED",ms:"\u9A6C\u6765\u8BED",mt:"\u9A6C\u8033\u4ED6\u8BED",mww:"\u767D\u82D7\u8BED",my:"\u7F05\u7538\u8BED",ne:"\u5C3C\u6CCA\u5C14\u8BED",nl:"\u8377\u5170\u8BED",no:"\u632A\u5A01\u8BED",ny:"\u9F50\u5207\u74E6\u8BED\uFF08\u5C3C\u626C\u8D3E\u8BED\uFF09",otq:"\u514B\u96F7\u5854\u7F57\u5965\u6258\u7C73\u8BED",pa:"\u65C1\u906E\u666E\u8BED",pl:"\u6CE2\u5170\u8BED",ps:"\u666E\u4EC0\u56FE\u8BED",pt:"\u8461\u8404\u7259\u8BED","pt-br":"\u8461\u8404\u7259\u8BED\uFF08\u5DF4\u897F\uFF09",ro:"\u7F57\u9A6C\u5C3C\u4E9A\u8BED",ru:"\u4FC4\u8BED",sd:"\u4FE1\u5FB7\u8BED",si:"\u50E7\u4F3D\u7F57\u8BED",sk:"\u65AF\u6D1B\u4F10\u514B\u8BED",sl:"\u65AF\u6D1B\u6587\u5C3C\u4E9A\u8BED",sm:"\u8428\u6469\u4E9A\u8BED",sn:"\u4FEE\u7EB3\u8BED",so:"\u7D22\u9A6C\u91CC\u8BED",sq:"\u963F\u5C14\u5DF4\u5C3C\u4E9A\u8BED",sr:"\u585E\u5C14\u7EF4\u4E9A\u8BED","sr-Cyrl":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u897F\u91CC\u5C14\u6587\uFF09","sr-Latn":"\u585E\u5C14\u7EF4\u4E9A\u8BED\uFF08\u62C9\u4E01\u6587\uFF09",st:"\u585E\u7D22\u6258\u8BED",su:"\u5DFD\u4ED6\u8BED",sv:"\u745E\u5178\u8BED",sw:"\u65AF\u74E6\u5E0C\u91CC\u8BED",ta:"\u6CF0\u7C73\u5C14\u8BED",te:"\u6CF0\u5362\u56FA\u8BED",tg:"\u5854\u5409\u514B\u8BED",th:"\u6CF0\u8BED",tlh:"\u514B\u6797\u8D21\u8BED","tlh-Qaak":"\u514B\u6797\u8D21\u8BED\uFF08piqaD\uFF09",to:"\u6C64\u52A0\u8BED",tr:"\u571F\u8033\u5176\u8BED",ty:"\u5854\u5E0C\u63D0\u8BED",ug:"\u7EF4\u543E\u5C14\u8BED",uk:"\u4E4C\u514B\u5170\u8BED",ur:"\u4E4C\u5C14\u90FD\u8BED",uz:"\u4E4C\u5179\u522B\u514B\u8BED",vi:"\u8D8A\u5357\u8BED",wyw:"\u6587\u8A00\u6587",xh:"\u73ED\u56FE\u8BED",yi:"\u610F\u7B2C\u7EEA\u8BED",yo:"\u7EA6\u9C81\u5DF4\u8BED",yua:"\u5C24\u5361\u5766\u739B\u96C5\u8BED",yue:"\u7CA4\u8BED","zh-CN":"\u7B80\u4F53\u4E2D\u6587","zh-TW":"\u7E41\u4F53\u4E2D\u6587","zh-CN-NE":"\u4E1C\u5317\u8BDD",zu:"\u7956\u9C81\u8BED","":"\u6240\u6709\u8BED\u8A00"},O2={placeholder:"\u8ACB\u9078\u64C7",af:"\u963F\u975E\u5229\u5361\u8A9E",am:"\u963F\u59C6\u54C8\u62C9\u8A9E",ar:"\u963F\u62C9\u4F2F\u8A9E",auto:"\u81EA\u52D5\u6AA2\u6E2C",az:"\u963F\u585E\u62DC\u7586\u8A9E",be:"\u767D\u4FC4\u7F85\u65AF\u8A9E",bg:"\u4FDD\u52A0\u5229\u4E9E\u8A9E",tn:"\u8D0A\u7D0D\u8A9E",bn:"\u5B5F\u52A0\u62C9\u8A9E",bs:"\u6CE2\u65AF\u5C3C\u4E9E\u8A9E",bo:"\u85CF\u8A9E",ca:"\u52A0\u6CF0\u862D\u8A9E",ceb:"\u5BBF\u9727\u8A9E",co:"\u79D1\u897F\u5609\u8A9E",cs:"\u6377\u514B\u8A9E",cy:"\u5A01\u723E\u65AF\u8A9E",da:"\u4E39\u9EA5\u8A9E",de:"\u5FB7\u8A9E",el:"\u5E0C\u81D8\u8A9E",en:"\u82F1\u8A9E",eo:"\u4E16\u754C\u8A9E",es:"\u897F\u73ED\u7259\u8A9E",et:"\u611B\u6C99\u5C3C\u4E9E\u8A9E",eu:"\u5DF4\u65AF\u514B\u8A9E",sa:"\u68B5\u8A9E",fa:"\u6CE2\u65AF\u8A9E",fi:"\u82AC\u862D\u8A9E",fil:"\u83F2\u5F8B\u8CD3\u8A9E",fj:"\u6590\u6FDF\u8A9E",fr:"\u6CD5\u8A9E",fy:"\u5F17\u91CC\u897F\u8A9E",ga:"\u611B\u723E\u862D\u8A9E",gd:"\u8607\u683C\u862D\u84CB\u723E\u8A9E",gl:"\u52A0\u5229\u897F\u4E9E\u8A9E",gu:"\u53E4\u5409\u62C9\u7279\u8A9E",ha:"\u8C6A\u6492\u8A9E",haw:"\u590F\u5A01\u5937\u8A9E",he:"\u5E0C\u4F2F\u4F86\u8A9E",hi:"\u5370\u5730\u8A9E",hmn:"\u82D7\u8A9E",hr:"\u514B\u7F85\u5730\u4E9E\u8A9E",ht:"\u6D77\u5730\u514B\u91CC\u5967\u723E\u8A9E",hu:"\u5308\u7259\u5229\u8A9E",hy:"\u4E9E\u7F8E\u5C3C\u4E9E\u8A9E",id:"\u5370\u5C3C\u8A9E",ig:"\u4F0A\u535A\u8A9E",is:"\u51B0\u5CF6\u8A9E",it:"\u610F\u5927\u5229\u8A9E",ja:"\u65E5\u8A9E",jw:"\u722A\u54C7\u8A9E",ka:"\u55AC\u6CBB\u4E9E\u8A9E",kk:"\u54C8\u85A9\u514B\u8A9E",km:"\u9AD8\u68C9\u8A9E",kn:"\u574E\u7D0D\u9054\u8A9E",ko:"\u97D3\u8A9E",ku:"\u5EAB\u723E\u5FB7\u8A9E",ky:"\u5409\u723E\u5409\u65AF\u8A9E",la:"\u62C9\u4E01\u8A9E",lb:"\u76E7\u68EE\u5821\u8A9E",lo:"\u8001\u64BE\u8A9E",lt:"\u7ACB\u9676\u5B9B\u8A9E",lv:"\u62C9\u812B\u7DAD\u4E9E\u8A9E",mg:"\u99AC\u62C9\u52A0\u65AF\u8A9E",mi:"\u6BDB\u5229\u8A9E",mk:"\u99AC\u5176\u9813\u8A9E",ml:"\u99AC\u62C9\u96C5\u62C9\u59C6\u8A9E",mn:"\u8499\u53E4\u8A9E",mr:"\u99AC\u62C9\u5730\u8A9E",ms:"\u99AC\u4F86\u8A9E",mt:"\u99AC\u723E\u4ED6\u8A9E",mww:"\u767D\u82D7\u8A9E",my:"\u7DEC\u7538\u8A9E",ne:"\u5C3C\u6CCA\u723E\u8A9E",nl:"\u8377\u862D\u8A9E",no:"\u632A\u5A01\u8A9E",ny:"\u9F4A\u5207\u74E6\u8A9E",otq:"\u594E\u96F7\u5854\u7F85\u5967\u6258\u7C73\u8A9E",pa:"\u65C1\u906E\u666E\u8A9E",pl:"\u6CE2\u862D\u8A9E",ps:"\u666E\u4EC0\u5716\u8A9E",pt:"\u8461\u8404\u7259\u8A9E","pt-br":"\u8461\u8404\u7259\u8A9E\uFF08\u5DF4\u897F\uFF09",ro:"\u7F85\u99AC\u5C3C\u4E9E\u8A9E",ru:"\u4FC4\u8A9E",sd:"\u4FE1\u5FB7\u8A9E",si:"\u50E7\u4F3D\u7F85\u8A9E",sk:"\u65AF\u6D1B\u4F10\u514B\u8A9E",sl:"\u65AF\u6D1B\u7DAD\u5C3C\u4E9E\u8A9E",sm:"\u85A9\u6469\u4E9E\u8A9E",sn:"\u7D39\u7D0D\u8A9E",so:"\u7D22\u99AC\u91CC\u8A9E",sq:"\u963F\u723E\u5DF4\u5C3C\u4E9E\u8A9E",sr:"\u585E\u723E\u7DAD\u4E9E\u8A9E","sr-Cyrl":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u897F\u91CC\u723E\u6587)","sr-Latn":"\u585E\u723E\u7DAD\u4E9E\u8A9E (\u62C9\u4E01\u6587)",st:"\u585E\u7D22\u6258\u8A9E",su:"\u5DFD\u4ED6\u8A9E",sv:"\u745E\u5178\u8A9E",sw:"\u65AF\u74E6\u5E0C\u91CC\u8A9E",ta:"\u6CF0\u7C73\u723E\u8A9E",te:"\u6CF0\u76E7\u56FA\u8A9E",tg:"\u5854\u5409\u514B\u8A9E",th:"\u6CF0\u8A9E",tlh:"\u514B\u6797\u8CA2\u8A9E","tlh-Qaak":"\u514B\u6797\u8CA2\u8A9E (piqaD)",to:"\u6771\u52A0\u8A9E",tr:"\u571F\u8033\u5176\u8A9E",ty:"\u5854\u5E0C\u63D0\u8A9E",ug:"\u7DAD\u543E\u723E\u8A9E",uk:"\u70CF\u514B\u862D\u8A9E",ur:"\u70CF\u723E\u90FD\u8A9E",uz:"\u70CF\u8332\u5225\u514B\u8A9E",vi:"\u8D8A\u5357\u8A9E",wyw:"\u6587\u8A00\u6587",xh:"\u79D1\u85A9\u8A9E",yi:"\u610F\u7B2C\u7DD2\u8A9E",yo:"\u7D04\u9B6F\u5DF4\u8A9E",yua:"\u5C24\u52A0\u6566\u99AC\u96C5\u8A9E",yue:"\u5EE3\u6771\u8A71 (\u50B3\u7D71)","zh-CN":"\u7C21\u9AD4\u4E2D\u6587","zh-TW":"\u7E41\u9AD4\u4E2D\u6587","zh-CN-NE":"\u6771\u5317\u8A71",zu:"\u7956\u9B6F\u8A9E","":"\u6240\u6709\u8A9E\u8A00"};var Nl=[{name:"touch",shortcuts:[{command:"touchShortcutsToggleTranslatePage",type:"finger"},{command:"touchShortcutsToggleTranslationMask",type:"finger"},{command:"touchShortcutsToggleTranslatePageOnlyTranslation",type:"finger"},{command:"touchShortcutsToggleTranslateTouchElement",type:"finger"}]},{name:"main",shortcuts:["toggleTranslatePage","shareToDraft","translateInputBox"]},{name:"mouse",shortcuts:[{command:"mouseHoverHoldKey",type:"mouseHoverHoldKey"},"toggleMouseHoverTranslateDirectly"]},{name:"others",shortcuts:["toggleTranslationMask","toggleTranslateToThePageEndImmediately","toggleTranslateTheMainPage","toggleOnlyTransation","toggleTranslateTheWholePage","toggleVideoSubtitlePreTranslation"]},{name:"shortcutsForTranslationServices",shortcuts:["translateWithDeepL","translateWithGoogle","translateWithOpenAI","translateWithBing","translateWithTransmart","translateWithGemini"]}],N2=["https://immersive-translate.owenyoung.com/options/","https://immersive-translate.owenyoung.com/auth-done/","https://dash.immersivetranslate.com/","https://dash.immersivetranslate.com/auth-done/","http://localhost:8000/dist/userscript/options/","http://localhost:8000/auth-done/","http://192.168.50.9:8000/dist/userscript/options/","http://192.168.31.51:8000/dist/userscript/options/","http://192.168.1.72:8000/dist/userscript/options/","https://www.deepl.com/translator","translate.google.com","http://localhost:8000/options/","http://192.168.50.9:8000/options/","http://192.168.31.51:8000/options/","http://192.168.1.72:8000/options/"],Dr="zh-CN",Ul="https://immersivetranslate.com/docs/communities/",g2=[{type:"select",name:"codename",labelKey:"field.translationEngine",default:"youdao",required:!1,options:[{label:"translationServices.google",value:"google"},{label:"translationServices.deepl",value:"deepl"},{label:"translationServices.youdao",value:"youdao"},{label:"translationServices.tencent",value:"tencent"},{label:"translationServices.aliyun",value:"aliyun"},{label:"translationServices.baidu",value:"baidu"},{label:"translationServices.caiyun",value:"caiyun"},{label:"translationServices.wechat",value:"wechat"},{label:"translationServices.ibm",value:"ibm"},{label:"translationServices.azure",value:"azure"},{label:"translationServices.aws",value:"aws"}]}],jl=["caiyun","cai"],Qn={bing:{name:"\u5FAE\u8F6F\u7FFB\u8BD1",homepage:"https://www.bing.com/translator"},google:{name:"Google",homepage:"https://translate.google.com/"},deepl:{name:"DeepL",homepage:"https://www.deepl.com/translator",docUrl:"https://immersivetranslate.com/docs/services/deepL/",providers:[{name:"pro",nameKey:"deepLProName",descriptionKey:"deepLProDescription",descriptionKeyForNormal:"deeplProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"deepLCustomName",descriptionKey:"deepLCustomDescription",descriptionLink1:"https://www.deepl.com/translator",descriptionLink2:"https://immersivetranslate.com/docs/services/deepL/"}],allProps:[{name:"authKey",providers:["custom"],label:"Auth Key",required:!0,type:"password"}]},openai:{name:"Open AI",homepage:"https://openai.com/api/",docUrl:"https://immersivetranslate.com/docs/services/openai/",providers:[{name:"pro",nameKey:"openaiProName",descriptionKey:"openaiProDescription",descriptionKeyForNormal:"openaiProDescriptionForNormal",descriptionLink1:"https://immersivetranslate.com/pricing"},{name:"custom",nameKey:"openaiCustomName",descriptionKey:"openaiCustomDescription",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/"}],allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",required:!1,type:"model-select",default:"gpt-3.5-turbo-1106",providers:["custom"],options:[{providers:["custom","pro"],label:"gpt-3.5-turbo",value:"gpt-3.5-turbo"},{providers:["custom"],label:"gpt-3.5-turbo-0125",value:"gpt-3.5-turbo-0125"},{providers:["custom","pro"],label:"gpt-3.5-turbo-1106",value:"gpt-3.5-turbo-1106"},{providers:["custom","pro"],label:"gpt-3.5-turbo-0613",value:"gpt-3.5-turbo-0613"},{providers:["custom"],label:"gpt-4-1106-preview",value:"gpt-4-1106-preview"},{providers:["custom"],label:"gpt-4-0125-preview",value:"gpt-4-0125-preview"},{providers:["custom"],label:"gpt-4",value:"gpt-4"}]},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.limitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:10,providers:["custom"]},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.openai.com/v1/chat/completions",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",optional:!0,providers:["custom"]},{name:"systemPrompt",label:"System Prompt",required:!1,descriptionKey:"description.systemPrompt",type:"textarea",optional:!0,default:"You are a translation engine, you can only translate text and cannot interpret it, and do not explain."},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:`Translate the text to {{to}}, please do not explain any sentences, just translate or leave them as they are.: -{{text}}`,optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},yandex:{name:"Yandex",homepage:"https://translate.yandex.com/"},gemini:{name:"Gemini",homepage:"https://makersuite.google.com/",docUrl:"https://immersivetranslate.com/docs/services/gemini/",beta:!0,allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",options:[{label:"gemini-1.0-pro-latest",value:"gemini-1.0-pro-latest"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:3,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/gemini/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},claude:{name:"Claude",homepage:"https://www.anthropic.com/",docUrl:"https://immersivetranslate.com/docs/services/claude/",allProps:[{name:"APIKEY",providers:["custom"],required:!0,type:"password"},{name:"model",labelKey:"field.model",descriptionKey:"description.model",optional:!0,required:!1,type:"model-select",default:"claude-3-haiku-20240307",options:[{label:"claude-3-haiku-20240307",value:"claude-3-haiku-20240307"},{label:"claude-3-sonnet-20240229",value:"claude-3-sonnet-20240229"},{label:"claude-3-opus-20240229",value:"claude-3-opus-20240229"},{label:"claude-2.1",value:"claude-2.1"}]},{name:"limit",required:!1,optional:!0,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",descriptionLink1:"https://immersivetranslate.com/docs/services/openai/",type:"number",default:1},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:10,optional:!0},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.anthropic.com/v1/messages",descriptionKey:"description.apiUrl",descriptionLink1:"https://immersivetranslate.com/docs/services/claude/",optional:!0},{name:"prompt",label:"Prompt",required:!1,descriptionKey:"description.prompt",type:"textarea",default:"",optional:!0},{name:"multiplePrompt",label:"Multiple Prompt",required:!1,descriptionKey:"description.multiplePrompt",type:"textarea",default:"",optional:!0},{name:"subtitlePrompt",label:"Subtitle Prompt",required:!1,descriptionKey:"description.subtitlePrompt",type:"textarea",default:"",optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:zs,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...g2,{type:"password",name:"apikey",required:!0}],props:g2},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},Hl={type:be+"ChildFrameToRootFrameIdentifier"},_g=["youtube","netflix","webvtt","khanacademy","bilibili","udemy","hulu","text_track","text_track_dynamic","general","live","ebutt","disneyplus","fmp4.xml","multi_attach_vtt","twitter","subsrt","xml","av"],Jr=["Ctrl","Shift","Alt","Auto","Off","OtherCustom","Other"],U2=["ctrl","alt","shift","cmd","command","option","control"],zl=[{key:"/"},{key:"="},{key:";"},{key:","},{key:"."},{key:":"},{key:"space",labelKey:"spaceKey",skipForStarting:!0},{key:"none",labelKey:"noneKey",skipForTrailing:!0}],qj=gn()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general",Ws="user_from_plugin",Tt="user_info",yo=gn()||Jn()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",ql=gn()||Jn()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",j2=ql+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",H2=ql+"&utm_source=extension&utm_medium=extension&utm_campaign=popup_more",Co=gn()||Jn()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",xa=gn()||Jn()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",nS=gn()||Jn()?"https://immersivetranslate.com/download/":"https://test.immersivetranslate.com/download/",rS=gn()||Jn()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",aS=gn()||Jn()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",Wj=xa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",z2=nS+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",q2=xa+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",Wl=xa+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",W2=rS+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",$2=aS+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",V2=Co+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true",$l="https://immersivetranslate.com/docs/usage/",K2="https://immersivetranslate.com/docs/communities/",G2=Pe().TRANSLATE_FILE_URL,Y2=G2+"?utm_source=extension&utm_medium=extension&utm_campaign=options_nav",J2=G2+"?utm_source=extension&utm_medium=extension&utm_campaign=float_ball";var pi=console,Mg=class{#e=performance.now();reset(){this.#e=performance.now()}stop(t){let n=performance.now(),r=Math.round(n-this.#e),a=Gn.green;r>1e4?a=Gn.red:r>1e3&&(a=Gn.yellow),pi.debug(Gn.dim(fo+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},$s=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&pi.log(Gn.dim(fo+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&pi.log(Gn.green(fo+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&pi.warn(Gn.yellow(fo+" WARN:"),...t)}error(...t){this.#e<=3&&pi.error(Gn.red(fo+" ERROR:"),...t)}fatal(...t){this.#e<=4&&pi.error(Gn.red(fo+" FATAL:"),...t)}timing(){return this.level===0?new Mg:{reset:()=>{},stop:()=>{}}}},I=new $s;m();function at(){try{let e=[Pe().EBOOK_BUILDER_URL,Pe().EBOOK_VIEWER_URL,Pe().SUBTITLE_BUILDER_URL,Pe().HTML_VIEWER_URL,Pe().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];gn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let o=new URL(a);return n.startsWith(o.pathname)&&t.includes(o.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}m();m();var Vl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.3",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};m();m();m();var Pg=/iPhone/i,Q2=/iPod/i,Z2=/iPad/i,X2=/\biOS-universal(?:.+)Mac\b/i,Fg=/\bAndroid(?:.+)Mobile\b/i,e1=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Kl=/Silk/i,Qr=/Windows Phone/i,t1=/\bWindows(?:.+)ARM\b/i,n1=/BlackBerry/i,r1=/BB10/i,a1=/Opera Mini/i,o1=/\b(CriOS|Chrome)(?:.+)Mobile/i,i1=/Mobile(?:.+)Firefox\b/i,s1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function iS(e){return t=>t.test(e)}function ot(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=iS(n),o={apple:{phone:a(Pg)&&!a(Qr),ipod:a(Q2),tablet:!a(Pg)&&(a(Z2)||s1(t))&&!a(Qr),universal:a(X2),device:(a(Pg)||a(Q2)||a(Z2)||a(X2)||s1(t))&&!a(Qr)},amazon:{phone:a(fi),tablet:!a(fi)&&a(Kl),device:a(fi)||a(Kl)},android:{phone:!a(Qr)&&a(fi)||!a(Qr)&&a(Fg),tablet:!a(Qr)&&!a(fi)&&!a(Fg)&&(a(Kl)||a(e1)),device:!a(Qr)&&(a(fi)||a(Kl)||a(Fg)||a(e1))||a(/\bokhttp\b/i)},windows:{phone:a(Qr),tablet:a(t1),device:a(Qr)||a(t1)},other:{blackberry:a(n1),blackberry10:a(r1),opera:a(a1),firefox:a(i1),chrome:a(o1),device:a(n1)||a(r1)||a(a1)||a(i1)||a(o1)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}var Bg="DENO",Gl="CHROME",Yl="FIREFOX";function u1(e){let t=Gl;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Yl:/deno/i.test(n)&&(t=Bg)}catch{}return e===Gl&&t===Gl||e===Yl&&t===Yl||e===Bg&&t===Bg}function l1(){return u1(Gl)}function c1(){return typeof Deno<"u"}function Zr(){return u1(Yl)}function Ea(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function d1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function To(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}m();var g1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},m1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:g1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:g1,query:()=>{},sendMessage:()=>{}}};var Q;c1()?Q=m1:Q=globalThis.immersiveTranslateBrowserAPI;var sS="";function Zn(){return sS||Vl.version}function kr(){return Q.runtime.getManifest().version}m();function p1(e){return e.replace(//g,">")}m();function Yt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function f1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function h1(e){if(e){let t=new Date(e.createTime),n=uS(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function uS(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,o]=n.split("/");return n=`${o}-${r}-${a}`,n}catch{return"unknown"}}m();m();function Te(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Bn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Bn[a]}else return"auto";else return Bn[r]}function kt(){return Te(document?.documentElement?.lang||"en")}function Vs(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+i.text.length>t||o.tempSentences.length>=n)&&(a.push(o),o={fromByClient:o.fromByClient,from:i.from,to:i.to,tempSentences:[],url:i.url}),(o.from!==i.from||o.to!==i.to)&&(o.tempSentences.length>0?(a.push(o),o={fromByClient:o.fromByClient,from:i.from,to:i.to,tempSentences:[],url:i.url}):(o.from=i.from,o.to=i.to)),o.tempSentences.push(i);return o.tempSentences.length>0&&a.push(o),a}function lS(e,t){let n=[],r=[];for(let a=0;a0?y1e4?a=Gn.red:r>1e3&&(a=Gn.yellow),pi.debug(Gn.dim(fo+" TIMING:"),t,"in",a(r+"ms")),this.#e=n}},$s=class{#e=1;get level(){return this.#e}setLevel(t){switch(t){case"debug":this.#e=0;break;case"info":this.#e=1;break;case"warn":this.#e=2;break;case"error":this.#e=3;break;case"fatal":this.#e=4;break}}debug(...t){this.#e<=0&&pi.log(Gn.dim(fo+" DEBUG:"),...t)}v(...t){this.#e<=0}info(...t){this.#e<=1&&pi.log(Gn.green(fo+" INFO:"),...t)}l(...t){this.#e<=1}warn(...t){this.#e<=2&&pi.warn(Gn.yellow(fo+" WARN:"),...t)}error(...t){this.#e<=3&&pi.error(Gn.red(fo+" ERROR:"),...t)}fatal(...t){this.#e<=4&&pi.error(Gn.red(fo+" FATAL:"),...t)}timing(){return this.level===0?new Mg:{reset:()=>{},stop:()=>{}}}},I=new $s;m();function at(){try{let e=[Pe().EBOOK_BUILDER_URL,Pe().EBOOK_VIEWER_URL,Pe().SUBTITLE_BUILDER_URL,Pe().HTML_VIEWER_URL,Pe().PDF_VIEWER_URL].filter(a=>!!a),t=["app.immersivetranslate.com"];gn()||t.push("localhost:38001");let n=globalThis.location.pathname;return e.find(a=>{let o=new URL(a);return n.startsWith(o.pathname)&&t.includes(o.host)})?!1:globalThis.self!==globalThis.top}catch{return!0}}m();m();var Vl={manifest_version:3,name:"__MSG_brandName__",description:"__MSG_brandDescription__",version:"1.4.4",default_locale:"en",background:{service_worker:"background.js"},web_accessible_resources:["styles/inject.css","pdf/index.html","video-subtitle/inject.js"],content_scripts:[{matches:["","file:///*","*://*/*"],js:["content_script.js"],run_at:"document_end",all_frames:!0},{matches:["","file:///*","*://*/*"],js:["content_start.js"],run_at:"document_start",all_frames:!0}],commands:{toggleTranslatePage:{suggested_key:{default:"Alt+A"},description:"__MSG_toggleTranslatePage__"},toggleTranslateTheWholePage:{suggested_key:{default:"Alt+W"},description:"__MSG_toggleTranslateTheWholePage__"},toggleOnlyTransation:{description:"__MSG_toggleOnlyTransation__"},toggleTranslateToThePageEndImmediately:{description:"__MSG_toggleTranslateToThePageEndImmediately__"},toggleTranslateTheMainPage:{description:"__MSG_toggleTranslateTheMainPage__"},toggleTranslationMask:{description:"__MSG_toggleTranslationMask__"},shareToDraft:{description:"__MSG_shareToDraft__"},toggleMouseHoverTranslateDirectly:{description:"__MSG_toggleMouseHoverTranslateDirectly__"},translateWithOpenAI:{description:"__MSG_translateWithOpenAI__"},translateWithDeepL:{description:"__MSG_translateWithDeepL__"},translateWithGoogle:{description:"__MSG_translateWithGoogle__"},translateWithTransmart:{description:"__MSG_translateWithTransmart__"},translateWithGemini:{description:"__MSG_translateWithGemini__"},translateWithBing:{description:"__MSG_translateWithBing__"},translateInputBox:{description:"__MSG_translateInputBox__"},toggleVideoSubtitlePreTranslation:{description:"__MSG_toggleVideoSubtitlePreTranslation__"}},options_page:"options.html",options_ui:{page:"options.html",open_in_tab:!0,browser_style:!1},permissions:["storage","activeTab","contextMenus","webRequest","webRequestBlocking","declarativeNetRequestWithHostAccess","declarativeNetRequestFeedback","declarativeNetRequest"],host_permissions:[""],declarative_net_request:{rule_resources:[{id:"ruleset_1",enabled:!0,path:"rules/request_modifier_rule.json"}]},action:{default_popup:"popup.html",default_icon:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"}},browser_action:{default_icon:"icons/32.png",default_popup:"popup.html",theme_icons:[{dark:"icons/32.png",light:"icons/dark-32.png",size:32},{dark:"icons/48.png",light:"icons/dark-48.png",size:48},{dark:"icons/64.png",light:"icons/dark-64.png",size:64},{dark:"icons/128.png",light:"icons/dark-128.png",size:128},{dark:"icons/256.png",light:"icons/dark-256.png",size:256}]},icons:{"32":"icons/32.png","48":"icons/48.png","64":"icons/64.png","128":"icons/128.png","256":"icons/256.png"},browser_specific_settings:{gecko:{id:"{5efceaa7-f3a2-4e59-a54b-85319448e305}",strict_min_version:"63.0"},gecko_android:{strict_min_version:"113.0"}},key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7JPn78UfqI3xIIOPPLPS74UTzLfJL1gQM8hlk/deKWvFP/WqUBnPJPdhQeF45sFpI1OjO70nFqdATT4/RwYAiZK7G/E6m27MDVnhHjszfzReOuoAEn9J3RnE2xEx5pFhRFcelhnwTTLrrn90aaPcaMtNsgXtZA1Ggz/SnX9I4ZygqpJYjx3Ql2t6SyNK222oRQiKMT93Rrjgyc8RFA7FKXsWglG0TvseRjbmG5Jk5gDx+2/YTcWGqCDotQnWnkPj/dBO23UAX7IpyJK3FGYdkvWFih6OVClHIIWY8mfCjjwSGbXNQNesaa9F2hrzBZ5MRTj4m7yj76mGxuPHPIE8mwIDAQAB"};m();m();m();var Pg=/iPhone/i,Q2=/iPod/i,Z2=/iPad/i,X2=/\biOS-universal(?:.+)Mac\b/i,Fg=/\bAndroid(?:.+)Mobile\b/i,e1=/Android/i,fi=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Kl=/Silk/i,Qr=/Windows Phone/i,t1=/\bWindows(?:.+)ARM\b/i,n1=/BlackBerry/i,r1=/BB10/i,a1=/Opera Mini/i,o1=/\b(CriOS|Chrome)(?:.+)Mobile/i,i1=/Mobile(?:.+)Firefox\b/i,s1=e=>typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints=="number"&&e.maxTouchPoints>1&&typeof globalThis.MSStream>"u";function iS(e){return t=>t.test(e)}function ot(e){let t={userAgent:"",platform:"",maxTouchPoints:0};!e&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e=="string"?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});let n=t.userAgent,r=n.split("[FBAN");typeof r[1]<"u"&&(n=r[0]),r=n.split("Twitter"),typeof r[1]<"u"&&(n=r[0]);let a=iS(n),o={apple:{phone:a(Pg)&&!a(Qr),ipod:a(Q2),tablet:!a(Pg)&&(a(Z2)||s1(t))&&!a(Qr),universal:a(X2),device:(a(Pg)||a(Q2)||a(Z2)||a(X2)||s1(t))&&!a(Qr)},amazon:{phone:a(fi),tablet:!a(fi)&&a(Kl),device:a(fi)||a(Kl)},android:{phone:!a(Qr)&&a(fi)||!a(Qr)&&a(Fg),tablet:!a(Qr)&&!a(fi)&&!a(Fg)&&(a(Kl)||a(e1)),device:!a(Qr)&&(a(fi)||a(Kl)||a(Fg)||a(e1))||a(/\bokhttp\b/i)},windows:{phone:a(Qr),tablet:a(t1),device:a(Qr)||a(t1)},other:{blackberry:a(n1),blackberry10:a(r1),opera:a(a1),firefox:a(i1),chrome:a(o1),device:a(n1)||a(r1)||a(a1)||a(i1)||a(o1)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}var Bg="DENO",Gl="CHROME",Yl="FIREFOX";function u1(e){let t=Gl;try{let n=navigator?.userAgent||"";/firefox/i.test(n)||typeof InstallTrigger<"u"?t=Yl:/deno/i.test(n)&&(t=Bg)}catch{}return e===Gl&&t===Gl||e===Yl&&t===Yl||e===Bg&&t===Bg}function l1(){return u1(Gl)}function c1(){return typeof Deno<"u"}function Zr(){return u1(Yl)}function Ea(){return!!navigator.maxTouchPoints||"ontouchstart"in document.documentElement}function d1(){return!!globalThis.matchMedia("(pointer:fine)").matches}function To(e){return!!(e?.confirmSupportMouse||globalThis.matchMedia("(pointer:fine)").matches)}m();var g1={addListener:()=>{},removeListener:()=>{},hasListener:()=>{}},m1={permissions:{contains:()=>{},request:()=>{}},runtime:{onMessage:g1,openOptionsPage:()=>{},lastError:{message:""}},storage:{sync:{get:()=>{},set:()=>{}}},tabs:{onUpdated:g1,query:()=>{},sendMessage:()=>{}}};var Q;c1()?Q=m1:Q=globalThis.immersiveTranslateBrowserAPI;var sS="";function Zn(){return sS||Vl.version}function kr(){return Q.runtime.getManifest().version}m();function p1(e){return e.replace(//g,">")}m();function Yt(e){return!!(e&&e.subscription&&e.subscription.subscriptionStatus==="active")}function f1(e){if(e){let t="unknown";if(e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?t="stripe":t="admin"),t==="stripe")return!0}return!1}function h1(e){if(e){let t=new Date(e.createTime),n=uS(t),r="free",a="unknown";return e.subscription&&e.subscription.subscriptionStatus==="active"&&(r=e.subscription.subscriptionType),e.subscription&&e.subscription.subscriptionId&&(e.subscription.subscriptionId.startsWith("sub_")?a="stripe":a="admin"),{user_type:r,user_register_day:n,subscription_from:a}}else return null}function uS(e){try{let n=e.toLocaleString("en-US",{timeZone:"Asia/Shanghai"}).split(" ")[0];n.endsWith(",")&&(n=n.slice(0,-1));let[r,a,o]=n.split("/");return n=`${o}-${r}-${a}`,n}catch{return"unknown"}}m();m();function Te(e){if(typeof e!="string")return"auto";let t=e.toLowerCase();if(t==="und")return"auto";if(t==="zh"||t.startsWith("zh-hans"))return"zh-CN";if(t.startsWith("zh-hant")||t.startsWith("zh-hk")||t.startsWith("zh-tw"))return"zh-TW";if(t.startsWith("zh-"))return"zh-CN";if(t==="iw")return"he";if(t==="jv")return"jw";let n=Bn.map(a=>a.toLowerCase()),r=n.indexOf(t);if(r===-1)if(t.indexOf("-")>=0){t=t.split("-")[0];let a=n.indexOf(t);return a===-1?"auto":Bn[a]}else return"auto";else return Bn[r]}function kt(){return Te(document?.documentElement?.lang||"en")}function Vs(e){if(Math.abs(e)<1024)return e+" Byte";let n=["KB","MB","GB","TB","PB","EB","ZB","YB"],r=-1;do e/=1024,++r;while(Math.abs(e)>=1024&&ru+l.text.length,0)+i.text.length>t||o.tempSentences.length>=n)&&(a.push(o),o={fromByClient:o.fromByClient,from:i.from,to:i.to,tempSentences:[],url:i.url}),(o.from!==i.from||o.to!==i.to)&&(o.tempSentences.length>0?(a.push(o),o={fromByClient:o.fromByClient,from:i.from,to:i.to,tempSentences:[],url:i.url}):(o.from=i.from,o.to=i.to)),o.tempSentences.push(i);return o.tempSentences.length>0&&a.push(o),a}function lS(e,t){let n=[],r=[];for(let a=0;a0?yt){let x=[];Rg(C,t,x);for(let S=0;S0&&y{let s=e.lastIndexOf(i,t);return s>o?s:o},-1);if(a===-1){let o=e.slice(0,t);if(o&&!o.trim())return;n.push({text:o,prefix:"",suffix:""}),e.length>t&&Rg(e.slice(t),t,n)}else{let o=e.slice(0,a+1);if(o&&o.trim()==="")return;o.startsWith(" ")?n.push({text:o.slice(1),prefix:" ",suffix:""}):n.push({text:o,prefix:"",suffix:""}),a+10){g.forEach(y=>{c.length>0&&y.providers&&y.providers.length>0&&!y.providers.includes(l)||(y.optional?f.push(y):p.push(y))});let h=f.concat(p).filter(y=>y.required);if(h.length>0){for(let y of h)if(!o[y.name]){u=!1;break}}}return{...a,id:t,selected:n[e]===t,ok:u,currentProvider:l,config:o,providers:a.providers||[],props:a.props||[],allProps:g,optionalProps:f,explicitProps:p}}var vo=(e,t)=>{let{config:n}=e,r=n.alpha,a=n.beta,o=n.canary,i=n.debug,s=e.user,u=Yt(s),l=Object.keys(Qn);return t!=="translationService"&&l.unshift("inherit"),l.filter(c=>{if(c==="inherit")return!0;let g=Qn[c];if(c.startsWith("mock"))return i?!0:c===e.config[t];if(c===e.config[t])return!0;if(c==="openai"&&We())return e.config.showOpenaiOnSafari||u?!0:!!(a||r||o||u);let p=!!g.canary,f=!!g.alpha,h=!!g.beta;return c===e[t]||p&&o||f&&(r||o)||h&&(a||r||o)?!0:!f&&!h&&!p}).map(c=>hi(t,c,e))};function Ks(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}function y1(e){return e.replace(/([a-zA-Z0-9]+)([\u4e00-\u9fa5]+)/g,"$1 $2").replace(/([\u4e00-\u9fa5]+)([a-zA-Z0-9]+)/g,"$1 $2")}m();var C1=be+"SyncStoreKey_";function jt(e,t){let n=C1+e;return Q.storage.sync.get(n).then(r=>r[n]===void 0?t:r[n])}function rt(e,t){let n=C1+e;return Q.storage.sync.set({[n]:t})}m();var xo=be+"CacheKey_";function Ig(e,t){let n=xo+e;return Q.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function cS(){let e=Q.storage.local.refresh;e&&e()}function Og(e,t){let n=xo+e;return Q.storage.local.get(n).then(r=>{if(r[n]===void 0)return t;let{value:a,expired:o}=r[n];return o&&or.startsWith(xo)).filter(r=>r!==xo+Tt);if(n.length>0)return Q.storage.local.remove(n)}}var gt={get:Ig,set:Ug,getExpired:Og,setExpired:Ng,remove:jg,clear:Hg,refresh:cS};m();var T1=["*://*/*","*","*://*"],x1="immersive-translate-wildcard-placeholder.com";function zg(e,t){try{let n=[];if(!t||(t&&!Array.isArray(t)?n=[t]:n=t,n.length===0))return null;if(n.some(s=>T1.includes(s)))return e;let r=new URL(e);r.hash="",r.search="";let a=r.href,o=r.hostname,i=r.port;if(n&&n.length>0){let s=n.find(u=>{if(!u)return!1;if(u===o)return!0;if(T1.includes(u))return!0;if(!u.includes("*")&&u.includes("://")){try{let l=new URL(u);if(l.pathname==="/"&&!u.endsWith("/")){let c=l.hostname===o,g=l.port===i;return l.port?c&&g:c}else return gS(a,u)}catch{}return!1}else{let l,c=u;if(u.includes("://")){let C=u.split("://");l=C[0],l==="*"&&C.length>1&&(l="*",u="https://"+C[1])}else l="*",u="https://"+u;let g=u.replace(/\*/g,x1),p;try{p=new URL(g)}catch{return I.debug("invalid match pattern",g,"raw match value:",c),!1}let f=p.host,h=p.pathname;h==="/"&&(c.replace("://","").includes("/")||(h="/*"));let y=dS(l+":",v1(f),v1(h));if(y){let C=new URL(a);return y.test(C.href)}else return!1}});if(s)return s}return null}catch{return null}}function v1(e){return e.replaceAll(x1,"*")}function dS(e,t,n){let r="^";return e==="*:"?r+="(http:|https:|file:)":r+=e,r+="//",t&&(e==="file:"||(t==="*"?r+="[^/]+?":(t.match(/^\*\./)&&(r+="[^/]*?",t=t.substring(1)),r+=t.replace(/\./g,"\\.").replace(/\*/g,"[^/]*")))),n?n==="*"||n==="/*"?r+="(/.*)?":n.includes("*")?(r+=n.replace(/\*/g,".*?"),r+="/?"):r+=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):r+="/?",r+="$",new RegExp(r)}function _t(e,t){return zg(e,t)!==null}function gS(e,t){let n=new URL(e),r=new URL(t);return n.hostname===r.hostname&&n.pathname===r.pathname&&n.protocol===r.protocol&&n.port===r.port}m();m();var E1=be+"StoreKey_";function Xr(e,t){let n=E1+e;return Q.storage.local.get(n).then(r=>r[n]===void 0?t:r[n])}function S1(e,t){let n=E1+e;return Q.storage.local.set({[n]:t})}m();m();m();m();function w1(e,t){return[e,!e||e.endsWith("/")?"":"/",t,".json"].join("")}function qg(e,t){let n=e;return t&&Object.keys(t).forEach(r=>{let a=t[r];if(a===void 0)return;let o=mS(r);if(typeof a=="object"||o){let i=a;o&&typeof i=="string"&&(i={tag:"a",href:i,target:"_blank",class:"immersive-translate-link"});let s=`<${r}>`,u=n.indexOf(s);if(u!==-1){let l=i.tag||"a",c=n.indexOf(``);if(c!==-1){let g=n.substring(u+s.length,c),p=Object.keys(i).filter(f=>f!=="tag").map(f=>`${f}="${i[f]}"`).join(" ");n=n.replace(`${s}${g}`,`<${l} ${p}>${g}`)}}}else if(a){let i=new RegExp("{"+r+"}","gm");n=n.replace(i,a.toString())}}),n}function Gs(e,t,n){let r=e[t];if(!r)return n;if(!n)return"";let a=n.split("."),o="";do{o+=a.shift();let i=r[o];i!==void 0&&(typeof i=="object"||!a.length)?(r=i,o=""):a.length?o+=".":r=n}while(a.length);return r}function Ar(e,t,n,r,a){if(!e.hasOwnProperty(n))return t;let o=Gs(e,n,t);return o===t&&n!==r&&(o=Gs(e,r,t)),qg(o,a)}function mS(e){if(typeof e=="number")return!0;if(e){let t=parseInt(e);return!isNaN(t)}else return!1}function Ht(e,t,n){return Ar(tn,t,e.config.interfaceLanguage,"en",n)}m();function D1(e,t){let n=new Date(e),r=n.getFullYear().toString(),a=(n.getMonth()+1).toString().padStart(2,"0"),o=n.getDate().toString().padStart(2,"0"),i=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),u=n.getSeconds().toString().padStart(2,"0");return t.replace("YYYY",r).replace("MM",a).replace("DD",o).replace("HH",i).replace("mm",s).replace("ss",u)}function k1(e){return new Date(e).getTime()}var J=class extends Error{status;constructor(t,n){if(t&&n){super(n),this.name=t;return}super(t)}initNetWork(t){return t&&(this.status=t),this}initStack(t){return t&&(this.stack=t),this}initData(t){return this.data=t,this}data;uiConfig(t){if(!this.message)return{};let n=null;if(n=this.handleProQuota(t)||this.handleUnavailableError(t)||this.handleProUser(t)||this.handleServiceMissingConfig(t)||this.handleNetwork(t)||this.handleFetchError(t),!n){let r=Ht.bind(null,t),a=this.getErrorMsg();n={type:"error",title:r("networkError"),errMsg:r("error.serveUnavailable",{serverName:r("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+r("errorReason",{message:a}),action:"changeService"}}return n}getErrorMsg(){return this.status?this.status<0?this.message:`${this.status}: ${this.message}`:this.message}handleUnavailableError(t){let n=Ht.bind(null,t),r=this.message.startsWith("bingAuth"),a=this.data?.translationService==="transmart"&&this.message.startsWith("Server is busy now");if(r||a)return this.message=this.message.replace("bingAuth:",""),{type:"network",title:n("networkError"),errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:this.message}),action:"changeService"}}handleServiceMissingConfig(t){let n=Ht.bind(null,t);if(this.message.endsWith(" are required")||this.message.includes("You didn't provide an API key"))return{type:"configError",title:n("error.serveConfigError"),errMsg:this.getErrorMsg()+"

"+n("error.reloadPageOfSetting"),action:"setting"}}handleNetwork(t){let n=Ht.bind(null,t),r="retry",a="network",o=n("networkError");if(!this.status||this.status<0)return;let i=this.getErrorMsg();return this.status===429?this.data?.translationService=="google"?i=`${n("error.googleLimitIp")}

${i}`:this.data?.translationService=="openai"&&(this.message.indexOf("Limit: 3 / min")>=0||this.message.includes("rate_limit_exceeded")&&this.message.includes("Limit 3"))?i=`${n("error.openAIFreeLimit")}

${i}`:this.data?.translationService=="openai"&&this.message.includes("You exceeded your current quota")?i=`${n("error.openAIExceededQuota")}

${i}`:this.data?.translationService=="gemini"&&this.message.includes("RESOURCE_EXHAUSTED")?i=`${n("error.gemini.429")}

${i}`:i=`${n("error.429")}

${i}`:this.status===403?this.data?.translationService=="claude"?i=`${n("error.claude.403")}

${i}`:i=`${n("error.403")}

${i}`:this.status===400?i=`${n("error.400")}

${i}`:this.status===502?i=`${n("error.502")}

${i}`:this.status===404&&i.includes("User subscription not found")&&(i=`${n("error.subscriptionExpired")}

${i}`,r="setting",a="configError",o=n("error.subscriptionExpiredTitle")),{type:a,title:o,errMsg:i,action:r}}handleFetchError(t){let n=Ht.bind(null,t);if(this.status!==-999)return;let r=this.getErrorMsg();return{type:"network",title:"",errMsg:n("error.serveUnavailable",{serverName:n("translationServices."+t.translationService),1:"https://dash.immersivetranslate.com/#general",2:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error",3:"https://immersivetranslate.com/pricing/?utm_source=extension&utm_medium=webpage&utm_campaign=service_error"})+"

"+n("errorReason",{message:r}),action:"changeService"}}handleProUser(t){let n=Ht.bind(null,t);if(!(this.data?.translationService!=="openai"&&this.data?.translationService!=="deepl")){if(this.message.indexOf("token invalid")>=0||this.message.indexOf("Login required")>=0)return{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"};if(this.message.indexOf("activate Pro")>=0)return t.user?{type:"upgrade",title:n("upgradeToProErrorTitle"),errMsg:n("error.proUpgrade"),action:"upgrade"}:{type:"notLogin",title:n("notLoginPro"),errMsg:n("error.proTokenInvalid"),action:"login"}}}handleProQuota(t){if(!this.message.startsWith("ProQuota:")||!t.user?.subscription)return;let n=Ht.bind(null,t);this.message=this.message.replace("ProQuota:","");let r=this.message;try{r=JSON.parse(this.message).error}catch{}let a=t.user.subscription,{subscriptionType:o,isTrial:i,openAITokenUsedCountResetTime:s,subscriptionTo:u}=a;return{type:"ProQuotaExceeded",title:"",errMsg:c.call(this),action:"retry"};function c(){let g=this.data?.translationService=="deepl"?"OpenAI":"Deepl",p=this.data?.translationService=="deepl"?"Deepl":"OpenAI",f=n("errorReason",{message:r});if(o=="onetime_7day")f+=n("proQuotaExceededError.onetime7day",{anotherService:g,brandId:ee,href:Wl});else{let h="";p=="OpenAI"?h=W2:h=$2,i?f+=n("proQuotaExceededError.trial",{anotherService:g,brandId:ee,href:V2}):f+=n("proQuotaExceededError.nonTrial",{anotherService:g,brandId:ee,href:h,translationService:p}),!i&&(a.cancelAtPeriodEnd==="false"||k1(u)>s)&&(f+=n("proQuotaExceededError.resetTime",{resetTime:D1(s,"YYYY-MM-DD HH:mm:ss")}))}return f}}};async function mr(e){let t;if(e&&e.retry&&e.retry>0)try{t=await Cd(A1.bind(null,e),{multiplier:2,maxAttempts:e.retry})}catch(n){throw n&&n.name==="RetryError"&&n.cause?n.cause:n}else t=await A1(e);return t}async function A1(e){e.body;let{url:t,responseType:n,...r}=e;n||(n="json"),r={mode:"cors",...r};let a=!0;e.fetchPolyfill&&(a=!1);let o=e.fetchPolyfill||fetch,i=3e4;if(e.timeout&&(i=e.timeout),a){let u=new AbortController,l=u.signal;setTimeout(()=>{u.abort()},i),r.signal=l}let s;try{s=await o(t,r)}catch(u){I.debug("fetch error",t,u);let l=u.message||"Unknown Error";throw new J("fetchError",l).initNetWork(-999).initStack(u.stack)}if(s.ok&&s.status>=200&&s.status<400){if(n==="json")return await s.json();if(n==="text")return await s.text();if(n==="raw"){let u=await s.text(),l=Object.fromEntries([...s.headers.entries()]),c=s.url;return c||(s.headers.get("X-Final-URL")?c=s.headers.get("X-Final-URL"):c=t),{body:u,headers:l,status:s.status,statusText:s.statusText,url:c}}else if(n==="stream"){let u="",l;if(s.body&&s.body instanceof ReadableStream)for await(let c of pS(s.body)){let g=new TextDecoder().decode(c);u+=g;let p;for(;(p=u.indexOf(` -`))>=0;){let f=u.slice(0,p).trim();if(u=u.slice(p+1),f.startsWith("event:")||f==="")continue;let h="";if(f.startsWith("data:")&&(h=f.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(C){I.debug("json error",C);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(f){I.error("parse response failed",f)}u&&I.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,p=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),p&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new J("fetchError",c).initNetWork(s.status)}}async function*pS(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}m();var Ys=new Map;function L1(){document.addEventListener(b2,e=>{let t=e;if(t&&t.detail){let n;try{n=JSON.parse(t.detail),Ys.has(n.id)&&(n.ok?Ys.get(n.id)(null,n.data):Ys.get(n.id)(new Error(n.errorMessage),null),Ys.delete(n.id))}catch{}}})}function Jl(e){let t=fS(64),n=new CustomEvent(p2,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{Ys.set(t,(o,i)=>{o?a(o):r(i)})})}function fS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let i=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,i=`${i}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=$g(s),{type:p,name:f}=g;if(p!==t)return!1;let h=$g(i),C=Js.get(p).get(f);if(!C)return this.logger.debug(`no message handler for ${p}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=C,S={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let A=b(r.payload,S);o({ok:!0,data:A})}catch(A){o({ok:!1,errorName:A.name,errorMessage:A.message,errorDetails:A.details,errorStatus:A.status})}return!1}else return b(r.payload,S).then(A=>{o({ok:!0,data:A})}).catch(A=>{o({ok:!1,errorName:A.name,errorMessage:A.message,errorDetails:A.message,errorStatus:A.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let o=this.fromType,i=Js.get(o);if(i.has(t))return i.get(t).connectionInstance;{let s=new Wg(`${o}:${t}`,this.logger);return Js.get(o).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Wg=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=$g(t),{type:a,id:o}=r;if(a!=="content_script"){let i={to:t,from:this.from,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");try{let s=await Q.runtime.sendMessage(i);return _1(i,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let i={from:this.from,to:t,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");let s=await Q.tabs.sendMessage(o,i);return _1(i,s,this.logger)}}};function _1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new J(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new J("noResponse","Unknown error")}function $g(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}m();var hS="";function bi(){return hS||globalThis.navigator.userAgent}function Vg(){return bi().includes("ImtFxiOS")}function M1(){let t=bi().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function bS(){return bi().includes("ImtFxAndroid")}function P1(){let e=bi();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function F1(){let t=bi().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function Qs(){let e=bi();if(Vg()||bS()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Ql;function yS(){return Ql||(Ql=new ea("content_script",!1).getConnection("pure_main",()=>{}),Ql)}var B1="G-MKMD9LWFTR";async function Eo(e){try{let t=Pe(),n=t.INSTALL_FROM==="firefox_store";if(Qs()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=me(),o=at(),i=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await jt("fakeUserId","");u||(u=await Xr("fakeUserId",""),u&&await rt("fakeUserId",u));let l=Zn(),c=new Date,g=await jt("installedAt","");g||(g=await Xr("installedAt",""),g&&await rt("installedAt",g)),u?g||(g=new Date(0).toISOString(),await rt("installedAt",g)):(u=CS(32),await rt("fakeUserId",u)),g||(g=c.toISOString(),await rt("installedAt",g));let p=new Date(g),f=R1(p),h=R1(c),y=f===h,C=c.getTime()-p.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${B1}&api_secret=${s}`;i||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${B1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let S=ti.parse(x),A=e.map(w=>{let v=w.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser){v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown";let L=Qs();L&&(v.browser_name=L.name,v.browser_version=L.version)}return S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),f&&(v.install_day=TS(p)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",C?v.is_new_user_this_week="1":v.is_new_user_this_week="0",o?v.main_frame=0:v.main_frame=1,{...w,params:v}}),P=await Zl({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:A})})}catch{}}function CS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} +`))>=0;){let f=u.slice(0,p).trim();if(u=u.slice(p+1),f.startsWith("event:")||f==="")continue;let h="";if(f.startsWith("data:")&&(h=f.slice(5).trim()),h==="[DONE]")break;let y;try{y=JSON.parse(h??"")}catch(C){I.debug("json error",C);continue}l=y}}return l}}else{let u;try{u=await s.text()}catch(f){I.error("parse response failed",f)}u&&I.error("fail response",u);let l="";u&&(l=u.slice(0,500));let c=l,p=new URL(t).hostname.endsWith(".immersivetranslate.com");throw t.endsWith("edge.microsoft.com/translate/auth")&&(c="bingAuth:"+l),p&&l.includes("quota exceeded")&&(c="ProQuota:"+l),new J("fetchError",c).initNetWork(s.status)}}async function*pS(e){let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)return;yield r}}finally{t.releaseLock()}}m();var Ys=new Map;function L1(){document.addEventListener(b2,e=>{let t=e;if(t&&t.detail){let n;try{n=JSON.parse(t.detail),Ys.has(n.id)&&(n.ok?Ys.get(n.id)(null,n.data):Ys.get(n.id)(new Error(n.errorMessage),null),Ys.delete(n.id))}catch{}}})}function Jl(e){let t=fS(64),n=new CustomEvent(p2,{detail:JSON.stringify({...e,type:"ask",id:t})});return document.dispatchEvent(n),new Promise((r,a)=>{Ys.set(t,(o,i)=>{o?a(o):r(i)})})}function fS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let i=r.from,s=r.to,u,l,c;a.tab&&a.tab.id&&(u=a.tab.id,i=`${i}:${u}`,l=a.tab.url,c=a.tab.active),this.logger.debug(`${r.to} received message [${r.payload.method}] from ${r.from}`,r.payload.data?r.payload.data:" ");let g=$g(s),{type:p,name:f}=g;if(p!==t)return!1;let h=$g(i),C=Js.get(p).get(f);if(!C)return this.logger.debug(`no message handler for ${p}:${s}, but it's ok`),!1;let{messageHandler:b,sync:x}=C,S={type:t,name:h.name,id:u,url:l,active:c};if(x){try{let A=b(r.payload,S);o({ok:!0,data:A})}catch(A){o({ok:!1,errorName:A.name,errorMessage:A.message,errorDetails:A.details,errorStatus:A.status})}return!1}else return b(r.payload,S).then(A=>{o({ok:!0,data:A})}).catch(A=>{o({ok:!1,errorName:A.name,errorMessage:A.message,errorDetails:A.message,errorStatus:A.status})}),!0}))}getConnection(t,n,r){let a=!1;r&&r.sync&&(a=!0);let o=this.fromType,i=Js.get(o);if(i.has(t))return i.get(t).connectionInstance;{let s=new Wg(`${o}:${t}`,this.logger);return Js.get(o).set(t,{messageHandler:n,sync:a,connectionInstance:s}),s}}},Wg=class{from;logger;constructor(t,n){this.from=t,this.logger=n}async sendMessage(t,n){let r=$g(t),{type:a,id:o}=r;if(a!=="content_script"){let i={to:t,from:this.from,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");try{let s=await Q.runtime.sendMessage(i);return _1(i,s,this.logger)}catch(s){if(a==="popup"){let u=`popup ${t} is not active, so the message does not send, ignore this error, ${JSON.stringify(n)}`;return this.logger.debug(u,n,t,s),Promise.resolve({message:u})}else throw s}}else{let i={from:this.from,to:t,payload:n};this.logger.debug(`${i.from} send message [${i.payload.method}] to ${i.to}`,i.payload.data?i.payload.data:" ");let s=await Q.tabs.sendMessage(o,i);return _1(i,s,this.logger)}}};function _1(e,t,n){if(t){if(t.ok)return n.debug(`${e.from} received response from ${e.to}:`,t.data?t.data:" "),t.data;throw new J(t.errorName||"UnknownError",t.errorMessage||"Unknown error").initNetWork(t.errorStatus)}else throw new J("noResponse","Unknown error")}function $g(e){let t=e.split(":");if(t.length<2)throw new Error("not a valid to string");let n={type:t[0],name:t[1]};if(t[0]==="content_script"){let r=parseInt(t[2]);if(!isNaN(r))n.id=r;else throw new Error("tab id not a valid number")}return n}m();var hS="";function bi(){return hS||globalThis.navigator.userAgent}function Vg(){return bi().includes("ImtFxiOS")}function M1(){let t=bi().match(/ImtFxiOS\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function bS(){return bi().includes("ImtFxAndroid")}function P1(){let e=bi();return/ImtFxAndroid\/(\d+\.\d+\.\d+)\/google/.test(e)}function F1(){let t=bi().match(/ImtFxAndroid\/(\d+\.\d+\.\d+)/);return t?t[1]:null}function Qs(){let e=bi();if(Vg()||bS()){let t=e.match(/Imt[\w/.]+/);if(t){let n=t[0].split("/"),r=n[0];return n[2]&&(r+="_"+n[2]),{name:r,version:n[1]}}}return null}var Ql;function yS(){return Ql||(Ql=new ea("content_script",!1).getConnection("pure_main",()=>{}),Ql)}var B1="G-MKMD9LWFTR";async function Eo(e){try{let t=Pe(),n=t.INSTALL_FROM==="firefox_store";if(Qs()?.name?.startsWith("ImtFx")&&(n=!1),n)return;let a=me(),o=at(),i=t.PROD==="1",s="sitc4WmvShWYwfU0dANM3Q",u=await jt("fakeUserId","");u||(u=await Xr("fakeUserId",""),u&&await rt("fakeUserId",u));let l=Zn(),c=new Date,g=await jt("installedAt","");g||(g=await Xr("installedAt",""),g&&await rt("installedAt",g)),u?g||(g=new Date(0).toISOString(),await rt("installedAt",g)):(u=CS(32),await rt("fakeUserId",u)),g||(g=c.toISOString(),await rt("installedAt",g));let p=new Date(g),f=R1(p),h=R1(c),y=f===h,C=c.getTime()-p.getTime()<7*24*60*60*1e3,b=`https://www.google-analytics.com/mp/collect?measurement_id=${B1}&api_secret=${s}`;i||(b=`https://www.google-analytics.com/debug/mp/collect?measurement_id=${B1}&api_secret=${s}`);let x="";typeof navigator<"u"&&(x=window.navigator.userAgent);let S=ti.parse(x),A=e.map(w=>{let v=w.params||{};if(S.os&&(v.os_name=S.os.name||"unknown",v.os_version=S.os.version||"unknown",v.os_version_name=S.os.versionName||"unknown"),S.browser){v.browser_name=S.browser.name||"unknown",v.browser_version=S.browser.version||"unknown";let L=Qs();L&&(v.browser_name=L.name,v.browser_version=L.version)}return S.platform&&(v.platform_type=S.platform.type||"unknown"),S.engine&&(v.engine_name=S.engine.name||"unknown",v.engine_version=S.engine.version||"unknown"),l&&(v.version=l),t.INSTALL_FROM&&(v.install_from=t.INSTALL_FROM),f&&(v.install_day=TS(p)),v.userscript=a.toString(),y?v.is_new_user_today="1":v.is_new_user_today="0",C?v.is_new_user_this_week="1":v.is_new_user_this_week="0",o?v.main_frame=0:v.main_frame=1,{...w,params:v}}),P=await Zl({responseType:"text",url:b,method:"POST",body:JSON.stringify({client_id:u,user_id:u,events:A})})}catch{}}function CS(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a",""],limit:5},custom:{placeholderDelimiters:["{","}"]},bing:{maxTextLengthPerRequest:1800,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},yandex:{maxTextLengthPerRequest:1e3,requestTimeout:1e4,retry:1,placeholderDelimiters:["","","b"]},deeplx:{limit:3,placeholderDelimiters:["@","#"]},d:{immediateTranslationTextCount:0,placeholderDelimiters:["@","#"]},papago:{placeholderDelimiters:["{","}"]},dpro:{apiUrl:"https://api.deepl.com/jsonrpc"},ai:{env:{imt_source_field:"text",imt_trans_field:"text",imt_sub_source_field:"source",imt_sub_trans_field:"translation",imt_yaml_item:`- id: {{id}} {{imt_source_field}}: {{text}}`,imt_subtitle_yaml_item:`- id: {{id}} {{imt_sub_source_field}}: {{text}}`,normal_result_yaml_example:`Example request: - id: 1 @@ -5190,7 +5190,7 @@ ${s}} `+t.rule.additionalInjectedCss.join(` `):t.rule.additionalInjectedCss&&(s+=` `+t.rule.additionalInjectedCss)),s&&zn(e,s,"immersive-translate-dynamic-injected-css")}m();m();m();var RS=0;function d(e,t,n,r,a){var o,i,s={};for(i in t)i=="ref"?o=t[i]:s[i]=t[i];var u={type:e,props:s,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--RS,__source:a,__self:r};if(typeof e=="function"&&(o=e.defaultProps))for(i in o)s[i]===void 0&&(s[i]=o[i]);return Be.vnode&&Be.vnode(u),u}function rm({value:e,defaultCase:t=null,cases:n}){return e==null?null:d(xe,{children:n[e]!=null?n[e]:t})}m();function am(){let[e,t]=$(location.hash);return le(()=>{let n=()=>t(location.hash);return globalThis.addEventListener("hashchange",n,!1),()=>{globalThis.removeEventListener("hashchange",n)}},[]),e}m();m();m();var l9={"zh-CN":{"languages.en":"\u82F1\u8BED","languages.ja":"\u65E5\u8BED","languages.ko":"\u97E9\u8BED","languages.es":"\u897F\u73ED\u7259\u8BED","languages.fr":"\u6CD5\u8BED","languages.de":"\u5FB7\u8BED","languages.it":"\u610F\u5927\u5229\u8BED","languages.pt":"\u8461\u8404\u7259\u8BED","languages.ru":"\u4FC4\u8BED","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"},"zh-TW":{"languages.en":"\u82F1\u8A9E","languages.ja":"\u65E5\u8A9E","languages.ko":"\u97D3\u8A9E","languages.es":"\u897F\u73ED\u7259\u8A9E","languages.fr":"\u6CD5\u8A9E","languages.de":"\u5FB7\u8A9E","languages.it":"\u610F\u5927\u5229\u8A9E","languages.pt":"\u8461\u8404\u7259\u8A9E","languages.ru":"\u4FC4\u8A9E","languages.wyw":"\u6587\u8A00\u6587","languages.":"\u5168\u90E8"}},c9={...tn,"zh-CN":{...l9["zh-CN"],...tn["zh-CN"]},"zh-TW":{...l9["zh-TW"],...tn["zh-TW"]}},wi=c9;function Ma(e,t,n){return Ar(c9,e,t,Dr,n)}var s0=()=>Bn.filter(e=>e!=="auto"),Jt=(e,t,n,r)=>{let a=R2[e]||e,o=I2[e],i=O2[e],s={"zh-CN":o,"zh-TW":i,en:a};if(n)return s[e]?s[e]:a;if(s[t]){let u=s[t];return r||e==="auto"||e==="placeholder"?u:`${u} (${a})`}else return a};m();m();m();m();m();m();m();m();m();m();var _r=class{accessToken;constructor(t){this.accessToken=t}async listAll(){let t=[],n="";do{let{nextPageToken:r,files:a}=await this.list(n).catch(o=>{throw o});t.push(...a),n=r||""}while(n);return t}async getConfig(t){try{return await(await fetch(`https://www.googleapis.com/drive/v3/files/${t}?alt=media`,{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(n){return I.error("get config error, use default",n),{}}}async delete(t){await fetch(`https://www.googleapis.com/drive/v3/files/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${this.accessToken}`}})}findByName(t){return this.list(void 0,`name = '${t}'`)}uploadConfig(t,n=_l){let r=new Blob([JSON.stringify(t,null,2)],{type:"application/json"});return this.upload({name:n,parents:["appDataFolder"],mimeType:"application/json"},r)}updateConfig(t,n){let r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"});return this.updateContent(t,r)}async upload(t,n){let r=new FormData;r.append("metadata",new Blob([JSON.stringify(t)],{type:"application/json; charset=UTF-8"})),r.append("file",n);let a=await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart",{method:"POST",headers:{Authorization:`Bearer ${this.accessToken}`},body:r});return a.ok?await a.json():Promise.reject(a.text())}async list(t,n){let r=new URL("https://www.googleapis.com/drive/v3/files");t&&r.searchParams.append("pageToken",t),n&&r.searchParams.append("q",n),r.searchParams.append("spaces","appDataFolder"),r.searchParams.append("fields","files(id,name,createdTime,modifiedTime,size)"),r.searchParams.append("pageSize","100"),r.searchParams.append("orderBy","createdTime desc");try{return I.debug("list api:",r.toString(),this.accessToken),await(await fetch(r.toString(),{headers:{Authorization:`Bearer ${this.accessToken}`}})).json()}catch(a){throw I.error("fetch google ip error",a),a}}async updateContent(t,n){return await(await fetch(`https://www.googleapis.com/upload/drive/v3/files/${t}?uploadType=media`,{method:"PATCH",headers:{Authorization:`Bearer ${this.accessToken}`},body:n})).text()}};function d9(e,t){let n=["https://www.googleapis.com/auth/drive.appdata"];return`https://accounts.google.com/o/oauth2/v2/auth?client_id=${Ll}&response_type=token&redirect_uri=${encodeURIComponent(t)}&scope=${encodeURIComponent(n.join(" "))}&state=${encodeURIComponent(JSON.stringify(e))}`}function g9(e){let t=e.match(/[#?](.*)/);return!t||t.length<1?null:{access_token:new URLSearchParams(t[1].split("#")[0]).get("access_token")}}async function om(e,t,n,r,a,o,i){if(I.debug(`autoSyncStrategy accessToken: ${e}`),t===null){I.debug("autoSyncStrategy settings is null");return}let s=new _r(e);try{let u=(await s.findByName(_l)).files;I.debug("files",u);let l=u[0]?.id,c=null;if(l&&(c=await s.getConfig(l).then(g=>({fileId:l,config:g}))),c){let{config:g,fileId:p}=c,f=g.updatedAt?new Date(g.updatedAt):new Date(0),h=t.updatedAt?new Date(t.updatedAt):new Date(0);if(I.debug("remoteUpdatedAt",f,"localUpdatedAt",h),f>h)I.debug("remote is newer, update local config",g),n(g),o&&o(!0);else if(f.getTime()===h.getTime())I.debug("remote and local are the same, do nothing"),o&&o(!1);else if(f(await e.removeAuthInfo(),Is()&&globalThis.location.reload(),r))}static async getAuthInfo(){let t=await Q.storage.local.get(Ta);if(t[Ta])return t[Ta]}static async removeAuthInfo(){return await Q.storage.local.remove(Ta)}static setAuthInfo(t){return Q.storage.local.set({[Ta]:t})}async auth(t=!1){let n=await e.getAuthInfo();if(I.debug(this.CLASSNAME,"token from cache:",n),n&&n.access_token&&await m9(n.access_token).then(o=>!0).catch(o=>!1))return Promise.resolve(n);let r=d9(this._state,this._redirectUrl);return I.debug(this.CLASSNAME,"auth url: "+r),Is()?this.userscriptAuthWorkflow(r,t):this.extensionAuthWorkflow(r).then(a=>(e.setAuthInfo(a),a))}async userscriptAuthWorkflow(t,n){return n&&await Q.storage.local.set({[Os]:!0}),globalThis.open(t,"_self"),Promise.resolve({})}extensionAuthWorkflow(t){let n,r=!1;return new Promise((a,o)=>{let i=()=>{Q.tabs.onUpdated.removeListener(s),Q.tabs.onRemoved.removeListener(u)},s=(p,f,h)=>{if(I.debug(this.CLASSNAME,"create tab onUpdated: "+h.url),n===p){let y=new URL(h.url||""),C=g9(h.url);y.pathname.startsWith("/auth-done")&&C?.access_token&&(I.debug(this.CLASSNAME,"auth done: "+h.url),a({access_token:C.access_token}),r=!0,Q.tabs.remove(p),i())}},u=(p,f)=>{I.debug(this.CLASSNAME,"create tab onRemoved: "+p),(p===n||!r)&&(i(),o(new Error("auth failed")))},l=Math.min(500,screen.availWidth),c=Math.min(650,screen.availHeight),g;Q.windows===void 0?g=Q.tabs.create({url:t}).then(p=>{n=p.id}):g=Q.windows.create({url:t,type:"popup",width:l,height:c,left:Math.round((screen.width-l)/2),top:Math.round((screen.height-c)/2)}).then(p=>{n=p.tabs[0].id}),g.then(()=>{Q.tabs.onUpdated.addListener(s),Q.tabs.onRemoved.addListener(u)}).catch(p=>{I.debug(this.CLASSNAME,"create tab failed: "+p),o(p)})})}};var OS="https://www.googleapis.com/oauth2/v3/tokeninfo",NS=Ll,US=Pe().REDIRECT_URL;function m9(e){if(!e)throw"Authorization failure";let t=`${OS}?access_token=${e}`,n=new Request(t,{method:"GET"});function r(a){return new Promise((o,i)=>{a.status!=200&&i("Token validation error"),a.json().then(s=>{s.aud&&s.aud===NS?o(e):i("Token validation error")})})}return fetch(n).then(r)}function p9(e,t=!1){let n=US;if(typeof window<"u"&&window.location.protocol.startsWith("http")){let a=window.location.hostname,o=window.location.port;n=`${window.location.protocol}//${a}${o?`:${o}`:""}/auth-done/`}return new Pa(e,n).auth(t)}function im(e,t=!1){return p9(e,t).then(n=>n.access_token||null)}m();m();m();function Fa(e,t){var n=(e&65535)+(t&65535),r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function jS(e,t){return e<>>32-t}function l0(e,t,n,r,a,o){return Fa(jS(Fa(Fa(t,e),Fa(r,o)),a),n)}function mn(e,t,n,r,a,o,i){return l0(t&n|~t&r,e,t,a,o,i)}function pn(e,t,n,r,a,o,i){return l0(t&r|n&~r,e,t,a,o,i)}function fn(e,t,n,r,a,o,i){return l0(t^n^r,e,t,a,o,i)}function hn(e,t,n,r,a,o,i){return l0(n^(t|~r),e,t,a,o,i)}function u0(e,t){e[t>>5]|=128<>>9<<4)+14]=t;var n,r,a,o,i,s=1732584193,u=-271733879,l=-1732584194,c=271733878;for(n=0;n>5]>>>t%32&255);return n}function sm(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(e.charCodeAt(t/8)&255)<16&&(r=u0(r,e.length*8)),n=0;n<16;n+=1)a[n]=r[n]^909522486,o[n]=r[n]^1549556828;return i=u0(a.concat(sm(t)),512+t.length*8),f9(u0(o.concat(i),512+128))}function h9(e){var t="0123456789abcdef",n="",r,a;for(a=0;a>>4&15)+t.charAt(r&15);return n}function um(e){return unescape(encodeURIComponent(e))}function b9(e){return HS(um(e))}function qS(e){return h9(b9(e))}function y9(e,t){return zS(um(e),um(t))}function WS(e,t){return h9(y9(e,t))}function qn(e,t,n){return t?n?y9(t,e):WS(t,e):n?b9(e):qS(e)}var Di=[];async function iu(e,t){return await new Promise((n,r)=>{let a=e,o=1,i=indexedDB.open(a,o);i.onsuccess=s=>{n(i.result)},i.onerror=s=>{r()},i.onupgradeneeded=s=>{let u=i.result,l=t||"cache";u.createObjectStore(l,{keyPath:"key"})}})}async function lm(e){let t=`${ee}-${e.service}@${e.from}->${e.to}`;return await VS(t,e)}async function cm(e){let t=qn(e.originalText),n=`${ee}-${e.service}@${e.from}->${e.to}`;return await $S(n,t)}async function $S(e,t){let n=await iu(e);return await new Promise((r,a)=>{if(!n)return a();let o="cache",s=n.transaction([o],"readonly").objectStore(o).get(t);s.onsuccess=u=>{n.close();let l=s.result;r(l)},s.onerror=u=>{n.close(),a()}})}async function VS(e,t){let n=await iu(e);return(await dm()).includes(e)||await KS(e),await new Promise(a=>{if(!n)return a(!1);let o="cache",s=n.transaction([o],"readwrite").objectStore(o).put(t);s.onsuccess=u=>{n.close(),a(!0)},s.onerror=u=>{n.close(),a(!1)}})}async function KS(e){let t="cache_list",n=await iu(ee+"-cacheList",t),a=n.transaction([t],"readwrite").objectStore(t).put({key:e});a.onsuccess=o=>{n.close(),Di.push(e)},a.onerror=o=>{n.close()}}async function dm(){if(Di&&Di.length>0)return Di;let e=await iu(ee+"-cacheList","cache_list");return Di=await new Promise(t=>{let n="cache_list",a=e.transaction([n],"readonly").objectStore(n).getAllKeys();a.onsuccess=o=>{e.close(),t(a.result)},a.onerror=o=>{e.close(),t([])}}),Di}async function gm(){try{let e=[];(await dm()).forEach(r=>{e.push(GS(r))});let n=await Promise.all(e);return Vs(n.reduce((r,a)=>r+a,0))}catch{return Vs(0)}}async function GS(e){let t=await iu(e),r=[...t.objectStoreNames].reduce((i,s)=>{let u=YS(t,s);return i.push(u),i},[]),a=await Promise.all(r);return t.close(),a.reduce((i,s)=>i+s,0)}async function YS(e,t){return await new Promise((n,r)=>{if(e==null)return r();let a=0,o=e.transaction([t]).objectStore(t).openCursor();o.onsuccess=i=>{let s=o.result;if(s){let u=s.value,l=JSON.stringify(u);a+=l.length,s.continue()}else n(a)},o.onerror=i=>r("error in "+t+": "+i)})}async function C9(){try{let t=(await dm()).map(r=>JS(r));return!!(await Promise.all(t)).every(r=>r)}catch{return!1}}async function JS(e){return await new Promise(t=>{let n=indexedDB.deleteDatabase(e);n.onsuccess=()=>{t(!0)},n.onerror=r=>{t(!1)}})}m();function QS(e,t){return Math.floor(Math.random()*(t-e+1))+e}var ZS=30,mm="RATE_LIMITER_TICKS",_o=class e{static strictTicks={};static clearStrictTicks(){eu(mm,"{}")}static async getStrictTicks(t,n){if(n)return this.strictTicks[t]||[];try{let r=await t0(mm);r&&(this.strictTicks=JSON.parse(r)||{})}catch(r){I.debug("Error setting rate limiter ticks",r),this.strictTicks[t]=[]}finally{return this.strictTicks[t]||[]}}static wait(t,n){return new Promise((r,a)=>{e.getDelay(t,n).then(o=>{setTimeout(()=>{r(o)},o)})})}static async setStrictTicks(t,n,r){try{if(this.strictTicks[t]=n,r)return;await eu(mm,JSON.stringify(this.strictTicks))}catch(a){I.debug("Error setting rate limiter ticks",a)}}static async getDelay(t,n,r=!1){if(!r){let l=QS(4,ZS);await xn(l)}let a=await this.getStrictTicks(t,r)||[],{limit:o,interval:i}=n,s=Date.now();if(a.length=u?(a.push(s),await this.setStrictTicks(t,a,r),0):(a.push(u),await this.setStrictTicks(t,a,r),u-s)}};var su=l1()?["action"]:["browser_action","page_action"],e7=[{id:"toggleTranslatePage",contexts:["page","frame","selection",...su]},{id:Us,contexts:su},{id:js,contexts:su},{id:Hs,contexts:su},{id:v2,contexts:su}];async function c0(e){e=e||await pt(),I.debug("update ContextMenu",e);for(let t of e7){let n=!0;e.isShowContextMenu===!1&&t.id==="toggleTranslatePage"&&(n=!1);let r=Ma(`browser.${t.id}`,e.interfaceLanguage);Q.contextMenus.update(t.id,{title:r,visible:n})}}m();function T9(e,t){let n=t;n||(n=Pe().IMMERSIVE_TRANSLATE_INJECTED_CSS||"");let a=`${`--immersive-translate-${e}`}: (.+?);`,o=new RegExp(a),i=n.match(o);return i?i[1]:""}m();function ki(e,t,n=[],r){let a=["notranslate"];return r&&a.push(B2),e&&(a.push(`${ee}-target-translation-theme-${e}`),t?a.push(`${Ag}-theme-${e}`):a.push(`${kg}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Ag):a.push(kg),a}function Ai(e){let t=["notranslate",Ol];return e&&t.push(`${ee}-target-translation-theme-${e}-inner`),t}function v9(e,t,n){let{rule:r,state:a}=n,{translationTheme:o}=a,{variables:i,isVertical:s}=e;i=i||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,g=Ao(n,!0),p="afterend",f=g[0],h=g[1],y=`${f}(\\d+)${h}`,C=new RegExp(y,"g"),b=tt.sanitize(u);i.length>0&&(b=b.replace(C,P=>{let w=b.indexOf(P),v=b[w-1]===" ",L=b[w+P.length]===" ",T=P.replace(new RegExp(g[0],"g"),"").replace(new RegExp(g[1],"g"),""),j=Number(T);if(isNaN(j))return P;let R=i[j];if(R&&R.type==="element"){let M=R.value.outerHTML;return v||(M=" "+M),L||(M=M+" "),M}else I.error("variable type not supported",R,P);return P}));let x=ki(o,e.inline,r.translationClasses||[],e.preWhitespace);s&&x.push(F2);let S=Ai(o),A="";return r.translationBlockStyle&&(A=`style="${r.translationBlockStyle}"`),b=`<${n.rule.targetWrapperTag} ${A} class="${x.join(" ")}" ${wr}="1"><${r.targetWrapperTag} class="${S.join(" ")}" ${wr}="1">${b}`,e.inline||(l==="smart"?b=`
${b}`:b=`${l}${b}`),e.inline&&(l!=="smart"?b=`${l}${b}`:b=`<${r.targetWrapperTag} class="notranslate" ${wr}="1"> ${b}`),c==="smart"?b=`${b}`:b=`${b}${c}`,{html:b,position:p}}m();function it(e){vg({type:"success",text:e})}function rn(e){vg({type:"error",text:e})}m();m();m();m();var pm={get:(e,t,n)=>{let r=t===void 0?e:{[e]:t};return Q.storage[n].get(r)},set:(e,t,n)=>Q.storage[n].set({[e]:t})};function d0(e,t,n){let[r]=$(()=>typeof t=="function"?t():t),[a]=$(n),[o,i]=$(r),[s,u]=$(!1),[l,c]=$("");le(()=>{pm.get(e,r,a).then(p=>{p[e]&&i(p[e]),u(!0),c("")}).catch(p=>{u(!1),c(p)})},[e,r,a]);let g=Ne(p=>{let f=typeof p=="function"?p(o):p;I.debug("new settings",f),pm.set(e,f,a).then(()=>{i(f),u(!0),c("")}).catch(h=>{i(f),u(!1),c(h)})},[a,e,o]);return[o,g,s,l]}m();function g0(e,t,n){let r=[];return function(){let[o,i,s,u]=d0(e,t,n),l=Ne(c=>{for(let g of r)g(c)},[]);return le(()=>(r.push(i),()=>{r.splice(r.indexOf(i),1)}),[i]),[o,l,s,u]}}function x9(e,t){return g0(e,t,"local")}function E9(e,t){return g0(e,t,"sync")}var t7="userConfig",n7=null,r7=E9(t7,n7);function $e(e){let[t,n,r,a]=r7(),o=Ne(i=>{let s=typeof i=="function"?i(t):i;s&&(s.updatedAt=new Date().toISOString()),n(s),e&&e(s)},[t]);return[t,o,r,a,n]}m();m();m();m();function m0(e,t){let n=e.original||e,r=null,{stayOriginalSelectors:a,delimiters:o,isPreWhitespace:i}=t,s=[],u={};for(let l=0;l2&&(b=`<${o[2]}${C}>`),u[C]=c,s.push({text:b,type:"variable"})}else s.push({text:c.textContent||"",type:"text"});else{let y=c.textContent||"";p&&(y=Aa(fm(c))),s.push({text:y,type:"text"})}else if(c.nodeType===Node.ELEMENT_NODE)if(c&&un(c,a)){let C=Object.keys(u).length,b=`${o[0]}${C}${o[1]}`;o.length>2&&(b=`<${o[2]}${C}>`),u[C]=c;let x=hm(s).endsWith(" ")?" ":"",S=Aa(c.innerText||c.textContent),A=Aa(c.nextSibling).startsWith(" ")?" ":"",P=tu(x+S+A),w=P[0]+b+P[1];if(x===" ")w=w.trimStart();else if(!w.startsWith(" ")){let v=tu(c.previousSibling)[1];v===""&&(v=" "),w=v+w}s.push({text:w,type:"variable"})}else{let y=hm(s).endsWith(" ")?" ":"",C=Aa(c.innerText||c.textContent);p&&(C=Aa(fm(c)));let b=Aa(c.nextSibling).startsWith(" ")?" ":"",x=tu(y+C+b),S=x[0]+(c.innerText?.trim()||c.textContent?.trim()||"")+x[1];if(y===" ")S=S.trimStart();else{let A=tu(c.previousSibling)[1];A===""&&(c.nodeName==="A"||c.nodeName==="CODE")&&(A=" "),S=A+S}s.push({text:S,type:"text"})}else{let y=hm(s).endsWith(" ")?" ":"",C="";c.textContent&&(C=Aa(fm(c))),y===" "&&(C=C.trimStart()),s.push({text:C,type:"text"})}}if(s&&s.length>0){let l="";for(let c=0;c0&&(p=s[c-1].text),c/g,">"))}e.targetText=tt.sanitize(e.targetText);let a=!1,o=e.text,i=o.split(" ").length,s=o.split(` -`).length;i<=n.blockMinWordCount&&o.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ao(t);if(l.length>2){let c=l[2];return a7({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=v9(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function fm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function a7(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:o,variables:i,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;i=i||[];let g=e.targetText;g=tt.sanitize(g);let p=g,f=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);i.length>0&&(p=p.replace(f,x=>{let S=p.indexOf(x),A=p[S-1]===" ",P=p[S+x.length]===" ",w=x.match(h);if(!w)return x;let v=w[1],L=Number(v);if(isNaN(L))return x;let D=i[Number(L)];if(D&&D.type==="element"){let T=D.value.outerHTML;return A||(T=" "+T),P||(T=T+" "),T}else if(D&&D.type==="text"){let T=D.value;return A||(T=" "+T),P||(T=T+" "),T}else I.error("variable type not supported",D,x);return x}));let y=ki(l,n,r||[],s),C=Ai(l),b="";return c&&(b=`style="${c}"`),p=`<${a} ${b} class="${y.join(" ")}" ${wr}="1"><${a} class="${C.join(" ")}" ${wr}="1">${p}`,n||(o==="smart"?p=`
${p}`:p=`${o}${p}`),n&&(o!=="smart"?p=`${o}${p}`:p=`<${a} class="notranslate" ${wr}="1"> ${p}`),u==="smart"?p=`${p}`:p=`${p}${u}`,{html:p,position:"afterend"}}function hm(e){let t=e[e.length-1];return t?t.text:""}function bm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let o=n[2],i=new RegExp(`<${o}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${o}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(i,c=>{let g=c.match(s);if(!g)return c;let p=g[1],f=Number(p);if(isNaN(f))return c;let h=r[p];return h||c})),u}else{let o=`${n[0]}(\\d+)${n[1]}`,i=new RegExp(o,"g");a=a.replace(i,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}m();m();m();m();m();m();var YV=D9(2),w9=D9(3);function D9(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),o=a.length-e+1;if(o<1)return r;for(;o--;)r[o]=a.slice(o,o+e);return r}}m();var o7=/\s+/g,i7=/[\t\n\v\f\r ]+/g;function k9(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?s7:u7;return String(e).replace(t.style==="html"?i7:o7,t.trim?l7(n):n)}function s7(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function u7(){return" "}function l7(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var A9={}.hasOwnProperty;function c7(e){return e==null?"":k9(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function d7(e){return w9(" "+c7(e)+" ")}function g7(e){let t=d7(e),n={},r=-1;for(;++rn&&(n=o,r=a)}return[r,n]}function C7(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function T7(e,t,n,r){t=x7(t,n,r);let a=[],o;if(t)for(o in t)p0.call(t,o)&&a.push([o,v7(e,t[o])]);return a.length===0?Cm():a.sort(E7)}function v7(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharactersi+s.length,0));let o=e.length-r;for(let i of F7){let s=i[1],u=i[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/o>.5?t==="zh-CN"?I9(e)?"zh-TW":"zh-CN":t:"auto"}var N9=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Tm=new Map(N9),B7=new Map(N9.map(([e,t])=>[t,e]));function U9(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>B7.get(s));!t&&t!==0&&(t=25);let a=h0(e);if(a!=="auto")return a;let o={minLength:t,whitelist:[...Tm.keys()]},i=M9(e,o);if(i&&i.length>0){if(i.length>1&&i[0][1]-i[1][1]<=.3)for(let c=0;c.5&&c/i.length<=.25){if(g=="eng"&&p<.95)break;return Tm.get(g)}}let[s,u]=i[0],l=Tm.get(s);if(l&&u>.9)return l}}catch(r){I.error(r)}return"auto"}m();m();var vm="Original";function Ze(){return vm}function Dn(e){vm=e,j9(vm)}m();var z9="auto",b0="auto",H9="auto";function q9(e){z9=e}function Xn(e){b0=e}function Mt(){return b0!=="auto"?b0:H9!=="auto"?H9:z9}function y0(){return b0}m();function Mo(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ra(e){try{if(!e||!Mo(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:o}=r;if(a&&o){let i=document.querySelector(a);if(!i)return"";t=i.getAttribute(o)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var Xe={},Ia=async function(e,t){let{method:n,data:r}=e,a=await Xe.updateGlobalContext(),o=Date.now();if(I.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Xe.translateTheWholePage(r),rt(gr,o);else if(n==="translateTheMainPage")await Xe.translateTheMainPage(r),rt(gr,o);else if(n==="translateToThePageEndImmediately")await Xe.translateToThePageEndImmediately(r),rt(gr,o);else if(n==="toggleTranslatePage")await Xe.toggleTranslatePage(r),rt(gr,o);else if(n==="toggleTranslateTheWholePage")await Xe.toggleTranslateTheWholePage(r),rt(gr,o);else if(n==="toggleTranslateTheMainPage")await Xe.toggleTranslateTheMainPage(r),rt(gr,o);else if(n==="toggleOnlyTransation")await Xe.ensureSwitchTranslationMode(r),rt(gr,o);else if(n==="translatePage")await Xe.translatePage(a,r),rt(gr,o);else if(n==="toggleTranslationMask")await Xe.toggleTranslationMask(r);else if(n==="restorePage")Xe.restorePage();else if(n==="retryFailedParagraphs")Xe.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Xe.switchTranslationMode(r.mode),await Xe.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Xe.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Pl,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Xe.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Ns,{detail:r}));else if(n==="translateWithOpenAI")await Xe.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Xe.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Xe.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Xe.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Xe.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Xe.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Xe.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")at()||await Xe.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!at())return JSON.stringify(a)}};function W9(e){Object.assign(Xe,e)}function $9(e){Object.assign(Xe,e)}function V9(e){Object.assign(Xe,e)}var R7=function(e,t){let{method:n,data:r}=e;if(I.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Ze();if(n==="getCurrentPageLanguage"){let a=Mt();return Xe.detectCurrentPageLanguage().catch(o=>{I.warn("detectCurrentPageLanguage failed",o)}),a}else{if(n==="setCurrentPageLanguageByClient")return Xn(r),Mt();if(n==="getContextString"){let a=Xe.getPureGlobalContext();return JSON.stringify(a)}else if(n=="getPdfWebUrl"){let a=Xe.getPureGlobalContext();return Ra(a?.rule)}}},C0,T0;function K9(){let e=v0();at()||I7(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function v0(){return C0||(C0=new ea("content_script",!1).getConnection("main",Ia),C0)}function I7(){return T0||(T0=new ea("content_script",!1).getConnection("main_sync",R7,{sync:!0}),T0)}m();var xm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],x0="https://transmart.qq.com/api/imt",ra=class e{static langMapReverse=new Map(xm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:x0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,o=e.langMapReverse.get(a);return o||a}};async function Pt(e){return await v0().sendMessage("background:main",e)}function de(e){return Al()?Jl({method:"request",data:e}):me()||kl()?(e.fetchPolyfill=globalThis.GM_fetch,mr(e)):Pt({method:"fetch",data:e})}function er(){return me()?pt():Pt({method:"getConfig"})}function kn(e){return me()?Do(e):Pt({method:"setUserConfig",data:e})}function An(){return me()?pr():Pt({method:"getUserConfig"})}function lu(){return me()?qt():Pt({method:"getLocalConfig"})}function E0(e){return me()?Wt(e):Pt({method:"setLocalConfig",data:e})}function G9(e){return me()?j1(e):Pt({method:"setBuildinConfig",data:e})}async function Oe(e){if(e.text){let n=h0(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(me()||We()){if(e.translateService&&!jl.includes(e.translateService))return Promise.resolve("auto");let r=U9(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Pt({method:"detectLanguage",data:e});return Promise.resolve(t)}function Y9(){return Pt({method:"detectTabLanguage"})}async function S0(e){let t=await Oe({text:e,pageLangs:["en"]});try{if(me()||We()){let n=e.substring(0,200);t=await ra.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function j9(e){let t=new CustomEvent(bo,{detail:e});if(document.dispatchEvent(t),me())return;v0().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function J9(e){return me()?cm(e):Pt({method:"queryParagraphCache",data:e})}async function Q9(e){if(me()){await lm(e);return}return Pt({method:"setParagraphCache",data:e})}async function Z9(){if(me())return Promise.resolve();await Pt({method:"mockRequest"})}function Li(e=!1,t=""){return me()?(Q.runtime.openOptionsPage(e,t),Promise.resolve()):Pt({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function w0(e=""){return me()||We()?Pe().OPTIONS_URL:Q.runtime.getURL("options.html")}function X9(e=""){return Q&&Q.runtime&&Q.runtime.getURL?Q.runtime.getURL("options.html"):""}function D0(e=!1){return me()?(Q.extra.openAboutPage(e),Promise.resolve()):Pt({method:"openAboutPage"})}function _i(e){return me()?(Q.extra.openInTab(e),Promise.resolve()):Pt({method:"openInTab",data:e})}function e6(e=!1){return me()?(Q.extra.openEbookViewerPage(e),Promise.resolve()):Pt({method:"openEbookViewerPage"})}function t6(e=!1){return me()?(Q.extra.openEbookBuilderPage(e),Promise.resolve()):Pt({method:"openEbookBuilderPage"})}function n6(e){We()}function Mi(e=!1,t){return me()?(Q.extra.openPdfViewerPage(e),Promise.resolve()):Pt({method:"openPdfViewerPage",data:{url:t}})}function r6(e=!1){return me()?(Q.extra.openSubtitleBuilderPage(e),Promise.resolve()):Pt({method:"openSubtitleBuilderPage"})}function Pi(e){return me()?Promise.resolve():Pt({method:"setBadge",data:{text:e}})}function a6(){return me()?(I.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Pt({method:"autoSyncLatestConfig"})}function k0(e,t=!1){return me()?Q.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function o6(e,t){return me()?_o.getDelay(e,t):Pt({method:"getDelay",data:{key:e,options:t}})}var ke=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,o=!1,i=!1,s=[],u=null,l=new Set;for(let C of a)C.from&&C.from!=="auto"&&l.add(C.from),C.refresh&&(o=!0),C.debug&&(i=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=b1(a,c,g)}catch(C){if(r)for(let b=0;bC));let p=[],f=[],h=(C,b,x)=>{let S="";if(b.translatedTexts&&b.translatedTexts[0]&&(S=b.translatedTexts[0]),f[C]||(f[C]=b,f[C].translatedTexts=Array(b.sentenceTotalParts).fill(null)),f[C].hasError)return;if(x){let w=x instanceof J?new J(x.name,x.message).initNetWork(x.status).initData(x.data):x;f[C].hasError=!0,b.callback&&b.callback(w,null,b.sentence);return}f[C].translatedTexts[b.partIndex]=S;let A=f[C],P=0;for(let w=0;w{let P=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(P=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:P,to:b.to,url:x,options:n,refresh:o,debug:i}),sourceTempSentences:b.tempSentences};{let w=P2;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(w=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let L=[],D=Lr(this.serviceConfig);if(b.tempSentences.forEach((H,B)=>{let k=Jg({text:H.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});H.force!==!0&&(k&&k.text&&k.text.trim().lengthB.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:H,from:P,to:b.to})}let T="";v&&v.length>=2?T=L.map((H,B)=>{let{item:k}=H;return B===L.length-1?k.text:k.text+v[0]+(B+1)+v[1]}).join(""):T=L.map(({item:H})=>H.text).join(w);let j=await this.translate({text:T,from:P,to:b.to,url:x,options:{...n,rawTextArrayLength:L.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:o,debug:i}),{text:R}=j,M=[];if(v&&v.length>=2){let H=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(H=v[2]);let B=new RegExp(H,"g");M=R.split(B)}else M=R.split(w);let O=[];if(M.length>L.length){for(let H=0;HH.text);return D=Lr(this.serviceConfig,!0),O.forEach((H,B)=>{let k=L[B],_=k.index,F=k.variables||{};Object.keys(F).length>0&&(H=bm({text:H,delimiters:D,variables:F})),N[_]=H}),{sourceTempSentences:b.tempSentences,text:N,from:j.from,to:j.to}}};p.push(A().then(P=>{let{text:w,sourceTempSentences:v}=P;for(let L=0;L{if(P instanceof J&&P.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let w=0;w{let b=C.sentence.text;return C.translatedTexts&&C.translatedTexts.length>0&&(b=C.translatedTexts.join("")),{...C.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],o=Lr(this.serviceConfig);if(this.serviceConfig&&o.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,p)=>{let f=Jg({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:o,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[p]!==!0&&(f&&f.text&&f.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){I.debug("formatAndTranslateList error",t,l)}let i=await this.translateList(n),{text:s}=i,u=t.text.map(l=>l);return o=Lr(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let p=g.index,f=g.variables,h=Object.keys(f);u[p]=l,h.length>0&&(u[p]=bm({text:l,delimiters:o,variables:f}))}}),{...i,text:u}}detectLanguageLocally(t){return Oe({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};m();m();var Fi="input is invalid type",Em=typeof window=="object",Oa=Em?window:{};Oa.JS_SHA256_NO_WINDOW&&(Em=!1);var O7=!Em&&typeof self=="object",N7=!Oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;N7?Oa=global:O7&&(Oa=self);var CG=!Oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,TG=typeof define=="function"&&define.amd,cu=!Oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Ce="0123456789abcdef".split(""),U7=[-2147483648,8388608,32768,128],fr=[24,16,8,0],A0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],L0=["hex","array","digest","arrayBuffer"],an=[];(Oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});cu&&(Oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var i6=function(e,t){return function(n){return new on(t,!0).update(n)[e]()}},u6=function(e){var t=i6("hex",e);t.create=function(){return new on(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[o>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};on.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=U7[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};on.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=this.blocks,l,c,g,p,f,h,y,C,b,x,S;for(l=16;l<64;++l)f=u[l-15],c=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,f=u[l-2],g=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(S=t&n,l=0;l<64;l+=4)this.first?(this.is224?(C=300032,f=u[0]-1413257819,s=f-150054599<<0,r=f+24177077<<0):(C=704751109,f=u[0]-210244248,s=f-1521486534<<0,r=f+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),C=e&t,p=C^e&n^S,y=a&o^~a&i,f=s+g+y+A0[l]+u[l],h=c+p,s=r+f<<0,r=f+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,p=b^r&t^C,y=s&a^~s&o,f=i+g+y+A0[l+1]+u[l+1],h=c+p,i=n+f<<0,n=f+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),x=n&r,p=x^n&e^b,y=i&s^~i&a,f=o+g+y+A0[l+2]+u[l+2],h=c+p,o=t+f<<0,t=f+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),S=t&n,p=S^t&r^x,y=o&i^~o&s,f=a+g+y+A0[l+3]+u[l+3],h=c+p,a=e+f<<0,e=f+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+o<<0,this.h6=this.h6+i<<0,this.h7=this.h7+s<<0};on.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=Ce[e>>28&15]+Ce[e>>24&15]+Ce[e>>20&15]+Ce[e>>16&15]+Ce[e>>12&15]+Ce[e>>8&15]+Ce[e>>4&15]+Ce[e&15]+Ce[t>>28&15]+Ce[t>>24&15]+Ce[t>>20&15]+Ce[t>>16&15]+Ce[t>>12&15]+Ce[t>>8&15]+Ce[t>>4&15]+Ce[t&15]+Ce[n>>28&15]+Ce[n>>24&15]+Ce[n>>20&15]+Ce[n>>16&15]+Ce[n>>12&15]+Ce[n>>8&15]+Ce[n>>4&15]+Ce[n&15]+Ce[r>>28&15]+Ce[r>>24&15]+Ce[r>>20&15]+Ce[r>>16&15]+Ce[r>>12&15]+Ce[r>>8&15]+Ce[r>>4&15]+Ce[r&15]+Ce[a>>28&15]+Ce[a>>24&15]+Ce[a>>20&15]+Ce[a>>16&15]+Ce[a>>12&15]+Ce[a>>8&15]+Ce[a>>4&15]+Ce[a&15]+Ce[o>>28&15]+Ce[o>>24&15]+Ce[o>>20&15]+Ce[o>>16&15]+Ce[o>>12&15]+Ce[o>>8&15]+Ce[o>>4&15]+Ce[o&15]+Ce[i>>28&15]+Ce[i>>24&15]+Ce[i>>20&15]+Ce[i>>16&15]+Ce[i>>12&15]+Ce[i>>8&15]+Ce[i>>4&15]+Ce[i&15];return this.is224||(u+=Ce[s>>28&15]+Ce[s>>24&15]+Ce[s>>20&15]+Ce[s>>16&15]+Ce[s>>12&15]+Ce[s>>8&15]+Ce[s>>4&15]+Ce[s&15]),u};on.prototype.toString=on.prototype.hex;on.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,o>>24&255,o>>16&255,o>>8&255,o&255,i>>24&255,i>>16&255,i>>8&255,i&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};on.prototype.array=on.prototype.digest;on.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function _0(e,t,n){var r,a=typeof e;if(a==="string"){var o=[],i=e.length,s=0,u;for(r=0;r>6,o[s++]=128|u&63):u<55296||u>=57344?(o[s++]=224|u>>12,o[s++]=128|u>>6&63,o[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),o[s++]=240|u>>18,o[s++]=128|u>>12&63,o[s++]=128|u>>6&63,o[s++]=128|u&63);e=o}else if(a==="object"){if(e===null)throw new Error(Fi);if(cu&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!cu||!ArrayBuffer.isView(e)))throw new Error(Fi)}else throw new Error(Fi);e.length>64&&(e=new on(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}on.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}_0.prototype=new on;_0.prototype.finalize=function(){if(on.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();on.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),on.prototype.finalize.call(this)}};var Bi=u6();Bi.sha256=Bi;Bi.sha224=u6(!0);Bi.sha256.hmac=l6();Bi.sha224.hmac=l6(!0);var c6=Bi;var d6=c6.sha256;function hr(e){return Promise.resolve(d6(e))}function M0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Na(e,t){let n=d6.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function g6(e,t){let n=await Na(e,t);return M0(n)}async function P0(e,t){let n=j7(t),r=await Na(e,n);return M0(r)}function j7(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var m6=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],du=class e extends ke{static langMap=new Map(m6);maxTextGroupLength=50;static langMapReverse=new Map(m6.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new J("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetText,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetTextList,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:o,version:i}){let s=`${o}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await hr(a)].join(` +`).length;i<=n.blockMinWordCount&&o.length<=n.blockMinTextCount&&s<2&&(a=!0);let u={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:r,inline:a,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},l=Ao(t);if(l.length>2){let c=l[2];return a7({delimiterTag:c,targetText:e.targetText,inline:a,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:r}).html}else{let c=v9(u,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return c.html}}function fm(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function a7(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:o,variables:i,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c}=e;i=i||[];let g=e.targetText;g=tt.sanitize(g);let p=g,f=new RegExp(`<${t}(\\d+)>(.*?)`,"g"),h=new RegExp(`<${t}(\\d+)>`);i.length>0&&(p=p.replace(f,x=>{let S=p.indexOf(x),A=p[S-1]===" ",P=p[S+x.length]===" ",w=x.match(h);if(!w)return x;let v=w[1],L=Number(v);if(isNaN(L))return x;let D=i[Number(L)];if(D&&D.type==="element"){let T=D.value.outerHTML;return A||(T=" "+T),P||(T=T+" "),T}else if(D&&D.type==="text"){let T=D.value;return A||(T=" "+T),P||(T=T+" "),T}else I.error("variable type not supported",D,x);return x}));let y=ki(l,n,r||[],s),C=Ai(l),b="";return c&&(b=`style="${c}"`),p=`<${a} ${b} class="${y.join(" ")}" ${wr}="1"><${a} class="${C.join(" ")}" ${wr}="1">${p}`,n||(o==="smart"?p=`
${p}`:p=`${o}${p}`),n&&(o!=="smart"?p=`${o}${p}`:p=`<${a} class="notranslate" ${wr}="1"> ${p}`),u==="smart"?p=`${p}`:p=`${p}${u}`,{html:p,position:"afterend"}}function hm(e){let t=e[e.length-1];return t?t.text:""}function bm(e){let{text:t,delimiters:n,variables:r}=e,a=t;if(n.length>2){let o=n[2],i=new RegExp(`<${o}(\\d+)>(.*?)`,"g"),s=new RegExp(`<${o}(\\d+)>`),u=t;return Object.keys(r).length>0&&(u=u.replace(i,c=>{let g=c.match(s);if(!g)return c;let p=g[1],f=Number(p);if(isNaN(f))return c;let h=r[p];return h||c})),u}else{let o=`${n[0]}(\\d+)${n[1]}`,i=new RegExp(o,"g");a=a.replace(i,s=>{let l=s.replace(new RegExp(n[0],"g"),"").replace(new RegExp(n[1],"g"),""),c=Number(l);return isNaN(c)?s:r[c]?r[c]:s})}return a}m();m();m();m();m();m();var YV=D9(2),w9=D9(3);function D9(e){if(typeof e!="number"||Number.isNaN(e)||e<1||e===Number.POSITIVE_INFINITY)throw new Error("`"+e+"` is not a valid argument for `n-gram`");return t;function t(n){let r=[];if(n==null)return r;let a=typeof n.slice=="function"?n:String(n),o=a.length-e+1;if(o<1)return r;for(;o--;)r[o]=a.slice(o,o+e);return r}}m();var o7=/\s+/g,i7=/[\t\n\v\f\r ]+/g;function k9(e,t){t?typeof t=="string"&&(t={style:t}):t={};let n=t.preserveLineEndings?s7:u7;return String(e).replace(t.style==="html"?i7:o7,t.trim?l7(n):n)}function s7(e){let t=/\r?\n|\r/.exec(e);return t?t[0]:" "}function u7(){return" "}function l7(e){return t;function t(n,r,a){return r===0||r+n.length===a.length?"":e(n)}}var A9={}.hasOwnProperty;function c7(e){return e==null?"":k9(String(e).replace(/[\u0021-\u0040]+/g," ")).trim().toLowerCase()}function d7(e){return w9(" "+c7(e)+" ")}function g7(e){let t=d7(e),n={},r=-1;for(;++rn&&(n=o,r=a)}return[r,n]}function C7(e,t){let n=e.match(t);return(n?n.length:0)/e.length||0}function T7(e,t,n,r){t=x7(t,n,r);let a=[],o;if(t)for(o in t)p0.call(t,o)&&a.push([o,v7(e,t[o])]);return a.length===0?Cm():a.sort(E7)}function v7(e,t){let n=0,r=-1;for(;++rt.traditionalCharacters?(t.detectedCharacters="simplified",t.detectionRate=t.simplifiedCharacters/t.traditionalCharacters|1):t.simplifiedCharactersi+s.length,0));let o=e.length-r;for(let i of F7){let s=i[1],u=i[0],l=e.match(s),c=l?l.length:0;c>n&&(n=c,t=u)}return n*2.5/o>.5?t==="zh-CN"?I9(e)?"zh-TW":"zh-CN":t:"auto"}var N9=[["afr","af"],["amh","am"],["arb","ar"],["azj","az"],["bel","be"],["bul","bg"],["ben","bn"],["bos","bs"],["cat","ca"],["ceb","ceb"],["ces","cs"],["dan","da"],["deu","de"],["ell","el"],["eng","en"],["epo","eo"],["spa","es"],["est","et"],["fas","fa"],["fin","fi"],["fra","fr"],["gax","ga"],["glg","gl"],["guj","gu"],["hau","ha"],["heb","he"],["hin","hi"],["hrv","hr"],["hun","hu"],["hye","hy"],["ind","id"],["ibo","ig"],["ita","it"],["jpn","ja"],["jav","jw"],["kat","ka"],["kaz","kk"],["khm","km"],["kan","kn"],["kor","ko"],["ckb","ku"],["lao","lo"],["lit","lt"],["lav","lv"],["min","mi"],["mkd","mk"],["mal","ml"],["mar","mr"],["mya","my"],["nep","ne"],["nld","nl"],["nob","no"],["nya","ny"],["pan","pa"],["pol","pl"],["pbu","ps"],["por","pt"],["ron","ro"],["rus","ru"],["sin","si"],["slk","sk"],["slv","sl"],["sna","sn"],["som","so"],["als","sq"],["srp","sr"],["sun","su"],["swe","sv"],["swh","sw"],["tam","ta"],["tel","te"],["tgk","tg"],["tha","th"],["toi","to"],["tur","tr"],["ukr","uk"],["urd","ur"],["uzn","uz"],["vie","vi"],["xho","xh"],["ydd","yi"],["yor","yo"],["cmn","zh-CN"],["zul","zu"]],Tm=new Map(N9),B7=new Map(N9.map(([e,t])=>[t,e]));function U9(e,t,n=["en"]){if(!e)return"auto";try{let r=n.map(s=>B7.get(s));!t&&t!==0&&(t=25);let a=h0(e);if(a!=="auto")return a;let o={minLength:t,whitelist:[...Tm.keys()]},i=M9(e,o);if(i&&i.length>0){if(i.length>1&&i[0][1]-i[1][1]<=.3)for(let c=0;c.5&&c/i.length<=.25){if(g=="eng"&&p<.95)break;return Tm.get(g)}}let[s,u]=i[0],l=Tm.get(s);if(l&&u>.9)return l}}catch(r){I.error(r)}return"auto"}m();m();var vm="Original";function Ze(){return vm}function Dn(e){vm=e,j9(vm)}m();var z9="auto",b0="auto",H9="auto";function q9(e){z9=e}function Xn(e){b0=e}function Mt(){return b0!=="auto"?b0:H9!=="auto"?H9:z9}function y0(){return b0}m();function Mo(e){return e?.id?.endsWith("pdfWebPage")||!1}function Ra(e){try{if(!e||!Mo(e))return"";let t="";if(e.pdfUrlExtractRule.attribute&&e.pdfUrlExtractRule.selector){let r=e.pdfUrlExtractRule,{selector:a,attribute:o}=r;if(a&&o){let i=document.querySelector(a);if(!i)return"";t=i.getAttribute(o)||""}}else t=document.querySelector("embed[type='application/pdf']")?.getAttribute("src")||"";if(t.startsWith("about"))return"";if(!t.startsWith("/"))return t;let n=new URL(location.href);return t.startsWith("//")?n.protocol+t:n.protocol+"//"+n.host+t}catch{return""}}var Xe={},Ia=async function(e,t){let{method:n,data:r}=e,a=await Xe.updateGlobalContext(),o=Date.now();if(I.debug(`content script received message: ${n}`,r||" "),n==="translateTheWholePage")await Xe.translateTheWholePage(r),rt(gr,o);else if(n==="translateTheMainPage")await Xe.translateTheMainPage(r),rt(gr,o);else if(n==="translateToThePageEndImmediately")await Xe.translateToThePageEndImmediately(r),rt(gr,o);else if(n==="toggleTranslatePage")await Xe.toggleTranslatePage(r),rt(gr,o);else if(n==="toggleTranslateTheWholePage")await Xe.toggleTranslateTheWholePage(r),rt(gr,o);else if(n==="toggleTranslateTheMainPage")await Xe.toggleTranslateTheMainPage(r),rt(gr,o);else if(n==="toggleOnlyTransation")await Xe.ensureSwitchTranslationMode(r),rt(gr,o);else if(n==="translatePage")await Xe.translatePage(a,r),rt(gr,o);else if(n==="toggleTranslationMask")await Xe.toggleTranslationMask(r);else if(n==="restorePage")Xe.restorePage();else if(n==="retryFailedParagraphs")Xe.retryFailedParagraphs();else if(n==="switchTranslationMode"){if(a.rule.isPdf)return;r&&r.mode&&(await Xe.switchTranslationMode(r.mode),await Xe.reloadSubtitleWithTranslationModeChanged())}else if(n==="autoEnableSubtitleChanged")Xe.autoEnableSubtitleChanged(a,r);else if(n=="shareToDraft")globalThis.document.dispatchEvent(new CustomEvent(Pl,{detail:r}));else if(n=="toggleTranslateToThePageEndImmediately")await Xe.toggleTranslateToThePageEndImmediately(r);else if(n==="toggleMouseHoverTranslateDirectly")globalThis.document.dispatchEvent(new CustomEvent(Ns,{detail:r}));else if(n==="translateWithOpenAI")await Xe.translatePageWithTranslationService("openai",r);else if(n==="translateWithGoogle")await Xe.translatePageWithTranslationService("google",r);else if(n==="translateWithDeepL")await Xe.translatePageWithTranslationService("deepl",r);else if(n==="translateWithBing")await Xe.translatePageWithTranslationService("bing",r);else if(n==="translateWithTransmart")await Xe.translatePageWithTranslationService("transmart",r);else if(n==="translateWithGemini")await Xe.translatePageWithTranslationService("gemini",r);else if(n==="translateInputBox")await Xe.translateInputBoxWithShortcut(a);else if(n!=="updateGlobalCtx"){if(n==="toggleVideoSubtitlePreTranslation")at()||await Xe.toggleVideoSubtitlePreTranslation();else if(n==="getAsyncContextString"&&!at())return JSON.stringify(a)}};function W9(e){Object.assign(Xe,e)}function $9(e){Object.assign(Xe,e)}function V9(e){Object.assign(Xe,e)}var R7=function(e,t){let{method:n,data:r}=e;if(I.debug(`content script received sync message: ${n}`,r||" "),n==="ping")return"pong";if(n==="getPageStatus")return Ze();if(n==="getCurrentPageLanguage"){let a=Mt();return Xe.detectCurrentPageLanguage().catch(o=>{I.warn("detectCurrentPageLanguage failed",o)}),a}else{if(n==="setCurrentPageLanguageByClient")return Xn(r),Mt();if(n==="getContextString"){let a=Xe.getPureGlobalContext(),{articleNode:o,bodyNode:i,...s}=a;return JSON.stringify(s)}else if(n=="getPdfWebUrl"){let a=Xe.getPureGlobalContext();return Ra(a?.rule)}}},C0,T0;function K9(){let e=v0();at()||I7(),e.sendMessage("popup:main_sync",{method:"ready"}).catch(n=>{})}function v0(){return C0||(C0=new ea("content_script",!1).getConnection("main",Ia),C0)}function I7(){return T0||(T0=new ea("content_script",!1).getConnection("main_sync",R7,{sync:!0}),T0)}m();var xm=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","ja"],["ko","ko"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],x0="https://transmart.qq.com/api/imt",ra=class e{static langMapReverse=new Map(xm.map(([t,n])=>[n,t]));static getClientKey(){return btoa("transmart_crx_"+navigator.userAgent).slice(0,100)}static async detectLanguageRemotelyByTransmart(t){let n={header:{fn:"text_analysis",client_key:e.getClientKey()},text:t.slice(0,280)},r=await de({url:x0,method:"POST",body:JSON.stringify(n)});if(r.header.ret_code!=="succ")throw new Error(r.message||r.header.ret_code);let a=r.language,o=e.langMapReverse.get(a);return o||a}};async function Pt(e){return await v0().sendMessage("background:main",e)}function de(e){return Al()?Jl({method:"request",data:e}):me()||kl()?(e.fetchPolyfill=globalThis.GM_fetch,mr(e)):Pt({method:"fetch",data:e})}function er(){return me()?pt():Pt({method:"getConfig"})}function kn(e){return me()?Do(e):Pt({method:"setUserConfig",data:e})}function An(){return me()?pr():Pt({method:"getUserConfig"})}function lu(){return me()?qt():Pt({method:"getLocalConfig"})}function E0(e){return me()?Wt(e):Pt({method:"setLocalConfig",data:e})}function G9(e){return me()?j1(e):Pt({method:"setBuildinConfig",data:e})}async function Oe(e){if(e.text){let n=h0(e.text);if(n!=="auto")return Promise.resolve(n)}else return"auto";if(me()||We()){if(e.translateService&&!jl.includes(e.translateService))return Promise.resolve("auto");let r=U9(e.text,e.minLength,e.pageLangs);return Promise.resolve(r)}let t=await Pt({method:"detectLanguage",data:e});return Promise.resolve(t)}function Y9(){return Pt({method:"detectTabLanguage"})}async function S0(e){let t=await Oe({text:e,pageLangs:["en"]});try{if(me()||We()){let n=e.substring(0,200);t=await ra.detectLanguageRemotelyByTransmart(n)}}catch{}return t}function j9(e){let t=new CustomEvent(bo,{detail:e});if(document.dispatchEvent(t),me())return;v0().sendMessage("popup:main_sync",{method:"setPageStatus",data:e}).catch(r=>{})}function J9(e){return me()?cm(e):Pt({method:"queryParagraphCache",data:e})}async function Q9(e){if(me()){await lm(e);return}return Pt({method:"setParagraphCache",data:e})}async function Z9(){if(me())return Promise.resolve();await Pt({method:"mockRequest"})}function Li(e=!1,t=""){return me()?(Q.runtime.openOptionsPage(e,t),Promise.resolve()):Pt({method:"openOptionsPage",data:{newTab:e,pageRoute:t}})}function w0(e=""){return me()||We()?Pe().OPTIONS_URL:Q.runtime.getURL("options.html")}function X9(e=""){return Q&&Q.runtime&&Q.runtime.getURL?Q.runtime.getURL("options.html"):""}function D0(e=!1){return me()?(Q.extra.openAboutPage(e),Promise.resolve()):Pt({method:"openAboutPage"})}function _i(e){return me()?(Q.extra.openInTab(e),Promise.resolve()):Pt({method:"openInTab",data:e})}function e6(e=!1){return me()?(Q.extra.openEbookViewerPage(e),Promise.resolve()):Pt({method:"openEbookViewerPage"})}function t6(e=!1){return me()?(Q.extra.openEbookBuilderPage(e),Promise.resolve()):Pt({method:"openEbookBuilderPage"})}function n6(e){We()}function Mi(e=!1,t){return me()?(Q.extra.openPdfViewerPage(e),Promise.resolve()):Pt({method:"openPdfViewerPage",data:{url:t}})}function r6(e=!1){return me()?(Q.extra.openSubtitleBuilderPage(e),Promise.resolve()):Pt({method:"openSubtitleBuilderPage"})}function Pi(e){return me()?Promise.resolve():Pt({method:"setBadge",data:{text:e}})}function a6(){return me()?(I.warn("autoSyncLatestConfig is not support in monkey"),Promise.resolve()):Pt({method:"autoSyncLatestConfig"})}function k0(e,t=!1){return me()?Q.extra.openInTab(e,t):globalThis.open(e,t?"_blank":"_self"),Promise.resolve()}function o6(e,t){return me()?_o.getDelay(e,t):Pt({method:"getDelay",data:{key:e,options:t}})}var ke=class{static langMap=new Map;serviceConfig;generalConfig;maxTextLength=1800;isSupportList=!0;maxTextGroupLength=50;requestTimeout=30*1e3;retry=2;translationOptions;minTextCount=2;constructor(t,n,r){this.serviceConfig=t,this.generalConfig=n,this.translationOptions=r,t?.retry&&(this.retry=t.retry),t?.requestTimeout&&(this.requestTimeout=Number(t.requestTimeout)),r&&r.minTextCount&&(this.minTextCount=r.minTextCount)}async init(){}getMaxTextGroupLength(){return this.maxTextGroupLength}getRateLimiter(){let t=this.getDefaultRateLimit()||{limit:7,interval:1250},n=this.serviceConfig;return n?.limit&&(t.limit=Number(n.limit)),n?.interval&&(t.interval=Number(n.interval)),t}formatRateLimit(t){return t.limit<1&&(t.interval=Math.round(1e3/t.limit),t.limit=1),t}getDefaultRateLimit(){return{limit:7,interval:1250}}getCacheKeyPrefix(){return""}translate(t){throw new Error("Not implemented")}translateList(t){throw new Error("Not implemented")}async multipleTranslate(t,n,r){if(t.sentences.length===0)return{sentences:[]};let{sentences:a}=t,o=!1,i=!1,s=[],u=null,l=new Set;for(let C of a)C.from&&C.from!=="auto"&&l.add(C.from),C.refresh&&(o=!0),C.debug&&(i=!0);let c=this.maxTextLength;this.serviceConfig&&this.serviceConfig.maxTextLengthPerRequest&&(c=this.serviceConfig.maxTextLengthPerRequest);let g=this.maxTextGroupLength;this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequest&&(g=this.serviceConfig.maxTextGroupLengthPerRequest),this.translationOptions&&this.translationOptions.sourceProgram&&["videoSubtitle","subtitle"].includes(this.translationOptions.sourceProgram)&&this.serviceConfig&&this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle&&(g=this.serviceConfig.maxTextGroupLengthPerRequestForSubtitle);try{s=b1(a,c,g)}catch(C){if(r)for(let b=0;bC));let p=[],f=[],h=(C,b,x)=>{let S="";if(b.translatedTexts&&b.translatedTexts[0]&&(S=b.translatedTexts[0]),f[C]||(f[C]=b,f[C].translatedTexts=Array(b.sentenceTotalParts).fill(null)),f[C].hasError)return;if(x){let w=x instanceof J?new J(x.name,x.message).initNetWork(x.status).initData(x.data):x;f[C].hasError=!0,b.callback&&b.callback(w,null,b.sentence);return}f[C].translatedTexts[b.partIndex]=S;let A=f[C],P=0;for(let w=0;w{let P=b.from;if(b.fromByClient&&b.fromByClient!=="auto"&&(P=b.fromByClient),this.isSupportList)return{...await this.formatAndTranslateList({text:b.tempSentences.map(v=>v.text),forces:b.tempSentences.map(v=>v.force),xpaths:b.tempSentences.map(v=>v.xpath||""),from:P,to:b.to,url:x,options:n,refresh:o,debug:i}),sourceTempSentences:b.tempSentences};{let w=P2;this.serviceConfig&&this.serviceConfig.translationTextSeparator&&(w=this.serviceConfig.translationTextSeparator);let v=null;this.serviceConfig&&this.serviceConfig.newlinePlaceholderDelimiters&&(v=this.serviceConfig.newlinePlaceholderDelimiters);let L=[],D=Lr(this.serviceConfig);if(b.tempSentences.forEach((H,B)=>{let k=Jg({text:H.text,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:D,glossaries:this.translationOptions.glossaries,excludeRegexps:this.translationOptions.excludeRegexps,targetLanguage:b.to});H.force!==!0&&(k&&k.text&&k.text.trim().lengthB.text);return Promise.resolve({sourceTempSentences:b.tempSentences,text:H,from:P,to:b.to})}let T="";v&&v.length>=2?T=L.map((H,B)=>{let{item:k}=H;return B===L.length-1?k.text:k.text+v[0]+(B+1)+v[1]}).join(""):T=L.map(({item:H})=>H.text).join(w);let j=await this.translate({text:T,from:P,to:b.to,url:x,options:{...n,rawTextArrayLength:L.length,sourceProgram:this.translationOptions.sourceProgram||""},refresh:o,debug:i}),{text:R}=j,M=[];if(v&&v.length>=2){let H=`${v[0]}\\d+${v[1]}`;v&&v.length>=3&&(H=v[2]);let B=new RegExp(H,"g");M=R.split(B)}else M=R.split(w);let O=[];if(M.length>L.length){for(let H=0;HH.text);return D=Lr(this.serviceConfig,!0),O.forEach((H,B)=>{let k=L[B],_=k.index,F=k.variables||{};Object.keys(F).length>0&&(H=bm({text:H,delimiters:D,variables:F})),N[_]=H}),{sourceTempSentences:b.tempSentences,text:N,from:j.from,to:j.to}}};p.push(A().then(P=>{let{text:w,sourceTempSentences:v}=P;for(let L=0;L{if(P instanceof J&&P.initData({translationService:this.translationOptions.translationService,isLogin:!!this.translationOptions.userToken,isPro:this.translationOptions.isPro}),r){for(let w=0;w{let b=C.sentence.text;return C.translatedTexts&&C.translatedTexts.length>0&&(b=C.translatedTexts.join("")),{...C.sentence,text:b}})}}async formatAndTranslateList(t){let n={...t},{forces:r}=t,a=[],o=Lr(this.serviceConfig);if(this.serviceConfig&&o.length>0)try{let{text:l,xpaths:c}=t;if(l.forEach((g,p)=>{let f=Jg({text:g,_systemExcludeWordRegex:this.generalConfig._systemExcludeWordRegex,delimiters:o,excludeRegexps:this.translationOptions.excludeRegexps,glossaries:this.translationOptions.glossaries,targetLanguage:t.to});r&&r[p]!==!0&&(f&&f.text&&f.text.trim().lengthg.text),n.xpaths=a.map(g=>g.xpath)}catch(l){I.debug("formatAndTranslateList error",t,l)}let i=await this.translateList(n),{text:s}=i,u=t.text.map(l=>l);return o=Lr(this.serviceConfig,!0),s.forEach((l,c)=>{let g=a[c];if(g){let p=g.index,f=g.variables,h=Object.keys(f);u[p]=l,h.length>0&&(u[p]=bm({text:l,delimiters:o,variables:f}))}}),{...i,text:u}}detectLanguageLocally(t){return Oe({text:t,minLength:18,pageLangs:[Mt(),"en"]})}detectLanguageRemotely(t){return Promise.resolve("auto")}detectLanguage(t){return t.length>=50?this.detectLanguageLocally(t):this.detectLanguageRemotely(t)}};m();m();var Fi="input is invalid type",Em=typeof window=="object",Oa=Em?window:{};Oa.JS_SHA256_NO_WINDOW&&(Em=!1);var O7=!Em&&typeof self=="object",N7=!Oa.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;N7?Oa=global:O7&&(Oa=self);var CG=!Oa.JS_SHA256_NO_COMMON_JS&&typeof module=="object"&&module.exports,TG=typeof define=="function"&&define.amd,cu=!Oa.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",Ce="0123456789abcdef".split(""),U7=[-2147483648,8388608,32768,128],fr=[24,16,8,0],A0=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],L0=["hex","array","digest","arrayBuffer"],an=[];(Oa.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"});cu&&(Oa.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e=="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer});var i6=function(e,t){return function(n){return new on(t,!0).update(n)[e]()}},u6=function(e){var t=i6("hex",e);t.create=function(){return new on(e)},t.update=function(a){return t.create().update(a)};for(var n=0;n>2]|=e[a]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|r&63)<=57344?(s[o>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|r&63)<=64?(this.block=s[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}};on.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=U7[t&3],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}};on.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=this.blocks,l,c,g,p,f,h,y,C,b,x,S;for(l=16;l<64;++l)f=u[l-15],c=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3,f=u[l-2],g=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,u[l]=u[l-16]+c+u[l-7]+g<<0;for(S=t&n,l=0;l<64;l+=4)this.first?(this.is224?(C=300032,f=u[0]-1413257819,s=f-150054599<<0,r=f+24177077<<0):(C=704751109,f=u[0]-210244248,s=f-1521486534<<0,r=f+143694565<<0),this.first=!1):(c=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),g=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),C=e&t,p=C^e&n^S,y=a&o^~a&i,f=s+g+y+A0[l]+u[l],h=c+p,s=r+f<<0,r=f+h<<0),c=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),g=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7),b=r&e,p=b^r&t^C,y=s&a^~s&o,f=i+g+y+A0[l+1]+u[l+1],h=c+p,i=n+f<<0,n=f+h<<0,c=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),g=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7),x=n&r,p=x^n&e^b,y=i&s^~i&a,f=o+g+y+A0[l+2]+u[l+2],h=c+p,o=t+f<<0,t=f+h<<0,c=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),g=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7),S=t&n,p=S^t&r^x,y=o&i^~o&s,f=a+g+y+A0[l+3]+u[l+3],h=c+p,a=e+f<<0,e=f+h<<0;this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0,this.h4=this.h4+a<<0,this.h5=this.h5+o<<0,this.h6=this.h6+i<<0,this.h7=this.h7+s<<0};on.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=Ce[e>>28&15]+Ce[e>>24&15]+Ce[e>>20&15]+Ce[e>>16&15]+Ce[e>>12&15]+Ce[e>>8&15]+Ce[e>>4&15]+Ce[e&15]+Ce[t>>28&15]+Ce[t>>24&15]+Ce[t>>20&15]+Ce[t>>16&15]+Ce[t>>12&15]+Ce[t>>8&15]+Ce[t>>4&15]+Ce[t&15]+Ce[n>>28&15]+Ce[n>>24&15]+Ce[n>>20&15]+Ce[n>>16&15]+Ce[n>>12&15]+Ce[n>>8&15]+Ce[n>>4&15]+Ce[n&15]+Ce[r>>28&15]+Ce[r>>24&15]+Ce[r>>20&15]+Ce[r>>16&15]+Ce[r>>12&15]+Ce[r>>8&15]+Ce[r>>4&15]+Ce[r&15]+Ce[a>>28&15]+Ce[a>>24&15]+Ce[a>>20&15]+Ce[a>>16&15]+Ce[a>>12&15]+Ce[a>>8&15]+Ce[a>>4&15]+Ce[a&15]+Ce[o>>28&15]+Ce[o>>24&15]+Ce[o>>20&15]+Ce[o>>16&15]+Ce[o>>12&15]+Ce[o>>8&15]+Ce[o>>4&15]+Ce[o&15]+Ce[i>>28&15]+Ce[i>>24&15]+Ce[i>>20&15]+Ce[i>>16&15]+Ce[i>>12&15]+Ce[i>>8&15]+Ce[i>>4&15]+Ce[i&15];return this.is224||(u+=Ce[s>>28&15]+Ce[s>>24&15]+Ce[s>>20&15]+Ce[s>>16&15]+Ce[s>>12&15]+Ce[s>>8&15]+Ce[s>>4&15]+Ce[s&15]),u};on.prototype.toString=on.prototype.hex;on.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,a=this.h4,o=this.h5,i=this.h6,s=this.h7,u=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,a>>24&255,a>>16&255,a>>8&255,a&255,o>>24&255,o>>16&255,o>>8&255,o&255,i>>24&255,i>>16&255,i>>8&255,i&255];return this.is224||u.push(s>>24&255,s>>16&255,s>>8&255,s&255),u};on.prototype.array=on.prototype.digest;on.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),e};function _0(e,t,n){var r,a=typeof e;if(a==="string"){var o=[],i=e.length,s=0,u;for(r=0;r>6,o[s++]=128|u&63):u<55296||u>=57344?(o[s++]=224|u>>12,o[s++]=128|u>>6&63,o[s++]=128|u&63):(u=65536+((u&1023)<<10|e.charCodeAt(++r)&1023),o[s++]=240|u>>18,o[s++]=128|u>>12&63,o[s++]=128|u>>6&63,o[s++]=128|u&63);e=o}else if(a==="object"){if(e===null)throw new Error(Fi);if(cu&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!cu||!ArrayBuffer.isView(e)))throw new Error(Fi)}else throw new Error(Fi);e.length>64&&(e=new on(t,!0).update(e).array());var l=[],c=[];for(r=0;r<64;++r){var g=e[r]||0;l[r]=92^g,c[r]=54^g}on.call(this,t,n),this.update(c),this.oKeyPad=l,this.inner=!0,this.sharedMemory=n}_0.prototype=new on;_0.prototype.finalize=function(){if(on.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();on.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(e),on.prototype.finalize.call(this)}};var Bi=u6();Bi.sha256=Bi;Bi.sha224=u6(!0);Bi.sha256.hmac=l6();Bi.sha224.hmac=l6(!0);var c6=Bi;var d6=c6.sha256;function hr(e){return Promise.resolve(d6(e))}function M0(e){return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}function Na(e,t){let n=d6.hmac.create(t);return n.update(e),Promise.resolve(n.array())}async function g6(e,t){let n=await Na(e,t);return M0(n)}async function P0(e,t){let n=j7(t),r=await Na(e,n);return M0(r)}function j7(e){let t=[];return e.replace(/../g,function(n){return t.push(parseInt(n,16)),""}),new Uint8Array(t).buffer}var m6=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],du=class e extends ke{static langMap=new Map(m6);maxTextGroupLength=50;static langMapReverse=new Map(m6.map(([t,n])=>[n,t]));static getUTCDate(t){let n=t.getUTCFullYear(),r=`${t.getUTCMonth()+1}`.padStart(2,"0"),a=`${t.getUTCDate()}`.padStart(2,"0");return`${n}-${r}-${a}`}secretId="";secretKey="";isSupportList=!0;constructor(t,n,r){if(super(t,n,r),!t||!t.secretId||!t.secretKey)throw new J("secretId and secretKey are required");this.secretId=t.secretId?.trim(),this.secretKey=t.secretKey?.trim()}getDefaultRateLimit(){return{limit:3,interval:1350}}async translate(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceText:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslate",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetText,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async translateList(t){let{text:n,from:r,to:a}=t,o=JSON.stringify({ProjectId:0,Source:e.langMap.get(r)||"auto",SourceTextList:n,Target:e.langMap.get(a)||a}),i=await this.signedRequest({secretId:this.secretId,secretKey:this.secretKey,action:"TextTranslateBatch",payload:o,service:"tmt",version:"2018-03-21"});return{text:i.Response.TargetTextList,from:e.langMapReverse.get(i.Response.Source)||r,to:e.langMapReverse.get(i.Response.Target)||a}}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:o,version:i}){let s=`${o}.tencentcloudapi.com`,u=new Date,l=`${new Date().valueOf()}`.slice(0,10),c=["POST","/","","content-type:application/json; charset=utf-8",`host:${s}`,"","content-type;host",await hr(a)].join(` `),g=e.getUTCDate(u),p=["TC3-HMAC-SHA256",l,`${g}/${o}/tc3_request`,await hr(c)].join(` `),f=await g6(g,`TC3${n}`),h=await P0(o,f),y=await P0("tc3_request",h),C=await P0(p,y),b=await de({retry:this.retry,url:`https://${o}.tencentcloudapi.com`,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:s,"X-TC-Action":r,"X-TC-Timestamp":l,"X-TC-Region":"ap-beijing","X-TC-Version":i,Authorization:`TC3-HMAC-SHA256 Credential=${t}/${g}/${o}/tc3_request, SignedHeaders=content-type;host, Signature=${C}`},body:a,timeout:this.requestTimeout});if(b instanceof Error)throw b;if(b.Response&&b.Response.Error&&b.Response.Error.Message)throw new J(b.Response.Error.Message);return b}};m();var p6=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh-TW"],["de","de"],["en","en"],["es","es"],["fr","fr"],["id","id"],["it","it"],["ja","jp"],["ko","kr"],["ms","ms"],["pt","pt"],["ru","ru"],["th","th"],["tr","tr"],["vi","vi"]],H7={"content-type":"application/json",Host:"wxapp.translator.qq.com","User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.32(0x18002035) NetType/WIFI Language/zh_TW",Referer:"https://servicewechat.com/wxb1070eabc6f9107e/117/page-frame.html"},gu=class e extends ke{static langMap=new Map(p6);static langMapReverse=new Map(p6.map(([t,n])=>[n,t]));isSupportList=!1;constructor(t,n,r){super(t,n,r)}async translate(t){let{text:n,from:r,to:a}=t,o=new URLSearchParams({source:r,target:a,sourceText:n,platform:"WeChat_APP",candidateLangs:"en|zh",guid:"oqdgX0SIwhvM0TmqzTHghWBvfk22"}).toString(),i=await de({url:`https://wxapp.translator.qq.com/api/translate?${o}`,retry:this.retry,method:"GET",headers:H7,timeout:this.requestTimeout});return{text:i.targetText,from:e.langMapReverse.get(i.source)||r,to:e.langMapReverse.get(i.target)||a}}};m();var f6=[["auto","auto"],["zh-CN","zh-CN"],["zh-TW","zh-TW"],["en","en"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["ceb","ceb"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["haw","haw"],["he","he"],["hi","hi"],["hmn","hmn"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["jw","jw"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["sa","sa"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["fil","tl"],["tr","tr"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zu","zu"]],Po=class e extends ke{static langMap=new Map(f6);static langMapReverse=new Map(f6.map(([t,n])=>[n,t]));isSupportList=!1;apiUrl="https://translate.googleapis.com/translate_a/single";constructor(t,n,r){super(t,n,r),t?.apiUrl&&(this.apiUrl=nn(this.apiUrl,t.apiUrl))}getDefaultRateLimit(){return{limit:10,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let o=e.langMap.get(r)||"auto",i=e.langMap.get(a)||a,s=await this.fetchWithoutToken(n,o,i);if(!s)throw new J("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new J("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async translateXml(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let o=e.langMap.get(r)||"auto",i=e.langMap.get(a)||a,s=await this.fetchXmlWithoutToken(n,o,i);if(!s)throw new J("google translate NETWORK_ERROR");if(!s.data[0]||s.data[0].length<=0)throw new J("google translate API_SERVER_ERROR");return{text:s.data[0].map(l=>l[0]).filter(Boolean).join(""),from:e.langMapReverse.get(s.data[2])||"auto",to:a}}async fetchXmlWithoutToken(t,n,r){let o="https://translate.googleapis.com/translate_a/t?"+new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}).toString();return{data:await de({retry:this.retry,url:o,timeout:this.requestTimeout})}}async fetchWithoutToken(t,n,r){let a=new URLSearchParams({client:"gtx",dt:"t",sl:n,tl:r,q:t}),o=this.apiUrl+"?"+a.toString();return{data:await de({retry:this.retry,url:o,timeout:this.requestTimeout})}}};m();m();m();function z7(e,t){return t?e+(t-e%t):e}function q7(e,t){return e.split(t).length-1}function Sm(e){let t=Date.now(),n=1;for(let r of e)n+=q7(r,"i");return z7(t,n)}function W7(e,t){return Math.floor(Math.random()*(t-e+1))+e}function wm(){return W7(1e6,1e8)}m();m();m();var Dm="https://www2.deepl.com/jsonrpc",km="auto",h6=[{code:"BG",language:"Bulgarian"},{code:"ZH",language:"Chinese"},{code:"CS",language:"Czech"},{code:"DA",language:"Danish"},{code:"NL",language:"Dutch"},{code:"EN",language:"English"},{code:"ET",language:"Estonian"},{code:"FI",language:"Finnish"},{code:"FR",language:"French"},{code:"DE",language:"German"},{code:"EL",language:"Greek"},{code:"HU",language:"Hungarian"},{code:"IT",language:"Italian"},{code:"JA",language:"Japanese"},{code:"LV",language:"Latvian"},{code:"LT",language:"Lithuanian"},{code:"PL",language:"Polish"},{code:"PT",language:"Portuguese"},{code:"RO",language:"Romanian"},{code:"RU",language:"Russian"},{code:"SK",language:"Slovak"},{code:"SL",language:"Slovenian"},{code:"ES",language:"Spanish"},{code:"SV",language:"Swedish"}];m();function $7(e=h6){return e.reduce((t,n)=>(t[n.code.toLowerCase()]=n.code,t[n.language.toLowerCase()]=n.code,t),{})}function Am(e){return $7()[e.toLowerCase()]}var V7={Accept:"*/*","Accept-Language":"en-US;q=0.8,en;q=0.7","Content-Type":"application/json",Origin:"https://www.deepl.com",Referer:"https://www.deepl.com/translator","Sec-Fetch-Dest":"empty","Sec-Fetch-Mode":"cors","Sec-Fetch-Site":"same-site"};function K7(e){return JSON.stringify(e).replace('"method":"',()=>{let t=e;return(t.id+3)%13===0||(t.id+5)%29===0?'"method" : "':'"method": "'})}function G7(e,t){return{id:1,jsonrpc:"2.0",method:"LMT_handle_texts",params:{timestamp:0,texts:[{text:"",requestAlternatives:3}],splitting:"newlines",lang:{source_lang_user_selected:e,target_lang:t}}}}async function Y7(e,t,n,r,a,o,i){let s=wm(),u=G7(r,n),l=[];t.forEach(p=>{l.push({text:p,requestAlternatives:3})}),u.id=s,u.params.texts=l,u.params.timestamp=Sm(t);let c=await de({retry:2,method:"POST",url:e,body:K7(u),headers:V7}),g={from:c.result.lang,to:n,text:[]};return c.result.texts.forEach(p=>{g.text.push(p.text)}),g}async function b6(e,t,n,r=km,a,o,i){return t?t&&t.length===1&&t[0]===""?{text:[""],from:r,to:n}:Y7(e,t,Am(n),Am(r)??"auto",a,o,i):{text:[],from:r,to:n}}var y6=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Ri=class e extends ke{static langMap=new Map(y6);static langMapReverse=new Map(y6.map(([t,n])=>[n,t]));maxTextGroupLength=3;maxTextLength=800;isSupportList=!0;API_URL=Dm;constructor(t,n,r){super(t,n,r),t&&t.apiUrl&&(this.API_URL=nn(Dm,t.apiUrl))}getDefaultRateLimit(){return{limit:1,interval:1050}}async translateList(t){let{text:n,to:r,from:a}=t,o=await b6(this.API_URL,n,e.langMap.get(r)||r,e.langMap.get(a)||"auto");return{text:o.text,from:e.langMapReverse.get(o.from),to:e.langMapReverse.get(o.to)}}};m();var mu=class e extends ke{static langMap=new Map(xm);clientKey;maxTextGroupLength=25;maxTextLength=1e3;isSupportList=!1;constructor(t,n,r){super(t,n,r),this.clientKey=ra.getClientKey()}async translate(t){let{text:n,to:r}=t,a=await this.detectLanguage(n),o=e.langMap.get(a)||a,i=e.langMap.get(r)||r;if(a===r)return{text:n,from:a,to:r};let s=Pe(),u=t.url;s.INSTALL_FROM==="firefox_store"&&(u=C6());let c=JSON.stringify({header:{fn:"auto_translation_block",client_key:this.clientKey},source:{text_block:n,lang:o,orig_url:u},target:{lang:i}}),g=await de({url:x0,body:c,method:"POST",retry:this.retry,timeout:this.requestTimeout});if(g.header.ret_code!=="succ")throw new J(g.message||g.header.ret_code);return{text:g.auto_translation,from:a||"auto",to:r}}getDefaultRateLimit(){return{limit:30,interval:1050}}async translateList(t){let{from:n,text:r,to:a}=t,o=Pe(),i=t.url;if(o.INSTALL_FROM==="firefox_store"&&(i=C6()),r.length===1){let f=await this.translate({from:n,text:r[0],to:a,url:i,options:t.options});return{text:[f.text],from:f.from,to:f.to}}let u=await this.detectLanguage(r.join(` `));if(u===a)return{text:r,from:u,to:a};let l=e.langMap.get(u)||u,c=e.langMap.get(a)||a,g=JSON.stringify({header:{fn:"auto_translation",client_key:this.clientKey},source:{text_list:r,lang:l,orig_url:i},target:{lang:c},type:"plain"}),p=await de({url:x0,body:g,method:"POST"});if(p.header.ret_code!=="succ")throw new J(p.message||p.header.ret_code);return{text:p.auto_translation,from:u||"auto",to:a}}detectLanguageLocally(t){return this.detectLanguageRemotely(t)}detectLanguageRemotely(t){return ra.detectLanguageRemotelyByTransmart(t)}};function C6(){let e=new Date;return e.setMinutes(e.getMinutes()-e.getMinutes()%5),e.setSeconds(0),e.setMilliseconds(0),`https://google.com/search?q=google&_t=${e.getTime()/1e3}`}m();m();function Lm(){return Math.random()>=.1}var Ii=class extends ke{isSupportList=!1;maxTextLength=1200;maxTextGroupLength=1;async translate(t){let{text:n}=t;if(!Lm())throw new J("404","\u6A21\u62DF\u9519\u8BEF");let r=n.match(/^\s*/)[0].length;return{text:n.slice(0,r)+"\u6A21\u62DF\uFF1A"+n.slice(r,-6),from:t.from,to:t.to}}async translateList(t){let{text:n,from:r,to:a}=t;if(await Z9(),!Lm())throw new J("404","\u6A21\u62DF\u9519\u8BEF");return n.length===0?{from:r,to:a,text:[""]}:{from:r,to:a,text:n.map(o=>{let i=o.match(/^\s*/)[0].length;return o.slice(0,i)+"\u6A21\u62DF\uFF1A"+o.slice(i,-6)})}}};m();var v6=[["auto","auto"],["zh-CN","zh"],["zh-TW","zh"],["en","en"],["ja","ja"],["de","de"],["fr","fr"],["it","it"],["es","es"],["nl","nl"],["pl","pl"],["pt","pt"],["ru","ru"]],_m=new Map(v6),T6=new Map(v6.map(([e,t])=>[t,e])),Mm=class e extends ke{static langMap=_m;static DEFAULT_CODENAME="deepl";apikey="";codename=e.DEFAULT_CODENAME;isSupportList=!1;maxTextGroupLength=1;constructor(t,n,r){if(super(t,n,r),!t||!t.apikey)throw new J("apikey are required");this.apikey=t.apikey?.trim(),t.codename&&(this.codename=t.codename)}async translate(t){let{text:n,from:r,to:a}=t,o=await de({retry:this.retry,url:`https://api.openl.club/services/${this.codename}/translate`,headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify({apikey:this.apikey,text:n,source_lang:_m.get(r)||"auto",target_lang:_m.get(a)||a}),timeout:this.requestTimeout});if(o.status){let i=o;return i.result&&a=="zh-TW",{text:i.result,from:T6.get(i.source_lang),to:T6.get(i.target_lang)}}else throw new J(o.msg)}},F0=Mm;m();var x6=[["auto",""],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH"],["ar","AR"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["pt-br","PT-BR"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],pu=new Map(x6),J7=new Map(x6.map(([e,t])=>[t,e])),Pm=class extends ke{static langMap=pu;authKey="";maxTextLength=1800;freeApiUrl="https://api-free.deepl.com/v2/translate";proApiUrl="https://api.deepl.com/v2/translate";immersiveTranslateApiUrl="https://deepl.immersivetranslate.com/v2/translate";immersiveTranslateDeeplTokenUrl="https://api.immersivetranslate.com";immersiveTranslateDeeplProApiUrl=gn()||Jn()?"https://api2.immersivetranslate.com/deepl/translate":"https://test-api2.immersivetranslate.com/deepl/translate";provider="custom";splitor="";qualityNoSymabol="";qualityMinTextLength;apiKeys=[];static async clearState(){}getRandomKey(){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}constructor(t,n,r){if(super(t,n,r),t=t||{},this.splitor=t.qualityDelimiterBetaV3||"",this.qualityNoSymabol=t.qualityNoSymoblBetaV3||"",this.qualityMinTextLength=t.qualityMinTextLengthV3||0,t.provider==="pro")if(this.provider="pro",r.userToken){if(!r.isPro)throw new J("Please activate Pro membership first, \u8BF7\u5148\u5F00\u901A Pro \u4F1A\u5458\u3002");this.authKey=r.userToken,this.apiKeys=this.authKey.split(",").map(a=>a.trim())}else throw new J("Login required, \u767B\u5F55\u540E\u624D\u53EF\u4EE5\u4F7F\u7528\u3002");else if(this.authKey=t.authKey?.trim(),this.apiKeys=this.authKey.split(",").map(a=>a.trim()),!this.authKey)throw new J("authKey are required");if(!this.authKey)throw new J("authKey are required");t&&t.freeApiUrl&&(this.freeApiUrl=nn(this.freeApiUrl,t.freeApiUrl)),t&&t.proApiUrl&&(this.proApiUrl=nn(this.proApiUrl,t.proApiUrl)),t&&t.immersiveTranslateApiUrl&&(this.immersiveTranslateApiUrl=nn(this.immersiveTranslateApiUrl,t.immersiveTranslateApiUrl)),t&&t.immersiveTranslateDeeplTokenUrl&&(this.immersiveTranslateDeeplTokenUrl=nn(this.immersiveTranslateDeeplTokenUrl,t.immersiveTranslateDeeplTokenUrl)),t&&t.immersiveTranslateDeeplProApiUrl&&(this.immersiveTranslateDeeplProApiUrl=nn(this.immersiveTranslateDeeplProApiUrl,t.immersiveTranslateDeeplProApiUrl))}async init(){}getRateLimiter(){let t=super.getRateLimiter();if(this.provider==="pro"){if(this.serviceConfig?.immersiveTranslateProLimit){let n=Number(this.serviceConfig.immersiveTranslateProLimit);return isNaN(n)&&(n=15),{limit:n,interval:t?.interval||1050}}return{limit:15,interval:t?.interval||1050}}return super.getRateLimiter()}getDefaultRateLimit(){return{limit:3,interval:1250}}async translateList(t){let{from:n,to:r}=t,a=this.getRandomKey(),{text:o,merged:i}=this.optimizationText(t),s={source_lang:pu.get(n)||"",target_lang:pu.get(r)||r,tag_handling:"html"};this.serviceConfig?.tag_handling&&(this.serviceConfig.tag_handling==="none"?delete s.tag_handling:s.tag_handling=this.serviceConfig.tag_handling);let u=new URLSearchParams(s);o.forEach(C=>{u.append("text",C)});let l=u.toString(),c={text:o,source_lang:pu.get(n)||"auto",target_lang:pu.get(r)||r},g=this.freeApiUrl;a.endsWith(":im")?g=this.immersiveTranslateApiUrl:a.endsWith(":fx")||(g=this.proApiUrl);let p,f={};t.refresh&&(f={"X-Refresh":"True"}),t.debug&&(f={...f,"X-Debug":"True"}),this.provider==="pro"?p=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...f,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):a.startsWith("immersive_")?p=await de({retry:this.retry,url:this.immersiveTranslateDeeplProApiUrl,method:"POST",body:JSON.stringify(c),headers:{...f,token:a,"Content-Type":"application/json"},timeout:this.requestTimeout}):p=await de({retry:2,url:g,method:"POST",body:l,headers:{Authorization:"DeepL-Auth-Key "+a,"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},extra:{overrideMimeType:"application/json; charset=utf-8"}});let{translations:h}=this.restoreText(p,i,!!t.debug),y=h.map(C=>C.text);if(r==="zh-TW"){let C=this.serviceConfig||{};C&&C.googleApiUrl&&(C.apiUrl=C.googleApiUrl);let x=await new Po(this.serviceConfig,this.generalConfig,this.translationOptions).translate({from:"zh-CN",to:"zh-TW",text:h.map(S=>S.text).join(`