const _0x5c9205=_0x2d7b;(function(_0x6a84d8,_0x16a28d){const _0x2c6c97=_0x2d7b,_0x4219a8=_0x6a84d8();while(!![]){try{const _0x1b7372=-parseInt(_0x2c6c97(0x252))/0x1*(parseInt(_0x2c6c97(0x28e))/0x2)+-parseInt(_0x2c6c97(0x1be))/0x3+parseInt(_0x2c6c97(0x30a))/0x4+parseInt(_0x2c6c97(0x2e3))/0x5*(parseInt(_0x2c6c97(0x291))/0x6)+-parseInt(_0x2c6c97(0x1f2))/0x7*(-parseInt(_0x2c6c97(0x2fb))/0x8)+-parseInt(_0x2c6c97(0x225))/0x9+parseInt(_0x2c6c97(0x17a))/0xa;if(_0x1b7372===_0x16a28d)break;else _0x4219a8['push'](_0x4219a8['shift']());}catch(_0x102d0e){_0x4219a8['push'](_0x4219a8['shift']());}}}(_0xfd5b,0x4445e));import{extension_settings,getContext}from'/scripts/extensions.js';import{characters,this_chid,getRequestHeaders,saveSettingsDebounced,eventSource,event_types}from'/script.js';import{defaultSettings,extensionName}from'../utils/settings.js';import{pluginAuthStatus,activatePluginAuthorization,getPasswordForDate}from'../utils/auth.js';import{fetchModels}from'../core/api.js';import{safeLorebooks,safeCharLorebooks,safeLorebookEntries,isTavernHelperAvailable}from'../core/tavernhelper-compatibility.js';import{setAvailableModels,populateModelDropdown,getLatestUpdateInfo}from'./state.js';import{fixCommand,testReplyChecker}from'../core/commands.js';import{createDrawer}from'../ui/drawer.js';import{messageFormatting}from'/script.js';import{executeManualCommand}from'../core/autoHideManager.js';import{showContentModal,showHtmlModal}from'./page-window.js';function displayDailyAuthCode(){const _0x59ee48=_0x2d7b,_0x5a3e19=document['getElementById']('amily2_daily_code_display'),_0x2c5740=document[_0x59ee48(0x28f)](_0x59ee48(0x216));if(_0x5a3e19&&_0x2c5740){const _0x32a4af=getPasswordForDate(new Date());_0x5a3e19[_0x59ee48(0x2c9)]=_0x32a4af,_0x2c5740[_0x59ee48(0x2d1)](_0x59ee48(0x2fa),()=>{const _0x4c35d1=_0x59ee48;navigator['clipboard'][_0x4c35d1(0x2ec)](_0x32a4af)[_0x4c35d1(0x19f)](()=>{const _0x364089=_0x4c35d1;toastr['success'](_0x364089(0x1ad));},()=>{const _0x4e4b9d=_0x4c35d1;toastr['error'](_0x4e4b9d(0x2d6));});});}}async function loadSillyTavernPresets(){const _0x4b6543=_0x2d7b;console[_0x4b6543(0x23d)](_0x4b6543(0x251));const _0xdea797=$(_0x4b6543(0x26f)),_0x1d0f0c=extension_settings[extensionName]||{},_0x32b9db=_0x1d0f0c[_0x4b6543(0x19a)];_0xdea797[_0x4b6543(0x235)]()['append'](new Option(_0x4b6543(0x21e),''));try{const _0x42d877=getContext(),_0x5ad2cd=_0x42d877['extensionSettings']?.[_0x4b6543(0x2c2)]?.[_0x4b6543(0x1ef)]||[];if(!_0x5ad2cd||_0x5ad2cd[_0x4b6543(0x1a5)]===0x0){_0xdea797[_0x4b6543(0x261)]($('','#amily2_opt_tavern_api_profile_select','input[name=\x22','#amily2_opt_rate_erotic','uid','#amily2_opt_rate_personal','#amily2_opt_worldbook_checkbox_list','#amily2_dialog_editor','show','scripts/extensions/third-party/ST-Amily2-Chat-Optimisation/NeiGe.md','之前选择的酒馆预设\x20\x22','lastUsedPresetName','
加载条目中...
','Amily2号','#amily2_opt_import_prompt_presets',']\x20加载世界书失败:','#amily2_unified_editor','#amily2_opt_top_p_value','url'];_0xfd5b=function(){return _0x59c85c;};return _0xfd5b();}function opt_getMergedSettings(){const _0x3b9941=_0x5c9205,_0x50995b=characters[this_chid],_0xcbafd9=extension_settings[extensionName]||defaultSettings,_0x1df789=_0x50995b?.['data']?.[_0x3b9941(0x2bb)]?.[extensionName]||{};return{..._0xcbafd9,..._0x1df789};}function opt_bindSlider(_0x4f833b,_0x2412b8,_0x1dfb42){const _0x27b5f9=_0x5c9205,_0x3d1110=_0x4f833b[_0x27b5f9(0x187)](_0x2412b8),_0x14f696=_0x4f833b[_0x27b5f9(0x187)](_0x1dfb42);_0x14f696[_0x27b5f9(0x273)](_0x3d1110[_0x27b5f9(0x179)]()),_0x3d1110['on'](_0x27b5f9(0x1c2),function(){const _0x22cc7a=_0x27b5f9;_0x14f696[_0x22cc7a(0x273)]($(this)[_0x22cc7a(0x179)]());});}async function opt_loadWorldbooks(_0x8fdebf){const _0xb6d0c5=_0x5c9205,_0x37b176=_0x8fdebf['find'](_0xb6d0c5(0x2a7)),_0x1973f2=opt_getMergedSettings(),_0x57c9d9=_0x1973f2['plotOpt_selectedWorldbooks']||[];_0x37b176[_0xb6d0c5(0x235)]();try{const _0x1bd903=await safeLorebooks();if(!_0x1bd903||_0x1bd903[_0xb6d0c5(0x1a5)]===0x0){_0x37b176['html'](_0xb6d0c5(0x258));return;}_0x1bd903[_0xb6d0c5(0x313)](_0xcd9797=>{const _0x856947=_0xb6d0c5,_0x3711ff=_0x856947(0x25b)+_0xcd9797['replace'](/[^a-zA-Z0-9]/g,'-'),_0x30e4d7=_0x57c9d9[_0x856947(0x2da)](_0xcd9797),_0x9f7422=$(_0x856947(0x21b)+_0x3711ff+'\x22\x20value=\x22'+_0xcd9797+'\x22\x20'+(_0x30e4d7?'checked':'')+_0x856947(0x1fc)+_0x3711ff+'\x22>'+_0xcd9797+_0x856947(0x205));_0x37b176[_0x856947(0x261)](_0x9f7422);});}catch(_0x340cb1){console[_0xb6d0c5(0x17d)]('['+extensionName+_0xb6d0c5(0x2b0),_0x340cb1),_0x37b176['html'](_0xb6d0c5(0x1fd)),toastr['error']('无法加载世界书列表,请查看控制台。');}}function _0x2d7b(_0xb90920,_0x44b9ae){const _0xfd5bc4=_0xfd5b();return _0x2d7b=function(_0x2d7bd4,_0x39b5b1){_0x2d7bd4=_0x2d7bd4-0x177;let _0x5a05b5=_0xfd5bc4[_0x2d7bd4];return _0x5a05b5;},_0x2d7b(_0xb90920,_0x44b9ae);}async function opt_loadWorldbookEntries(_0x23817b){const _0x24c948=_0x5c9205,_0x45066d=_0x23817b[_0x24c948(0x187)](_0x24c948(0x293)),_0x5880db=_0x23817b[_0x24c948(0x187)](_0x24c948(0x222));_0x45066d['html'](_0x24c948(0x2ad)),_0x5880db['text']('');const _0x1d5382=opt_getMergedSettings(),_0x472d85=_0x1d5382['plotOpt_worldbookSource']||'character';let _0x232f07=[];if(_0x472d85===_0x24c948(0x288))_0x232f07=_0x1d5382[_0x24c948(0x30d)]||[];else{if(this_chid===-0x1||!characters[this_chid]){_0x45066d[_0x24c948(0x26e)]('未选择角色。
'),_0x5880db['text']('');return;}try{const _0x3ba841=await safeCharLorebooks({'type':_0x24c948(0x189)});if(_0x3ba841[_0x24c948(0x1a0)])_0x232f07[_0x24c948(0x2f8)](_0x3ba841[_0x24c948(0x1a0)]);if(_0x3ba841[_0x24c948(0x18a)]?.[_0x24c948(0x1a5)])_0x232f07[_0x24c948(0x2f8)](..._0x3ba841[_0x24c948(0x18a)]);}catch(_0x3e877c){console[_0x24c948(0x17d)]('['+extensionName+_0x24c948(0x223),_0x3e877c),toastr[_0x24c948(0x17d)](_0x24c948(0x2bf)),_0x45066d[_0x24c948(0x26e)]('获取角色世界书失败。
');return;}}const _0x1374c5=_0x232f07;let _0x385b0f=_0x1d5382[_0x24c948(0x1b3)]||{},_0x5d6b7e=0x0,_0x491f02=0x0;if(_0x1374c5[_0x24c948(0x1a5)]===0x0){_0x45066d[_0x24c948(0x26e)](_0x24c948(0x23a));return;}try{const _0x16eb7c=[];for(const _0x4d37a0 of _0x1374c5){const _0x1d5c6c=await safeLorebookEntries(_0x4d37a0);_0x1d5c6c[_0x24c948(0x313)](_0x141750=>{const _0x2880d2=_0x24c948;_0x16eb7c[_0x2880d2(0x2f8)]({..._0x141750,'bookName':_0x4d37a0});});}_0x45066d[_0x24c948(0x235)](),_0x5d6b7e=_0x16eb7c['length'];if(_0x5d6b7e===0x0){_0x45066d[_0x24c948(0x26e)](_0x24c948(0x2f0)),_0x5880db['text']('0\x20条目.');return;}_0x16eb7c[_0x24c948(0x27e)]((_0x187fff,_0x5e14c4)=>(_0x187fff[_0x24c948(0x2bc)]||'')[_0x24c948(0x2c6)](_0x5e14c4[_0x24c948(0x2bc)]||''))[_0x24c948(0x313)](_0x5165ec=>{const _0x54242f=_0x24c948,_0x1978fb='amily2-opt-entry-'+_0x5165ec['bookName'][_0x54242f(0x262)](/[^a-zA-Z0-9]/g,'-')+'-'+_0x5165ec['uid'],_0x2a9f71=_0x385b0f[_0x5165ec[_0x54242f(0x1d8)]]?.['includes'](_0x5165ec[_0x54242f(0x2a5)])??!![],_0x54b48d=$(_0x54242f(0x21b)+_0x1978fb+_0x54242f(0x2d4)+_0x5165ec[_0x54242f(0x1d8)]+_0x54242f(0x25e)+_0x5165ec[_0x54242f(0x2a5)]+'\x22\x20'+(_0x2a9f71?_0x54242f(0x25c):'')+'>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20