mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 13:35:51 +00:00
2 lines
40 KiB
JavaScript
2 lines
40 KiB
JavaScript
const _0x2c3756=_0x3135;(function(_0x25ad9c,_0x199cfd){const _0xe9e2d6=_0x3135,_0x65fccd=_0x25ad9c();while(!![]){try{const _0x994063=-parseInt(_0xe9e2d6(0x278))/0x1*(-parseInt(_0xe9e2d6(0x28d))/0x2)+-parseInt(_0xe9e2d6(0x1df))/0x3+-parseInt(_0xe9e2d6(0x22e))/0x4*(parseInt(_0xe9e2d6(0x262))/0x5)+-parseInt(_0xe9e2d6(0x256))/0x6+parseInt(_0xe9e2d6(0x210))/0x7+-parseInt(_0xe9e2d6(0x21a))/0x8+parseInt(_0xe9e2d6(0x1f2))/0x9;if(_0x994063===_0x199cfd)break;else _0x65fccd['push'](_0x65fccd['shift']());}catch(_0xc6f0a8){_0x65fccd['push'](_0x65fccd['shift']());}}}(_0x26b0,0x20781));function _0x26b0(){const _0x26ce82=['【修改】:\x20','join','\x20行位置插入了新行。','已成功创建新表格:[','fill','其他重要信息','error','移动。','【增加】:\x20','every','上层叙事者明确要求需要删除时','createObjectURL','未在AI返回内容中找到有效的\x20<Amily2Edit>\x20指令块。','准备执行从AI返回的\x20','【清除全局预设】\x0a\x0a您确定要清除已设置的全局预设吗?\x0a\x0a清除后,新聊天将恢复使用扩展内置的默认表格模板。','冻结留存/禁止删除','click','left','上层叙事者在第四面墙外对故事或游戏进行提示、要求、命令时/上层叙事者使用括号包裹提示、要求、命令时','stringify','公告栏','用户取消了全局预设导入操作。','记录时空信息的表格,应保持在一行/日期信息应精确到至几年几月几日(如果日期未知,应随便胡编一个日期)/时段规定(凌晨:0时至5时;早晨:5时至8时;上午:8时至11时;中午:11时至13时;下午:13时至16时;傍晚:16时至19时;晚上:19时至24时)/时间信息应精确至几时几分(如果时间未知,应随便胡编一个时间)/地点应为当前叙述的地点,且约精确越好','设置成功','结束时间','(该表当前内容为空)\x0a','物品名','表格顺序调整后的状态已强制写入最新消息并立即保存。','废黜表格后的状态已强制写入最新消息并立即保存。','\x22\x20已重命名为\x20\x22','无需清除,当前未设置任何全局预设。','Amily2-Table-Preset-v2.0-clean','用户取消了清除全局预设的操作。','match','此表不存在任何一行时','重命名失败','无法找到可锚定的消息或保存失败,新表格可能不会被持久化!','文件格式无效或缺少版本号/表格数据。','\x20的列。','191982HhfLlC','rule_add',',\x20data=','填表完成','\x20行。','导入的预设已强制写入最新消息并立即保存。','清空行数据后的状态已强制写入最新消息并立即保存。','below','\x20行已删除。','当前没有设置全局预设。','当叙述的场景、时间、人物变更时','number','拥有者','”已向','filter',']\x20的顺序已调整。','无法找到可锚定的消息或保存失败,删除操作可能不会被持久化!','input',']\x20的规则已更新。','978606EBekTT','note','\x22\x20的表格已存在。','\x20列。',']\x20已被成功废黜。','trim','length','未找到任何表格数据或全局预设,使用默认模板。','\x20的表格。','无法导出:当前表格状态为空。','name','无法找到可锚定的消息或保存失败,清空操作可能不会被持久化!','clear','导入失败:','body','与<user>关系','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20{\x20insertRow,\x20deleteRow,\x20updateRow\x20}\x20=\x20runner;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','加载全局预设失败:\x20','当大家赴约时/任务或命令有进展、完成、失败时/任务、命令、约定被取消时','】已成功导出。','object','】已开始下载。','AI指令意图更新不存在的行\x20(rowIndex:\x20','fromCharCode','headers','【删除】:\x20','对某人很贵重或有特殊纪念意义的物品','removeChild','操作已取消。','已根据AI的指示成功更新表格!','540778rvDcHr','无法移动表格:索引\x20','操作成功','执行者',']\x20的列“','任务名','confirm','时空栏','当角色的外貌、身体、衣着出现持久性变化时(如:五官长开、伤痕、减肥、染发、更衣、衣物破损等)/当角色有新的身份、职业、爱好时/当角色和<user>的关系改变时/当角色更换住所时/当角色提到重要信息时','splice','777832XuXmMj','全局预设已成功导入并保存到扩展设置中。','rule_delete','\x20的第\x20','Amily2-','无法清空:当前表格状态为空。','target','所有表格的剧情内容已清空。','重要原因','具体描述',']\x20在第\x20','导入预设失败:\x20','Amily2-Table-Preset-v2.0-full','名为\x20\x22','chat','记录已完成或进展中重要、关键事情的任务、命令、约定/禁止记录不重要、不关键的事情/开始和结束时间应精确至具体日期、时段、时间','\x20列的','amily2_ai_template','accept','\x20(索引\x20','4PBUJIG','extra','对<user>态度','function','result','当某人获得贵重或含有特殊意义的物品时/当某个已有物品获得特殊意义时','batchFillerRuleTemplate','message','预设已成功导入并应用。','这是一个新创建的表格。','UI操作\x20\x22','some','消耗品彻底使用完后/一次性物品被使用后','新列\x201','warn','onchange','纯净预设','\x0a\x20\x20\x20\x20\x20\x20\x20\x20','\x20中找不到索引为\x20','split','readAsText','插入行失败:找不到索引为\x20','batch_filler_flow_template','导出成功','执行AI指令时发生错误:\x20','无法创建表格:名为\x20\x22','\x0a*\x20','\x20已在边界。','isArray','全局预设已被清除。','上层叙事者明确要求需要修改时','map',']\x20新增了一行。','用户取消了导入操作。','revokeObjectURL','重命名失败:表格不存在。','mes','无法创建表格:名称不能为空。','replace','导入操作已取消。','80964kzHuMo','导入全局预设失败:\x20','全局预设已设置!新聊天将默认使用此预设。','download','当特定时间约定一起去做某件重要、关键的事时/某角色收到做某件重要、关键事情的命令或任务时/某角色确定执行某件重要、关键的事时','重命名失败:名为\x20\x22','amily2-force-ui-reload','rule_update','执行AI指令:\x20deleteRow(tableIndex=','表格名称不能为空。','size','batch_filler_rule_template','258545BzNCdG','aiTemplate',']\x20的第\x20','执行AI指令:\x20insertRow(tableIndex=','.json','新表格状态已强制写入最新消息并立即保存。','\x20中操作。','在第\x20','type','href','AI\x20指令更新了表格\x20[','执行AI指令时出错:\x20',')\x20的第\x20','全局预设已清除,新聊天将使用默认模板。',']\x20新增了一列。',']\x20末尾新增一行。','没有可导出的表格数据。','任务栏','version','导入的预设中缺少指令模板字段,模板将不会被更新。','createElement','成功删除了表格\x20','1VTXrLo','global_table_preset','onload','...]','amily2_tables_data','batchFillerFlowTemplate','角色名','当本轮出现表中没有的新角色时,应插入','runner','\x20行移动到第\x20','add','\x20条表格操作指令...','操作完成','tables','files','aiFlowTemplate','成功在表格\x20','物品栏','success','aiRuleTemplate','删除列失败:在表格\x20','346862rMWOKt',']\x20的表头“','info','push','已清除所有单元格高亮标记。','forEach','完整备份',',\x20rowIndex=','injectionFlowTemplate','成功将表格\x20','物品发生变化时/消耗品产生损耗时','above','file','\x22\x20已更新内存状态。','parse','上层叙事者留下的各种提示、要求、命令/禁止私自增、删、改','重命名失败:名称不能为空。','创建失败','AI指令块为空,无需执行任何操作。','Amily2-Table-Preset-v3.0-separated_templates','表格\x20[','rows','),已智能转换为在表格\x20['];_0x26b0=function(){return _0x26ce82;};return _0x26b0();}import{getContext,extension_settings}from'/scripts/extensions.js';import{saveChat,saveSettingsDebounced}from'/script.js';import{log}from'./logger.js';import{getChatPiece,saveChatDebounced}from'../../utils/utils.js';import{extensionName}from'../../utils/settings.js';import{DEFAULT_AI_RULE_TEMPLATE,DEFAULT_AI_FLOW_TEMPLATE}from'./settings.js';const TABLE_DATA_KEY=_0x2c3756(0x27c);let currentTablesState=null,highlightedCells=new Set();export function addHighlight(_0x1866f1,_0x59fb15,_0x4583b1){const _0x40b8a7=_0x2c3756,_0x43b894=_0x1866f1+'-'+_0x59fb15+'-'+_0x4583b1;highlightedCells[_0x40b8a7(0x282)](_0x43b894);}export function getHighlights(){return highlightedCells;}export function clearHighlights(){const _0x301320=_0x2c3756;highlightedCells[_0x301320(0x260)]>0x0&&(highlightedCells[_0x301320(0x1fe)](),log(_0x301320(0x291),_0x301320(0x28f)));}export function setMemoryState(_0xf3ffac){currentTablesState=_0xf3ffac;}export function getMemoryState(){return currentTablesState;}const defaultTemplate={'tables':[{'name':_0x2c3756(0x217),'headers':['日期','时段','时间','地点','此地角色'],'note':_0x2c3756(0x2ba),'rule_add':_0x2c3756(0x1da),'rule_delete':'此表大于一行时应删除多余行','rule_update':_0x2c3756(0x1e9),'rows':[]},{'name':'角色栏','headers':[_0x2c3756(0x27e),'外貌','身体','衣着','性格','身份','职业',_0x2c3756(0x201),_0x2c3756(0x230),'爱好','住所',_0x2c3756(0x2a9)],'note':'角色的基础信息csv表格,思考本轮有否有其中的角色,他应作出什么反应/外貌指:五官、面容、肤色、发型等/身体指:体型、身材、肤色、罩杯等/衣着指:身上的穿戴、服装的式样等/身份指:出身、社会地位等/职业指职责、岗位等/与<user>关系指:角色与<user>的社会关系(如:父亲、母亲、姐姐、妻子等)/爱好指:拥有浓厚兴趣和喜爱的某种事物、人物、活动/住所指:经常居住地','rule_add':_0x2c3756(0x27f),'rule_delete':'角色明确死亡且以后绝不会再出场时','rule_update':_0x2c3756(0x218),'rows':[]},{'name':_0x2c3756(0x273),'headers':[_0x2c3756(0x215),'类型','详情','状态',_0x2c3756(0x213),'地点','结果','开始时间',_0x2c3756(0x2bc)],'note':_0x2c3756(0x229),'rule_add':_0x2c3756(0x25a),'rule_delete':_0x2c3756(0x2b3),'rule_update':_0x2c3756(0x204),'rows':[]},{'name':_0x2c3756(0x289),'headers':[_0x2c3756(0x2be),'类型','详情','状态',_0x2c3756(0x1eb),_0x2c3756(0x222)],'note':_0x2c3756(0x20c),'rule_add':_0x2c3756(0x233),'rule_delete':_0x2c3756(0x23a),'rule_update':_0x2c3756(0x297),'rows':[]},{'name':_0x2c3756(0x2b8),'headers':['类型',_0x2c3756(0x223)],'note':_0x2c3756(0x29c),'rule_add':_0x2c3756(0x2b6),'rule_delete':_0x2c3756(0x2ae),'rule_update':_0x2c3756(0x24c),'rows':[]}]};function getDefaultTables(){const _0x3a23b6=_0x2c3756;return log('从预设模板生成默认表格...','info'),JSON['parse'](JSON['stringify'](defaultTemplate[_0x3a23b6(0x285)]));}export function loadTables(_0x50b34b=-0x1){const _0x5199dc=_0x2c3756,_0x307617=getContext();if(_0x307617&&_0x307617['chat']&&_0x307617[_0x5199dc(0x228)][_0x5199dc(0x1f8)]>0x0){const _0x35624b=_0x50b34b===-0x1?_0x307617[_0x5199dc(0x228)][_0x5199dc(0x1f8)]-0x1:_0x50b34b-0x1;for(let _0xadbd92=_0x35624b;_0xadbd92>=0x0;_0xadbd92--){const _0x31dc08=_0x307617[_0x5199dc(0x228)][_0xadbd92];if(_0x31dc08[_0x5199dc(0x22f)]&&_0x31dc08[_0x5199dc(0x22f)][TABLE_DATA_KEY]){log(_0x5199dc(0x269)+_0xadbd92+'\x20条消息中找到基准表格数据。',_0x5199dc(0x28f));let _0x38e48c=JSON['parse'](JSON[_0x5199dc(0x2b7)](_0x31dc08[_0x5199dc(0x22f)][TABLE_DATA_KEY]));return _0x38e48c[_0x5199dc(0x292)](_0x24580e=>{const _0x2e632a=_0x5199dc;if(_0x24580e[_0x2e632a(0x1f3)]===undefined)_0x24580e[_0x2e632a(0x1f3)]='无';if(_0x24580e['rule_add']===undefined)_0x24580e[_0x2e632a(0x1e0)]='允许';if(_0x24580e[_0x2e632a(0x21c)]===undefined)_0x24580e[_0x2e632a(0x21c)]='允许';if(_0x24580e[_0x2e632a(0x25d)]===undefined)_0x24580e[_0x2e632a(0x25d)]='允许';}),currentTablesState=_0x38e48c,currentTablesState;}}}if(extension_settings[extensionName]?.[_0x5199dc(0x279)]){log('未在聊天记录中找到表格,正在加载全局预设...','info');try{const _0x6a1a8=extension_settings[extensionName][_0x5199dc(0x279)];return currentTablesState=JSON[_0x5199dc(0x29b)](JSON[_0x5199dc(0x2b7)](_0x6a1a8[_0x5199dc(0x285)])),currentTablesState;}catch(_0x3fab7f){log(_0x5199dc(0x203)+_0x3fab7f[_0x5199dc(0x235)],_0x5199dc(0x2aa));}}return log(_0x5199dc(0x1f9),_0x5199dc(0x28f)),currentTablesState=getDefaultTables(),currentTablesState;}export function saveStateToMessage(_0x23234e,_0x3e18de){const _0x204cf8=_0x2c3756;if(!_0x23234e||!_0x3e18de)return log('缺少状态或目标消息,无法保存。',_0x204cf8(0x2aa)),![];return!_0x3e18de[_0x204cf8(0x22f)]&&(_0x3e18de[_0x204cf8(0x22f)]={}),_0x3e18de['extra'][TABLE_DATA_KEY]=JSON[_0x204cf8(0x29b)](JSON[_0x204cf8(0x2b7)](_0x23234e)),log('表格状态已准备写入消息\x20['+_0x3e18de[_0x204cf8(0x252)]['substring'](0x0,0x14)+_0x204cf8(0x27b),_0x204cf8(0x28f)),!![];}export function saveTables(_0x33ee0e='未知操作'){const _0x592a5e=_0x2c3756;return log(_0x592a5e(0x238)+_0x33ee0e+_0x592a5e(0x29a),_0x592a5e(0x28f)),!![];}export function deleteColumn(_0x4bf7ed,_0x445bd5){const _0x42d097=_0x2c3756,_0x3b78b4=getMemoryState();if(!_0x3b78b4[_0x4bf7ed]||_0x445bd5<0x0||_0x445bd5>=_0x3b78b4[_0x4bf7ed][_0x42d097(0x20a)][_0x42d097(0x1f8)]){log(_0x42d097(0x28c)+_0x4bf7ed+_0x42d097(0x240)+_0x445bd5+_0x42d097(0x1de),'error');return;}_0x3b78b4[_0x4bf7ed][_0x42d097(0x20a)]['splice'](_0x445bd5,0x1),_0x3b78b4[_0x4bf7ed][_0x42d097(0x2a2)][_0x42d097(0x292)](_0x9832ae=>{const _0x133ae9=_0x42d097;_0x9832ae['length']>_0x445bd5&&_0x9832ae[_0x133ae9(0x219)](_0x445bd5,0x1);}),log(_0x42d097(0x277)+_0x4bf7ed+_0x42d097(0x21d)+(_0x445bd5+0x1)+_0x42d097(0x1f5),'success'),saveTables(_0x3b78b4);}export function moveRow(_0xf2fc05,_0x2d93bc,_0x2a462d){const _0x9f1547=_0x2c3756,_0x55af44=getMemoryState(),_0x54ae5c=_0x55af44[_0xf2fc05];if(!_0x54ae5c||_0x2d93bc<0x0||_0x2d93bc>=_0x54ae5c[_0x9f1547(0x2a2)]['length'])return;const _0x2f0e92=_0x2a462d==='up'?_0x2d93bc-0x1:_0x2d93bc+0x1;if(_0x2f0e92<0x0||_0x2f0e92>=_0x54ae5c[_0x9f1547(0x2a2)][_0x9f1547(0x1f8)])return;const [_0x3950fb]=_0x54ae5c[_0x9f1547(0x2a2)][_0x9f1547(0x219)](_0x2d93bc,0x1);_0x54ae5c[_0x9f1547(0x2a2)]['splice'](_0x2f0e92,0x0,_0x3950fb),log(_0x9f1547(0x296)+_0xf2fc05+'\x20的第\x20'+(_0x2d93bc+0x1)+_0x9f1547(0x281)+(_0x2f0e92+0x1)+'\x20行。',_0x9f1547(0x28a)),saveTables(_0x55af44);}export function insertRow(_0x33bb7f,_0x15dd30,_0x338165=_0x2c3756(0x1e6)){const _0x20ec40=_0x2c3756,_0x8dfe84=getMemoryState(),_0x499dc0=_0x8dfe84[_0x33bb7f];if(!_0x499dc0){log(_0x20ec40(0x243)+_0x33bb7f+_0x20ec40(0x1fa),'error');return;}let _0x2cc409;typeof _0x15dd30===_0x20ec40(0x1ea)?_0x2cc409=_0x338165===_0x20ec40(0x298)?_0x15dd30:_0x15dd30+0x1:_0x2cc409=_0x499dc0['rows']['length'];if(_0x2cc409<0x0)_0x2cc409=0x0;if(_0x2cc409>_0x499dc0[_0x20ec40(0x2a2)][_0x20ec40(0x1f8)])_0x2cc409=_0x499dc0['rows'][_0x20ec40(0x1f8)];const _0x1f1983=new Array(_0x499dc0[_0x20ec40(0x20a)][_0x20ec40(0x1f8)])[_0x20ec40(0x2a8)]('');if(typeof _0x15dd30===_0x20ec40(0x206)&&_0x15dd30!==null)for(const _0x2bfa0e in _0x15dd30){const _0x3b8b40=parseInt(_0x2bfa0e,0xa);!isNaN(_0x3b8b40)&&_0x3b8b40<_0x1f1983[_0x20ec40(0x1f8)]&&(_0x1f1983[_0x3b8b40]=_0x15dd30[_0x2bfa0e],addHighlight(_0x33bb7f,_0x2cc409,_0x3b8b40));}_0x499dc0[_0x20ec40(0x2a2)]['splice'](_0x2cc409,0x0,_0x1f1983),log(_0x20ec40(0x288)+_0x499dc0['name']+_0x20ec40(0x22d)+_0x33bb7f+_0x20ec40(0x26e)+(_0x2cc409+0x1)+_0x20ec40(0x2a6),_0x20ec40(0x28a));const _0x3da161=getContext();if(_0x3da161[_0x20ec40(0x228)]&&_0x3da161['chat'][_0x20ec40(0x1f8)]>0x0){const _0x259fe6=_0x3da161[_0x20ec40(0x228)][_0x3da161['chat'][_0x20ec40(0x1f8)]-0x1];if(saveStateToMessage(_0x8dfe84,_0x259fe6)){saveChat();return;}}saveChatDebounced();}export function addRow(_0x44004f){const _0x480d08=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x44004f])return;const _0x241d84=currentTablesState[_0x44004f],_0x11a84d=_0x241d84[_0x480d08(0x20a)]['length'],_0x17d85e=Array(_0x11a84d)[_0x480d08(0x2a8)]('');_0x241d84[_0x480d08(0x2a2)][_0x480d08(0x290)](_0x17d85e);const _0x2c6007=_0x480d08(0x2a1)+_0x241d84[_0x480d08(0x1fc)]+_0x480d08(0x24e);log(_0x2c6007,_0x480d08(0x28f));const _0x3d8f01=getContext();if(_0x3d8f01[_0x480d08(0x228)]&&_0x3d8f01[_0x480d08(0x228)][_0x480d08(0x1f8)]>0x0){const _0x58479c=_0x3d8f01[_0x480d08(0x228)][_0x3d8f01[_0x480d08(0x228)]['length']-0x1];if(saveStateToMessage(currentTablesState,_0x58479c)){saveChat();return;}}saveChatDebounced();}export function addColumn(_0x46144d){const _0x2c5e16=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x46144d])return;const _0x43081d=currentTablesState[_0x46144d],_0x1812ee='新列\x20'+(_0x43081d[_0x2c5e16(0x20a)][_0x2c5e16(0x1f8)]+0x1);_0x43081d[_0x2c5e16(0x20a)][_0x2c5e16(0x290)](_0x1812ee),_0x43081d['rows'][_0x2c5e16(0x292)](_0x3c72eb=>_0x3c72eb[_0x2c5e16(0x290)](''));const _0x470166=_0x2c5e16(0x2a1)+_0x43081d[_0x2c5e16(0x1fc)]+_0x2c5e16(0x270);log(_0x470166,_0x2c5e16(0x28f));const _0x5ecd21=getContext();if(_0x5ecd21[_0x2c5e16(0x228)]&&_0x5ecd21[_0x2c5e16(0x228)][_0x2c5e16(0x1f8)]>0x0){const _0x39843c=_0x5ecd21[_0x2c5e16(0x228)][_0x5ecd21[_0x2c5e16(0x228)][_0x2c5e16(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x39843c)){saveChat();return;}}saveChatDebounced();}export function updateHeader(_0x261c8d,_0x2edd69,_0x110292){const _0x5460c9=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x261c8d]||currentTablesState[_0x261c8d][_0x5460c9(0x20a)][_0x2edd69]===undefined)return;const _0x5c338d=currentTablesState[_0x261c8d]['name'],_0x5c9f92=currentTablesState[_0x261c8d]['headers'][_0x2edd69];currentTablesState[_0x261c8d][_0x5460c9(0x20a)][_0x2edd69]=_0x110292;const _0x4b6dcc=_0x5460c9(0x2a1)+_0x5c338d+_0x5460c9(0x28e)+_0x5c9f92+'”已更新为“'+_0x110292+'”。';log(_0x4b6dcc,_0x5460c9(0x28f));const _0x4f6537=getContext();if(_0x4f6537[_0x5460c9(0x228)]&&_0x4f6537[_0x5460c9(0x228)][_0x5460c9(0x1f8)]>0x0){const _0x139324=_0x4f6537[_0x5460c9(0x228)][_0x4f6537['chat'][_0x5460c9(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x139324)){saveChat();return;}}saveChatDebounced();}export async function deleteRow(_0x39968c,_0x5a0be7){const _0x130e82=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x39968c]||!currentTablesState[_0x39968c][_0x130e82(0x2a2)][_0x5a0be7])return;const _0x29ac4d=currentTablesState[_0x39968c]['name'];currentTablesState[_0x39968c][_0x130e82(0x2a2)][_0x130e82(0x219)](_0x5a0be7,0x1);const _0x1440ad=_0x130e82(0x2a1)+_0x29ac4d+_0x130e82(0x264)+(_0x5a0be7+0x1)+_0x130e82(0x1e7);log(_0x1440ad,_0x130e82(0x28f));const _0x47c3d=getContext();if(_0x47c3d[_0x130e82(0x228)]&&_0x47c3d['chat'][_0x130e82(0x1f8)]>0x0){const _0x4b81bd=_0x47c3d[_0x130e82(0x228)][_0x47c3d[_0x130e82(0x228)]['length']-0x1];if(saveStateToMessage(currentTablesState,_0x4b81bd)){await saveChat();return;}}await saveChatDebounced();}export function insertColumn(_0x1b9bed,_0x1edaae,_0x17b6d6){const _0x140203=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x1b9bed])return;const _0x6c4876=currentTablesState[_0x1b9bed],_0x51eef2=_0x17b6d6===_0x140203(0x2b5)?_0x1edaae:_0x1edaae+0x1,_0x47564b='新列';_0x6c4876[_0x140203(0x20a)][_0x140203(0x219)](_0x51eef2,0x0,_0x47564b),_0x6c4876['rows']['forEach'](_0x290b5f=>_0x290b5f['splice'](_0x51eef2,0x0,''));const _0x5b02c7=_0x140203(0x2a1)+_0x6c4876[_0x140203(0x1fc)]+_0x140203(0x224)+(_0x1edaae+0x1)+_0x140203(0x22a)+(_0x17b6d6===_0x140203(0x2b5)?'左侧':'右侧')+'插入了新列。';log(_0x5b02c7,_0x140203(0x28f));const _0x286938=getContext();if(_0x286938[_0x140203(0x228)]&&_0x286938[_0x140203(0x228)][_0x140203(0x1f8)]>0x0){const _0x4304ba=_0x286938[_0x140203(0x228)][_0x286938[_0x140203(0x228)][_0x140203(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x4304ba)){saveChat();return;}}saveChatDebounced();}export function moveColumn(_0x53134a,_0x511494,_0xd8401f){const _0x3457e2=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x53134a])return;const _0x4a309f=currentTablesState[_0x53134a],_0x311809=_0x4a309f[_0x3457e2(0x20a)],_0x50836a=_0x4a309f[_0x3457e2(0x2a2)],_0x2783d5=_0xd8401f===_0x3457e2(0x2b5)?_0x511494-0x1:_0x511494+0x1;if(_0x2783d5<0x0||_0x2783d5>=_0x311809[_0x3457e2(0x1f8)]){log('无法移动列:索引\x20'+_0x511494+_0x3457e2(0x249),_0x3457e2(0x23c));return;}const [_0x54c8ec]=_0x311809[_0x3457e2(0x219)](_0x511494,0x1);_0x311809[_0x3457e2(0x219)](_0x2783d5,0x0,_0x54c8ec),_0x50836a[_0x3457e2(0x292)](_0x5a1dd7=>{const _0x21819a=_0x3457e2,[_0x14d3f6]=_0x5a1dd7['splice'](_0x511494,0x1);_0x5a1dd7[_0x21819a(0x219)](_0x2783d5,0x0,_0x14d3f6);});const _0x257507=_0x3457e2(0x2a1)+_0x4a309f['name']+_0x3457e2(0x214)+_0x54c8ec+_0x3457e2(0x1ec)+(_0xd8401f==='left'?'左':'右')+_0x3457e2(0x2ab);log(_0x257507,'info');const _0x2d7f05=getContext();if(_0x2d7f05[_0x3457e2(0x228)]&&_0x2d7f05[_0x3457e2(0x228)][_0x3457e2(0x1f8)]>0x0){const _0x114566=_0x2d7f05[_0x3457e2(0x228)][_0x2d7f05[_0x3457e2(0x228)][_0x3457e2(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x114566)){saveChat();return;}}saveChatDebounced();}export function deleteTable(_0x49d158){const _0x1867ca=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x49d158])return;const _0x28e3d8=currentTablesState[_0x49d158][_0x1867ca(0x1fc)];currentTablesState[_0x1867ca(0x219)](_0x49d158,0x1);const _0xa69f4a=_0x1867ca(0x2a1)+_0x28e3d8+_0x1867ca(0x1f6);log(_0xa69f4a,_0x1867ca(0x28a));const _0x22d77b=getContext();if(_0x22d77b[_0x1867ca(0x228)]&&_0x22d77b['chat'][_0x1867ca(0x1f8)]>0x0){const _0x1c9166=_0x22d77b[_0x1867ca(0x228)][_0x22d77b['chat'][_0x1867ca(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x1c9166)){saveChat(),log(_0x1867ca(0x2c0),_0x1867ca(0x28a));return;}}log(_0x1867ca(0x1ef),_0x1867ca(0x2aa)),saveChatDebounced();}function _0x3135(_0x20d7cc,_0x3647f2){const _0x26b038=_0x26b0();return _0x3135=function(_0x313532,_0x2b169b){_0x313532=_0x313532-0x1da;let _0x132e78=_0x26b038[_0x313532];return _0x132e78;},_0x3135(_0x20d7cc,_0x3647f2);}export function addTable(_0x39f416){const _0x12ce87=_0x2c3756;if(!_0x39f416||!_0x39f416[_0x12ce87(0x1f7)]()){log(_0x12ce87(0x253),_0x12ce87(0x2aa)),toastr[_0x12ce87(0x2aa)](_0x12ce87(0x25f),_0x12ce87(0x29e));return;}!currentTablesState&&loadTables();if(currentTablesState[_0x12ce87(0x239)](_0x2608ce=>_0x2608ce[_0x12ce87(0x1fc)]===_0x39f416[_0x12ce87(0x1f7)]())){log(_0x12ce87(0x247)+_0x39f416+_0x12ce87(0x1f4),_0x12ce87(0x2aa)),toastr['error']('名为\x20\x22'+_0x39f416+_0x12ce87(0x1f4),'创建失败');return;}const _0x3d0de6={'name':_0x39f416[_0x12ce87(0x1f7)](),'headers':[_0x12ce87(0x23b)],'rows':[],'note':_0x12ce87(0x237),'rule_add':'允许','rule_delete':'允许','rule_update':'允许'};currentTablesState[_0x12ce87(0x290)](_0x3d0de6);const _0x2711ce=_0x12ce87(0x2a7)+_0x39f416['trim']()+']。';log(_0x2711ce,'success');const _0x348eeb=getContext();if(_0x348eeb[_0x12ce87(0x228)]&&_0x348eeb[_0x12ce87(0x228)]['length']>0x0){const _0x3a1d3e=_0x348eeb[_0x12ce87(0x228)][_0x348eeb[_0x12ce87(0x228)][_0x12ce87(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x3a1d3e)){saveChat(),log(_0x12ce87(0x267),_0x12ce87(0x28a));return;}}log(_0x12ce87(0x1dc),'error'),saveChatDebounced();}export function renameTable(_0x302714,_0x34cd67){const _0x150d25=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x302714]){log(_0x150d25(0x251),_0x150d25(0x2aa)),toastr[_0x150d25(0x2aa)]('表格不存在。',_0x150d25(0x1db));return;}const _0x30a679=_0x34cd67[_0x150d25(0x1f7)]();if(!_0x30a679){log(_0x150d25(0x29d),_0x150d25(0x2aa)),toastr['error'](_0x150d25(0x25f),_0x150d25(0x1db));return;}if(currentTablesState[_0x150d25(0x239)]((_0xd02c6c,_0x3f21b0)=>_0x3f21b0!==_0x302714&&_0xd02c6c[_0x150d25(0x1fc)]===_0x30a679)){log(_0x150d25(0x25b)+_0x30a679+_0x150d25(0x1f4),'error'),toastr[_0x150d25(0x2aa)](_0x150d25(0x227)+_0x30a679+_0x150d25(0x1f4),_0x150d25(0x1db));return;}const _0x2f819c=currentTablesState[_0x302714][_0x150d25(0x1fc)];currentTablesState[_0x302714][_0x150d25(0x1fc)]=_0x30a679,log('表格\x20\x22'+_0x2f819c+_0x150d25(0x2c1)+_0x30a679+'\x22。',_0x150d25(0x28a));const _0x15e903=getContext();if(_0x15e903[_0x150d25(0x228)]&&_0x15e903['chat'][_0x150d25(0x1f8)]>0x0){const _0x4a6bbf=_0x15e903[_0x150d25(0x228)][_0x15e903['chat'][_0x150d25(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x4a6bbf)){saveChat();return;}}saveChatDebounced();}export function moveTable(_0x3d32ec,_0x52bcac){const _0x1fb0a2=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x3d32ec])return;const _0x28f57d=_0x52bcac==='up'?_0x3d32ec-0x1:_0x3d32ec+0x1;if(_0x28f57d<0x0||_0x28f57d>=currentTablesState[_0x1fb0a2(0x1f8)]){log(_0x1fb0a2(0x211)+_0x3d32ec+_0x1fb0a2(0x249),_0x1fb0a2(0x23c));return;}const _0x520377=currentTablesState[_0x3d32ec];currentTablesState[_0x3d32ec]=currentTablesState[_0x28f57d],currentTablesState[_0x28f57d]=_0x520377;const _0x2f9248=_0x1fb0a2(0x2a1)+_0x520377[_0x1fb0a2(0x1fc)]+_0x1fb0a2(0x1ee);log(_0x2f9248,_0x1fb0a2(0x28a));const _0xa1fa9a=getContext();if(_0xa1fa9a['chat']&&_0xa1fa9a[_0x1fb0a2(0x228)][_0x1fb0a2(0x1f8)]>0x0){const _0x1db3e9=_0xa1fa9a['chat'][_0xa1fa9a[_0x1fb0a2(0x228)][_0x1fb0a2(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x1db3e9)){saveChat(),log(_0x1fb0a2(0x2bf),_0x1fb0a2(0x28a));return;}}log('无法找到可锚定的消息或保存失败,顺序调整可能不会被持久化!','error'),saveChatDebounced();}export function updateTableRules(_0x1fa67c,_0x2bc603){const _0x1a3899=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x1fa67c])return;const _0xa0e49=currentTablesState[_0x1fa67c];_0xa0e49['note']=_0x2bc603['note'],_0xa0e49['rule_add']=_0x2bc603[_0x1a3899(0x1e0)],_0xa0e49[_0x1a3899(0x21c)]=_0x2bc603[_0x1a3899(0x21c)],_0xa0e49[_0x1a3899(0x25d)]=_0x2bc603[_0x1a3899(0x25d)];const _0x5389b2='表格\x20['+_0xa0e49[_0x1a3899(0x1fc)]+_0x1a3899(0x1f1);log(_0x5389b2,_0x1a3899(0x28f));const _0x142747=getContext();if(_0x142747[_0x1a3899(0x228)]&&_0x142747[_0x1a3899(0x228)][_0x1a3899(0x1f8)]>0x0){const _0x16ee84=_0x142747[_0x1a3899(0x228)][_0x142747[_0x1a3899(0x228)][_0x1a3899(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x16ee84)){saveChat();return;}}saveChatDebounced();}export function updateRow(_0x22ec5e,_0x24c8ee,_0x296ddb){const _0x4b3080=_0x2c3756;if(!currentTablesState||!currentTablesState[_0x22ec5e]){log('AI指令错误:尝试在不存在的表格索引\x20'+_0x22ec5e+_0x4b3080(0x268),_0x4b3080(0x2aa));return;}const _0xe017a0=currentTablesState[_0x22ec5e];if(_0x24c8ee>=_0xe017a0[_0x4b3080(0x2a2)][_0x4b3080(0x1f8)]){log(_0x4b3080(0x208)+_0x24c8ee+_0x4b3080(0x2a3)+_0xe017a0[_0x4b3080(0x1fc)]+_0x4b3080(0x271),_0x4b3080(0x23c)),insertRow(_0x22ec5e,_0x296ddb);return;}const _0x2d18a6=_0xe017a0[_0x4b3080(0x2a2)][_0x24c8ee];for(const _0x31bc11 in _0x296ddb){const _0x54fbdf=parseInt(_0x31bc11,0xa);_0x54fbdf<_0x2d18a6[_0x4b3080(0x1f8)]&&(_0x2d18a6[_0x54fbdf]=_0x296ddb[_0x54fbdf],addHighlight(_0x22ec5e,_0x24c8ee,_0x54fbdf));}const _0x4da9e2=_0x4b3080(0x26c)+_0xe017a0[_0x4b3080(0x1fc)]+_0x4b3080(0x264)+(_0x24c8ee+0x1)+_0x4b3080(0x1e3);log(_0x4da9e2,_0x4b3080(0x28f));const _0x50303c=getContext();if(_0x50303c[_0x4b3080(0x228)]&&_0x50303c[_0x4b3080(0x228)][_0x4b3080(0x1f8)]>0x0){const _0x57f8b5=_0x50303c['chat'][_0x50303c[_0x4b3080(0x228)][_0x4b3080(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x57f8b5)){saveChat();return;}}saveChatDebounced();}export function clearAllTables(){const _0x1f750f=_0x2c3756;if(!currentTablesState){log(_0x1f750f(0x21f),_0x1f750f(0x2aa));return;}currentTablesState[_0x1f750f(0x292)](_0x1aebf7=>{const _0x16eb0a=_0x1f750f;_0x1aebf7[_0x16eb0a(0x2a2)]=[];}),log('所有表格的行数据已在内存中清空。','warn');const _0xe27725=getContext();if(_0xe27725['chat']&&_0xe27725[_0x1f750f(0x228)][_0x1f750f(0x1f8)]>0x0){const _0x2350d8=_0xe27725[_0x1f750f(0x228)][_0xe27725[_0x1f750f(0x228)][_0x1f750f(0x1f8)]-0x1];if(saveStateToMessage(currentTablesState,_0x2350d8)){saveChat(),log(_0x1f750f(0x1e5),'success'),toastr[_0x1f750f(0x28a)](_0x1f750f(0x221),_0x1f750f(0x284));return;}}log(_0x1f750f(0x1fd),_0x1f750f(0x2aa)),saveChatDebounced();}export function convertTablesToCsvString(){!currentTablesState&&loadTables();if(!currentTablesState)return'';let _0x2b8d00='';return currentTablesState['forEach']((_0x2ceeff,_0x212288)=>{const _0x18c7ae=_0x3135;_0x2b8d00+=_0x18c7ae(0x248)+_0x212288+':'+_0x2ceeff[_0x18c7ae(0x1fc)]+'\x0a',_0x2b8d00+='【说明】:\x0a'+(_0x2ceeff[_0x18c7ae(0x1f3)]||'无')+'\x0a';const _0x1b472e=_0x2ceeff[_0x18c7ae(0x1fc)][_0x18c7ae(0x254)](/\s/g,'')+'内容';_0x2b8d00+='<'+_0x1b472e+'>\x0a';const _0x5ac177=_0x2ceeff['headers'][_0x18c7ae(0x24d)]((_0x338d08,_0x34ff9e)=>_0x34ff9e+':'+_0x338d08)['join'](',');_0x2b8d00+='rowIndex,'+_0x5ac177+'\x0a',_0x2ceeff['rows'][_0x18c7ae(0x1f8)]===0x0?_0x2b8d00+=_0x18c7ae(0x2bd):_0x2ceeff[_0x18c7ae(0x2a2)]['forEach']((_0x4eb1a7,_0x30409d)=>{const _0x90c61f=_0x18c7ae;if(Array[_0x90c61f(0x24a)](_0x4eb1a7)){const _0x338b3f=_0x4eb1a7[_0x90c61f(0x24d)](_0x41da3e=>{return _0x41da3e===null||_0x41da3e===undefined||_0x41da3e===''?'未知':_0x41da3e['toString']();})[_0x90c61f(0x2a5)](',');_0x2b8d00+=_0x30409d+','+_0x338b3f+'\x0a';}}),_0x2b8d00+='</'+_0x1b472e+'>\x0a',_0x2b8d00+=_0x18c7ae(0x2ac)+(_0x2ceeff[_0x18c7ae(0x1e0)]||'允许')+'\x0a',_0x2b8d00+=_0x18c7ae(0x20b)+(_0x2ceeff[_0x18c7ae(0x21c)]||'允许')+'\x0a',_0x2b8d00+=_0x18c7ae(0x2a4)+(_0x2ceeff[_0x18c7ae(0x25d)]||'允许')+'\x0a',_0x212288<currentTablesState['length']-0x1&&(_0x2b8d00+='\x0a---\x0a');}),_0x2b8d00;}export function convertTablesToCsvStringForContentOnly(){const _0x4e748c=_0x2c3756,_0x52bae5=getMemoryState();if(!_0x52bae5||_0x52bae5[_0x4e748c(0x1f8)]===0x0)return'';let _0xadada2='';return _0x52bae5[_0x4e748c(0x292)](_0x4f700e=>{const _0x140bc9=_0x4e748c;_0xadada2+='\x0a<'+_0x4f700e[_0x140bc9(0x1fc)]+'>\x0a';const _0x13179e=_0x4f700e[_0x140bc9(0x20a)][_0x140bc9(0x24d)]((_0x107555,_0x85b8c7)=>String[_0x140bc9(0x209)](0x41+_0x85b8c7)+':'+_0x107555)[_0x140bc9(0x2a5)](',');_0xadada2+=_0x13179e+'\x0a',Array[_0x140bc9(0x24a)](_0x4f700e[_0x140bc9(0x2a2)])&&_0x4f700e['rows']['length']>0x0?_0x4f700e[_0x140bc9(0x2a2)][_0x140bc9(0x292)]((_0x289456,_0x97703f)=>{const _0x255f6c=_0x140bc9;if(Array[_0x255f6c(0x24a)](_0x289456)){const _0x1c0ed7=_0x289456[_0x255f6c(0x2a5)](',');_0xadada2+=_0x97703f+0x1+':'+_0x1c0ed7+'\x0a';}}):_0xadada2+=_0x140bc9(0x2bd),_0xadada2+='</'+_0x4f700e[_0x140bc9(0x1fc)]+'>\x0a';}),_0xadada2[_0x4e748c(0x1f7)]();}loadTables();export function getBatchFillerRuleTemplate(){return extension_settings[extensionName]?.['batch_filler_rule_template']??DEFAULT_AI_RULE_TEMPLATE;}export function saveBatchFillerRuleTemplate(_0x13e86d){const _0x38b688=_0x2c3756;extension_settings[extensionName][_0x38b688(0x261)]=_0x13e86d,saveSettingsDebounced();}export function getBatchFillerFlowTemplate(){const _0x5e0ab6=_0x2c3756;return extension_settings[extensionName]?.[_0x5e0ab6(0x244)]??DEFAULT_AI_FLOW_TEMPLATE;}export function saveBatchFillerFlowTemplate(_0x554511){extension_settings[extensionName]['batch_filler_flow_template']=_0x554511,saveSettingsDebounced();}export function getAiFlowTemplateForInjection(){const _0x35fef1=_0x2c3756;return extension_settings[extensionName]?.[_0x35fef1(0x22b)]??DEFAULT_AI_FLOW_TEMPLATE;}export async function updateTableFromText(_0x29255d){const _0x5d9373=_0x2c3756;if(!_0x29255d){log('AI返回内容为空,无法更新表格。','warn');return;}const _0x109228=_0x29255d[_0x5d9373(0x2c5)](/<Amily2Edit>([\s\S]*?)<\/Amily2Edit>/);if(!_0x109228||!_0x109228[0x1]){log(_0x5d9373(0x2b0),'warn');return;}let _0x15a9dc=_0x109228[0x1][_0x5d9373(0x254)](/<!--|-->/g,'')['trim']();if(!_0x15a9dc){log(_0x5d9373(0x29f),'info');return;}const _0x347ad7=_0x15a9dc[_0x5d9373(0x241)]('\x0a')[_0x5d9373(0x1ed)](_0x36721=>_0x36721['trim']()!=='');log(_0x5d9373(0x2b1)+_0x347ad7[_0x5d9373(0x1f8)]+_0x5d9373(0x283),_0x5d9373(0x28f));const _0x3578c1={'insertRow':(_0x2a728b,_0xe1f7)=>{const _0x24a90d=_0x5d9373;log(_0x24a90d(0x265)+_0x2a728b+_0x24a90d(0x1e1)+JSON['stringify'](_0xe1f7)+')',_0x24a90d(0x28f)),insertRow(_0x2a728b,_0xe1f7);},'deleteRow':(_0x56c6eb,_0x1e8eb0)=>{const _0x1d8aa8=_0x5d9373;log(_0x1d8aa8(0x25e)+_0x56c6eb+_0x1d8aa8(0x294)+_0x1e8eb0+')',_0x1d8aa8(0x28f)),deleteRow(_0x56c6eb,_0x1e8eb0);},'updateRow':(_0x348878,_0x11d804,_0x56765a)=>{const _0x1cad9a=_0x5d9373;log('执行AI指令:\x20updateRow(tableIndex='+_0x348878+_0x1cad9a(0x294)+_0x11d804+_0x1cad9a(0x1e1)+JSON[_0x1cad9a(0x2b7)](_0x56765a)+')',_0x1cad9a(0x28f)),updateRow(_0x348878,_0x11d804,_0x56765a);}};try{const _0x158e12=Object['getPrototypeOf'](async function(){})['constructor'],_0x570ae5=new _0x158e12(_0x5d9373(0x280),_0x5d9373(0x202)+_0x15a9dc+_0x5d9373(0x23f));await _0x570ae5(_0x3578c1),log('所有AI指令已成功执行完毕。','success'),toastr[_0x5d9373(0x28a)](_0x5d9373(0x20f),_0x5d9373(0x1e2)),document['dispatchEvent'](new CustomEvent(_0x5d9373(0x25c)));}catch(_0xd2d5db){log(_0x5d9373(0x246)+_0xd2d5db[_0x5d9373(0x235)],'error'),toastr[_0x5d9373(0x2aa)](_0x5d9373(0x26d)+_0xd2d5db[_0x5d9373(0x235)],'执行失败');}}export function saveAiTemplate(_0x5a34be){const _0x2bcb02=_0x2c3756;extension_settings[extensionName][_0x2bcb02(0x22b)]=_0x5a34be,saveSettingsDebounced();}export function getAiTemplate(){return getAiFlowTemplateForInjection();}function exportPresetBase(_0x3dc0ef=![]){const _0x49a839=_0x2c3756;if(!currentTablesState){log(_0x49a839(0x1fb),_0x49a839(0x2aa)),toastr[_0x49a839(0x2aa)](_0x49a839(0x272));return;}let _0x2dbb4c,_0x2cc132,_0x1598e2;_0x3dc0ef?(_0x2dbb4c=JSON['parse'](JSON[_0x49a839(0x2b7)](currentTablesState)),_0x2cc132=_0x49a839(0x226),_0x1598e2=_0x49a839(0x293)):(_0x2dbb4c=currentTablesState[_0x49a839(0x24d)](_0xa61de0=>({'name':_0xa61de0[_0x49a839(0x1fc)],'headers':_0xa61de0['headers'],'note':_0xa61de0[_0x49a839(0x1f3)],'rule_add':_0xa61de0[_0x49a839(0x1e0)],'rule_delete':_0xa61de0[_0x49a839(0x21c)],'rule_update':_0xa61de0[_0x49a839(0x25d)],'rows':[]})),_0x2cc132=_0x49a839(0x2c3),_0x1598e2=_0x49a839(0x23e));const _0x1d7c4c={'version':_0x49a839(0x2a0),'batchFillerRuleTemplate':getBatchFillerRuleTemplate(),'batchFillerFlowTemplate':getBatchFillerFlowTemplate(),'injectionFlowTemplate':getAiFlowTemplateForInjection(),'tables':_0x2dbb4c},_0x4b3146=new Blob([JSON[_0x49a839(0x2b7)](_0x1d7c4c,null,0x2)],{'type':'application/json'}),_0x3337f0=URL[_0x49a839(0x2af)](_0x4b3146),_0x247152=document[_0x49a839(0x276)]('a');_0x247152[_0x49a839(0x26b)]=_0x3337f0,_0x247152[_0x49a839(0x259)]=_0x49a839(0x21e)+_0x1598e2+'-'+new Date()['toISOString']()['slice'](0x0,0xa)+_0x49a839(0x266),document['body']['appendChild'](_0x247152),_0x247152[_0x49a839(0x2b4)](),document[_0x49a839(0x200)][_0x49a839(0x20d)](_0x247152),URL[_0x49a839(0x250)](_0x3337f0),log('【'+_0x1598e2+_0x49a839(0x205),_0x49a839(0x28a)),toastr[_0x49a839(0x28a)]('【'+_0x1598e2+_0x49a839(0x207),_0x49a839(0x245));}export function exportPreset(){exportPresetBase(![]);}export function exportPresetFull(){exportPresetBase(!![]);}export function importPreset(_0x2618e2){const _0x55fad2=_0x2c3756,_0x2d6b86=document[_0x55fad2(0x276)](_0x55fad2(0x1f0));_0x2d6b86[_0x55fad2(0x26a)]=_0x55fad2(0x299),_0x2d6b86['accept']=_0x55fad2(0x266),_0x2d6b86[_0x55fad2(0x23d)]=_0x389fc3=>{const _0x52d8b6=_0x55fad2,_0x6152c3=_0x389fc3[_0x52d8b6(0x220)][_0x52d8b6(0x286)][0x0];if(!_0x6152c3)return;const _0x1df9c1=new FileReader();_0x1df9c1['onload']=_0x1816ea=>{const _0x4608c8=_0x52d8b6;try{const _0x166daa=JSON[_0x4608c8(0x29b)](_0x1816ea[_0x4608c8(0x220)][_0x4608c8(0x232)]);if(!_0x166daa[_0x4608c8(0x274)]||!Array['isArray'](_0x166daa['tables']))throw new Error(_0x4608c8(0x1dd));const _0x358b17=window[_0x4608c8(0x216)]('【警告】\x0a\x0a导入操作将完全覆盖您当前的AI指令模板和所有表格(包括结构和内容)。\x0a\x0a此操作不可逆,是否确定要继续?');if(!_0x358b17){log(_0x4608c8(0x24f),'info'),toastr[_0x4608c8(0x28f)](_0x4608c8(0x255));return;}if(_0x166daa['version']===_0x4608c8(0x2a0))saveBatchFillerRuleTemplate(_0x166daa[_0x4608c8(0x234)]||''),saveBatchFillerFlowTemplate(_0x166daa[_0x4608c8(0x27d)]||''),saveAiTemplate(_0x166daa[_0x4608c8(0x295)]||'');else{if(_0x166daa[_0x4608c8(0x28b)]!==undefined&&_0x166daa[_0x4608c8(0x287)]!==undefined)saveBatchFillerRuleTemplate(_0x166daa['aiRuleTemplate']||''),saveBatchFillerFlowTemplate(_0x166daa['aiFlowTemplate']||''),saveAiTemplate(_0x166daa[_0x4608c8(0x287)]||'');else _0x166daa['aiTemplate']?(saveBatchFillerRuleTemplate(''),saveBatchFillerFlowTemplate(_0x166daa[_0x4608c8(0x263)]||''),saveAiTemplate(_0x166daa[_0x4608c8(0x263)]||'')):log(_0x4608c8(0x275),_0x4608c8(0x23c));}const _0x4fcd0c=_0x166daa['tables'];_0x4fcd0c['forEach'](_0x473c4d=>{const _0x3bd12d=_0x4608c8;if(_0x473c4d[_0x3bd12d(0x1fc)]===undefined||_0x473c4d[_0x3bd12d(0x20a)]===undefined||_0x473c4d['rows']===undefined)throw new Error('导入的表格数据格式不正确:\x20'+JSON[_0x3bd12d(0x2b7)](_0x473c4d));if(_0x473c4d[_0x3bd12d(0x1f3)]===undefined)_0x473c4d['note']='无';if(_0x473c4d[_0x3bd12d(0x1e0)]===undefined)_0x473c4d[_0x3bd12d(0x1e0)]='允许';if(_0x473c4d[_0x3bd12d(0x21c)]===undefined)_0x473c4d[_0x3bd12d(0x21c)]='允许';if(_0x473c4d[_0x3bd12d(0x25d)]===undefined)_0x473c4d[_0x3bd12d(0x25d)]='允许';}),setMemoryState(_0x4fcd0c);const _0x3dba74=getContext();if(_0x3dba74['chat']&&_0x3dba74['chat'][_0x4608c8(0x1f8)]>0x0){const _0x201123=_0x3dba74['chat'][_0x3dba74[_0x4608c8(0x228)]['length']-0x1];saveStateToMessage(getMemoryState(),_0x201123)&&(saveChat(),log(_0x4608c8(0x1e4),_0x4608c8(0x28a)));}else saveChatDebounced();log(_0x4608c8(0x236),'success'),toastr[_0x4608c8(0x28a)]('预设已成功导入!','导入成功'),typeof _0x2618e2===_0x4608c8(0x231)&&_0x2618e2();}catch(_0x3a2e02){log(_0x4608c8(0x225)+_0x3a2e02[_0x4608c8(0x235)],_0x4608c8(0x2aa)),toastr[_0x4608c8(0x2aa)]('导入失败:'+_0x3a2e02[_0x4608c8(0x235)],'错误');}},_0x1df9c1[_0x52d8b6(0x242)](_0x6152c3);},_0x2d6b86['click']();}export function isCurrentTablesEmpty(){const _0x52fd05=_0x2c3756,_0x9ede28=getMemoryState();if(!_0x9ede28||_0x9ede28['length']===0x0)return!![];return _0x9ede28[_0x52fd05(0x2ad)](_0x1ceaec=>!_0x1ceaec[_0x52fd05(0x2a2)]||_0x1ceaec[_0x52fd05(0x2a2)][_0x52fd05(0x1f8)]===0x0);}export function clearGlobalPreset(){const _0x5b8b92=_0x2c3756;if(extension_settings[extensionName]&&extension_settings[extensionName]['global_table_preset']){const _0x4c97ca=window[_0x5b8b92(0x216)](_0x5b8b92(0x2b2));_0x4c97ca?(delete extension_settings[extensionName][_0x5b8b92(0x279)],saveSettingsDebounced(),log(_0x5b8b92(0x24b),_0x5b8b92(0x28a)),toastr[_0x5b8b92(0x28a)](_0x5b8b92(0x26f),_0x5b8b92(0x212))):(log(_0x5b8b92(0x2c4),_0x5b8b92(0x28f)),toastr[_0x5b8b92(0x28f)]('操作已取消。'));}else log(_0x5b8b92(0x2c2),_0x5b8b92(0x28f)),toastr['info'](_0x5b8b92(0x1e8),'提示');}export function importGlobalPreset(_0x5d2fad){const _0x16eaf1=_0x2c3756,_0x18b4da=document[_0x16eaf1(0x276)]('input');_0x18b4da[_0x16eaf1(0x26a)]=_0x16eaf1(0x299),_0x18b4da[_0x16eaf1(0x22c)]='.json',_0x18b4da[_0x16eaf1(0x23d)]=_0x59322b=>{const _0x390e9b=_0x16eaf1,_0x138ba1=_0x59322b['target'][_0x390e9b(0x286)][0x0];if(!_0x138ba1)return;const _0x2055be=new FileReader();_0x2055be[_0x390e9b(0x27a)]=_0x537bbb=>{const _0x743fd3=_0x390e9b;try{const _0x48bc3e=JSON['parse'](_0x537bbb[_0x743fd3(0x220)]['result']);if(!_0x48bc3e[_0x743fd3(0x274)]||!Array[_0x743fd3(0x24a)](_0x48bc3e[_0x743fd3(0x285)]))throw new Error(_0x743fd3(0x1dd));const _0xacca2d=window[_0x743fd3(0x216)]('【全局预设导入】\x0a\x0a这将把选定的预设设置为所有新聊天的默认表格。\x0a\x0a此操作将覆盖任何已存在的全局预设,是否确定?');if(!_0xacca2d){log(_0x743fd3(0x2b9),_0x743fd3(0x28f)),toastr[_0x743fd3(0x28f)](_0x743fd3(0x20e));return;}const _0x4f8f09=_0x48bc3e[_0x743fd3(0x285)][_0x743fd3(0x24d)](_0xe1d0fd=>({'name':_0xe1d0fd[_0x743fd3(0x1fc)],'headers':_0xe1d0fd[_0x743fd3(0x20a)],'note':_0xe1d0fd[_0x743fd3(0x1f3)],'rule_add':_0xe1d0fd[_0x743fd3(0x1e0)],'rule_delete':_0xe1d0fd['rule_delete'],'rule_update':_0xe1d0fd[_0x743fd3(0x25d)],'rows':[]}));!extension_settings[extensionName]&&(extension_settings[extensionName]={}),extension_settings[extensionName][_0x743fd3(0x279)]={'version':_0x48bc3e[_0x743fd3(0x274)],'tables':_0x4f8f09,'batchFillerRuleTemplate':_0x48bc3e[_0x743fd3(0x234)],'batchFillerFlowTemplate':_0x48bc3e['batchFillerFlowTemplate'],'injectionFlowTemplate':_0x48bc3e[_0x743fd3(0x295)]},saveSettingsDebounced(),log(_0x743fd3(0x21b),_0x743fd3(0x28a)),toastr['success'](_0x743fd3(0x258),_0x743fd3(0x2bb)),typeof _0x5d2fad==='function'&&_0x5d2fad();}catch(_0x30993f){log(_0x743fd3(0x257)+_0x30993f[_0x743fd3(0x235)],_0x743fd3(0x2aa)),toastr[_0x743fd3(0x2aa)](_0x743fd3(0x1ff)+_0x30993f[_0x743fd3(0x235)],'错误');}},_0x2055be['readAsText'](_0x138ba1);},_0x18b4da['click']();}
|