memory-eternal 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/lib/client.js +5 -5
- package/package.json +1 -1
- package/web/app.js +8 -8
package/lib/client.js
CHANGED
|
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var Dt=(t,l)=>{for(var d in l)at(t,d,{get:l[d],enumerable:!0})},ht=(t,l,d,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let g of Tt(l))!Rt.call(t,g)&&g!==d&&at(t,g,{get:()=>l[g],enumerable:!(x=Lt(l,g))||x.enumerable});return t};var At=(t,l,d)=>(d=t!=null?It(Bt(t)):{},ht(l||!t||!t.__esModule?at(d,"default",{value:t,enumerable:!0}):d,t)),jt=t=>ht(at({},"__esModule",{value:!0}),t);var aa={};Dt(aa,{EN:()=>Ct,MemoryLibrary:()=>_t,ZH:()=>kt,apply:()=>Et,inject:()=>Ft});module.exports=jt(aa);var o=At(require("react"),1),e=require("react/jsx-runtime"),We="memory-eternal",j="/memory-eternal/api",Ft=["settingsScope","slots","locale","connection","remote"],kt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},Ct={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},rt=["all","project","knowledge","content","prompt","business","tool","mistake"],Ue={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Re={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},nt="deepseek-harness",Ye=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":nt:d==="deepseek harness"?nt:l.split(":")[0]||nt},$t=[nt,"claude","codex","cursor","codex-desktop"],St=(t=[])=>[...new Set([...$t,...(t||[]).map(Ye)])],Ce=`
|
|
6
|
+
var zt=Object.create;var at=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var Dt=(t,l)=>{for(var d in l)at(t,d,{get:l[d],enumerable:!0})},ht=(t,l,d,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let g of Lt(l))!Bt.call(t,g)&&g!==d&&at(t,g,{get:()=>l[g],enumerable:!(x=It(l,g))||x.enumerable});return t};var Rt=(t,l,d)=>(d=t!=null?zt(Tt(t)):{},ht(l||!t||!t.__esModule?at(d,"default",{value:t,enumerable:!0}):d,t)),At=t=>ht(at({},"__esModule",{value:!0}),t);var aa={};Dt(aa,{EN:()=>kt,MemoryLibrary:()=>Ht,ZH:()=>wt,apply:()=>$t,inject:()=>jt});module.exports=At(aa);var o=Rt(require("react"),1),e=require("react/jsx-runtime"),We="memory-eternal",j="/memory-eternal/api",jt=["settingsScope","slots","locale","connection","remote"],wt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},kt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},rt=["all","project","knowledge","content","prompt","business","tool","mistake"],Ue={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},De={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},nt="deepseek-harness",Ye=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":nt:d==="deepseek harness"?nt:l.split(":")[0]||nt},Ft=[nt,"claude","codex","cursor","codex-desktop"],Ct=(t=[])=>[...new Set([...Ft,...(t||[]).map(Ye)])],Ce=`
|
|
7
7
|
.memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
|
|
8
8
|
.mc-card { background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 12px; padding: 14px 16px; }
|
|
9
9
|
.mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
|
|
@@ -129,11 +129,11 @@ var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDe
|
|
|
129
129
|
.me-graph-ctxmenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
|
|
130
130
|
.me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
|
|
131
131
|
.me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
|
|
132
|
-
`;function
|
|
132
|
+
`;function $t(t){t.effect(()=>t.locale.register(We,{zh:wt,en:kt}),"memory-eternal: locale");let l=t.locale.bind(We);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:We,order:25,label:()=>l("nav"),locale:We,inject:()=>({})},()=>o.default.createElement(Pt,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${We}:footer`,order:100,label:()=>l("nav"),locale:We,inject:()=>({})},d=>o.default.createElement(Ot,{t:l,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function Et(){let[t,l]=(0,o.useState)("http://127.0.0.1:7999/");return(0,o.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&l(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function Pt({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsx)(Mt,{t,onReload:()=>{},version:0})]})}function Ot({t,wide:l}){let[d,x]=(0,o.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${l?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>x(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(St,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(Wt,{t,onClose:()=>x(!1)})]})}function Wt({t,onClose:l,tab:d}){let[x,g]=(0,o.useState)(!1),i=Et(),S=d==="config"?`${j}/ui/config?tab=config`:d?`${i.replace(/\/$/,"")}/?tab=${d}`:i;return(0,o.useEffect)(()=>{let D=I=>{I.key==="Escape"&&l()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[l]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:l,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsx)("div",{className:"me-modal",onClick:D=>D.stopPropagation(),style:x?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>g(D=>!D),"aria-label":t(x?"exitFullscreen":"enterFullscreen"),title:t(x?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:x?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:l,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{src:S,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function St(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}function Ht({t,inModal:l,onClose:d,onFull:x,full:g}){let[i,S]=(0,o.useState)(null),[D,I]=(0,o.useState)([]),[k,L]=(0,o.useState)(!0),[y,N]=(0,o.useState)(""),[F,A]=(0,o.useState)("all"),[f,$]=(0,o.useState)(""),[Y,Se]=(0,o.useState)("all"),[O,K]=(0,o.useState)("all"),[E,le]=(0,o.useState)(()=>{try{let c=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),z={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(c&&z[c])return z[c]}catch{}return"cards"}),[te,he]=(0,o.useState)("recent"),[h,u]=(0,o.useState)(null),w=(0,o.useRef)(null),H=(0,o.useRef)(null),[_,Q]=(0,o.useState)(!1),[ee,q]=(0,o.useState)(null),[Z,xe]=(0,o.useState)(!1),[pe,Ke]=(0,o.useState)(!0),[we,ne]=(0,o.useState)(null),[re,m]=(0,o.useState)(0),P=(0,o.useCallback)(()=>m(c=>c+1),[]),U=(0,o.useRef)(null),[se,be]=(0,o.useState)(100),Ie=(0,o.useRef)(null),Le=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(E!=="cards")return;let c=Ie.current,z=Le.current;if(!c)return;let a=new IntersectionObserver(ae=>{ae[0]&&ae[0].isIntersecting&&be(ye=>ye+24)},{root:z||null,rootMargin:"400px"});return a.observe(c),()=>a.disconnect()},[E,D,F,f]);let Ee=(0,o.useCallback)(async(c=F,z=f,a=O)=>{try{L(!0),N("");let ae=new URLSearchParams;c&&c!=="all"&&ae.set("kind",c),z.trim()&&ae.set("q",z.trim()),ae.set("status",a||"all"),ae.set("limit","500");let Te=await(await fetch(`${j}/cards?${ae.toString()}`)).json();Te.ok&&(I(Te.cards||[]),be(100))}catch(ae){N(String(ae&&ae.message?ae.message:ae))}finally{L(!1)}},[F,f,O]),de=(0,o.useCallback)(async()=>{try{let[c,z]=await Promise.all([fetch(`${j}/overview`).then(a=>a.json()),fetch(`${j}/cards?status=all&limit=500`).then(a=>a.json())]);c.ok&&S(c),z.ok&&(I(z.cards||[]),be(100))}catch(c){N(String(c&&c.message?c.message:c))}finally{L(!1)}},[]),Re=async c=>{try{let a=await(await fetch(`${j}/delete?path=${encodeURIComponent(c)}`)).json();a.ok?(u({ok:!0,msg:t("deleted")}),await de()):u({ok:!1,msg:a.error||t("deleteFail")})}catch{u({ok:!1,msg:t("deleteFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)};(0,o.useEffect)(()=>(de(),()=>{U.current&&clearTimeout(U.current)}),[de]);let oe=c=>{$(c),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>Ee(F,c,O),280)},qe=c=>{A(c),Ee(c,f,O)};(0,o.useEffect)(()=>{Ee(F,f,O)},[O]);let ve=async c=>{try{let a=await(await fetch(`${j}/card?path=${encodeURIComponent(c.path||c.id)}`)).json();a.ok&&q({path:a.path,title:c.title,text:a.text})}catch(z){N(String(z&&z.message?z.message:z))}},r=async(c,z)=>{Q(!0);try{let a=await fetch(`${j}/export`);if(!a.ok)throw new Error("HTTP "+a.status);let ae=await a.json();if(!ae.ok)throw new Error(ae.error||"export failed");let ye,Te,Xe;c==="json"?(Te="memory-vault.json",Xe="application/json",ye=JSON.stringify(ae.cards.map(Be=>({path:Be.path,title:Be.title,kind:Be.kind,text:Be.text})),null,2)):(Te="memory-vault.md",Xe="text/markdown;charset=utf-8",ye=ae.cards.map(Be=>Be.text.trim()).filter(Boolean).join(`
|
|
133
133
|
|
|
134
134
|
---
|
|
135
135
|
|
|
136
|
-
`));let je=new Blob([ye],{type:Xe}),Fe=await ea(je,Te,!1);if(!Fe.ok){u({ok:!1,msg:t("exportFail")}),Q(!1);return}u({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(a){u({ok:!1,msg:t("exportFail")+" \xB7 "+(a.message||"")})}finally{Q(!1)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2600)},n=async c=>{let z=c.target.files&&c.target.files[0];if(c.target.value="",!!z){try{let a=await z.text(),ye=await(await fetch(`${j}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:a})).json();ye.ok?(await de(),u({ok:!0,msg:t("importedVault")+"\uFF1A"+(ye.imported||0)+(ye.skipped?t("importedSkipped")+ye.skipped:"")})):u({ok:!1,msg:ye.error||t("importFail")})}catch{u({ok:!1,msg:t("importFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2400)}},M=(0,o.useMemo)(()=>{let c=R.slice();return Y!=="all"&&(c=c.filter(z=>Ye(z.submittedBy)===Y)),O!=="all"&&(c=c.filter(z=>(z.status||"approved")===O)),te==="title"?c.sort((z,a)=>String(z.title||"").localeCompare(String(a.title||""))):te==="hot"?c.sort((z,a)=>(a.weight||a.links||0)-(z.weight||z.links||0)):c.sort((z,a)=>new Date(a.updated||0).getTime()-new Date(z.updated||0).getTime()),c},[R,te,Y,O]),V=(0,o.useMemo)(()=>[...new Set(R.map(c=>Ye(c.submittedBy)))],[R]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ce}),h&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(h.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:h.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:h.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:h.msg})]}),l&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(Mt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),x&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:x,"aria-label":t(g?"exitFull":"fullscreen"),children:g?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${pe?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ke(c=>!c),"aria-label":t(pe?"collapse":"expand"),title:t(pe?"collapse":"expand"),children:pe?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="cards"?" active":""}`,onClick:()=>re("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="graph"?" active":""}`,onClick:()=>re("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="stats"?" active":""}`,onClick:()=>re("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="audit"?" active":""}`,onClick:()=>re("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F6E1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="optimize"?" active":""}`,onClick:()=>re("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F5D1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="config"?" active":""}`,onClick:()=>re("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Le,children:[F==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(He,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(He,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(He,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(He,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(He,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(He,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:f,onChange:c=>ie(c.target.value)}),(0,e.jsx)("input",{ref:H,type:"file",accept:".json,application/json",style:{display:"none"},onChange:n}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>H.current&&H.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ne({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:_,onClick:()=>r("md"),children:t(_?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:_,onClick:()=>r("json"),children:t(_?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(),children:t("refresh")})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[rt.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${$===c?" active":""}`,onClick:()=>qe(c),children:t(c==="all"?"all":Re[c])},c)),(0,e.jsxs)("select",{value:Y,onChange:c=>Se(c.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),St(V).map(c=>(0,e.jsx)("option",{value:c,children:c},c))]}),(0,e.jsxs)("select",{value:O,onChange:c=>K(c.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${te===c.key?" active":""}`,onClick:()=>he(c.key),children:c.label},c.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),F==="cards"?k&&!R.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):R.length===0?(0,e.jsx)("div",{className:"mc-empty",children:t("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:M.slice(0,se).map(c=>(0,e.jsx)(Kt,{card:c,t,query:f.trim(),onOpen:ve,onDelete:De},c.path))}),M.length>se&&(0,e.jsx)("div",{ref:Ie,style:{height:1}})]}):F==="graph"?(0,e.jsx)(Vt,{t,onOpen:ve,all:Z,onAllChange:xe,onMutate:P,active:F==="graph"}):F==="config"?(0,e.jsx)(Nt,{t,onReload:()=>de(),version:oe}):F==="stats"?(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}):F==="audit"?(0,e.jsx)(Ut,{t,onReload:()=>de(),version:oe}):F==="optimize"?(0,e.jsx)(Yt,{t,onReload:()=>de(),version:oe}):(0,e.jsx)(xt,{t,tab:"stats",onReload:()=>de(),version:oe}),ee&&(0,e.jsx)(Xt,{t,card:ee,query:f.trim(),onClose:()=>q(null),onDelete:c=>{q(null),De(c)},onFeedback:c=>{let z=ee.path;fetch(`${j}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:f.trim(),path:z,useful:c})}).then(()=>u({ok:!0,msg:t(c?"fbUseful":"fbIrr")})).catch(()=>{}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}}),(0,e.jsx)(qt,{t,newCard:we,setNewCard:ne,onCreated:()=>{de(),P(),u({ok:!0,msg:t("created")}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}})]})]})]})}var He=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]});function Nt({t,onReload:l,version:d,compact:x}){let[g,i]=(0,o.useState)(null),[S,R]=(0,o.useState)(0),[I,k]=(0,o.useState)(null),[L,y]=(0,o.useState)(null),[N,$]=(0,o.useState)(!1),[A,f]=(0,o.useState)(null),[E,Y]=(0,o.useState)(null),[Se,O]=(0,o.useState)(""),[K,F]=(0,o.useState)(""),[re,te]=(0,o.useState)(""),[he,h]=(0,o.useState)(""),[u,w]=(0,o.useState)(null),H=(0,o.useRef)(null),_=(m,P=!0)=>{H.current&&clearTimeout(H.current),w({msg:m,ok:P}),H.current=setTimeout(()=>w(null),1900)},Q=(0,o.useCallback)(async()=>{try{let[m,P,U]=await Promise.all([fetch(`${j}/config`).then(se=>se.json()).catch(()=>null),fetch(`${j}/setup-status`).then(se=>se.json()).catch(()=>null),fetch(`${j}/budget`).then(se=>se.json()).catch(()=>null)]);m&&m.ok?(i(m),R(m.revision??0),k(m.schema??null),y({...m.config??{}}),f(m.dsh??null),$(m.writable===!1),O("")):U&&U.ok?(y({...U}),$(!0),O(t("configNeedsDsh"))):O(t("adminLoadFail")),P&&P.ok&&Y(P),te("")}catch{O(t("adminLoadFail"))}},[t]);(0,o.useEffect)(()=>{Q()},[d,Q]);let ee=(m,P)=>y(U=>({...U??{},[m]:P})),q=m=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[m]||m,Z=async()=>{if(L){if(N){_(t("editInSetting"),!1);return}F("save");try{let P=await(await fetch(`${j}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:L,expectedRevision:S})})).json();if(P&&P.ok){let U=P.note||t("savedOk");te(t("savedOk")+(P.note?` \xB7 ${P.note}`:"")),_(U),await Q()}else O(P?.error||t("saveFail")),_(P?.error||t("saveFail"),!1)}catch{O(t("saveFail")),_(t("saveFail"),!1)}finally{F("")}}},xe=()=>{y({...g?.config??{}}),te("")},pe={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},Ke=async m=>{let P=pe[m];P&&y(U=>({...U??{},...P}))},we=async(m,P)=>{F(m+P);try{let se=await(await fetch(`${j}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:m,action:P})})).json();se&&se.ok?_(P==="install"?`\u2705 ${m} MCP \u5DF2\u5B89\u88C5`:`\u2705 ${m} MCP \u5DF2\u5378\u8F7D`):_(`\u274C ${m} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A${se?.error||""}`,!1);try{let be=await fetch(`${j}/setup-status`).then(Ie=>Ie.json());be&&be.ok&&Y(be)}catch{}}catch{_(t("mergeFail"),!1)}finally{F("")}},ne=({k:m,label:P,type:U="text",step:se,min:be,max:Ie})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:P||m}),(0,e.jsx)("input",{type:U,step:se,min:be,max:Ie,value:L?L[m]??"":"",onChange:Le=>ee(m,U==="number"?Number(Le.target.value):Le.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),oe=({k:m,label:P})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(L&&L[m]),onChange:U=>ee(m,U.target.checked)}),(0,e.jsx)("span",{children:P||m})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:x?"0 0 auto":1,minHeight:0,maxHeight:x?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ce}),u&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(u.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:u.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:u.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:u.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[Se&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",Se]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",t("retry")]})]}),N&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),re&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",re]}),g&&(g.version||g.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:g.dsh?.label||t("nav")}),g.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",g.version]}),g.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",g.dsh.vaultDir]})]}),E&&E.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:E.agents.map(m=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:m.isDsh?m.label||"DeepSeek Harness":m.name}),m.isDsh&&m.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",m.version]}),!m.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),m.installed&&m.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),m.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),m.mcpConfigured===!0&&m.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),m.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",m.recallTool?t("enabled"):t("disabled"),")"]})]}),m.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",m.hook]}),!m.isDsh&&m.installed&&m.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!K,onClick:()=>we(m.name,"install"),children:t("installMcp")}),!m.isDsh&&m.installed&&m.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!K,onClick:()=>{window.confirm(t("uninstallConfirm"))&&we(m.name,"uninstall")},children:t("uninstallMcp")})]},m.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),he&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:he})})]}),L?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(m=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ke(m),disabled:!!K,children:[m==="A"?"\u{1F7E2} ":m==="B"?"\u{1F4B0} ":"\u2B50 ",pe[m].label]},m))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(oe,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(oe,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(ne,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(ne,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(ne,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(ne,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(ne,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(oe,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(oe,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(oe,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(ne,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(ne,{k:"recallMinScore",label:t("recallMinScore"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:L.auditMode??"all",onChange:m=>ee("auditMode",m.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(vt,{label:t("auditExemptAgents"),value:L.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(E?.agents||[]).filter(m=>!m.isDsh).map(m=>({value:m.name,label:m.name}))],onChange:m=>ee("auditExemptAgents",m)}),(0,e.jsx)(vt,{label:t("auditExemptKinds"),value:L.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...rt.filter(m=>m!=="all").map(m=>({value:m,label:t(Re[m])}))],onChange:m=>ee("auditExemptKinds",m)}),(0,e.jsx)(ne,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(oe,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:L.autoWebMode??"init",onChange:m=>ee("autoWebMode",m.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(ne,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(ne,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(ne,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(oe,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(oe,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:xe,disabled:!!K,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:Z,disabled:!!K||K==="save"||N,children:K==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Ut({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)([]),[R,I]=(0,o.useState)("all"),[k,L]=(0,o.useState)("all"),[y,N]=(0,o.useState)(""),[$,A]=(0,o.useState)(new Set),[f,E]=(0,o.useState)(""),[Y,Se]=(0,o.useState)("pending"),O=[...new Set([...x,...i].map(h=>h.submittedBy).filter(Boolean))],K=(0,o.useCallback)(async()=>{try{let h=await fetch(`${j}/audit/list`).then(u=>u.json());h.ok&&(g(h.pending||[]),S(h.rejected||[]),A(new Set))}catch{}},[]);(0,o.useEffect)(()=>{K()},[d,K]);let F=(Y==="pending"?x:i).filter(h=>{if(R!=="all"&&h.kind!==R||k!=="all"&&Ye(h.submittedBy)!==k)return!1;if(y){let u=(h.created||"").slice(0,10);if(u&&u!==y)return!1}return!0}),re=h=>A(u=>{let w=new Set(u);return w.has(h)?w.delete(h):w.add(h),w}),te=async(h,u)=>{E("apply");try{for(let w of u||[...$])await fetch(`${j}/${h==="approved"?"audit/approve":h==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(w)}${h==="delete"?"&permanent=0":""}`);await K(),l&&l()}catch{}finally{E("")}},he=[...$];return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:R,onChange:h=>I(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),rt.filter(h=>h!=="all").map(h=>(0,e.jsx)("option",{value:h,children:t(Re[h])},h))]}),(0,e.jsxs)("select",{value:k,onChange:h=>L(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),St(O).map(h=>(0,e.jsx)("option",{value:h,children:h},h))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:h=>N(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${Y==="pending"?" me-on":""}`,onClick:()=>Se("pending"),children:[t("pending"),"\uFF08",x.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${Y==="rejected"?" me-on":""}`,onClick:()=>Se("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:F.length>0&&he.length===F.length,onChange:h=>{h.target.checked?A(new Set(F.map(u=>u.path))):A(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!he.length||!!f,onClick:()=>te("approved"),children:["\u2713 ",t(Y==="rejected"?"restore":"approve")]}),Y==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!f,onClick:()=>te("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!f,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete")},children:["\u{1F5D1} ",t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9"]})]}),F.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:F.map(h=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:$.has(h.path),onChange:()=>re(h.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[h.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ye(h.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:h.created?h.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:h.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:h.severity==="high"?"#f87171":"#9ca3af"},children:h.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.reason||"-"}),Y==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te("approved",[h.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>te("rejected",[h.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>te("approved",[h.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete",[h.path])},children:"\u{1F5D1}"})]})]},h.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Yt({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)(""),R=(0,o.useCallback)(async()=>{try{let k=await fetch(`${j}/recycle/list`).then(L=>L.json());k.ok&&g(k.items||[])}catch{}},[]);(0,o.useEffect)(()=>{R()},[d,R]);let I=async(k,L)=>{S(k+L);try{k==="restore"?await fetch(`${j}/recycle/restore?path=${encodeURIComponent(L)}`):k==="purge"&&await fetch(`${j}/recycle/purge?path=${encodeURIComponent(L)}`),await R(),l&&l()}catch{}finally{S("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i,onClick:async()=>{S("purgeAll");try{await fetch(`${j}/recycle/purge-expired?days=0`),await R()}catch{}finally{S("")}},children:t("emptyRecycle")})]}),x.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:x.map(k=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[k.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(k.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>I("restore",k.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&I("purge",k.path)},children:t("purge")})]},k.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Kt=({card:t,t:l,onOpen:d,query:x,onDelete:g})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[t.kind]||Ue.other}}),x?wt(t.title,x):t.title,Qt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#f59e0b"},children:l("statusPending")}),t.status==="rejected"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#ef4444"},children:l("statusRejected")}),(!t.status||t.status==="approved")&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#10b981"},children:l("statusApproved")})]}),(0,e.jsx)("p",{children:x?wt(t.summary||"",x):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsx)("span",{className:"mc-tag",children:i},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:l(Re[t.kind])}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ye(t.submittedBy)]}),(0,e.jsx)("span",{children:zt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&g&&g(t.path)},children:"\u2715"})]})]});function xt({t,tab:l,onReload:d,version:x}){let[g,i]=(0,o.useState)(null),[S,R]=(0,o.useState)(""),[I,k]=(0,o.useState)(null),[L,y]=(0,o.useState)(null),[N,$]=(0,o.useState)(""),[A,f]=(0,o.useState)(""),[E,Y]=(0,o.useState)(!1),Se=(0,o.useCallback)(async()=>{if(N){$("");return}try{let u=await fetch(`${j}/todayBrief`).then(w=>w.json());$(u.ok&&u.brief||"")}catch{}},[N]),O=(0,o.useCallback)(async()=>{if(!(!I||!I.merge||!I.merge.length)&&window.confirm(t("mergeAllConfirm"))){f("merge");try{let u={},w=q=>u[q]===void 0?q:u[q]=w(u[q]),H=(q,Z)=>{u[w(q)]=w(Z)},_=new Set;for(let q of I.merge)_.add(q.a.path),_.add(q.b.path),H(q.a.path,q.b.path);let Q={};for(let q of _){let Z=w(q);(Q[Z]=Q[Z]||[]).push(q)}let ee=0;for(let q of Object.values(Q)){if(q.length<2)continue;(await fetch(`${j}/merge?paths=${encodeURIComponent(q.join(","))}`).then(xe=>xe.json())).ok&&ee++}await K(),d&&d()}catch{}f("")}},[I,K,d,t]);async function K(){try{let u=await Promise.all([fetch(`${j}/stats`),fetch(`${j}/budget`)]),[w,H]=await Promise.all(u.map(_=>_.json()));w.ok&&i(w),H.ok&&y(H),R(w.ok?"":t("adminLoadFail"))}catch{R(t("adminLoadFail"))}}let F=(0,o.useCallback)(async()=>{f("scan");try{let u=await fetch(`${j}/optimize`).then(w=>w.json());u.ok&&k(u)}catch{R(t("adminLoadFail"))}finally{f("")}},[t]);(0,o.useEffect)(()=>{K()},[x]);let re=async(u,w)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${j}/merge?paths=${encodeURIComponent(u+","+w)}`).then(_=>_.json())).ok&&(await K(),d&&d())}catch{}},te=async u=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${j}/delete?path=${encodeURIComponent(u)}`).then(H=>H.json())).ok&&(await K(),d&&d())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],h=({title:u,kind:w,updated:H,path:_})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[w]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:zt(H)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te(_),children:[t("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[S&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",S]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:K,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Se,children:N?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),N&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:N})]}),g&&(0,e.jsxs)(e.Fragment,{children:[g.trend&&g.trend.length>0&&(()=>{let u=g.trend,w=Math.max(...u.map(ee=>ee.count),1),H=260,_=50,Q=H/u.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:H,height:_,style:{display:"block",width:"100%",height:50},children:u.map((ee,q)=>{let Z=Math.round(ee.count/w*(_-4));return(0,e.jsx)("rect",{x:q*Q+1,y:_-Z,width:Math.max(Q-2,2),height:Z,rx:1.5,fill:ee.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:ee.count>0?.85:.35},ee.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:he.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[u]||"#666"}}),t(Re[u]),": ",g.byKind?.[u]||0]},u))})]}),L&&(L.budgetChars||L.recallLimit||L.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:L.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:L.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",L.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",g.todayCards?.length||0,"\uFF09"]}),g.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:g.todayCards.map(u=>(0,e.jsx)(h,{title:u.title,kind:u.kind,updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!A,onClick:F,children:A==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),I&&I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){f("oneclick");try{let u=JSON.stringify({cleanupStale:E}),H=await(await fetch(`${j}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:u})).json();H&&H.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${H.plan.merged} ${t("optimizedMerged")}${E?` \xB7 ${H.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await K(),d&&d(),k(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{f("")}}},children:A==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),I&&I.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:E,onChange:u=>Y(u.target.checked)}),t("oneClickAlsoStale")]})]}),!I&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),I&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:O,children:t(A==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),I.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:I.merge.map((u,w)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[u.a.title," \u21C4 ",u.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(u.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>re(u.a.path,u.b.path),children:t("mergeNow")})]},w))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",I.stale?.length||0,"\uFF09"]}),I.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!A,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;f("clean");let u=0;for(let w of I.stale)try{await fetch(`${j}/delete?path=${encodeURIComponent(w.path)}`),u++}catch{}f(""),notify(`${u} ${t("deletedStale")}`),await K(),d&&d()},children:t("cleanStale")})}),I.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.stale.map(u=>(0,e.jsx)(h,{title:u.title,kind:"other",updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var lt=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
136
|
+
`));let je=new Blob([ye],{type:Xe}),Fe=await ea(je,Te,!1);if(!Fe.ok){u({ok:!1,msg:t("exportFail")}),Q(!1);return}u({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(a){u({ok:!1,msg:t("exportFail")+" \xB7 "+(a.message||"")})}finally{Q(!1)}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2600)},n=async c=>{let z=c.target.files&&c.target.files[0];if(c.target.value="",!!z){try{let a=await z.text(),ye=await(await fetch(`${j}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:a})).json();ye.ok?(await de(),u({ok:!0,msg:t("importedVault")+"\uFF1A"+(ye.imported||0)+(ye.skipped?t("importedSkipped")+ye.skipped:"")})):u({ok:!1,msg:ye.error||t("importFail")})}catch{u({ok:!1,msg:t("importFail")})}w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2400)}},M=(0,o.useMemo)(()=>{let c=D.slice();return Y!=="all"&&(c=c.filter(z=>Ye(z.submittedBy)===Y)),O!=="all"&&(c=c.filter(z=>(z.status||"approved")===O)),te==="title"?c.sort((z,a)=>String(z.title||"").localeCompare(String(a.title||""))):te==="hot"?c.sort((z,a)=>(a.weight||a.links||0)-(z.weight||z.links||0)):c.sort((z,a)=>new Date(a.updated||0).getTime()-new Date(z.updated||0).getTime()),c},[D,te,Y,O]),V=(0,o.useMemo)(()=>[...new Set(D.map(c=>Ye(c.submittedBy)))],[D]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ce}),h&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(h.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:h.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:h.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:h.msg})]}),l&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(St,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),x&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:x,"aria-label":t(g?"exitFull":"fullscreen"),children:g?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${pe?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ke(c=>!c),"aria-label":t(pe?"collapse":"expand"),title:t(pe?"collapse":"expand"),children:pe?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="cards"?" active":""}`,onClick:()=>le("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="graph"?" active":""}`,onClick:()=>le("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="stats"?" active":""}`,onClick:()=>le("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="audit"?" active":""}`,onClick:()=>le("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F6E1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="optimize"?" active":""}`,onClick:()=>le("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F5D1}\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${E==="config"?" active":""}`,onClick:()=>le("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),pe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Le,children:[E==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(He,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(He,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(He,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(He,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(He,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(He,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),E==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:f,onChange:c=>oe(c.target.value)}),(0,e.jsx)("input",{ref:H,type:"file",accept:".json,application/json",style:{display:"none"},onChange:n}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>H.current&&H.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ne({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:_,onClick:()=>r("md"),children:t(_?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:_,onClick:()=>r("json"),children:t(_?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(),children:t("refresh")})]}),E==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[rt.map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${F===c?" active":""}`,onClick:()=>qe(c),children:t(c==="all"?"all":De[c])},c)),(0,e.jsxs)("select",{value:Y,onChange:c=>Se(c.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Ct(V).map(c=>(0,e.jsx)("option",{value:c,children:c},c))]}),(0,e.jsxs)("select",{value:O,onChange:c=>K(c.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(c=>(0,e.jsx)("button",{type:"button",className:`mc-chip${te===c.key?" active":""}`,onClick:()=>he(c.key),children:c.label},c.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),(0,e.jsx)("div",{style:{display:E==="cards"?"contents":"none"},children:k?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):y?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(),children:t("retry")})]}):D.length===0?(0,e.jsx)("div",{className:"mc-empty",children:t("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:M.slice(0,se).map(c=>(0,e.jsx)(Yt,{card:c,t,query:f.trim(),onOpen:ve,onDelete:Re},c.path))}),M.length>se&&(0,e.jsx)("div",{ref:Ie,style:{height:1}})]})}),(0,e.jsx)("div",{style:{display:E==="graph"?"flex":"none",flex:1,minHeight:0},children:(0,e.jsx)(Vt,{t,onOpen:ve,all:Z,onAllChange:xe,onMutate:P,active:!0})}),(0,e.jsx)("div",{style:{display:E==="config"?"contents":"none"},children:(0,e.jsx)(Mt,{t,onReload:()=>de(),version:re})}),(0,e.jsx)("div",{style:{display:E==="stats"?"contents":"none"},children:(0,e.jsx)(Kt,{t,tab:"stats",onReload:()=>de(),version:re})}),(0,e.jsx)("div",{style:{display:E==="audit"?"contents":"none"},children:(0,e.jsx)(_t,{t,onReload:()=>de(),version:re})}),(0,e.jsx)("div",{style:{display:E==="optimize"?"contents":"none"},children:(0,e.jsx)(Ut,{t,onReload:()=>de(),version:re})}),ee&&(0,e.jsx)(Xt,{t,card:ee,query:f.trim(),onClose:()=>q(null),onDelete:c=>{q(null),Re(c)},onFeedback:c=>{let z=ee.path;fetch(`${j}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:f.trim(),path:z,useful:c})}).then(()=>u({ok:!0,msg:t(c?"fbUseful":"fbIrr")})).catch(()=>{}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}}),(0,e.jsx)(qt,{t,newCard:we,setNewCard:ne,onCreated:()=>{de(),P(),u({ok:!0,msg:t("created")}),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>u(null),2e3)}})]})]})]})}var He=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]});function Mt({t,onReload:l,version:d,compact:x}){let[g,i]=(0,o.useState)(null),[S,D]=(0,o.useState)(0),[I,k]=(0,o.useState)(null),[L,y]=(0,o.useState)(null),[N,F]=(0,o.useState)(!1),[A,f]=(0,o.useState)(null),[$,Y]=(0,o.useState)(null),[Se,O]=(0,o.useState)(""),[K,E]=(0,o.useState)(""),[le,te]=(0,o.useState)(""),[he,h]=(0,o.useState)(""),[u,w]=(0,o.useState)(null),H=(0,o.useRef)(null),_=(m,P=!0)=>{H.current&&clearTimeout(H.current),w({msg:m,ok:P}),H.current=setTimeout(()=>w(null),1900)},Q=(0,o.useCallback)(async()=>{try{let[m,P,U]=await Promise.all([fetch(`${j}/config`).then(se=>se.json()).catch(()=>null),fetch(`${j}/setup-status`).then(se=>se.json()).catch(()=>null),fetch(`${j}/budget`).then(se=>se.json()).catch(()=>null)]);m&&m.ok?(i(m),D(m.revision??0),k(m.schema??null),y({...m.config??{}}),f(m.dsh??null),F(m.writable===!1),O("")):U&&U.ok?(y({...U}),F(!0),O(t("configNeedsDsh"))):O(t("adminLoadFail")),P&&P.ok&&Y(P),te("")}catch{O(t("adminLoadFail"))}},[t]);(0,o.useEffect)(()=>{Q()},[d,Q]);let ee=(m,P)=>y(U=>({...U??{},[m]:P})),q=m=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[m]||m,Z=async()=>{if(L){if(N){_(t("editInSetting"),!1);return}E("save");try{let P=await(await fetch(`${j}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:L,expectedRevision:S})})).json();if(P&&P.ok){let U=P.note||t("savedOk");te(t("savedOk")+(P.note?` \xB7 ${P.note}`:"")),_(U),await Q()}else O(P?.error||t("saveFail")),_(P?.error||t("saveFail"),!1)}catch{O(t("saveFail")),_(t("saveFail"),!1)}finally{E("")}}},xe=()=>{y({...g?.config??{}}),te("")},pe={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},Ke=async m=>{let P=pe[m];P&&y(U=>({...U??{},...P}))},we=async(m,P)=>{E(m+P);try{let se=await(await fetch(`${j}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:m,action:P})})).json();se&&se.ok?_(P==="install"?`\u2705 ${m} MCP \u5DF2\u5B89\u88C5`:`\u2705 ${m} MCP \u5DF2\u5378\u8F7D`):_(`\u274C ${m} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A${se?.error||""}`,!1);try{let be=await fetch(`${j}/setup-status`).then(Ie=>Ie.json());be&&be.ok&&Y(be)}catch{}}catch{_(t("mergeFail"),!1)}finally{E("")}},ne=({k:m,label:P,type:U="text",step:se,min:be,max:Ie})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:P||m}),(0,e.jsx)("input",{type:U,step:se,min:be,max:Ie,value:L?L[m]??"":"",onChange:Le=>ee(m,U==="number"?Number(Le.target.value):Le.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),re=({k:m,label:P})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(L&&L[m]),onChange:U=>ee(m,U.target.checked)}),(0,e.jsx)("span",{children:P||m})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:x?"0 0 auto":1,minHeight:0,maxHeight:x?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ce}),u&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(u.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:u.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:u.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:u.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[Se&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",Se]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",t("retry")]})]}),N&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),le&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",le]}),g&&(g.version||g.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:g.dsh?.label||t("nav")}),g.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",g.version]}),g.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",g.dsh.vaultDir]})]}),$&&$.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:$.agents.map(m=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:m.isDsh?m.label||"DeepSeek Harness":m.name}),m.isDsh&&m.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",m.version]}),!m.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),m.installed&&m.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),m.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),m.mcpConfigured===!0&&m.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),m.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",m.recallTool?t("enabled"):t("disabled"),")"]})]}),m.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",m.hook]}),!m.isDsh&&m.installed&&m.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!K,onClick:()=>we(m.name,"install"),children:t("installMcp")}),!m.isDsh&&m.installed&&m.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!K,onClick:()=>{window.confirm(t("uninstallConfirm"))&&we(m.name,"uninstall")},children:t("uninstallMcp")})]},m.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),he&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:he})})]}),L?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(m=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ke(m),disabled:!!K,children:[m==="A"?"\u{1F7E2} ":m==="B"?"\u{1F4B0} ":"\u2B50 ",pe[m].label]},m))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(re,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(re,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(ne,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(ne,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(ne,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(ne,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(ne,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(re,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(re,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(re,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(ne,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(ne,{k:"recallMinScore",label:t("recallMinScore"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:L.auditMode??"all",onChange:m=>ee("auditMode",m.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(xt,{label:t("auditExemptAgents"),value:L.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...($?.agents||[]).filter(m=>!m.isDsh).map(m=>({value:m.name,label:m.name}))],onChange:m=>ee("auditExemptAgents",m)}),(0,e.jsx)(xt,{label:t("auditExemptKinds"),value:L.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...rt.filter(m=>m!=="all").map(m=>({value:m,label:t(De[m])}))],onChange:m=>ee("auditExemptKinds",m)}),(0,e.jsx)(ne,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(re,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:L.autoWebMode??"init",onChange:m=>ee("autoWebMode",m.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(ne,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(ne,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(ne,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(re,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(re,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:xe,disabled:!!K,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:Z,disabled:!!K||K==="save"||N,children:K==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function _t({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)([]),[D,I]=(0,o.useState)("all"),[k,L]=(0,o.useState)("all"),[y,N]=(0,o.useState)(""),[F,A]=(0,o.useState)(new Set),[f,$]=(0,o.useState)(""),[Y,Se]=(0,o.useState)("pending"),O=[...new Set([...x,...i].map(h=>h.submittedBy).filter(Boolean))],K=(0,o.useCallback)(async()=>{try{let h=await fetch(`${j}/audit/list`).then(u=>u.json());h.ok&&(g(h.pending||[]),S(h.rejected||[]),A(new Set))}catch{}},[]);(0,o.useEffect)(()=>{K()},[d,K]);let E=(Y==="pending"?x:i).filter(h=>{if(D!=="all"&&h.kind!==D||k!=="all"&&Ye(h.submittedBy)!==k)return!1;if(y){let u=(h.created||"").slice(0,10);if(u&&u!==y)return!1}return!0}),le=h=>A(u=>{let w=new Set(u);return w.has(h)?w.delete(h):w.add(h),w}),te=async(h,u)=>{$("apply");try{for(let w of u||[...F])await fetch(`${j}/${h==="approved"?"audit/approve":h==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(w)}${h==="delete"?"&permanent=0":""}`);await K(),l&&l()}catch{}finally{$("")}},he=[...F];return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:D,onChange:h=>I(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),rt.filter(h=>h!=="all").map(h=>(0,e.jsx)("option",{value:h,children:t(De[h])},h))]}),(0,e.jsxs)("select",{value:k,onChange:h=>L(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),Ct(O).map(h=>(0,e.jsx)("option",{value:h,children:h},h))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:h=>N(h.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${Y==="pending"?" me-on":""}`,onClick:()=>Se("pending"),children:[t("pending"),"\uFF08",x.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${Y==="rejected"?" me-on":""}`,onClick:()=>Se("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:E.length>0&&he.length===E.length,onChange:h=>{h.target.checked?A(new Set(E.map(u=>u.path))):A(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!he.length||!!f,onClick:()=>te("approved"),children:["\u2713 ",t(Y==="rejected"?"restore":"approve")]}),Y==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!f,onClick:()=>te("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!f,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete")},children:["\u{1F5D1} ",t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9"]})]}),E.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:E.map(h=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:F.has(h.path),onChange:()=>le(h.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[h.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ye(h.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:h.created?h.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:h.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:h.severity==="high"?"#f87171":"#9ca3af"},children:h.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.reason||"-"}),Y==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te("approved",[h.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>te("rejected",[h.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>te("approved",[h.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete")||"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&te("delete",[h.path])},children:"\u{1F5D1}"})]})]},h.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Ut({t,onReload:l,version:d}){let[x,g]=(0,o.useState)([]),[i,S]=(0,o.useState)(""),D=(0,o.useCallback)(async()=>{try{let k=await fetch(`${j}/recycle/list`).then(L=>L.json());k.ok&&g(k.items||[])}catch{}},[]);(0,o.useEffect)(()=>{D()},[d,D]);let I=async(k,L)=>{S(k+L);try{k==="restore"?await fetch(`${j}/recycle/restore?path=${encodeURIComponent(L)}`):k==="purge"&&await fetch(`${j}/recycle/purge?path=${encodeURIComponent(L)}`),await D(),l&&l()}catch{}finally{S("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i,onClick:async()=>{S("purgeAll");try{await fetch(`${j}/recycle/purge-expired?days=0`),await D()}catch{}finally{S("")}},children:t("emptyRecycle")})]}),x.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:x.map(k=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[k.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(k.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>I("restore",k.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&I("purge",k.path)},children:t("purge")})]},k.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Yt=({card:t,t:l,onOpen:d,query:x,onDelete:g})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[t.kind]||Ue.other}}),x?vt(t.title,x):t.title,Qt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#f59e0b"},children:l("statusPending")}),t.status==="rejected"&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#ef4444"},children:l("statusRejected")}),(!t.status||t.status==="approved")&&(0,e.jsx)("span",{className:"mc-status",style:{background:"#10b981"},children:l("statusApproved")})]}),(0,e.jsx)("p",{children:x?vt(t.summary||"",x):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsx)("span",{className:"mc-tag",children:i},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:l(De[t.kind])}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ye(t.submittedBy)]}),(0,e.jsx)("span",{children:Nt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&g&&g(t.path)},children:"\u2715"})]})]});function Kt({t,tab:l,onReload:d,version:x}){let[g,i]=(0,o.useState)(null),[S,D]=(0,o.useState)(""),[I,k]=(0,o.useState)(null),[L,y]=(0,o.useState)(null),[N,F]=(0,o.useState)(""),[A,f]=(0,o.useState)(""),[$,Y]=(0,o.useState)(!1),Se=(0,o.useCallback)(async()=>{if(N){F("");return}try{let u=await fetch(`${j}/todayBrief`).then(w=>w.json());F(u.ok&&u.brief||"")}catch{}},[N]),O=(0,o.useCallback)(async()=>{if(!(!I||!I.merge||!I.merge.length)&&window.confirm(t("mergeAllConfirm"))){f("merge");try{let u={},w=q=>u[q]===void 0?q:u[q]=w(u[q]),H=(q,Z)=>{u[w(q)]=w(Z)},_=new Set;for(let q of I.merge)_.add(q.a.path),_.add(q.b.path),H(q.a.path,q.b.path);let Q={};for(let q of _){let Z=w(q);(Q[Z]=Q[Z]||[]).push(q)}let ee=0;for(let q of Object.values(Q)){if(q.length<2)continue;(await fetch(`${j}/merge?paths=${encodeURIComponent(q.join(","))}`).then(xe=>xe.json())).ok&&ee++}await K(),d&&d()}catch{}f("")}},[I,K,d,t]);async function K(){try{let u=await Promise.all([fetch(`${j}/stats`),fetch(`${j}/budget`)]),[w,H]=await Promise.all(u.map(_=>_.json()));w.ok&&i(w),H.ok&&y(H),D(w.ok?"":t("adminLoadFail"))}catch{D(t("adminLoadFail"))}}let E=(0,o.useCallback)(async()=>{f("scan");try{let u=await fetch(`${j}/optimize`).then(w=>w.json());u.ok&&k(u)}catch{D(t("adminLoadFail"))}finally{f("")}},[t]);(0,o.useEffect)(()=>{K()},[x]);let le=async(u,w)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${j}/merge?paths=${encodeURIComponent(u+","+w)}`).then(_=>_.json())).ok&&(await K(),d&&d())}catch{}},te=async u=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${j}/delete?path=${encodeURIComponent(u)}`).then(H=>H.json())).ok&&(await K(),d&&d())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],h=({title:u,kind:w,updated:H,path:_})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[w]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:Nt(H)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>te(_),children:[t("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[S&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",S]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:K,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Se,children:N?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),N&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:N})]}),g&&(0,e.jsxs)(e.Fragment,{children:[g.trend&&g.trend.length>0&&(()=>{let u=g.trend,w=Math.max(...u.map(ee=>ee.count),1),H=260,_=50,Q=H/u.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:H,height:_,style:{display:"block",width:"100%",height:50},children:u.map((ee,q)=>{let Z=Math.round(ee.count/w*(_-4));return(0,e.jsx)("rect",{x:q*Q+1,y:_-Z,width:Math.max(Q-2,2),height:Z,rx:1.5,fill:ee.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:ee.count>0?.85:.35},ee.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:g.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:he.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[u]||"#666"}}),t(De[u]),": ",g.byKind?.[u]||0]},u))})]}),L&&(L.budgetChars||L.recallLimit||L.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:L.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:L.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",L.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",g.todayCards?.length||0,"\uFF09"]}),g.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:g.todayCards.map(u=>(0,e.jsx)(h,{title:u.title,kind:u.kind,updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!A,onClick:E,children:A==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),I&&I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){f("oneclick");try{let u=JSON.stringify({cleanupStale:$}),H=await(await fetch(`${j}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:u})).json();H&&H.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${H.plan.merged} ${t("optimizedMerged")}${$?` \xB7 ${H.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await K(),d&&d(),k(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{f("")}}},children:A==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),I&&I.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:$,onChange:u=>Y(u.target.checked)}),t("oneClickAlsoStale")]})]}),!I&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),I&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!A,onClick:O,children:t(A==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),I.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:I.merge.map((u,w)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[u.a.title," \u21C4 ",u.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(u.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>le(u.a.path,u.b.path),children:t("mergeNow")})]},w))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",I.stale?.length||0,"\uFF09"]}),I.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!A,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;f("clean");let u=0;for(let w of I.stale)try{await fetch(`${j}/delete?path=${encodeURIComponent(w.path)}`),u++}catch{}f(""),notify(`${u} ${t("deletedStale")}`),await K(),d&&d()},children:t("cleanStale")})}),I.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.stale.map(u=>(0,e.jsx)(h,{title:u.title,kind:"other",updated:u.updated,path:u.path},u.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var lt=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
137
137
|
|
|
138
138
|
## \u80CC\u666F
|
|
139
139
|
- \u95EE\u9898\u63CF\u8FF0
|
|
@@ -178,8 +178,8 @@ var It=Object.create;var at=Object.defineProperty;var Lt=Object.getOwnPropertyDe
|
|
|
178
178
|
-
|
|
179
179
|
|
|
180
180
|
## \u98CE\u9669/\u963B\u585E
|
|
181
|
-
- `}];function qt({t,newCard:l,setNewCard:d,onCreated:x}){if(!l)return null;let g=lt.find(y=>y.key===l.template),i=l.body||(g?g.body:""),S=l.kind||(g?g.kind:"knowledge"),R=l.tags||(g?g.tags.join(", "):""),I=l._creating,k=y=>{let N=lt.find($=>$.key===y);d($=>({...$,template:y,kind:N?N.kind:$.kind,body:N?N.body:$.body,tags:N?N.tags.join(", "):$.tags}))},L=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${j}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||"\u65E0\u6807\u9898",kind:S,tags:R.split(",").map(N=>N.trim()).filter(Boolean),body:i,source:"manual"})}).then(N=>N.json())).ok?(d(null),x&&x()):d(N=>({...N,_creating:!1}))}catch{d(N=>({...N,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[lt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>k(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:S,onChange:y=>d(N=>({...N,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(N=>({...N,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:R,onChange:y=>d(N=>({...N,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(N=>({...N,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:I,onClick:L,children:t(I?"exporting":"createCard")})})]})]})]})}function Xt({t,card:l,query:d,onClose:x,onDelete:g,onFeedback:i}){(0,o.useEffect)(()=>{let k=L=>{L.key==="Escape"&&x()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[x]);let[S,R]=(0,o.useState)(!1),I=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:x,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",onClick:k=>k.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),I&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>R(k=>!k),children:t(S?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&g&&g(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:x,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:S?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ta(l.text)}})]})]})}function Vt({t,onOpen:l,all:d,onAllChange:x,onMutate:g,active:i}){let[S,R]=(0,o.useState)(null),[I,k]=(0,o.useState)(""),L=(0,o.useRef)(!1),y=(0,o.useCallback)(async()=>{try{L.current=!1;let f=await(await fetch(`${j}/graph${d?"?all=1":""}`)).json();f.ok?(R(f),k(""),L.current=!0):(R(null),k(f.error||t("error")))}catch(A){k(String(A&&A.message?A.message:A))}},[d,t]);(0,o.useEffect)(()=>{if(!i||L.current)return;let A=!0;return fetch(`${j}/graph${d?"?all=1":""}`).then(f=>f.json()).then(f=>{A&&(f.ok?(R(f),k(""),L.current=!0):(R(null),k(f.error||t("error"))))}).catch(f=>{A&&k(String(f&&f.message?f.message:f))}),()=>{A=!1}},[d,t,i]);let N=(0,o.useCallback)(async A=>{try{let E=await(await fetch(`${j}/delete?path=${encodeURIComponent(A)}`)).json();return E&&E.ok?(await y(),g&&g(),!0):!1}catch{return!1}},[y]),$=(0,o.useCallback)(async A=>{if(!A||A.length<2)return!1;try{let f=await fetch(`${j}/merge?paths=${encodeURIComponent(A.join(","))}`).then(E=>E.json());return f&&f.ok?(await y(),g&&g(),!0):!1}catch{return!1}},[y,g]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ce}),I&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",I]}),!S&&!I&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),S&&S.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),S&&S.nodes.length>0&&(0,e.jsx)(Jt,{nodes:S.nodes,edges:S.edges,onOpen:l,onDelete:N,onMerge:$,t,all:d,onAllChange:x,countLabel:`${S.nodes.length} ${t("nodes")} \xB7 ${Gt(S.edges)} ${t("edges")}`})]})}function Gt(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var _e={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Jt({nodes:t,edges:l,onOpen:d,onDelete:x,onMerge:g,t:i,countLabel:S,all:R,onAllChange:I}){let k=(0,o.useRef)(null),L=(0,o.useRef)(null),y=(0,o.useRef)(null),N=(0,o.useRef)(null),$=(0,o.useRef)(null),A=(0,o.useRef)(d);(0,o.useEffect)(()=>{A.current=d},[d]);let f=(0,o.useRef)(x);(0,o.useEffect)(()=>{f.current=x},[x]);let E=(0,o.useRef)(g);(0,o.useEffect)(()=>{E.current=g},[g]);let[Y,Se]=(0,o.useState)(""),[O,K]=(0,o.useState)(null),F=(0,o.useRef)("");(0,o.useEffect)(()=>{F.current=Y.trim().toLowerCase()},[Y]),(0,o.useEffect)(()=>{let r=y.current;if(!r)return;let n=Y.trim().toLowerCase();if(!n)return;let M=r.nodes.find(V=>(V.name||"").toLowerCase().includes(n));M&&(y.current.selectedId=M.id,K(M.id),r.panX=r.w/2-M.x*r.zoom,r.panY=r.h/2-M.y*r.zoom,r.render&&r.render())},[Y]);let[re,te]=(0,o.useState)("all"),[he,h]=(0,o.useState)(!1),u=(0,o.useRef)("all"),[w,H]=(0,o.useState)(""),_=(0,o.useRef)(""),[Q,ee]=(0,o.useState)(!1),q=(0,o.useRef)(!1),[Z,xe]=(0,o.useState)(null);(0,o.useEffect)(()=>{u.current=re},[re]),(0,o.useEffect)(()=>{_.current=w},[w]),(0,o.useEffect)(()=>{q.current=Q},[Q]);let pe=(0,o.useMemo)(()=>{let r=new Map;for(let n of t)for(let M of n.tags||[]){let V=String(M).trim();V&&r.set(V,(r.get(V)||0)+1)}return[...r.entries()].sort((n,M)=>M[1]-n[1]).slice(0,24).map(([n,M])=>({tag:n,n:M}))},[t]),Ke=(()=>{let r=Y.trim().toLowerCase();return!!r&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(r)||String(n.kind||"").toLowerCase().includes(r)||String(Re[n.kind]||"").toLowerCase().includes(r))})();(0,o.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[Y]),(0,o.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[re,w,Q]);let we=(0,o.useRef)(null),[ne,oe]=(0,o.useState)([]),[m,P]=(0,o.useState)(null),[U,se]=(0,o.useState)(!1),[be,Ie]=(0,o.useState)(null),[Le,Ee]=(0,o.useState)(""),de=(0,o.useRef)(null),De=(0,o.useRef)(null),ie=(r,n=!0)=>{de.current&&clearTimeout(de.current),Ie({msg:r,ok:n}),de.current=setTimeout(()=>Ie(null),1900)},qe=r=>{Ee(r),De.current&&clearTimeout(De.current),De.current=setTimeout(()=>Ee(""),1600)};(0,o.useEffect)(()=>()=>{de.current&&clearTimeout(de.current),De.current&&clearTimeout(De.current)},[]);let ve=(0,o.useMemo)(()=>t.reduce((r,n)=>(r[n.id]=n,r),{}),[t]);return(0,o.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let n=r.getContext("2d");if(!n)return;let M=Math.max(1,window.devicePixelRatio||1),V=()=>document.documentElement.getAttribute("data-theme")==="dark",c={};l.forEach(s=>{c[s.source]=(c[s.source]||0)+1,c[s.target]=(c[s.target]||0)+1});let z=Math.max(1,...Object.values(c)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(c[s.id]||0)/z*8),x:0,y:0,vx:0,vy:0})),edges:l.map(s=>({sourceNodeId:s.source,targetNodeId:s.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:M,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,v)=>(s[v.id]=v,s),{}),a.nodes.forEach((s,v)=>{let b=v/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(b)*60,s.y=Math.sin(b)*60});let ae=[...new Set(a.nodes.map(s=>s.type))];a.clustered=ae.length>1,a.typeCenters={},ae.forEach((s,v)=>{let b=v/ae.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(b)*160,y:Math.sin(b)*160}}),y.current=a;let ye=()=>{let s=r.clientWidth,v=r.clientHeight;a.w=s,a.h=v,r.width=s*M,r.height=v*M,n.setTransform(M,0,0,M,0,0)};ye();let Te=new ResizeObserver(ye);Te.observe(r.parentElement);let Xe=(s,v)=>s&&s.length>v?s.slice(0,v)+"\u2026":s,je=(s,v,b,C)=>{if(n.beginPath(),C==="rect")n.rect(s-b,v-b*.75,b*2,b*1.5);else if(C==="diamond")n.moveTo(s,v-b),n.lineTo(s+b,v),n.lineTo(s,v+b),n.lineTo(s-b,v),n.closePath();else if(C==="hexagon"){for(let T=0;T<6;T++){let X=Math.PI/3*T-Math.PI/2,W=s+b*Math.cos(X),me=v+b*Math.sin(X);T===0?n.moveTo(W,me):n.lineTo(W,me)}n.closePath()}else n.arc(s,v,b,0,Math.PI*2)},Fe=()=>{if(!a.nodes.length)return;let s=1/0,v=-1/0,b=1/0,C=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),v=Math.max(v,p.x),b=Math.min(b,p.y),C=Math.max(C,p.y)});let T=20,X=v-s+T*2,W=C-b+T*2,me=Math.min(a.w/X,a.h/W);a.zoom=Math.max(.35,Math.min(1.8,me)),a.panX=a.w/2-(s+v)/2*a.zoom,a.panY=a.h/2-(b+C)/2*a.zoom};N.current=Fe;let Be=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=F.current,a.kindFilter=u.current,a.timeMode=q.current,a.tagFilter=_.current;let s=a.tagFilter,v=a.kindFilter,b=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");n.save(),n.strokeStyle=V()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let p=0;p<a.w;p+=24)n.beginPath(),n.moveTo(p,0),n.lineTo(p,a.h),n.stroke();for(let p=0;p<a.h;p+=24)n.beginPath(),n.moveTo(0,p),n.lineTo(a.w,p),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let C={};a.nodes.forEach(p=>C[p.id]=p);let T=a.nodes.length>40,X=T?1.5:.55,W=a.selectedId||a.hoverId;a.edges.forEach(p=>{let G=C[p.sourceNodeId],B=C[p.targetNodeId];if(!G||!B)return;if(v!=="all"){let et=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,fe=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(et!==v&&fe!==v)return}if(s){let et=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),fe=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!et&&!fe)return}let D=B.x-G.x,J=B.y-G.y,le=Math.sqrt(D*D+J*J)||1,ce=T?12:18,ue=-J/le*ce,ge=D/le*ce,Me=(G.x+B.x)/2+ue,Ne=(G.y+B.y)/2+ge,ze=_e.colors[a.domainById[G.id]&&a.domainById[G.id].kind||"other"],$e=W&&(p.sourceNodeId===W||p.targetNodeId===W),ot=W?$e?.6:.08:T?.14:.24,it=parseInt(ze.slice(1,3),16),Ge=parseInt(ze.slice(3,5),16),Qe=parseInt(ze.slice(5,7),16);n.strokeStyle="rgba("+it+","+Ge+","+Qe+","+ot+")",n.lineWidth=$e?1.6+(p.weight||1):.8+(p.weight||1)*.5,n.beginPath(),n.moveTo(G.x,G.y),n.quadraticCurveTo(Me,Ne,B.x,B.y),n.stroke()});let me=[];if(a.nodes.forEach(p=>{let G=a.domainById[p.id]||{},B=G.kind||"other",D=a.timeMode?Zt(G.updated):_e.colors[B],J=_e.shapes[B],le=a.selectedId===p.id,ce=a.hoverId===p.id,ue=a.searchTerm||"",ge=!ue||(p.name||"").toLowerCase().includes(ue)||String(Re[B]||"").toLowerCase().includes(ue)||String(B).toLowerCase().includes(ue),Me=v==="all"||B===v,Ne=!s||(G.tags||[]).includes(s),ze=W&&p.id!==W&&!a.edges.some(fe=>fe.sourceNodeId===W&&fe.targetNodeId===p.id||fe.targetNodeId===W&&fe.sourceNodeId===p.id)||ue&&!ge||!Me||!Ne;n.save(),n.globalAlpha=ze?.08:1,(le||ce)&&(n.shadowColor=D,n.shadowBlur=le?20:14),je(p.x,p.y,p.r,J);let $e=parseInt(D.slice(1,3),16),ot=parseInt(D.slice(3,5),16),it=parseInt(D.slice(5,7),16),Ge=n.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);Ge.addColorStop(0,"rgba("+Math.min(255,$e+70)+","+Math.min(255,ot+70)+","+Math.min(255,it+70)+",0.95)"),Ge.addColorStop(1,D),n.fillStyle=Ge,n.fill(),n.restore(),le?(n.save(),je(p.x,p.y,p.r+3,J),n.strokeStyle=D,n.lineWidth=3,n.shadowColor=D,n.shadowBlur=12,n.stroke(),n.restore()):ce?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle=D,n.lineWidth=2,n.stroke(),n.restore()):ue&&ge?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(p.id)>=0&&(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Qe=Xe(p.name,16);if((le||ce||a.zoom>X||!T&&a.zoom>.6)&&Me&&Ne){let fe=1/a.zoom;n.font="500 "+(12*fe).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ae=n.measureText(Qe).width+16*fe,tt=18*fe,Pe=p.y+p.r+8*fe,yt=!0;for(let Oe of me)if(p.x-Ae/2<Oe.x+Oe.w&&p.x+Ae/2>Oe.x&&Pe<Oe.y+Oe.h&&Pe+tt>Oe.y){yt=!1;break}if(!yt&&!le&&!ce)return;me.push({x:p.x-Ae/2,y:Pe,w:Ae,h:tt}),n.fillStyle=V()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(p.x-Ae/2,Pe,Ae,tt,4*fe):n.rect(p.x-Ae/2,Pe,Ae,tt),n.fill(),n.strokeStyle=V()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*fe,n.stroke(),n.fillStyle=V()?le||ce?"#eee":"#bbb":le||ce?"#111":"#444",n.textAlign="center",n.fillText(Qe,p.x,Pe+13*fe)}}),n.restore(),a.marquee){let p=a.marquee,G=Math.min(p.sx,p.ex),B=Math.min(p.sy,p.ey),D=Math.abs(p.ex-p.sx),J=Math.abs(p.ey-p.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(G,B,D,J),n.strokeRect(G,B,D,J),n.restore()}if(a.hoverId&&we.current){let p=a.domainById[a.hoverId],G=a.nodes.find(function(B){return B.id===a.hoverId});if(p&&G){let B=a.edges.filter(function(le){return le.sourceNodeId===p.id||le.targetNodeId===p.id}).length,D=G.x*a.zoom+a.panX,J=G.y*a.zoom+a.panY;we.current.style.display="block",we.current.style.left=D+14+"px",we.current.style.top=J-6+"px",we.current.innerHTML="<b>"+b(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+b(p.kind||"")+" \xB7 "+B+" \u8FDE\u63A5</span>"}}else we.current&&(we.current.style.display="none")},ke=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(dt))};a.wake=ke,a.render=Be;let st=()=>{let s=a.nodes.length;a.tickCount++;let b=.9-Math.min(.4,a.tickCount/1500),C=s>1e3?3e3:s>100?2e3:s>50?1200:800,T=s>100?.002:.005,X=s>1e3?.012:s>100?.005:.01,W=s>1e3?6:s>200?12:24,me={};a.nodes.forEach(B=>me[B.id]=B);for(let B=0;B<s;B++){if(a.dragNode===a.nodes[B])continue;let D=a.nodes[B],J=0,le=0;for(let ge=0;ge<s;ge++){if(B===ge)continue;let Me=D.x-a.nodes[ge].x,Ne=D.y-a.nodes[ge].y,ze=Math.sqrt(Me*Me+Ne*Ne)||1,$e=C/(ze*ze);J+=Me/ze*$e,le+=Ne/ze*$e}if(a.clustered&&a.typeCenters[D.type]){let ge=a.typeCenters[D.type];J+=(ge.x-D.x)*.006,le+=(ge.y-D.y)*.006}else J-=D.x*X,le-=D.y*X;let ce=(D.vx+J)*b,ue=(D.vy+le)*b;ce=Math.max(-W,Math.min(W,ce)),ue=Math.max(-W,Math.min(W,ue)),D.vx=ce,D.vy=ue}a.edges.forEach(B=>{let D=me[B.sourceNodeId],J=me[B.targetNodeId];if(!D||!J)return;let le=J.x-D.x,ce=J.y-D.y,ue=Math.sqrt(le*le+ce*ce)||1,ge=(ue-100)*T,Me=le/ue*ge,Ne=ce/ue*ge;a.dragNode!==D&&(D.vx+=Me,D.vy+=Ne),a.dragNode!==J&&(J.vx-=Me,J.vy-=Ne)});let p=0;a.nodes.forEach(B=>{a.dragNode!==B&&(B.x+=B.vx,B.y+=B.vy,p+=B.vx*B.vx+B.vy*B.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Fe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},dt=()=>{if(a.running){try{st(),Be()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(dt)}},Ve=(s,v)=>{let b=r.getBoundingClientRect();return{x:(s-b.left-a.panX)/a.zoom,y:(v-b.top-a.panY)/a.zoom}},Je=s=>{let v=a.domainById[s];return!(!v||u.current!=="all"&&v.kind!==u.current||_.current&&!(v.tags||[]).includes(_.current))},Ze=(s,v,b)=>Math.max(v,Math.min(b,s)),ct=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+36){b=T.id;break}}b!==a.hoverId&&(a.hoverId=b,ke())},pt=s=>{if(s.button!==0)return;let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+25){b=T;break}}if(s.shiftKey){if(b){a.shiftClick=b.id;return}a.marquee={sx:s.clientX,sy:s.clientY,ex:s.clientX,ey:s.clientY};return}a.dragStart={x:s.clientX,y:s.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=b||null,b&&(a.dragOffset={dx:b.x-v.x,dy:b.y-v.y})},mt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ke();return}if(!a.dragStart)return;let v=s.clientX-a.dragStart.x,b=s.clientY-a.dragStart.y;if(Math.abs(v)+Math.abs(b)>3&&(a.dragging=!0),a.dragNode){let C=Ve(s.clientX,s.clientY);a.dragNode.x=C.x+a.dragOffset.dx,a.dragNode.y=C.y+a.dragOffset.dy,ke()}else a.dragging&&(a.panX=Ze(a.dragStart.px+v,-1e5,1e5),a.panY=Ze(a.dragStart.py+b,-1e5,1e5),ke())},ut=s=>{if(a.marquee){let b=a.marquee;a.marquee=null;let C=r.getBoundingClientRect(),T=Math.min(b.sx,b.ex)-C.left,X=Math.max(b.sx,b.ex)-C.left,W=Math.min(b.sy,b.ey)-C.top,me=Math.max(b.sy,b.ey)-C.top,p=a.nodes.filter(G=>{let B=G.x*a.zoom+a.panX,D=G.y*a.zoom+a.panY;return B>=T&&B<=X&&D>=W&&D<=me}).map(G=>G.id);a.multi=p,oe(p),ke();return}let v=a.dragStart&&!a.dragging;if(a.shiftClick){let b=a.shiftClick;a.shiftClick=null;let C=Array.isArray(a.multi)?a.multi.slice():[];C.includes(b)||C.push(b),a.multi=C,oe(C),ke();return}if(v){let b=Ve(s.clientX,s.clientY),C=null;for(let T=a.nodes.length-1;T>=0;T--){let X=a.nodes[T];if(!Je(X.id))continue;let W=X.x-b.x,me=X.y-b.y;if(W*W+me*me<X.r*X.r+20){C=X;break}}C?(a.selectedId=C.id,K(C.id),ke()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],oe([])),K(null),ke())}a.dragStart=null,a.dragging=!1,a.dragNode=null},gt=s=>{s.preventDefault();let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+25){b=T;break}}if(b){let C=a.domainById[b.id];C&&xe({x:s.clientX,y:s.clientY,id:b.id,path:C.id,title:C.title})}else xe(null)},ft=s=>{s.preventDefault();let v=r.getBoundingClientRect(),b=(s.clientX-v.left-a.panX)/a.zoom,C=(s.clientY-v.top-a.panY)/a.zoom,T=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=Ze(a.panX+b*(a.zoom-T),-1e5,1e5),a.panY=Ze(a.panY+C*(a.zoom-T),-1e5,1e5),a.zoom=T,ke()};r.addEventListener("mousemove",ct),r.addEventListener("mousedown",pt),window.addEventListener("mousemove",mt),window.addEventListener("mouseup",ut),r.addEventListener("wheel",ft,{passive:!1}),r.addEventListener("contextmenu",gt),$.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],oe([]),Fe(),ke()};for(let s=0;s<200;s++)st();Fe(),ke();let bt=()=>h(!1);return window.addEventListener("mousedown",bt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Te.disconnect(),r.removeEventListener("mousemove",ct),r.removeEventListener("mousedown",pt),window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",ut),r.removeEventListener("wheel",ft),r.removeEventListener("contextmenu",gt),window.removeEventListener("mousedown",bt)}},[t,l]),(0,e.jsxs)("div",{className:"me-graph",ref:L,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:Y,onChange:r=>Se(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>h(r=>!r),"aria-expanded":he,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",re!=="all"||Q||w?"\u25CF":"\u25BE"]}),he&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${re==="all"&&!Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{te("all"),ee(!1)},children:i("all")}),Object.keys(Ue).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${re===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>te(n=>n===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[r]||Ue[r]}}),i(Re[r])]},r)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ee(r=>!r),children:["\u23F1 ",i("timeDim")]}),pe.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:pe.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${w===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>H(n=>n===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(re!=="all"||Q||w)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{te("all"),ee(!1),H("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!R,onChange:r=>I&&I(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${Q?" me-on":""}`,onClick:()=>ee(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(n=>{n&&P({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>N.current&&N.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{K(null),te("all"),$.current&&$.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:we,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Ke&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),Z&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),Z&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:Z.x,top:Z.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{A.current({path:Z.path,title:Z.title}),xe(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Z.id&&(y.current.selectedId=Z.id,K(Z.id)),xe(null);let r=y.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(Z.title||"")}catch{}xe(null),ie(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,n=r&&Array.isArray(r.multi)?r.multi.slice():[],M=Z.id;if(M&&!n.includes(M)&&n.push(M),xe(null),n.length<2){ie(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let V=E.current&&E.current(n);V&&V.then?V.then(c=>c?ie(i("merged")):ie(i("mergeFail"),!1)).catch(()=>ie(i("mergeFail"),!1)):V&&ie(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Z.path;xe(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(f.current?await f.current(r):!1)?ie(i("deleted")):ie(i("deleteFail"),!1)}catch{ie(i("deleteFail"),!1)}})()},children:i("delete")})]}),ne.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[ne.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=ne.map(z=>ve[z]).filter(Boolean).map(z=>z.title||z.name).join(`
|
|
182
|
-
`),M=new Blob([n],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(M),c=document.createElement("a");c.href=V,c.download="memory-selected.txt",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(V),1e3),
|
|
181
|
+
- `}];function qt({t,newCard:l,setNewCard:d,onCreated:x}){if(!l)return null;let g=lt.find(y=>y.key===l.template),i=l.body||(g?g.body:""),S=l.kind||(g?g.kind:"knowledge"),D=l.tags||(g?g.tags.join(", "):""),I=l._creating,k=y=>{let N=lt.find(F=>F.key===y);d(F=>({...F,template:y,kind:N?N.kind:F.kind,body:N?N.body:F.body,tags:N?N.tags.join(", "):F.tags}))},L=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${j}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||"\u65E0\u6807\u9898",kind:S,tags:D.split(",").map(N=>N.trim()).filter(Boolean),body:i,source:"manual"})}).then(N=>N.json())).ok?(d(null),x&&x()):d(N=>({...N,_creating:!1}))}catch{d(N=>({...N,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[lt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>k(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:S,onChange:y=>d(N=>({...N,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(N=>({...N,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:D,onChange:y=>d(N=>({...N,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(N=>({...N,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:I,onClick:L,children:t(I?"exporting":"createCard")})})]})]})]})}function Xt({t,card:l,query:d,onClose:x,onDelete:g,onFeedback:i}){(0,o.useEffect)(()=>{let k=L=>{L.key==="Escape"&&x()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[x]);let[S,D]=(0,o.useState)(!1),I=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:x,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",onClick:k=>k.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),I&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>D(k=>!k),children:t(S?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&g&&g(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:x,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:S?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ta(l.text)}})]})]})}function Vt({t,onOpen:l,all:d,onAllChange:x,onMutate:g,active:i}){let[S,D]=(0,o.useState)(null),[I,k]=(0,o.useState)(""),L=(0,o.useRef)(!1),y=(0,o.useCallback)(async()=>{try{L.current=!1;let f=await(await fetch(`${j}/graph${d?"?all=1":""}`)).json();f.ok?(D(f),k(""),L.current=!0):(D(null),k(f.error||t("error")))}catch(A){k(String(A&&A.message?A.message:A))}},[d,t]);(0,o.useEffect)(()=>{if(!i||L.current)return;let A=!0;return fetch(`${j}/graph${d?"?all=1":""}`).then(f=>f.json()).then(f=>{A&&(f.ok?(D(f),k(""),L.current=!0):(D(null),k(f.error||t("error"))))}).catch(f=>{A&&k(String(f&&f.message?f.message:f))}),()=>{A=!1}},[d,t,i]);let N=(0,o.useCallback)(async A=>{try{let $=await(await fetch(`${j}/delete?path=${encodeURIComponent(A)}`)).json();return $&&$.ok?(await y(),g&&g(),!0):!1}catch{return!1}},[y]),F=(0,o.useCallback)(async A=>{if(!A||A.length<2)return!1;try{let f=await fetch(`${j}/merge?paths=${encodeURIComponent(A.join(","))}`).then($=>$.json());return f&&f.ok?(await y(),g&&g(),!0):!1}catch{return!1}},[y,g]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ce}),I&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",I]}),!S&&!I&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),S&&S.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),S&&S.nodes.length>0&&(0,e.jsx)(Jt,{nodes:S.nodes,edges:S.edges,onOpen:l,onDelete:N,onMerge:F,t,all:d,onAllChange:x,countLabel:`${S.nodes.length} ${t("nodes")} \xB7 ${Gt(S.edges)} ${t("edges")}`})]})}function Gt(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var _e={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Jt({nodes:t,edges:l,onOpen:d,onDelete:x,onMerge:g,t:i,countLabel:S,all:D,onAllChange:I}){let k=(0,o.useRef)(null),L=(0,o.useRef)(null),y=(0,o.useRef)(null),N=(0,o.useRef)(null),F=(0,o.useRef)(null),A=(0,o.useRef)(d);(0,o.useEffect)(()=>{A.current=d},[d]);let f=(0,o.useRef)(x);(0,o.useEffect)(()=>{f.current=x},[x]);let $=(0,o.useRef)(g);(0,o.useEffect)(()=>{$.current=g},[g]);let[Y,Se]=(0,o.useState)(""),[O,K]=(0,o.useState)(null),E=(0,o.useRef)("");(0,o.useEffect)(()=>{E.current=Y.trim().toLowerCase()},[Y]),(0,o.useEffect)(()=>{let r=y.current;if(!r)return;let n=Y.trim().toLowerCase();if(!n)return;let M=r.nodes.find(V=>(V.name||"").toLowerCase().includes(n));M&&(y.current.selectedId=M.id,K(M.id),r.panX=r.w/2-M.x*r.zoom,r.panY=r.h/2-M.y*r.zoom,r.render&&r.render())},[Y]);let[le,te]=(0,o.useState)("all"),[he,h]=(0,o.useState)(!1),u=(0,o.useRef)("all"),[w,H]=(0,o.useState)(""),_=(0,o.useRef)(""),[Q,ee]=(0,o.useState)(!1),q=(0,o.useRef)(!1),[Z,xe]=(0,o.useState)(null);(0,o.useEffect)(()=>{u.current=le},[le]),(0,o.useEffect)(()=>{_.current=w},[w]),(0,o.useEffect)(()=>{q.current=Q},[Q]);let pe=(0,o.useMemo)(()=>{let r=new Map;for(let n of t)for(let M of n.tags||[]){let V=String(M).trim();V&&r.set(V,(r.get(V)||0)+1)}return[...r.entries()].sort((n,M)=>M[1]-n[1]).slice(0,24).map(([n,M])=>({tag:n,n:M}))},[t]),Ke=(()=>{let r=Y.trim().toLowerCase();return!!r&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(r)||String(n.kind||"").toLowerCase().includes(r)||String(De[n.kind]||"").toLowerCase().includes(r))})();(0,o.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[Y]),(0,o.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[le,w,Q]);let we=(0,o.useRef)(null),[ne,re]=(0,o.useState)([]),[m,P]=(0,o.useState)(null),[U,se]=(0,o.useState)(!1),[be,Ie]=(0,o.useState)(null),[Le,Ee]=(0,o.useState)(""),de=(0,o.useRef)(null),Re=(0,o.useRef)(null),oe=(r,n=!0)=>{de.current&&clearTimeout(de.current),Ie({msg:r,ok:n}),de.current=setTimeout(()=>Ie(null),1900)},qe=r=>{Ee(r),Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>Ee(""),1600)};(0,o.useEffect)(()=>()=>{de.current&&clearTimeout(de.current),Re.current&&clearTimeout(Re.current)},[]);let ve=(0,o.useMemo)(()=>t.reduce((r,n)=>(r[n.id]=n,r),{}),[t]);return(0,o.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let n=r.getContext("2d");if(!n)return;let M=Math.max(1,window.devicePixelRatio||1),V=()=>document.documentElement.getAttribute("data-theme")==="dark",c={};l.forEach(s=>{c[s.source]=(c[s.source]||0)+1,c[s.target]=(c[s.target]||0)+1});let z=Math.max(1,...Object.values(c)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(c[s.id]||0)/z*8),x:0,y:0,vx:0,vy:0})),edges:l.map(s=>({sourceNodeId:s.source,targetNodeId:s.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:M,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,v)=>(s[v.id]=v,s),{}),a.nodes.forEach((s,v)=>{let b=v/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(b)*60,s.y=Math.sin(b)*60});let ae=[...new Set(a.nodes.map(s=>s.type))];a.clustered=ae.length>1,a.typeCenters={},ae.forEach((s,v)=>{let b=v/ae.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(b)*160,y:Math.sin(b)*160}}),y.current=a;let ye=()=>{let s=r.clientWidth,v=r.clientHeight;a.w=s,a.h=v,r.width=s*M,r.height=v*M,n.setTransform(M,0,0,M,0,0)};ye();let Te=new ResizeObserver(ye);Te.observe(r.parentElement);let Xe=(s,v)=>s&&s.length>v?s.slice(0,v)+"\u2026":s,je=(s,v,b,C)=>{if(n.beginPath(),C==="rect")n.rect(s-b,v-b*.75,b*2,b*1.5);else if(C==="diamond")n.moveTo(s,v-b),n.lineTo(s+b,v),n.lineTo(s,v+b),n.lineTo(s-b,v),n.closePath();else if(C==="hexagon"){for(let T=0;T<6;T++){let X=Math.PI/3*T-Math.PI/2,W=s+b*Math.cos(X),me=v+b*Math.sin(X);T===0?n.moveTo(W,me):n.lineTo(W,me)}n.closePath()}else n.arc(s,v,b,0,Math.PI*2)},Fe=()=>{if(!a.nodes.length)return;let s=1/0,v=-1/0,b=1/0,C=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),v=Math.max(v,p.x),b=Math.min(b,p.y),C=Math.max(C,p.y)});let T=20,X=v-s+T*2,W=C-b+T*2,me=Math.min(a.w/X,a.h/W);a.zoom=Math.max(.35,Math.min(1.8,me)),a.panX=a.w/2-(s+v)/2*a.zoom,a.panY=a.h/2-(b+C)/2*a.zoom};N.current=Fe;let Be=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=E.current,a.kindFilter=u.current,a.timeMode=q.current,a.tagFilter=_.current;let s=a.tagFilter,v=a.kindFilter,b=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");n.save(),n.strokeStyle=V()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let p=0;p<a.w;p+=24)n.beginPath(),n.moveTo(p,0),n.lineTo(p,a.h),n.stroke();for(let p=0;p<a.h;p+=24)n.beginPath(),n.moveTo(0,p),n.lineTo(a.w,p),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let C={};a.nodes.forEach(p=>C[p.id]=p);let T=a.nodes.length>40,X=T?1.5:.55,W=a.selectedId||a.hoverId;a.edges.forEach(p=>{let G=C[p.sourceNodeId],B=C[p.targetNodeId];if(!G||!B)return;if(v!=="all"){let et=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,fe=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(et!==v&&fe!==v)return}if(s){let et=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),fe=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!et&&!fe)return}let R=B.x-G.x,J=B.y-G.y,ie=Math.sqrt(R*R+J*J)||1,ce=T?12:18,ue=-J/ie*ce,ge=R/ie*ce,Me=(G.x+B.x)/2+ue,Ne=(G.y+B.y)/2+ge,ze=_e.colors[a.domainById[G.id]&&a.domainById[G.id].kind||"other"],$e=W&&(p.sourceNodeId===W||p.targetNodeId===W),ot=W?$e?.6:.08:T?.14:.24,it=parseInt(ze.slice(1,3),16),Ge=parseInt(ze.slice(3,5),16),Qe=parseInt(ze.slice(5,7),16);n.strokeStyle="rgba("+it+","+Ge+","+Qe+","+ot+")",n.lineWidth=$e?1.6+(p.weight||1):.8+(p.weight||1)*.5,n.beginPath(),n.moveTo(G.x,G.y),n.quadraticCurveTo(Me,Ne,B.x,B.y),n.stroke()});let me=[];if(a.nodes.forEach(p=>{let G=a.domainById[p.id]||{},B=G.kind||"other",R=a.timeMode?Zt(G.updated):_e.colors[B],J=_e.shapes[B],ie=a.selectedId===p.id,ce=a.hoverId===p.id,ue=a.searchTerm||"",ge=!ue||(p.name||"").toLowerCase().includes(ue)||String(De[B]||"").toLowerCase().includes(ue)||String(B).toLowerCase().includes(ue),Me=v==="all"||B===v,Ne=!s||(G.tags||[]).includes(s),ze=W&&p.id!==W&&!a.edges.some(fe=>fe.sourceNodeId===W&&fe.targetNodeId===p.id||fe.targetNodeId===W&&fe.sourceNodeId===p.id)||ue&&!ge||!Me||!Ne;n.save(),n.globalAlpha=ze?.08:1,(ie||ce)&&(n.shadowColor=R,n.shadowBlur=ie?20:14),je(p.x,p.y,p.r,J);let $e=parseInt(R.slice(1,3),16),ot=parseInt(R.slice(3,5),16),it=parseInt(R.slice(5,7),16),Ge=n.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);Ge.addColorStop(0,"rgba("+Math.min(255,$e+70)+","+Math.min(255,ot+70)+","+Math.min(255,it+70)+",0.95)"),Ge.addColorStop(1,R),n.fillStyle=Ge,n.fill(),n.restore(),ie?(n.save(),je(p.x,p.y,p.r+3,J),n.strokeStyle=R,n.lineWidth=3,n.shadowColor=R,n.shadowBlur=12,n.stroke(),n.restore()):ce?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle=R,n.lineWidth=2,n.stroke(),n.restore()):ue&&ge?(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(p.id)>=0&&(n.save(),je(p.x,p.y,p.r+2,J),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Qe=Xe(p.name,16);if((ie||ce||a.zoom>X||!T&&a.zoom>.6)&&Me&&Ne){let fe=1/a.zoom;n.font="500 "+(12*fe).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ae=n.measureText(Qe).width+16*fe,tt=18*fe,Pe=p.y+p.r+8*fe,yt=!0;for(let Oe of me)if(p.x-Ae/2<Oe.x+Oe.w&&p.x+Ae/2>Oe.x&&Pe<Oe.y+Oe.h&&Pe+tt>Oe.y){yt=!1;break}if(!yt&&!ie&&!ce)return;me.push({x:p.x-Ae/2,y:Pe,w:Ae,h:tt}),n.fillStyle=V()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(p.x-Ae/2,Pe,Ae,tt,4*fe):n.rect(p.x-Ae/2,Pe,Ae,tt),n.fill(),n.strokeStyle=V()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*fe,n.stroke(),n.fillStyle=V()?ie||ce?"#eee":"#bbb":ie||ce?"#111":"#444",n.textAlign="center",n.fillText(Qe,p.x,Pe+13*fe)}}),n.restore(),a.marquee){let p=a.marquee,G=Math.min(p.sx,p.ex),B=Math.min(p.sy,p.ey),R=Math.abs(p.ex-p.sx),J=Math.abs(p.ey-p.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect(G,B,R,J),n.strokeRect(G,B,R,J),n.restore()}if(a.hoverId&&we.current){let p=a.domainById[a.hoverId],G=a.nodes.find(function(B){return B.id===a.hoverId});if(p&&G){let B=a.edges.filter(function(ie){return ie.sourceNodeId===p.id||ie.targetNodeId===p.id}).length,R=G.x*a.zoom+a.panX,J=G.y*a.zoom+a.panY;we.current.style.display="block",we.current.style.left=R+14+"px",we.current.style.top=J-6+"px",we.current.innerHTML="<b>"+b(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+b(p.kind||"")+" \xB7 "+B+" \u8FDE\u63A5</span>"}}else we.current&&(we.current.style.display="none")},ke=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(dt))};a.wake=ke,a.render=Be;let st=()=>{let s=a.nodes.length;a.tickCount++;let b=.9-Math.min(.4,a.tickCount/1500),C=s>1e3?3e3:s>100?2e3:s>50?1200:800,T=s>100?.002:.005,X=s>1e3?.012:s>100?.005:.01,W=s>1e3?6:s>200?12:24,me={};a.nodes.forEach(B=>me[B.id]=B);for(let B=0;B<s;B++){if(a.dragNode===a.nodes[B])continue;let R=a.nodes[B],J=0,ie=0;for(let ge=0;ge<s;ge++){if(B===ge)continue;let Me=R.x-a.nodes[ge].x,Ne=R.y-a.nodes[ge].y,ze=Math.sqrt(Me*Me+Ne*Ne)||1,$e=C/(ze*ze);J+=Me/ze*$e,ie+=Ne/ze*$e}if(a.clustered&&a.typeCenters[R.type]){let ge=a.typeCenters[R.type];J+=(ge.x-R.x)*.006,ie+=(ge.y-R.y)*.006}else J-=R.x*X,ie-=R.y*X;let ce=(R.vx+J)*b,ue=(R.vy+ie)*b;ce=Math.max(-W,Math.min(W,ce)),ue=Math.max(-W,Math.min(W,ue)),R.vx=ce,R.vy=ue}a.edges.forEach(B=>{let R=me[B.sourceNodeId],J=me[B.targetNodeId];if(!R||!J)return;let ie=J.x-R.x,ce=J.y-R.y,ue=Math.sqrt(ie*ie+ce*ce)||1,ge=(ue-100)*T,Me=ie/ue*ge,Ne=ce/ue*ge;a.dragNode!==R&&(R.vx+=Me,R.vy+=Ne),a.dragNode!==J&&(J.vx-=Me,J.vy-=Ne)});let p=0;a.nodes.forEach(B=>{a.dragNode!==B&&(B.x+=B.vx,B.y+=B.vy,p+=B.vx*B.vx+B.vy*B.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Fe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},dt=()=>{if(a.running){try{st(),Be()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(dt)}},Ve=(s,v)=>{let b=r.getBoundingClientRect();return{x:(s-b.left-a.panX)/a.zoom,y:(v-b.top-a.panY)/a.zoom}},Je=s=>{let v=a.domainById[s];return!(!v||u.current!=="all"&&v.kind!==u.current||_.current&&!(v.tags||[]).includes(_.current))},Ze=(s,v,b)=>Math.max(v,Math.min(b,s)),ct=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+36){b=T.id;break}}b!==a.hoverId&&(a.hoverId=b,ke())},pt=s=>{if(s.button!==0)return;let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+25){b=T;break}}if(s.shiftKey){if(b){a.shiftClick=b.id;return}a.marquee={sx:s.clientX,sy:s.clientY,ex:s.clientX,ey:s.clientY};return}a.dragStart={x:s.clientX,y:s.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=b||null,b&&(a.dragOffset={dx:b.x-v.x,dy:b.y-v.y})},mt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ke();return}if(!a.dragStart)return;let v=s.clientX-a.dragStart.x,b=s.clientY-a.dragStart.y;if(Math.abs(v)+Math.abs(b)>3&&(a.dragging=!0),a.dragNode){let C=Ve(s.clientX,s.clientY);a.dragNode.x=C.x+a.dragOffset.dx,a.dragNode.y=C.y+a.dragOffset.dy,ke()}else a.dragging&&(a.panX=Ze(a.dragStart.px+v,-1e5,1e5),a.panY=Ze(a.dragStart.py+b,-1e5,1e5),ke())},ut=s=>{if(a.marquee){let b=a.marquee;a.marquee=null;let C=r.getBoundingClientRect(),T=Math.min(b.sx,b.ex)-C.left,X=Math.max(b.sx,b.ex)-C.left,W=Math.min(b.sy,b.ey)-C.top,me=Math.max(b.sy,b.ey)-C.top,p=a.nodes.filter(G=>{let B=G.x*a.zoom+a.panX,R=G.y*a.zoom+a.panY;return B>=T&&B<=X&&R>=W&&R<=me}).map(G=>G.id);a.multi=p,re(p),ke();return}let v=a.dragStart&&!a.dragging;if(a.shiftClick){let b=a.shiftClick;a.shiftClick=null;let C=Array.isArray(a.multi)?a.multi.slice():[];C.includes(b)||C.push(b),a.multi=C,re(C),ke();return}if(v){let b=Ve(s.clientX,s.clientY),C=null;for(let T=a.nodes.length-1;T>=0;T--){let X=a.nodes[T];if(!Je(X.id))continue;let W=X.x-b.x,me=X.y-b.y;if(W*W+me*me<X.r*X.r+20){C=X;break}}C?(a.selectedId=C.id,K(C.id),ke()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],re([])),K(null),ke())}a.dragStart=null,a.dragging=!1,a.dragNode=null},gt=s=>{s.preventDefault();let v=Ve(s.clientX,s.clientY),b=null;for(let C=a.nodes.length-1;C>=0;C--){let T=a.nodes[C];if(!Je(T.id))continue;let X=T.x-v.x,W=T.y-v.y;if(X*X+W*W<T.r*T.r+25){b=T;break}}if(b){let C=a.domainById[b.id];C&&xe({x:s.clientX,y:s.clientY,id:b.id,path:C.id,title:C.title})}else xe(null)},ft=s=>{s.preventDefault();let v=r.getBoundingClientRect(),b=(s.clientX-v.left-a.panX)/a.zoom,C=(s.clientY-v.top-a.panY)/a.zoom,T=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=Ze(a.panX+b*(a.zoom-T),-1e5,1e5),a.panY=Ze(a.panY+C*(a.zoom-T),-1e5,1e5),a.zoom=T,ke()};r.addEventListener("mousemove",ct),r.addEventListener("mousedown",pt),window.addEventListener("mousemove",mt),window.addEventListener("mouseup",ut),r.addEventListener("wheel",ft,{passive:!1}),r.addEventListener("contextmenu",gt),F.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],re([]),Fe(),ke()};for(let s=0;s<200;s++)st();Fe(),ke();let bt=()=>h(!1);return window.addEventListener("mousedown",bt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Te.disconnect(),r.removeEventListener("mousemove",ct),r.removeEventListener("mousedown",pt),window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",ut),r.removeEventListener("wheel",ft),r.removeEventListener("contextmenu",gt),window.removeEventListener("mousedown",bt)}},[t,l]),(0,e.jsxs)("div",{className:"me-graph",ref:L,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:Y,onChange:r=>Se(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>h(r=>!r),"aria-expanded":he,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",le!=="all"||Q||w?"\u25CF":"\u25BE"]}),he&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${le==="all"&&!Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{te("all"),ee(!1)},children:i("all")}),Object.keys(Ue).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${le===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>te(n=>n===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[r]||Ue[r]}}),i(De[r])]},r)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ee(r=>!r),children:["\u23F1 ",i("timeDim")]}),pe.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:pe.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${w===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>H(n=>n===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(le!=="all"||Q||w)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{te("all"),ee(!1),H("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!D,onChange:r=>I&&I(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${Q?" me-on":""}`,onClick:()=>ee(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(n=>{n&&P({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>N.current&&N.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{K(null),te("all"),F.current&&F.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:we,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Ke&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),Z&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),Z&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:Z.x,top:Z.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{A.current({path:Z.path,title:Z.title}),xe(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Z.id&&(y.current.selectedId=Z.id,K(Z.id)),xe(null);let r=y.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(Z.title||"")}catch{}xe(null),oe(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,n=r&&Array.isArray(r.multi)?r.multi.slice():[],M=Z.id;if(M&&!n.includes(M)&&n.push(M),xe(null),n.length<2){oe(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let V=$.current&&$.current(n);V&&V.then?V.then(c=>c?oe(i("merged")):oe(i("mergeFail"),!1)).catch(()=>oe(i("mergeFail"),!1)):V&&oe(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Z.path;xe(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(f.current?await f.current(r):!1)?oe(i("deleted")):oe(i("deleteFail"),!1)}catch{oe(i("deleteFail"),!1)}})()},children:i("delete")})]}),ne.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[ne.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=ne.map(z=>ve[z]).filter(Boolean).map(z=>z.title||z.name).join(`
|
|
182
|
+
`),M=new Blob([n],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(M),c=document.createElement("a");c.href=V,c.download="memory-selected.txt",document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(V),1e3),oe(ne.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(ne.length<2){oe(i("mergeNeed"),!1);return}let r=ne.map(M=>ve[M]?ve[M].id:M);if(!window.confirm(i("mergeConfirm")))return;re([]);let n=y.current;n&&(n.multi=[]),fetch(`${j}/merge?paths=${encodeURIComponent(r.join(","))}`).then(M=>M.json()).then(M=>{M&&M.ok?oe(i("merged")):oe(i("mergeFail"),!1)}).catch(()=>oe(i("mergeFail"),!1))},children:i("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(i("deleteConfirm")))return;let r=ne.map(M=>ve[M]?ve[M].id:M);re([]);let n=y.current;n&&(n.multi=[]),(async()=>{let M=0;for(let V of r)try{(f.current?await f.current(V):!1)&&M++}catch{}oe(M+i("deletedSelected"),M>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=y.current;r&&(r.multi=[]),re([]);let n=y.current;n&&n.render&&n.render()},children:i("clearSelection")})]}),O&&(0,e.jsxs)("div",{className:"me-graph-sidebar",style:{position:"absolute",right:10,top:10,zIndex:3,maxWidth:240,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:12,fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:ve[O]?ve[O].title||ve[O].name:O}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ve[O]?i(De[ve[O].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===O||r.target===O)||[]).slice(0,8).map((r,n)=>{let M=r.source===O?r.target:r.source,V=ve[M];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:c=>{c.preventDefault();let z=y.current;z&&(z.selectedId=M,z.hoverId=M,z.wake&&z.wake()),K(M)},children:V?(V.title||V.name).slice(0,28):M},n)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),be&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(be.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:be.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:be.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:be.msg})]}),m&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{m.url&&URL.revokeObjectURL(m.url),P(null),se(!1)},children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:U?"100vw":900,width:U?"100vw":"92vw",maxHeight:U?"100vh":"90vh",height:U?"100vh":void 0,borderRadius:U?0:14},onClick:r=>r.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:m.url,download:"memory-graph.png",onClick:()=>{qe("download"),oe(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(Le==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{qe("full"),se(r=>!r),oe(i("fullscreen"))},children:i(Le==="full"?"done":U?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=m.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{qe("copy"),oe(i("copied"))}).catch(()=>{oe(i("copyFail"),!1)}):oe(i("copyFail"),!1)},children:i(Le==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{m.url&&URL.revokeObjectURL(m.url),P(null),se(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:U?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:m.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:U?"calc(100vh - 64px)":"70vh",borderRadius:U?0:8,cursor:"zoom-in"},onClick:()=>se(r=>!r)})})]})]})]})}function Zt(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let d=(Date.now()-l)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function xt({label:t,value:l=[],options:d,onChange:x,placeholder:g,z:i=20}){let[S,D]=(0,o.useState)(!1),I=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!S)return;let f=$=>{I.current&&!I.current.contains($.target)&&D(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[S]);let k=Array.isArray(l)?l:[],L=k.includes("__all__"),y=L?d.find(f=>f.value==="__all__")?.label||"":k.length?k.map(f=>d.find($=>$.value===f)?.label||f).join("\u3001"):"",N=(f,$)=>{if(f.value==="__all__"){x($?["__all__"]:[]);return}let Y=new Set(k);Y.has("__all__")&&Y.delete("__all__"),$?Y.add(f.value):Y.delete(f.value),x([...Y])},F=d.find(f=>f.value==="__all__"),A=d.filter(f=>f.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t}),(0,e.jsxs)("div",{ref:I,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>D(f=>!f),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||g||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),S&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[F&&(0,e.jsxs)("label",{onClick:f=>f.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("input",{type:"checkbox",checked:L,onChange:f=>N(F,f.target.checked)}),(0,e.jsx)("span",{children:F.label})]}),A.map(f=>(0,e.jsxs)("label",{onClick:$=>$.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:k.includes(f.value),onChange:$=>N(f,$.target.checked)}),(0,e.jsx)("span",{children:f.label})]},f.value))]})]})]})}function Qt(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function ea(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),S=await i.createWritable();return await S.write(t),await S.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let x=URL.createObjectURL(t),g=document.createElement("a");return g.href=x,g.download=l,document.body.appendChild(g),g.click(),document.body.removeChild(g),setTimeout(()=>URL.revokeObjectURL(x),1e3),{ok:!0,picked:!1,name:l}}function vt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),x=l.toLowerCase(),g=[],i=0;for(;i<t.length;){let S=d.indexOf(x,i);if(S<0){g.push(t.slice(i));break}S>i&&g.push(t.slice(i,S)),g.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(S,S+x.length)},S)),i=S+x.length}return g}function ta(t){if(!t)return"";let l=String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),d=[];return l=l.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(x,g,i){return d.push("<pre><code>"+i+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(x,g,i){return"<h"+g.length+">"+i+"</h"+g.length+">"}),l=l.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),l=l.replace(/`([^`\n]+)`/g,"<code>$1</code>"),l=l.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),l=l.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(x,g,i){return/^(https?:|\/)/.test(i)?'<a href="'+i+'" target="_blank" rel="noopener noreferrer">'+g+"</a>":g}),l=l.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),l=l.replace(/^\s*(>)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),l=l.replace(/\n/g,"<br/>"),l=l.replace(/\u0000(\d+)\u0000/g,function(x,g){return d[g]}),l}function Nt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,x=l.toDateString()===d.toDateString(),g=S=>String(S).padStart(2,"0"),i=`${g(l.getHours())}:${g(l.getMinutes())}`;return x?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
|
|
183
183
|
|
|
184
184
|
return module.exports;
|
|
185
185
|
},
|