Deploying to gh-pages from @ fishjar/kiss-translator@2650e5cf7c 🚀

This commit is contained in:
fishjar
2025-11-22 13:21:39 +00:00
parent 61cdd92214
commit 73ba693d31
9 changed files with 144 additions and 433 deletions

View File

@@ -55599,7 +55599,7 @@ const Alert = /*#__PURE__*/react.forwardRef(function Alert(inProps, ref) {
false ? 0 : void 0;
/* harmony default export */ const Alert_Alert = (Alert);
;// CONCATENATED MODULE: ./src/config/app.js
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.11".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
const APP_NAME="KISS Translator".trim().split(/\s+/).join("-");const APP_LCNAME=APP_NAME.toLowerCase();const APP_UPNAME=APP_NAME.toUpperCase();const APP_CONSTS={fabID:"".concat(APP_LCNAME,"-fab"),boxID:"".concat(APP_LCNAME,"-box"),popupID:"".concat(APP_LCNAME,"-popup")};const APP_VERSION="2.0.12".split(".");const THEME_LIGHT="light";const THEME_DARK="dark";
;// CONCATENATED MODULE: ./src/config/api.js
const DEFAULT_HTTP_TIMEOUT=10000;// 调用超时时间
const DEFAULT_FETCH_LIMIT=10;// 默认最大任务数量
@@ -55706,9 +55706,7 @@ const OPT_STYLE_COLORFUL="colorful";// 多彩
const OPT_STYLE_ALL=[OPT_STYLE_NONE,OPT_STYLE_LINE,OPT_STYLE_DOTLINE,OPT_STYLE_DASHLINE,OPT_STYLE_DASHLINE_BOLD,OPT_STYLE_WAVYLINE,OPT_STYLE_WAVYLINE_BOLD,OPT_STYLE_DASHBOX,OPT_STYLE_DASHBOX_BOLD,OPT_STYLE_MARKER,OPT_STYLE_GRADIENT_MARKER,OPT_STYLE_FUZZY,OPT_STYLE_HIGHLIGHT,OPT_STYLE_BLOCKQUOTE,OPT_STYLE_GRADIENT,OPT_STYLE_BLINK,OPT_STYLE_GLOW,OPT_STYLE_COLORFUL];const DEFAULT_CUSTOM_STYLES=[{styleSlug:"custom",styleName:"Custom Style",styleCode:"color: #209CEE;"}];
;// CONCATENATED MODULE: ./src/config/rules.js
const rules_GLOBAL_KEY="*";const REMAIN_KEY="-";const SHADOW_KEY=">>>";const DEFAULT_COLOR="#209CEE";// 默认高亮背景色/线条颜色
const DEFAULT_TRANS_TAG="font";// export const DEFAULT_SELECT_STYLE =
// "-webkit-line-clamp: unset; max-height: none; height: auto;";
const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
const DEFAULT_TRANS_TAG="font";const DEFAULT_SELECT_STYLE="-webkit-line-clamp: unset; max-height: none; height: auto;";const OPT_TIMING_PAGESCROLL="mk_pagescroll";// 滚动加载翻译
const OPT_TIMING_PAGEOPEN="mk_pageopen";// 直接翻译到底
const OPT_TIMING_MOUSEOVER="mk_mouseover";const OPT_TIMING_CONTROL="mk_ctrlKey";const OPT_TIMING_SHIFT="mk_shiftKey";const OPT_TIMING_ALT="mk_altKey";const OPT_TIMING_ALL=[OPT_TIMING_PAGESCROLL,OPT_TIMING_PAGEOPEN,OPT_TIMING_MOUSEOVER,OPT_TIMING_CONTROL,OPT_TIMING_SHIFT,OPT_TIMING_ALT];const OPT_SPLIT_PARAGRAPH_DISABLE="split_disable";const OPT_SPLIT_PARAGRAPH_TEXTLENGTH="split_textlength";const OPT_SPLIT_PARAGRAPH_PUNCTUATION="split_punctuation";const OPT_SPLIT_PARAGRAPH_ALL=[OPT_SPLIT_PARAGRAPH_DISABLE,OPT_SPLIT_PARAGRAPH_PUNCTUATION,OPT_SPLIT_PARAGRAPH_TEXTLENGTH];const OPT_HIGHLIGHT_WORDS_DISABLE="highlight_disable";const OPT_HIGHLIGHT_WORDS_BEFORETRANS="highlight_beforetrans";const OPT_HIGHLIGHT_WORDS_AFTERTRANS="highlight_aftertrans";const OPT_HIGHLIGHT_WORDS_ALL=[OPT_HIGHLIGHT_WORDS_DISABLE,OPT_HIGHLIGHT_WORDS_BEFORETRANS,OPT_HIGHLIGHT_WORDS_AFTERTRANS];const DEFAULT_SELECTOR="h1, h2, h3, h4, h5, h6, li, p, dd, blockquote, figcaption, label, legend";const DEFAULT_IGNORE_SELECTOR="button, footer, pre, mark, nav";const DEFAULT_KEEP_SELECTOR="code, cite, math, .math, a:has(code)";const rules_DEFAULT_RULE={pattern:"",// 匹配网址
selector:"",// 选择器
@@ -55766,7 +55764,7 @@ transOpen:"false",// 开启翻译
textExtStyle:"",// 译文附加样式
termsStyle:"font-weight: bold;",// 专业术语样式
highlightStyle:"color: red;",// 高亮词汇样式
selectStyle:"",// 选择器节点样式
selectStyle:DEFAULT_SELECT_STYLE,// 选择器节点样式
parentStyle:"",// 选择器父节点样式
grandStyle:"",// 选择器祖节点样式
injectJs:"",// 注入JS
@@ -55946,7 +55944,19 @@ const client_client="userscript";const client_isExt=CLIENT_EXTS.includes(client_
* 浏览器兼容插件另可用于判断是插件模式还是网页模式方便开发
* @returns
*/function _browser(){try{return __webpack_require__(2465);}catch(err){// kissLog("browser", err);
}}const browser_browser=_browser();const browser_isBg=()=>(globalThis===null||globalThis===void 0?void 0:globalThis.ContextType)==="BACKGROUND";const isBuiltinAIAvailable="LanguageDetector"in globalThis&&"Translator"in globalThis;
}}const browser_browser=_browser();const getContext=()=>{const context=globalThis.__KISS_CONTEXT__;if(context)return context;// if (typeof window === "undefined" || typeof document === "undefined") {
// return "background";
// }
// const extensionOrigin = browser.runtime.getURL("");
// if (!window.location.href.startsWith(extensionOrigin)) {
// return "content";
// }
// const pathname = window.location.pathname;
// if (pathname.includes("popup")) return "popup";
// if (pathname.includes("options")) return "options";
// if (pathname.includes("sidepanel")) return "sidepanel";
// if (pathname.includes("background")) return "background";
return"undefined";};const browser_isBg=()=>getContext()==="background";const isOptions=()=>getContext()==="options";const isBuiltinAIAvailable="LanguageDetector"in globalThis&&"Translator"in globalThis;
;// CONCATENATED MODULE: ./src/libs/utils.js
/**
* 限制数字大小
@@ -56698,7 +56708,7 @@ _classPrivateFieldBase(this,_scheduleNext)[_scheduleNext]();},_classPrivateField
;// CONCATENATED MODULE: ./src/libs/cache.js
/**
* 清除缓存数据
*/const tryClearCaches=async()=>{try{if(isExt&&!isBg){await sendBgMsg(MSG_CLEAR_CACHES);}else{await caches.delete(CACHE_NAME);}}catch(err){kissLog("clean caches",err);}};/**
*/const tryClearCaches=async()=>{try{if(isExt&&!isBg()){await sendBgMsg(MSG_CLEAR_CACHES);}else{await caches.delete(CACHE_NAME);}}catch(err){kissLog("clean caches",err);}};/**
* 构造缓存 request
* @param {*} input
* @param {*} init
@@ -56708,7 +56718,7 @@ _classPrivateFieldBase(this,_scheduleNext)[_scheduleNext]();},_classPrivateField
* @param {*} input
* @param {*} init
* @returns
*/const getHttpCache=async _ref=>{let{input,init}=_ref;try{const request=await newCacheReq(input,init);const cache=await caches.open(storage_CACHE_NAME);const response=await cache.match(request);if(response){const res=await parseResponse(response);return res;}}catch(err){log_kissLog("get cache",err);}return null;};/**
*/const getHttpCache=async _ref=>{let{input,init,expect}=_ref;try{const request=await newCacheReq(input,init);const cache=await caches.open(storage_CACHE_NAME);const response=await cache.match(request);if(response){const res=await parseResponse(response,expect);return res;}}catch(err){log_kissLog("get cache",err);}return null;};/**
* 插入 caches
* @param {*} input
* @param {*} init
@@ -56719,7 +56729,7 @@ await cache.put(req,res);}catch(err){log_kissLog("put cache",err);}};/**
* 解析 response
* @param {*} res
* @returns
*/const parseResponse=async res=>{if(!res){throw new Error("Response object does not exist");}if(!res.ok){var _res$headers$get;const msg={url:res.url,status:res.status};if((_res$headers$get=res.headers.get("Content-Type"))!==null&&_res$headers$get!==void 0&&_res$headers$get.includes("json")){msg.response=await res.json();}throw new Error(JSON.stringify(msg));}const contentType=res.headers.get("Content-Type");if(contentType!==null&&contentType!==void 0&&contentType.includes("json")){return res.json();}else if(contentType!==null&&contentType!==void 0&&contentType.includes("audio")){const blob=await res.blob();return blobToBase64(blob);}return res.text();};/**
*/const parseResponse=async function(res){let expect=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(!res){throw new Error("Response object does not exist");}if(!res.ok){const msg={url:res.url,status:res.status,statusText:res.statusText};try{const errorText=await res.clone().text();try{msg.response=JSON.parse(errorText);}catch(_unused){msg.response=errorText;}}catch(e){msg.response="Unable to read error body";}throw new Error(JSON.stringify(msg));}const contentType=res.headers.get("Content-Type")||"";if(expect==="blob")return res.blob();if(expect==="text")return res.text();if(expect==="json")return res.json();if(expect==="audio"||contentType.includes("audio")||contentType.includes("image")||contentType.includes("video")){const blob=await res.blob();return blobToBase64(blob);}const text=await res.text();if(!text)return null;try{return JSON.parse(text);}catch(err){return text;}};/**
* getHttpCache 兼容性封装
* @param {*} input
* @param {*} init
@@ -56753,7 +56763,7 @@ Object.assign(init,{timeout});const{body,headers,status,statusText}=window.KISS_
* 处理请求
* @param {*} param0
* @returns
*/const fetchHandle=async _ref2=>{let{input,init,opts}=_ref2;const res=await fetchPatcher(input,init,opts);return parseResponse(res);};/**
*/const fetchHandle=async _ref2=>{let{input,init,opts}=_ref2;const res=await fetchPatcher(input,init,opts);return parseResponse(res,opts.expect);};/**
* fetch 兼容性封装
* @param {*} args
* @returns
@@ -56824,14 +56834,14 @@ stream:false};const headers={"Content-type":"application/json"};if(key){headers.
*/const genTransReq=async _ref21=>{let{reqHook}=_ref21,args=_objectWithoutProperties(_ref21,trans_excluded);const{apiType,apiSlug,key,systemPrompt,// userPrompt,
nobatchPrompt=defaultNobatchPrompt,nobatchUserPrompt=defaultNobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,glossary,customHeader,customBody,events,tone}=args;if(API_SPE_TYPES.mulkeys.has(apiType)){args.key=keyPick(apiSlug,key,keyMap);}if(apiType===OPT_TRANS_DEEPLX){args.url=keyPick(apiSlug,args.url,urlMap);}if(API_SPE_TYPES.ai.has(apiType)){args.systemPrompt=events?systemPrompt:genSystemPrompt({systemPrompt:useBatchFetch?systemPrompt:nobatchPrompt,from,to,fromLang,toLang,texts,docInfo,tone});args.userPrompt=events?JSON.stringify(events):genUserPrompt({nobatchUserPrompt,useBatchFetch,from,to,fromLang,toLang,texts,docInfo,tone,glossary});}const{url="",body=null,headers={},userMsg=null,method="POST"}=genReqFuncs[apiType](args);// 合并用户自定义headers和body
if(customHeader!==null&&customHeader!==void 0&&customHeader.trim()){Object.assign(headers,parseJsonObj(customHeader));}if(customBody!==null&&customBody!==void 0&&customBody.trim()){Object.assign(body,parseJsonObj(customBody));}// 执行 request hook
if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()&&!events){try{interpreter.run("exports.reqHook = ".concat(reqHook));const hookResult=await interpreter.exports.reqHook(_objectSpread2(_objectSpread2({},args),{},{defaultSystemPrompt: defaultSystemPrompt,defaultSubtitlePrompt: defaultSubtitlePrompt,defaultNobatchPrompt: defaultNobatchPrompt,defaultNobatchUserPrompt: defaultNobatchUserPrompt}),{url,body,headers,userMsg,method});if(hookResult&&hookResult.url){return genInit(hookResult);}}catch(err){log_kissLog("run req hook",err);}}return genInit({url,body,headers,userMsg,method});};/**
if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()&&!events){try{const req={url,body,headers,userMsg,method};interpreter.run("exports.reqHook = ".concat(reqHook));const hookResult=await interpreter.exports.reqHook(_objectSpread2(_objectSpread2({},args),{},{defaultSystemPrompt: defaultSystemPrompt,defaultSubtitlePrompt: defaultSubtitlePrompt,defaultNobatchPrompt: defaultNobatchPrompt,defaultNobatchUserPrompt: defaultNobatchUserPrompt,req}),req);if(hookResult&&hookResult.url){return genInit(hookResult);}}catch(err){log_kissLog("run req hook",err);throw new Error("Request hook error: ".concat(err.message));}}return genInit({url,body,headers,userMsg,method});};/**
* 解析翻译接口返回数据
* @param {*} res
* @param {*} param3
* @returns
*/const parseTransRes=async(res,_ref22)=>{var _res$sentences,_res$,_res$translations,_res$result,_res$result$texts,_res$result2,_res$auto_translation,_res$choices,_res$choices$,_modelMsg,_res$candidates,_res$candidates$,_modelMsg$parts$0$tex,_modelMsg2,_modelMsg2$parts,_modelMsg2$parts$,_res$content,_res$content$0$text,_res$content2,_res$content2$,_res$result3,_res$choices2,_res$choices2$,_modelMsg3;let{texts,from,to,fromLang,toLang,langMap,resHook,// thinkIgnore,
history,userMsg,apiType,useBatchFetch}=_ref22;// 执行 response hook
if(resHook!==null&&resHook!==void 0&&resHook.trim()){try{interpreter.run("exports.resHook = ".concat(resHook));const hookResult=await interpreter.exports.resHook({apiType,userMsg,res,texts,from,to,fromLang,toLang,langMap,extractJson: extractJson,parseAIRes});if(hookResult&&Array.isArray(hookResult.translations)){if(history&&userMsg&&hookResult.modelMsg){history.add(userMsg,hookResult.modelMsg);}return hookResult.translations;}else if(Array.isArray(hookResult)){return hookResult;}}catch(err){log_kissLog("run res hook",err);}}let modelMsg="";// todo: 根据结果抛出实际异常信息
if(resHook!==null&&resHook!==void 0&&resHook.trim()){try{interpreter.run("exports.resHook = ".concat(resHook));const hookResult=await interpreter.exports.resHook({apiType,userMsg,res,texts,from,to,fromLang,toLang,langMap,extractJson: extractJson,parseAIRes});if(hookResult&&Array.isArray(hookResult.translations)){if(history&&userMsg&&hookResult.modelMsg){history.add(userMsg,hookResult.modelMsg);}return hookResult.translations;}else if(Array.isArray(hookResult)){return hookResult;}}catch(err){log_kissLog("run res hook",err);throw new Error("Response hook error: ".concat(err.message));}}let modelMsg="";// todo: 根据结果抛出实际异常信息
switch(apiType){case OPT_TRANS_GOOGLE:return[[res===null||res===void 0?void 0:(_res$sentences=res.sentences)===null||_res$sentences===void 0?void 0:_res$sentences.map(item=>item.trans).join(" "),res===null||res===void 0?void 0:res.src]];case OPT_TRANS_GOOGLE_2:return res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$.map((_,i)=>{var _res$2,_res$3;return[res===null||res===void 0?void 0:(_res$2=res[0])===null||_res$2===void 0?void 0:_res$2[i],res===null||res===void 0?void 0:(_res$3=res[1])===null||_res$3===void 0?void 0:_res$3[i]];});case OPT_TRANS_MICROSOFT:case OPT_TRANS_AZUREAI:return res===null||res===void 0?void 0:res.map(item=>{var _item$detectedLanguag;return[item.translations.map(item=>item.text).join(" "),(_item$detectedLanguag=item.detectedLanguage)===null||_item$detectedLanguag===void 0?void 0:_item$detectedLanguag.language];});case OPT_TRANS_DEEPL:return res===null||res===void 0?void 0:(_res$translations=res.translations)===null||_res$translations===void 0?void 0:_res$translations.map(item=>[item.text,item.detected_source_language]);case OPT_TRANS_DEEPLFREE:return[[res===null||res===void 0?void 0:(_res$result=res.result)===null||_res$result===void 0?void 0:(_res$result$texts=_res$result.texts)===null||_res$result$texts===void 0?void 0:_res$result$texts.map(item=>item.text).join(" "),res===null||res===void 0?void 0:(_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang]];case OPT_TRANS_DEEPLX:return[[res===null||res===void 0?void 0:res.data,res===null||res===void 0?void 0:res.source_lang]];case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}return[[json.tgt_text,json.from]];case OPT_TRANS_BAIDU:if(res.type===1){return[[Object.keys(JSON.parse(res.result).content[0].mean[0].cont)[0],res.from]];}else if(res.type===2){return[[res.data.map(item=>item.dst).join(" "),res.from]];}break;case OPT_TRANS_TENCENT:return res===null||res===void 0?void 0:(_res$auto_translation=res.auto_translation)===null||_res$auto_translation===void 0?void 0:_res$auto_translation.map(text=>[text,res===null||res===void 0?void 0:res.src_lang]);case OPT_TRANS_VOLCENGINE:return[[res===null||res===void 0?void 0:res.translation,res===null||res===void 0?void 0:res.detected_language]];case api_OPT_TRANS_OPENAI:case api_OPT_TRANS_GEMINI_2:case api_OPT_TRANS_OPENROUTER:modelMsg=res===null||res===void 0?void 0:(_res$choices=res.choices)===null||_res$choices===void 0?void 0:(_res$choices$=_res$choices[0])===null||_res$choices$===void 0?void 0:_res$choices$.message;if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_modelMsg=modelMsg)===null||_modelMsg===void 0?void 0:_modelMsg.content,useBatchFetch);case api_OPT_TRANS_GEMINI:modelMsg=res===null||res===void 0?void 0:(_res$candidates=res.candidates)===null||_res$candidates===void 0?void 0:(_res$candidates$=_res$candidates[0])===null||_res$candidates$===void 0?void 0:_res$candidates$.content;if(history&&userMsg&&modelMsg){history.add(userMsg,modelMsg);}return parseAIRes((_modelMsg$parts$0$tex=(_modelMsg2=modelMsg)===null||_modelMsg2===void 0?void 0:(_modelMsg2$parts=_modelMsg2.parts)===null||_modelMsg2$parts===void 0?void 0:(_modelMsg2$parts$=_modelMsg2$parts[0])===null||_modelMsg2$parts$===void 0?void 0:_modelMsg2$parts$.text)!==null&&_modelMsg$parts$0$tex!==void 0?_modelMsg$parts$0$tex:"",useBatchFetch);case api_OPT_TRANS_CLAUDE:modelMsg={role:res===null||res===void 0?void 0:res.role,content:res===null||res===void 0?void 0:(_res$content=res.content)===null||_res$content===void 0?void 0:_res$content.text};if(history&&userMsg&&modelMsg){history.add(userMsg,{role:modelMsg.role,content:modelMsg.content});}return parseAIRes((_res$content$0$text=res===null||res===void 0?void 0:(_res$content2=res.content)===null||_res$content2===void 0?void 0:(_res$content2$=_res$content2[0])===null||_res$content2$===void 0?void 0:_res$content2$.text)!==null&&_res$content$0$text!==void 0?_res$content$0$text:"",useBatchFetch);case OPT_TRANS_CLOUDFLAREAI:return[[res===null||res===void 0?void 0:(_res$result3=res.result)===null||_res$result3===void 0?void 0:_res$result3.translated_text]];case api_OPT_TRANS_OLLAMA:modelMsg=res===null||res===void 0?void 0:(_res$choices2=res.choices)===null||_res$choices2===void 0?void 0:(_res$choices2$=_res$choices2[0])===null||_res$choices2$===void 0?void 0:_res$choices2$.message;// const deepModels = thinkIgnore
// .split(",")
// .filter((model) => model?.trim());
@@ -56916,7 +56926,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, *
* @param {*} lan
* @param {*} spd
* @returns
*/const apis_apiBaiduTTS=function(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const input="https://fanyi.baidu.com/gettts?".concat(queryString.stringify({lan,text,spd}));return fetchData(input);};/**
*/const apiBaiduTTS=function(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const input="https://fanyi.baidu.com/gettts?".concat(queryString.stringify({lan,text,spd}));return fetchData(input);};/**
* 腾讯语言识别
* @param {*} text
* @returns
@@ -56933,7 +56943,7 @@ keyfrom:"webdict"});const init={headers:{accept:"application/json, text/plain, *
* @param {*} param0
* @returns
*/const apiTranslate=async _ref2=>{let{text,fromLang="auto",toLang,apiSetting=DEFAULT_API_SETTING,docInfo={},glossary,useCache=true,usePool=true}=_ref2;if(!text){throw new Error("The text cannot be empty.");}const{apiType,apiSlug,useBatchFetch}=apiSetting;const langMap=OPT_LANGS_TO_SPEC[apiType]||OPT_LANGS_SPEC_DEFAULT;const from=langMap.get(fromLang);const to=langMap.get(toLang);if(!to){throw new Error("The target lang: ".concat(toLang," not support"));}// todo: 优化缓存失效因素
const[v1,v2]="2.0.11".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据
const[v1,v2]="2.0.12".split(".");const cacheOpts={apiSlug,text,fromLang,toLang,version:[v1,v2].join(".")};const cacheInput="".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts));// 查询缓存数据
if(useCache){const cache=await cache_getHttpCachePolyfill(cacheInput);if(cache!==null&&cache!==void 0&&cache.trText){return cache;}}// 请求接口数据
let tranlation=[];if(apiType===OPT_TRANS_BUILTINAI){tranlation=await apiBuiltinAITranslate({text,from,to,apiSetting});}else if(useBatchFetch&&API_SPE_TYPES.batch.has(apiType)){const{apiSlug,batchInterval,batchSize,batchLength}=apiSetting;const key="".concat(apiSlug,"_").concat(fromLang,"_").concat(toLang);const queue=getBatchQueue(key,handleTranslate,{batchInterval,batchSize,batchLength});tranlation=await queue.addTask(text,{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}else{[tranlation]=await handleTranslate([text],{from,to,fromLang,toLang,langMap,docInfo,glossary,apiSetting,usePool});}let trText="";let srLang="";let srCode="";if(Array.isArray(tranlation)){[trText,srLang=""]=tranlation;if(srLang){srCode=OPT_LANGS_TO_CODE[apiType].get(srLang)||"";}}else if(typeof tranlation==="string"){trText=tranlation;}if(!trText){throw new Error("tanslate api got empty trtext");}const isSame=fromLang==="auto"&&srLang===to;// 插入缓存
if(useCache){cache_putHttpCachePolyfill(cacheInput,null,{trText,isSame,srLang,srCode});}return{trText,srLang,srCode,isSame};};// 字幕处理/翻译
@@ -59750,7 +59760,7 @@ var n = {};
return t.length === e && "." !== t && ".." !== t;
};
},
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.11","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"2.0.12","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules_v2.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on_v2.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off_v2.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
It.sep = "win32" === te ? "\\" : "/";
var ee = Symbol("globstar **");
It.GLOBSTAR = ee;
@@ -61567,7 +61577,7 @@ function useDebouncedCallback(callback,delay){const callbackRef=(0,react.useRef)
(0,react.useEffect)(()=>{let isMounted=true;const loadInitialData=async()=>{try{const storedVal=await storage.getObj(key);if(storedVal===undefined||storedVal===null){await storage.setObj(key,defaultVal);}else if(isMounted){setData(storedVal);}}catch(err){log_kissLog("storage load error for key: ".concat(key),err);}finally{if(isMounted){setIsLoading(false);}}};loadInitialData();return()=>{isMounted=false;};},[key,defaultVal]);// 远端同步
const runSync=(0,react.useCallback)(async(keyToSync,valueToSync)=>{try{const res=await syncData(keyToSync,valueToSync);if(res!==null&&res!==void 0&&res.isNew){setData(res.value);}}catch(error){log_kissLog("Sync failed",keyToSync);}},[]);const debouncedSync=useDebouncedCallback(runSync,3000);// 持久化
(0,react.useEffect)(()=>{if(isLoading){return;}if(data===null){return;}storage.setObj(key,data).catch(err=>{log_kissLog("storage save error for key: ".concat(key),err);});// 触发远端同步
if(syncKey){debouncedSync(syncKey,data);}},[key,syncKey,isLoading,data,debouncedSync]);/**
if(syncKey&&isOptions()){debouncedSync(syncKey,data);}},[key,syncKey,isLoading,data,debouncedSync]);/**
* 全量替换状态值
* @param {any | ((prevData: any) => any)} valueOrFn 新的值或一个返回新值的函数
*/const save=(0,react.useCallback)(valueOrFn=>{// kissLog("save storage:", valueOrFn);
@@ -62135,9 +62145,9 @@ Divider.muiSkipListHighlight = true;
false ? 0 : void 0;
/* harmony default export */ const Divider_Divider = (Divider);
;// CONCATENATED MODULE: ./src/hooks/Loading.js
function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});}
function Loading(){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})]});}
;// CONCATENATED MODULE: ./src/hooks/Setting.js
const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,isSettingPage}=_ref;const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,isSettingPage?KV_SETTING_KEY:"");(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isSettingPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(client_isExt){await msg_sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isSettingPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({setting,updateSetting,updateChild,reloadSetting:reload}),[setting,updateSetting,updateChild,reload]);if(isLoading){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}if(!setting){/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/**
const SettingContext=/*#__PURE__*/(0,react.createContext)({setting:setting_DEFAULT_SETTING,updateSetting:()=>{},reloadSetting:()=>{}});function SettingProvider(_ref){let{children,context}=_ref;const isOptionsPage=(0,react.useMemo)(()=>context==="options",[context]);const{data:setting,isLoading,update,reload}=useStorage(storage_STOKEY_SETTING,setting_DEFAULT_SETTING,KV_SETTING_KEY);(0,react.useEffect)(()=>{if(typeof(setting===null||setting===void 0?void 0:setting.darkMode)==="boolean"){update(currentSetting=>_objectSpread2(_objectSpread2({},currentSetting),{},{darkMode:currentSetting.darkMode?"dark":"light"}));}},[setting===null||setting===void 0?void 0:setting.darkMode,update]);(0,react.useEffect)(()=>{if(!isOptionsPage)return;(async()=>{try{logger.setLevel(setting===null||setting===void 0?void 0:setting.logLevel);if(client_isExt){await msg_sendBgMsg(MSG_SET_LOGLEVEL,setting===null||setting===void 0?void 0:setting.logLevel);}}catch(error){logger.error("Failed to fetch log level, using default.",error);}})();},[isOptionsPage,setting===null||setting===void 0?void 0:setting.logLevel]);const updateSetting=(0,react.useCallback)(objOrFn=>{update(objOrFn);debounceSyncMeta(KV_SETTING_KEY);},[update]);const updateChild=(0,react.useCallback)(key=>async obj=>{updateSetting(prev=>_objectSpread2(_objectSpread2({},prev),{},{[key]:_objectSpread2(_objectSpread2({},(prev===null||prev===void 0?void 0:prev[key])||{}),obj)}));},[updateSetting]);const value=(0,react.useMemo)(()=>({context,setting,updateSetting,updateChild,reloadSetting:reload}),[context,setting,updateSetting,updateChild,reload]);if(isLoading){return isOptionsPage?/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{}):null;}if(!setting){return isOptionsPage?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Alert_Alert,{severity:"error",sx:{maxWidth:600,margin:"60px auto"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"\u6570\u636E\u52A0\u8F7D\u51FA\u9519\uFF0C\u8BF7\u5237\u65B0\u9875\u9762\u6216\u5378\u8F7D\u540E\u91CD\u65B0\u5B89\u88C5\u3002"}),/*#__PURE__*/(0,jsx_runtime.jsx)("p",{children:"Data loading error, please refresh the page or uninstall and reinstall."})]})}):null;}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingContext.Provider,{value:value,children:children});}/**
* 设置 hook
* @returns
*/function useSetting(){return (0,react.useContext)(SettingContext);}
@@ -75209,9 +75219,12 @@ onKeyUp(new Set(pressedKeys),e);pressedKeys.delete(e.code);};const handleBlur=()
* @param {() => void} fn - 匹配成功后执行的回调
* @param {EventTarget} target - 监听目标
* @returns {() => void} - 注销函数
*/const shortcutRegister=function(){let targetKeys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];let fn=arguments.length>1?arguments[1]:undefined;let target=arguments.length>2&&arguments[2]!==undefined?arguments[2]:document;if(targetKeys.length===0)return()=>{};const targetKeySet=new Set(targetKeys);const onKeyDown=(pressedKeys,event)=>{if(isSameSet(targetKeySet,pressedKeys)){// event.preventDefault(); // 阻止浏览器的默认行为
// event.stopPropagation(); // 阻止事件继续(向父元素)冒泡
fn();}};const onKeyUp=()=>{};return shortcutListener(onKeyDown,onKeyUp,target);};/**
*/const shortcutRegister=function(){let targetKeys=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];let fn=arguments.length>1?arguments[1]:undefined;let target=arguments.length>2&&arguments[2]!==undefined?arguments[2]:document;if(targetKeys.length===0)return()=>{};const targetKeySet=new Set(targetKeys);let hasInterference=false;const onKeyDown=(pressedKeys,event)=>{// if (isSameSet(targetKeySet, pressedKeys)) {
// // event.preventDefault(); // 阻止浏览器的默认行为
// // event.stopPropagation(); // 阻止事件继续(向父元素)冒泡
// fn();
// }
if(!targetKeySet.has(event.code)){hasInterference=true;}};const onKeyUp=(pressedKeys,event)=>{if(isSameSet(targetKeySet,pressedKeys)&&!hasInterference){fn();}if(pressedKeys.size===1){hasInterference=false;}};return shortcutListener(onKeyDown,onKeyUp,target);};/**
* 高阶函数为目标函数增加计次和超时重置功能
* @param {() => void} fn - 需要被包装的函数
* @param {number} step - 需要触发的次数
@@ -76582,7 +76595,7 @@ var BrightnessAuto = __webpack_require__(4080);
;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js
function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{sx:{ml:1},onClick:toggleDarkMode,color:"inherit",children:darkMode==="dark"?/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{}):darkMode==="light"?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(BrightnessAuto/* default */.Z,{})});}
;// CONCATENATED MODULE: ./src/views/Options/Header.js
function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header);
function Header(props){const i18n=useI18n();const{onDrawerToggle}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppBar_AppBar,{color:"primary",position:"sticky",sx:{zIndex:1300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Toolbar_Toolbar,{variant:"dense",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{sx:{display:{sm:"none",xs:"block"}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"inherit","aria-label":"open drawer",onClick:onDrawerToggle,edge:"start",children:/*#__PURE__*/(0,jsx_runtime.jsx)(icons_material_Menu/* default */.Z,{})})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{flexGrow:1,fontWeight:"bold"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{underline:"none",color:"inherit",href:"https://github.com/fishjar/kiss-translator",target:"_blank",children:"".concat(i18n("app_name")," v").concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]})});}/* harmony default export */ const Options_Header = (Header);
;// CONCATENATED MODULE: ./src/views/Options/Layout.js
function Layout(){const navWidth=256;const location=dist_useLocation();const theme=useTheme_useTheme();const[open,setOpen]=(0,react.useState)(false);const isSm=useMediaQuery(theme.breakpoints.up("sm"));const handleDrawerToggle=()=>{setOpen(!open);};(0,react.useEffect)(()=>{setOpen(false);},[location]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CssBaseline_CssBaseline,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(Options_Header,{onDrawerToggle:handleDrawerToggle}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Box_Box,{sx:{display:"flex"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"nav",sx:{width:{sm:navWidth},flexShrink:{sm:0}},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Navigator,{PaperProps:{style:{width:navWidth}},variant:isSm?"permanent":"temporary",open:isSm?true:open,onClose:handleDrawerToggle})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Box_Box,{component:"main",sx:{flex:1,p:2,width:"100%"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Outlet,{})})]})]});}
// EXTERNAL MODULE: ./node_modules/.pnpm/@mui+icons-material@5.15.15_@mui+material@5.15.15_@emotion+react@11.11.1_@types+react@18.2.79_zdo5tzcazfyjzm354hmuezm3pe/node_modules/@mui/icons-material/ContentCopy.js
@@ -76759,7 +76772,7 @@ mediaQuery.addEventListener("change",handleChange);return()=>mediaQuery.removeEv
const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/**
* 注入页面的脚本请求并接受GM接口信息
* @param {*} param0
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.11",eventName:ping};};/**
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"2.0.12",eventName:ping};};/**
* 适配GM脚本
*/const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/**
* 监听并回应页面对GM接口的请求
@@ -81278,17 +81291,11 @@ var VolumeUp = __webpack_require__(9938);
* 声音播放hook
* @param {*} src
* @returns
*/function useAudio(src){const audioRef=(0,react.useRef)(null);const[error,setError]=(0,react.useState)(null);const[ready,setReady]=(0,react.useState)(false);const[playing,setPlaying]=(0,react.useState)(false);const onPlay=(0,react.useCallback)(()=>{var _audioRef$current;(_audioRef$current=audioRef.current)===null||_audioRef$current===void 0?void 0:_audioRef$current.play();},[]);(0,react.useEffect)(()=>{if(!src){return;}const audio=new Audio(src);audio.addEventListener("error",err=>setError(err));audio.addEventListener("canplaythrough",()=>setReady(true));audio.addEventListener("play",()=>setPlaying(true));audio.addEventListener("ended",()=>setPlaying(false));audioRef.current=audio;},[src]);return{error,ready,playing,onPlay};}/**
* 获取语音hook
* @param {*} text
* @param {*} lan
* @param {*} spd
* @returns
*/function useTextAudio(text){let lan=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"uk";let spd=arguments.length>2&&arguments[2]!==undefined?arguments[2]:3;const[src,setSrc]=useState("");useEffect(()=>{(async()=>{try{setSrc(await apiBaiduTTS(text,lan,spd));}catch(err){kissLog("baidu tts",err);}})();},[text,lan,spd]);return useAudio(src);}
*/function useAudio(src){const audioRef=(0,react.useRef)(null);const[error,setError]=(0,react.useState)(null);const[ready,setReady]=(0,react.useState)(false);const[playing,setPlaying]=(0,react.useState)(false);const[loading,setLoading]=(0,react.useState)(false);const onPlay=(0,react.useCallback)(async()=>{if(!audioRef.current)return;try{await audioRef.current.play();}catch(err){logger.info("Playback failed:",err);setPlaying(false);}},[]);const onPause=(0,react.useCallback)(()=>{var _audioRef$current;(_audioRef$current=audioRef.current)===null||_audioRef$current===void 0?void 0:_audioRef$current.pause();},[]);(0,react.useEffect)(()=>{if(!src)return;let ignore=false;let objectUrl=null;setReady(false);setError(null);setPlaying(false);setLoading(true);const audio=new Audio();audioRef.current=audio;const handleCanPlay=()=>setReady(true);const handlePlay=()=>setPlaying(true);const handlePause=()=>setPlaying(false);const handleEnded=()=>setPlaying(false);const handleError=e=>{if(!ignore){setError(audio.error||e);setReady(false);setLoading(false);}};audio.addEventListener("canplaythrough",handleCanPlay);audio.addEventListener("play",handlePlay);audio.addEventListener("pause",handlePause);audio.addEventListener("ended",handleEnded);audio.addEventListener("error",handleError);const loadAudio=async()=>{try{const data=await fetch_fetchData(src,{},{expect:"audio"});if(ignore)return;audio.src=data;setLoading(false);}catch(err){if(!ignore){logger.info("Audio fetch failed:",err);setError(err);setLoading(false);}}};loadAudio();return()=>{ignore=true;audio.pause();audio.removeAttribute("src");if(objectUrl){URL.revokeObjectURL(objectUrl);}audio.removeEventListener("canplaythrough",handleCanPlay);audio.removeEventListener("play",handlePlay);audio.removeEventListener("pause",handlePause);audio.removeEventListener("ended",handleEnded);audio.removeEventListener("error",handleError);};},[src]);return{loading,error,ready,playing,onPlay,onPause};}
;// CONCATENATED MODULE: ./src/views/Selection/AudioBtn.js
function AudioBtn(_ref){let{src}=_ref;const{error,ready,playing,onPlay}=useAudio(src);if(error||!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{disabled:true,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}if(playing){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"primary",size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:onPlay,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}
function AudioBtn(_ref){let{src}=_ref;const{error,ready,playing,onPlay}=useAudio(src);if(error||!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{disabled:true,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}if(playing){return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{color:"primary",size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:onPlay,size:"small",children:/*#__PURE__*/(0,jsx_runtime.jsx)(VolumeUp/* default */.Z,{fontSize:"inherit"})});}function BaiduAudioBtn(_ref2){let{text,lan="uk",spd=3}=_ref2;if(!text)return null;const src="https://fanyi.baidu.com/gettts?".concat(query_string.stringify({lan,text,spd}));return/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:src});}
;// CONCATENATED MODULE: ./src/views/Selection/DictHandler.js
const dictHandlers={[OPT_DICT_BING]:{apiFn:apiMicrosoftDict,reWord:data=>data===null||data===void 0?void 0:data.word,toText:data=>{var _data$trs;return(data===null||data===void 0?void 0:(_data$trs=data.trs)===null||_data$trs===void 0?void 0:_data$trs.map(_ref=>{let{pos,def}=_ref;return"".concat(pos?"[".concat(pos,"] "):"").concat(def);}))||[];},uiAudio:data=>{var _data$aus;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",children:data===null||data===void 0?void 0:(_data$aus=data.aus)===null||_data$aus===void 0?void 0:_data$aus.map(_ref2=>{let{key,audio,phonetic}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:phonetic}),/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:audio})]},key);})});},uiTrans:data=>{var _data$trs2;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$trs2=data.trs)===null||_data$trs2===void 0?void 0:_data$trs2.map((_ref3,idx)=>{let{pos,def}=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),def]},idx);})});}},[OPT_DICT_YOUDAO]:{apiFn:apiYoudaoDict,reWord:data=>{var _data$ec,_data$ec$word;return data===null||data===void 0?void 0:(_data$ec=data.ec)===null||_data$ec===void 0?void 0:(_data$ec$word=_data$ec.word)===null||_data$ec$word===void 0?void 0:_data$ec$word["return-phrase"];},toText:data=>{var _data$ec2,_data$ec2$word,_data$ec2$word$trs;return(data===null||data===void 0?void 0:(_data$ec2=data.ec)===null||_data$ec2===void 0?void 0:(_data$ec2$word=_data$ec2.word)===null||_data$ec2$word===void 0?void 0:(_data$ec2$word$trs=_data$ec2$word.trs)===null||_data$ec2$word$trs===void 0?void 0:_data$ec2$word$trs.map(_ref4=>{let{pos,tran}=_ref4;return"".concat(pos?"[".concat(pos,"] "):"").concat(tran);}))||[];},uiAudio:data=>{var _data$ec3,_data$ec3$word,_data$ec4,_data$ec4$word;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"UK [".concat(data===null||data===void 0?void 0:(_data$ec3=data.ec)===null||_data$ec3===void 0?void 0:(_data$ec3$word=_data$ec3.word)===null||_data$ec3$word===void 0?void 0:_data$ec3$word.ukphone,"]")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"US [".concat(data===null||data===void 0?void 0:(_data$ec4=data.ec)===null||_data$ec4===void 0?void 0:(_data$ec4$word=_data$ec4.word)===null||_data$ec4$word===void 0?void 0:_data$ec4$word.usphone,"]")})})]});},uiTrans:data=>{var _data$ec5,_data$ec5$word,_data$ec5$word$trs;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$ec5=data.ec)===null||_data$ec5===void 0?void 0:(_data$ec5$word=_data$ec5.word)===null||_data$ec5$word===void 0?void 0:(_data$ec5$word$trs=_data$ec5$word.trs)===null||_data$ec5$word$trs===void 0?void 0:_data$ec5$word$trs.map((_ref5,idx)=>{let{pos,tran}=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),tran]},idx);})});}}};
const dictHandlers={[OPT_DICT_BING]:{apiFn:apiMicrosoftDict,reWord:data=>data===null||data===void 0?void 0:data.word,toText:data=>{var _data$trs;return(data===null||data===void 0?void 0:(_data$trs=data.trs)===null||_data$trs===void 0?void 0:_data$trs.map(_ref=>{let{pos,def}=_ref;return"".concat(pos?"[".concat(pos,"] "):"").concat(def);}))||[];},uiAudio:data=>{var _data$aus;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",children:data===null||data===void 0?void 0:(_data$aus=data.aus)===null||_data$aus===void 0?void 0:_data$aus.map(_ref2=>{let{key,audio,phonetic}=_ref2;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:phonetic}),/*#__PURE__*/(0,jsx_runtime.jsx)(AudioBtn,{src:audio})]},key);})});},uiTrans:data=>{var _data$trs2;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$trs2=data.trs)===null||_data$trs2===void 0?void 0:_data$trs2.map((_ref3,idx)=>{let{pos,def}=_ref3;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),def]},idx);})});}},[OPT_DICT_YOUDAO]:{apiFn:apiYoudaoDict,reWord:data=>{var _data$ec,_data$ec$word;return data===null||data===void 0?void 0:(_data$ec=data.ec)===null||_data$ec===void 0?void 0:(_data$ec$word=_data$ec.word)===null||_data$ec$word===void 0?void 0:_data$ec$word["return-phrase"];},toText:data=>{var _data$ec2,_data$ec2$word,_data$ec2$word$trs;return(data===null||data===void 0?void 0:(_data$ec2=data.ec)===null||_data$ec2===void 0?void 0:(_data$ec2$word=_data$ec2.word)===null||_data$ec2$word===void 0?void 0:(_data$ec2$word$trs=_data$ec2$word.trs)===null||_data$ec2$word$trs===void 0?void 0:_data$ec2$word$trs.map(_ref4=>{let{pos,tran}=_ref4;return"".concat(pos?"[".concat(pos,"] "):"").concat(tran);}))||[];},uiAudio:data=>{var _data$ec3,_data$ec3$word,_data$ec4,_data$ec4$word,_data$ec5,_data$ec5$word,_data$ec6,_data$ec6$word;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"UK [".concat(data===null||data===void 0?void 0:(_data$ec3=data.ec)===null||_data$ec3===void 0?void 0:(_data$ec3$word=_data$ec3.word)===null||_data$ec3$word===void 0?void 0:_data$ec3$word.ukphone,"]")}),/*#__PURE__*/(0,jsx_runtime.jsx)(BaiduAudioBtn,{text:data===null||data===void 0?void 0:(_data$ec4=data.ec)===null||_data$ec4===void 0?void 0:(_data$ec4$word=_data$ec4.word)===null||_data$ec4$word===void 0?void 0:_data$ec4$word["return-phrase"],lan:"uk"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",style:{display:"inline-block",paddingRight:"1em"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"span",children:"US [".concat(data===null||data===void 0?void 0:(_data$ec5=data.ec)===null||_data$ec5===void 0?void 0:(_data$ec5$word=_data$ec5.word)===null||_data$ec5$word===void 0?void 0:_data$ec5$word.usphone,"]")}),/*#__PURE__*/(0,jsx_runtime.jsx)(BaiduAudioBtn,{text:data===null||data===void 0?void 0:(_data$ec6=data.ec)===null||_data$ec6===void 0?void 0:(_data$ec6$word=_data$ec6.word)===null||_data$ec6$word===void 0?void 0:_data$ec6$word["return-phrase"],lan:"en"})]})]});},uiTrans:data=>{var _data$ec7,_data$ec7$word,_data$ec7$word$trs;return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"ul",children:data===null||data===void 0?void 0:(_data$ec7=data.ec)===null||_data$ec7===void 0?void 0:(_data$ec7$word=_data$ec7.word)===null||_data$ec7$word===void 0?void 0:(_data$ec7$word$trs=_data$ec7$word.trs)===null||_data$ec7$word$trs===void 0?void 0:_data$ec7$word$trs.map((_ref5,idx)=>{let{pos,tran}=_ref5;return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"li",children:[pos&&"[".concat(pos,"] "),tran]},idx);})});}}};
;// CONCATENATED MODULE: ./src/views/Selection/DictCont.js
function DictBody(_ref){let{text,setCopyText,setRealWord,dict}=_ref;const{loading,error,data}=useAsyncNow(dict.apiFn,text);(0,react.useEffect)(()=>{if(!data){return;}const realWord=dict.reWord(data)||text;const copyText=[realWord,dict.toText(data).join("\n")].join("\n");setRealWord(realWord);setCopyText(copyText);},[data,text,dict,setCopyText,setRealWord]);const uiAudio=(0,react.useMemo)(()=>dict.uiAudio(data),[data,dict]);const uiTrans=(0,react.useMemo)(()=>dict.uiTrans(data),[data,dict]);if(loading){return/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{size:16});}if(error){return/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error});}if(!data){return/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{children:"Not found!"});}return/*#__PURE__*/(0,jsx_runtime.jsxs)(Typography_Typography,{component:"div",children:[uiAudio,uiTrans]});}function DictCont(_ref2){let{text,enDict}=_ref2;const[copyText,setCopyText]=(0,react.useState)(text);const[realWord,setRealWord]=(0,react.useState)(text);const dict=dictHandlers[enDict];return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:1,children:[text&&/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{variant:"subtitle1",style:{fontWeight:"bold"},children:realWord}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(CopyBtn,{text:copyText}),/*#__PURE__*/(0,jsx_runtime.jsx)(FavBtn,{word:realWord})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{}),dict&&/*#__PURE__*/(0,jsx_runtime.jsx)(DictBody,{text:text,setCopyText:setCopyText,setRealWord:setRealWord,dict:dict})]});}
;// CONCATENATED MODULE: ./src/views/Selection/SugCont.js
@@ -81328,11 +81335,11 @@ var StylesSetting_templateObject;function StyleFields(_ref){let{customStyle,dele
;// CONCATENATED MODULE: ./src/views/Options/index.js
function Options(){const[error,setError]=(0,react.useState)("");const[ready,setReady]=(0,react.useState)(false);(0,react.useEffect)(()=>{(async()=>{if(isGm){// 等待GM注入
let i=0;for(;;){var _window,_window$APP_INFO;if(((_window=window)===null||_window===void 0?void 0:(_window$APP_INFO=_window.APP_INFO)===null||_window$APP_INFO===void 0?void 0:_window$APP_INFO.name)==="KISS Translator"){const{version,eventName}=window.APP_INFO;// 检查版本是否一致
if(version!=="2.0.11"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.11","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.11",")\u3002"));return;}if(eventName){// 注入GM接口
if(version!=="2.0.12"){setError("The version of the local script(v".concat(version,") is not the latest version(v").concat("2.0.12","). \u672C\u5730\u811A\u672C\u4E4B\u7248\u672C(v").concat(version,")\u975E\u6700\u65B0\u7248(v").concat("2.0.12",")\u3002"));return;}if(eventName){// 注入GM接口
adaptScript(eventName);}break;}if(++i>8){setError("Time out. Please confirm whether to install or enable KISS Translator GreaseMonkey script? 连接超时,请检查是否安装或启用简约翻译油猴脚本。");return;}await sleep(1000);}}// 同步数据
await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.11")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{isSettingPage:true,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});}
await trySyncSettingAndRules();setReady(true);})();},[]);if(error){return/*#__PURE__*/(0,jsx_runtime.jsxs)("center",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("2.0.12")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Alert_Alert,{severity:"error",children:error}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(material_Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"})]})]});}if(!ready){return/*#__PURE__*/(0,jsx_runtime.jsx)(Loading,{});}return/*#__PURE__*/(0,jsx_runtime.jsx)(SettingProvider,{context:"options",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Theme,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(AlertProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConfirmProvider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(HashRouter,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Routes,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(Route,{path:"/",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Layout,{}),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{index:true,element:/*#__PURE__*/(0,jsx_runtime.jsx)(Settings,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"rules",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Rules,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"styles",element:/*#__PURE__*/(0,jsx_runtime.jsx)(StylesSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"input",element:/*#__PURE__*/(0,jsx_runtime.jsx)(InputSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"tranbox",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Tranbox,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"mousehover",element:/*#__PURE__*/(0,jsx_runtime.jsx)(MouseHoverSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"subtitle",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SubtitleSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"apis",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Apis,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"sync",element:/*#__PURE__*/(0,jsx_runtime.jsx)(SyncSetting,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"words",element:/*#__PURE__*/(0,jsx_runtime.jsx)(FavWords,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"playground",element:/*#__PURE__*/(0,jsx_runtime.jsx)(Playgound,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Route,{path:"about",element:/*#__PURE__*/(0,jsx_runtime.jsx)(About,{})})]})})})})})})});}
;// CONCATENATED MODULE: ./src/options.js
const options_root=client.createRoot(document.getElementById("root"));options_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Options,{})}));
globalThis.__KISS_CONTEXT__="options";const options_root=client.createRoot(document.getElementById("root"));options_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Options,{})}));
})();
/******/ })()