memory-eternal 0.8.0 → 0.9.0
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/README.en.md +26 -0
- package/README.md +12 -0
- package/index.js +161 -48
- package/lib/api.js +10 -5
- package/lib/capture.js +69 -1
- package/lib/client.js +6 -6
- package/lib/vault.js +0 -40
- package/package.json +1 -1
- package/web/app.js +10 -10
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 Lt=Object.create;var ot=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ft=(t,l)=>{for(var c in l)ot(t,c,{get:l[c],enumerable:!0})},wt=(t,l,c,v)=>{if(l&&typeof l=="object"||typeof l=="function")for(let g of Rt(l))!jt.call(t,g)&&g!==c&&ot(t,g,{get:()=>l[g],enumerable:!(v=Dt(l,g))||v.enumerable});return t};var $t=(t,l,c)=>(c=t!=null?Lt(At(t)):{},wt(l||!t||!t.__esModule?ot(c,"default",{value:t,enumerable:!0}):c,t)),Pt=t=>wt(ot({},"__esModule",{value:!0}),t);var la={};Ft(la,{EN:()=>Nt,MemoryLibrary:()=>Yt,ZH:()=>Mt,apply:()=>Wt,inject:()=>Et});module.exports=Pt(la);var n=$t(require("react"),1),e=require("react/jsx-runtime"),We="memory-eternal",W="/memory-eternal/api",Et=["settingsScope","slots","locale","connection","remote"],Mt={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",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
6
|
+
var Bt=Object.create;var it=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ft=(t,l)=>{for(var d in l)it(t,d,{get:l[d],enumerable:!0})},kt=(t,l,d,v)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of At(l))!jt.call(t,u)&&u!==d&&it(t,u,{get:()=>l[u],enumerable:!(v=Dt(l,u))||v.enumerable});return t};var Pt=(t,l,d)=>(d=t!=null?Bt(Rt(t)):{},kt(l||!t||!t.__esModule?it(d,"default",{value:t,enumerable:!0}):d,t)),$t=t=>kt(it({},"__esModule",{value:!0}),t);var ra={};Ft(ra,{EN:()=>zt,MemoryLibrary:()=>qt,ZH:()=>Nt,apply:()=>Ht,inject:()=>Et});module.exports=$t(ra);var n=Pt(require("react"),1),e=require("react/jsx-runtime"),Ke="memory-eternal",E="/memory-eternal/api",Et=["settingsScope","slots","locale","connection","remote"],Nt={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",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",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",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
7
7
|
|
|
8
8
|
## \u80CC\u666F
|
|
9
9
|
- \u95EE\u9898\u63CF\u8FF0
|
|
@@ -48,7 +48,7 @@ var Lt=Object.create;var ot=Object.defineProperty;var Dt=Object.getOwnPropertyDe
|
|
|
48
48
|
-
|
|
49
49
|
|
|
50
50
|
## \u98CE\u9669/\u963B\u585E
|
|
51
|
-
- `},
|
|
51
|
+
- `},zt={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",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",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",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
|
|
52
52
|
|
|
53
53
|
## Background
|
|
54
54
|
- Problem
|
|
@@ -93,7 +93,7 @@ Option A, because:
|
|
|
93
93
|
-
|
|
94
94
|
|
|
95
95
|
## Risks/blockers
|
|
96
|
-
- `},
|
|
96
|
+
- `},ct=["all","project","knowledge","content","prompt","business","tool","mistake"],$e={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Ct={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},je={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Ze="deepseek-harness",We=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":Ze:d==="deepseek harness"?Ze:l.split(":")[0]||Ze},Ot=[Ze,"claude","codex","cursor","codex-desktop"],It=(t=[])=>[...new Set([...Ot,...(t||[]).map(We)])],Wt={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Ne=`
|
|
97
97
|
.memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
|
|
98
98
|
.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; }
|
|
99
99
|
.mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
|
|
@@ -219,12 +219,12 @@ Option A, because:
|
|
|
219
219
|
.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; }
|
|
220
220
|
.me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
|
|
221
221
|
.me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
|
|
222
|
-
`;function
|
|
222
|
+
`;function Ht(t){t.effect(()=>t.locale.register(Ke,{zh:Nt,en:zt}),"memory-eternal: locale");let l=t.locale.bind(Ke);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Ke,order:25,label:()=>l("nav"),locale:Ke,inject:()=>({})},()=>n.default.createElement(Ut,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ke}:footer`,order:100,label:()=>l("nav"),locale:Ke,inject:()=>({})},d=>n.default.createElement(Kt,{t:l,locale:t.locale,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function _t(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.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 Ut({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)(Tt,{t,onReload:()=>{},version:0})]})}function Kt({t,locale:l,wide:d}){let[v,u]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${d?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>u(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Lt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),v&&(0,e.jsx)(Yt,{t,locale:l,onClose:()=>u(!1)})]})}function Yt({t,locale:l,onClose:d,tab:v}){let[u,i]=(0,n.useState)(!1),A=(0,n.useRef)(null),M=_t(),T=(0,n.useCallback)(R=>l&&typeof l.subscribe=="function"?l.subscribe(R):()=>{},[l]),z=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),w=(0,n.useSyncExternalStore)(T,z),y=w&&(w.active==="zh"||w.active==="en")?w.active:null,x=(0,n.useRef)(null);x.current===null&&y&&(x.current=y);let H=(0,n.useMemo)(()=>{let R=x.current?`lang=${x.current}`:"";return v==="config"?`${E}/ui/config?tab=config${R?`&${R}`:""}`:v?`${M.replace(/\/$/,"")}/?tab=${v}${R?`&${R}`:""}`:R?`${M}${M.endsWith("/")?"":"/"}?${R}`:M},[M,v]);return(0,n.useEffect)(()=>{let R=A.current&&A.current.contentWindow;R&&y&&R.postMessage({source:"memory-eternal",type:"locale",lang:y},"*")},[y]),(0,n.useEffect)(()=>{let R=I=>{I.key==="Escape"&&d()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[d]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:d,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("div",{className:"me-modal",onClick:R=>R.stopPropagation(),style:u?{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:()=>i(R=>!R),"aria-label":t(u?"exitFullscreen":"enterFullscreen"),title:t(u?"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:u?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:d,"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",{ref:A,src:H,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Lt(){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 qt({t,inModal:l,onClose:d,onFull:v,full:u}){let[i,A]=(0,n.useState)(null),[M,T]=(0,n.useState)([]),[z,w]=(0,n.useState)(!0),[y,x]=(0,n.useState)(null),[H,R]=(0,n.useState)(""),[I,O]=(0,n.useState)("all"),[k,j]=(0,n.useState)(""),[le,Q]=(0,n.useState)("all"),[$,ze]=(0,n.useState)("all"),[F,se]=(0,n.useState)(()=>{try{let m=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),a={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(m&&a[m])return a[m]}catch{}return"cards"}),[b,oe]=(0,n.useState)("recent"),[g,C]=(0,n.useState)(null),N=(0,n.useRef)(null),ee=(0,n.useRef)(null),[X,Y]=(0,n.useState)(!1),[q,G]=(0,n.useState)(null),[xe,Ee]=(0,n.useState)(!1),[ve,ke]=(0,n.useState)(!0),[de,pe]=(0,n.useState)(null),[c,_]=(0,n.useState)(0),K=(0,n.useCallback)(()=>_(m=>m+1),[]),ne=(0,n.useRef)(null),[we,Te]=(0,n.useState)(100),De=(0,n.useRef)(null),Xe=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(F!=="cards")return;let m=De.current,a=Xe.current;if(!m)return;let W=new IntersectionObserver(V=>{V[0]&&V[0].isIntersecting&&Te(he=>he+24)},{root:a||null,rootMargin:"400px"});return W.observe(m),()=>W.disconnect()},[F,M,I,k]);let Ae=(0,n.useCallback)(async(m=I,a=k,W=$)=>{try{w(!0),R("");let V=new URLSearchParams;m&&m!=="all"&&V.set("kind",m),a.trim()&&V.set("q",a.trim()),V.set("status",W||"all"),V.set("limit","500");let Re=await(await fetch(`${E}/cards?${V.toString()}`)).json();Re.ok&&(T(Re.cards||[]),Te(100))}catch(V){R(String(V&&V.message?V.message:V))}finally{w(!1)}},[I,k,$]),me=(0,n.useCallback)(async()=>{try{let[m,a,W]=await Promise.all([fetch(`${E}/overview`).then(V=>V.json()),fetch(`${E}/cards?status=all&limit=500`).then(V=>V.json()),fetch(`${E}/capture-log`).then(V=>V.json()).catch(()=>null)]);m.ok&&A(m),a.ok&&(T(a.cards||[]),Te(100)),x(W&&W.ok&&W.available&&W.health||null)}catch(m){R(String(m&&m.message?m.message:m))}finally{w(!1)}},[]),ie=async m=>{try{let W=await(await fetch(`${E}/delete?path=${encodeURIComponent(m)}`)).json();W.ok?(C({ok:!0,msg:t("deleted")}),await me()):C({ok:!1,msg:W.error||t("deleteFail")})}catch{C({ok:!1,msg:t("deleteFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>C(null),2e3)};(0,n.useEffect)(()=>(me(),()=>{ne.current&&clearTimeout(ne.current)}),[me]);let Ve=m=>{j(m),ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>Ae(I,m,$),280)},Ce=m=>{O(m),Ae(m,k,$)};(0,n.useEffect)(()=>{Ae(I,k,$)},[$]);let r=async m=>{try{let W=await(await fetch(`${E}/card?path=${encodeURIComponent(m.path||m.id)}`)).json();W.ok&&G({path:W.path,title:m.title,text:W.text})}catch(a){R(String(a&&a.message?a.message:a))}},o=async(m,a)=>{Y(!0);try{let W=await fetch(`${E}/export`);if(!W.ok)throw new Error("HTTP "+W.status);let V=await W.json();if(!V.ok)throw new Error(V.error||"export failed");let he,Re,He;m==="json"?(Re="memory-vault.json",He="application/json",he=JSON.stringify(V.cards.map(Se=>({path:Se.path,title:Se.title,kind:Se.kind,text:Se.text})),null,2)):(Re="memory-vault.md",He="text/markdown;charset=utf-8",he=V.cards.map(Se=>Se.text.trim()).filter(Boolean).join(`
|
|
223
223
|
|
|
224
224
|
---
|
|
225
225
|
|
|
226
|
-
`));let Ze=new Blob([me],{type:Pe}),qe=await oa(Ze,Be,!1);if(!qe.ok){u({ok:!1,msg:t("exportFail")}),le(!1);return}u({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+qe.name})}catch(A){u({ok:!1,msg:t("exportFail")+" \xB7 "+(A.message||"")})}finally{le(!1)}k.current&&clearTimeout(k.current),k.current=setTimeout(()=>u(null),2600)},r=async d=>{let S=d.target.files&&d.target.files[0];if(d.target.value="",!!S){try{let A=await S.text(),me=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:A})).json();me.ok?(await ve(),u({ok:!0,msg:t("importedVault")+"\uFF1A"+(me.imported||0)+(me.skipped?t("importedSkipped")+me.skipped:"")})):u({ok:!1,msg:me.error||t("importFail")})}catch{u({ok:!1,msg:t("importFail")})}k.current&&clearTimeout(k.current),k.current=setTimeout(()=>u(null),2400)}},o=(0,n.useMemo)(()=>{let d=N.slice();return j!=="all"&&(d=d.filter(S=>Ke(S.submittedBy)===j)),V!=="all"&&(d=d.filter(S=>(S.status||"approved")===V)),J==="title"?d.sort((S,A)=>String(S.title||"").localeCompare(String(A.title||""))):J==="hot"?d.sort((S,A)=>(A.weight||A.links||0)-(S.weight||S.links||0)):d.sort((S,A)=>new Date(A.updated||0).getTime()-new Date(S.updated||0).getTime()),d},[N,J,j,V]),I=(0,n.useMemo)(()=>[...new Set(N.map(d=>Ke(d.submittedBy)))],[N]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ce}),b&&(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 "+(b.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:b.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:b.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:b.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)(It,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),v&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:v,"aria-label":t(g?"exitFull":"fullscreen"),children:g?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:c,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${ie?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ae(d=>!d),"aria-label":t(ie?"collapse":"expand"),title:t(ie?"collapse":"expand"),children:ie?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="cards"?" active":""}`,onClick:()=>ce("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="graph"?" active":""}`,onClick:()=>ce("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="stats"?" active":""}`,onClick:()=>ce("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="audit"?" active":""}`,onClick:()=>ce("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="optimize"?" active":""}`,onClick:()=>ce("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="config"?" active":""}`,onClick:()=>ce("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),ie&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Ie,children:[P==="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"})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:w,onChange:d=>je(d.target.value)}),(0,e.jsx)("input",{ref:H,type:"file",accept:".json,application/json",style:{display:"none"},onChange:r}),(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:()=>he({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:X,onClick:()=>we("md"),children:t(X?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:X,onClick:()=>we("json"),children:t(X?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ve(),children:t("refresh")})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[dt.map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${E===d?" active":""}`,onClick:()=>ne(d),children:t(d==="all"?"all":Te[d])},d)),(0,e.jsxs)("select",{value:j,onChange:d=>$(d.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")]}),zt(I).map(d=>(0,e.jsx)("option",{value:d,children:d},d))]}),(0,e.jsxs)("select",{value:V,onChange:d=>U(d.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(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${J===d.key?" active":""}`,onClick:()=>pe(d.key),children:d.label},d.key))]}),h&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",h]}),(0,e.jsx)("div",{style:{display:P==="cards"?"contents":"none"},children:z?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):h?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",h," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ve(),children:t("retry")})]}):N.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:o.slice(0,q).map(d=>(0,e.jsx)(Vt,{card:d,t,query:w.trim(),onOpen:$e,onDelete:Le},d.path))}),o.length>q&&(0,e.jsx)("div",{ref:xe,style:{height:1}})]})}),(0,e.jsx)("div",{style:{display:P==="graph"?"flex":"none",flex:1,minHeight:0},children:(0,e.jsx)(Qt,{t,onOpen:$e,all:ye,onAllChange:re,onMutate:p,active:!0,visible:P==="graph"})}),(0,e.jsx)("div",{style:{display:P==="config"?"contents":"none"},children:(0,e.jsx)(Bt,{t,onReload:()=>ve(),version:te})}),(0,e.jsx)("div",{style:{display:P==="stats"?"contents":"none"},children:(0,e.jsx)(Gt,{t,tab:"stats",onReload:()=>ve(),version:te})}),(0,e.jsx)("div",{style:{display:P==="audit"?"contents":"none"},children:(0,e.jsx)(qt,{t,onReload:()=>ve(),version:te})}),(0,e.jsx)("div",{style:{display:P==="optimize"?"contents":"none"},children:(0,e.jsx)(Xt,{t,onReload:()=>ve(),version:te})}),Z&&(0,e.jsx)(Zt,{t,card:Z,query:w.trim(),onClose:()=>_(null),onDelete:d=>{_(null),Le(d)},onFeedback:d=>{let S=Z.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:w.trim(),path:S,useful:d})}).then(()=>u({ok:!0,msg:t(d?"fbUseful":"fbIrr")})).catch(()=>{}),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>u(null),2e3)}}),(0,e.jsx)(Jt,{t,newCard:Ye,setNewCard:he,onCreated:()=>{ve(),p(),u({ok:!0,msg:t("created")}),k.current&&clearTimeout(k.current),k.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 Bt({t,onReload:l,version:c,compact:v}){let[g,i]=(0,n.useState)(null),[R,N]=(0,n.useState)(0),[B,z]=(0,n.useState)(null),[C,h]=(0,n.useState)(null),[y,E]=(0,n.useState)(!1),[T,w]=(0,n.useState)(null),[K,j]=(0,n.useState)(null),[$,V]=(0,n.useState)(""),[U,P]=(0,n.useState)(""),[ce,J]=(0,n.useState)(""),[pe,b]=(0,n.useState)(""),[u,k]=(0,n.useState)(null),H=(0,n.useRef)(null),X=(p,O=!0)=>{H.current&&clearTimeout(H.current),k({msg:p,ok:O}),H.current=setTimeout(()=>k(null),1900)},le=(p,O)=>Object.keys(O).reduce((q,ae)=>q.split("{"+ae+"}").join(O[ae]),t(p)),Z=(0,n.useCallback)(async()=>{try{let[p,O,q]=await Promise.all([fetch(`${W}/config`).then(ae=>ae.json()).catch(()=>null),fetch(`${W}/setup-status`).then(ae=>ae.json()).catch(()=>null),fetch(`${W}/budget`).then(ae=>ae.json()).catch(()=>null)]);p&&p.ok?(i(p),N(p.revision??0),z(p.schema??null),h({...p.config??{}}),w(p.dsh??null),E(p.writable===!1),V("")):q&&q.ok?(h({...q}),E(!0),V(t("configNeedsDsh"))):V(t("adminLoadFail")),O&&O.ok&&j(O),J("")}catch{V(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{Z()},[c,Z]);let _=(p,O)=>h(q=>({...q??{},[p]:O})),ye=p=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[p]||p,re=async()=>{if(C){if(y){X(t("editInSetting"),!1);return}P("save");try{let p=await fetch(`${W}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:C,expectedRevision:R})}),O=await p.json();if(O&&O.ok)J(t("savedOk")+(O.note?` \xB7 ${t("restartHint")}`:"")),X(t("savedOk")),await Z();else{let q=p.status===409?t("conflictRefresh"):O?.error||t("saveFail");V(q),X(q,!1)}}catch{V(t("saveFail")),X(t("saveFail"),!1)}finally{P("")}}},ie=()=>{h({...g?.config??{}}),J("")},Ae={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}},Ye=async p=>{let O=Ae[p];O&&h(q=>({...q??{},...O}))},he=async(p,O)=>{P(p+O);try{let ae=await(await fetch(`${W}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:p,action:O})})).json();ae&&ae.ok?X(le(O==="install"?"mcpInstalled":"mcpUninstalled",{agent:p})):X(le("mcpActionFail",{agent:p,error:ae?.error||""}),!1);try{let xe=await fetch(`${W}/setup-status`).then(Ie=>Ie.json());xe&&xe.ok&&j(xe)}catch{}}catch{X(t("mergeFail"),!1)}finally{P("")}},te=({k:p,label:O,type:q="text",step:ae,min:xe,max:Ie})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:O||p}),(0,e.jsx)("input",{type:q,step:ae,min:xe,max:Ie,value:C?C[p]??"":"",onChange:Ne=>_(p,q==="number"?Number(Ne.target.value):Ne.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}})]}),se=({k:p,label:O})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(C&&C[p]),onChange:q=>_(p,q.target.checked)}),(0,e.jsx)("span",{children:O||p})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:v?"0 0 auto":1,minHeight:0,maxHeight:v?"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:[$&&(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 ",$]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Z,children:["\u21BB ",t("retry")]})]}),y&&(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")]}),ce&&(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 ",ce]}),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:t("dshHostLabel")}),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]})]}),K&&K.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:K.agents.map(p=>(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:p.isDsh?t("dshHostLabel"):p.name}),p.isDsh&&p.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",p.version]}),!p.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),p.installed&&p.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),p.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),p.mcpConfigured===!0&&p.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),p.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",p.recallTool?t("enabled"):t("disabled"),")"]})]}),p.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",p.hook]}),!p.isDsh&&p.installed&&p.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!U,onClick:()=>he(p.name,"install"),children:t("installMcp")}),!p.isDsh&&p.installed&&p.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!U,onClick:()=>{window.confirm(t("uninstallConfirm"))&&he(p.name,"uninstall")},children:t("uninstallMcp")})]},p.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),pe&&(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:pe})})]}),C?(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(p=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ye(p),disabled:!!U,children:[p==="A"?"\u{1F7E2} ":p==="B"?"\u{1F4B0} ":"\u2B50 ",Ae[p].label]},p))})]}),(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)(se,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(se,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(te,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(te,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(te,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(te,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(te,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(se,{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)(se,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(se,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(te,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(te,{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:C.auditMode??"all",onChange:p=>_("auditMode",p.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)(Ct,{label:t("auditExemptAgents"),value:C.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(K?.agents||[]).filter(p=>!p.isDsh).map(p=>({value:p.name,label:p.name}))],onChange:p=>_("auditExemptAgents",p)}),(0,e.jsx)(Ct,{label:t("auditExemptKinds"),value:C.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...dt.filter(p=>p!=="all").map(p=>({value:p,label:t(Te[p])}))],onChange:p=>_("auditExemptKinds",p)}),(0,e.jsx)(te,{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)(se,{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:C.autoWebMode??"init",onChange:p=>_("autoWebMode",p.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)(te,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(te,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(te,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(se,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(se,{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:ie,disabled:!!U,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:re,disabled:!!U||U==="save"||y,children:U==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function qt({t,onReload:l,version:c}){let[v,g]=(0,n.useState)([]),[i,R]=(0,n.useState)([]),[N,B]=(0,n.useState)("all"),[z,C]=(0,n.useState)("all"),[h,y]=(0,n.useState)(""),[E,T]=(0,n.useState)(new Set),[w,K]=(0,n.useState)(""),[j,$]=(0,n.useState)("pending"),V=[...new Set([...v,...i].map(b=>b.submittedBy).filter(Boolean))],U=(0,n.useCallback)(async()=>{try{let b=await fetch(`${W}/audit/list`).then(u=>u.json());b.ok&&(g(b.pending||[]),R(b.rejected||[]),T(new Set))}catch{}},[]);(0,n.useEffect)(()=>{U()},[c,U]);let P=(j==="pending"?v:i).filter(b=>{if(N!=="all"&&b.kind!==N||z!=="all"&&Ke(b.submittedBy)!==z)return!1;if(h){let u=(b.created||"").slice(0,10);if(u&&u!==h)return!1}return!0}),ce=b=>T(u=>{let k=new Set(u);return k.has(b)?k.delete(b):k.add(b),k}),J=async(b,u)=>{K("apply");try{for(let k of u||[...E])await fetch(`${W}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(k)}${b==="delete"?"&permanent=0":""}`);await U(),l&&l()}catch{}finally{K("")}},pe=[...E];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:N,onChange:b=>B(b.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")}),dt.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(Te[b])},b))]}),(0,e.jsxs)("select",{value:z,onChange:b=>C(b.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")}),zt(V).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:h,onChange:b=>y(b.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${j==="pending"?" me-on":""}`,onClick:()=>$("pending"),children:[t("pending"),"\uFF08",v.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${j==="rejected"?" me-on":""}`,onClick:()=>$("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:P.length>0&&pe.length===P.length,onChange:b=>{b.target.checked?T(new Set(P.map(u=>u.path))):T(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!pe.length||!!w,onClick:()=>J("approved"),children:["\u2713 ",t(j==="rejected"?"restore":"approve")]}),j==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!pe.length||!!w,onClick:()=>J("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!pe.length||!!w,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&J("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),P.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:P.map(b=>(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:E.has(b.path),onChange:()=>ce(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ke(b.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.created?b.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:b.severity==="high"?"#f87171":"#9ca3af"},children:b.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.reason||"-"}),j==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>J("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>J("rejected",[b.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:()=>J("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&J("delete",[b.path])},children:"\u{1F5D1}"})]})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Xt({t,onReload:l,version:c}){let[v,g]=(0,n.useState)([]),[i,R]=(0,n.useState)(""),N=(0,n.useCallback)(async()=>{try{let z=await fetch(`${W}/recycle/list`).then(C=>C.json());z.ok&&g(z.items||[])}catch{}},[]);(0,n.useEffect)(()=>{N()},[c,N]);let B=async(z,C)=>{R(z+C);try{z==="restore"?await fetch(`${W}/recycle/restore?path=${encodeURIComponent(C)}`):z==="purge"&&await fetch(`${W}/recycle/purge?path=${encodeURIComponent(C)}`),await N(),l&&l()}catch{}finally{R("")}};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()=>{R("purgeAll");try{await fetch(`${W}/recycle/purge-expired?days=0`),await N()}catch{}finally{R("")}},children:t("emptyRecycle")})]}),v.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:v.map(z=>(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[z.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(z.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>B("restore",z.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"))&&B("purge",z.path)},children:t("purge")})]},z.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Vt=({card:t,t:l,onOpen:c,query:v,onDelete:g})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>c(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ue[t.kind]||Ue.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:kt[t.kind]||"\u{1F4CE}"}),v?St(t.title,v):t.title,na(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",l("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",l("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",l("statusApproved")]})]}),(0,e.jsx)("p",{children:v?St(t.summary||"",v):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[kt[t.kind]||"\u{1F4CE}"," ",l(Te[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ke(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",Tt(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:"\u{1F5D1}"})]})]});function Gt({t,tab:l,onReload:c,version:v}){let[g,i]=(0,n.useState)(null),[R,N]=(0,n.useState)(""),[B,z]=(0,n.useState)(null),[C,h]=(0,n.useState)(null),[y,E]=(0,n.useState)(""),[T,w]=(0,n.useState)(""),[K,j]=(0,n.useState)(!1),$=(0,n.useCallback)(async()=>{if(y){E("");return}try{let u=await fetch(`${W}/todayBrief`).then(k=>k.json());E(u.ok&&u.brief||"")}catch{}},[y]),V=(0,n.useCallback)(async()=>{if(!(!B||!B.merge||!B.merge.length)&&window.confirm(t("mergeAllConfirm"))){w("merge");try{let u={},k=_=>u[_]===void 0?_:u[_]=k(u[_]),H=(_,ye)=>{u[k(_)]=k(ye)},X=new Set;for(let _ of B.merge)X.add(_.a.path),X.add(_.b.path),H(_.a.path,_.b.path);let le={};for(let _ of X){let ye=k(_);(le[ye]=le[ye]||[]).push(_)}let Z=0;for(let _ of Object.values(le)){if(_.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(_.join(","))}`).then(re=>re.json())).ok&&Z++}await U(),c&&c()}catch{}w("")}},[B,U,c,t]);async function U(){try{let u=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/budget`)]),[k,H]=await Promise.all(u.map(X=>X.json()));k.ok&&i(k),H.ok&&h(H),N(k.ok?"":t("adminLoadFail"))}catch{N(t("adminLoadFail"))}}let P=(0,n.useCallback)(async()=>{w("scan");try{let u=await fetch(`${W}/optimize`).then(k=>k.json());u.ok&&z(u)}catch{N(t("adminLoadFail"))}finally{w("")}},[t]);(0,n.useEffect)(()=>{U()},[v]);let ce=async(u,k)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(u+","+k)}`).then(X=>X.json())).ok&&(await U(),c&&c())}catch{}},J=async u=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(u)}`).then(H=>H.json())).ok&&(await U(),c&&c())}catch{}},pe=["project","knowledge","content","prompt","business","tool","mistake"],b=({title:u,kind:k,updated:H,path:X})=>(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[k]||"#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:Tt(H)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>J(X),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:[R&&(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 ",R]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:U,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:$,children:y?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),y&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:y})]}),g&&(0,e.jsxs)(e.Fragment,{children:[g.trend&&g.trend.length>0&&(()=>{let u=g.trend,k=Math.max(...u.map(Z=>Z.count),1),H=260,X=50,le=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:X,style:{display:"block",width:"100%",height:50},children:u.map((Z,_)=>{let ye=Math.round(Z.count/k*(X-4));return(0,e.jsx)("rect",{x:_*le+1,y:X-ye,width:Math.max(le-2,2),height:ye,rx:1.5,fill:Z.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:Z.count>0?.85:.35},Z.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:pe.map(u=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[u]||"#666"}}),t(Te[u]),": ",g.byKind?.[u]||0]},u))})]}),C&&(C.budgetChars||C.recallLimit||C.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:C.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:C.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",C.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)(b,{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:!!T,onClick:P,children:T==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),B&&B.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!T,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){w("oneclick");try{let u=JSON.stringify({cleanupStale:K}),H=await(await fetch(`${W}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:u})).json();H&&H.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${H.plan.merged} ${t("optimizedMerged")}${K?` \xB7 ${H.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await U(),c&&c(),z(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{w("")}}},children:T==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),B&&B.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:K,onChange:u=>j(u.target.checked)}),t("oneClickAlsoStale")]})]}),!B&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),B&&(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}}),B.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!T,onClick:V,children:t(T==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),B.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:B.merge.map((u,k)=>(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:()=>ce(u.a.path,u.b.path),children:t("mergeNow")})]},k))}):(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",B.stale?.length||0,"\uFF09"]}),B.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!T,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;w("clean");let u=0;for(let k of B.stale)try{await fetch(`${W}/delete?path=${encodeURIComponent(k.path)}`),u++}catch{}w(""),notify(`${u} ${t("deletedStale")}`),await U(),c&&c()},children:t("cleanStale")})}),B.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:B.stale.map(u=>(0,e.jsx)(b,{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 st=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function Jt({t,newCard:l,setNewCard:c,onCreated:v}){if(!l)return null;let g=st.find(h=>h.key===l.template),i=l.body||(g?t(g.bodyKey):""),R=l.kind||(g?g.kind:"knowledge"),N=l.tags||(g?t(g.tagKey):""),B=l._creating,z=h=>{let y=st.find(E=>E.key===h);c(E=>({...E,template:h,kind:y?y.kind:E.kind,body:y?t(y.bodyKey):E.body,tags:y?t(y.tagKey):E.tags}))},C=async()=>{if(!(!l.title&&!i)){c(h=>({...h,_creating:!0}));try{(await fetch(`${W}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:R,tags:N.split(",").map(y=>y.trim()).filter(Boolean),body:i,source:"manual"})}).then(y=>y.json())).ok?(c(null),v&&v()):c(y=>({...y,_creating:!1}))}catch{c(y=>({...y,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>c(null),children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:h=>h.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:()=>c(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:[st.map(h=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===h.key?" me-on":""}`,onClick:()=>z(h.key),children:t(h.label)},h.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>c(h=>({...h,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:R,onChange:h=>c(y=>({...y,kind:h.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(h=>(0,e.jsx)("option",{value:h,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:h},h))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:h=>c(y=>({...y,title:h.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:N,onChange:h=>c(y=>({...y,tags:h.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:h=>c(y=>({...y,body:h.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:B,onClick:C,children:t(B?"exporting":"createCard")})})]})]})]})}function Zt({t,card:l,query:c,onClose:v,onDelete:g,onFeedback:i}){(0,n.useEffect)(()=>{let z=C=>{C.key==="Escape"&&v()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[v]);let[R,N]=(0,n.useState)(!1),B=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:v,children:[(0,e.jsx)("style",{children:Ce}),(0,e.jsxs)("div",{className:"me-dialog",onClick:z=>z.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:[c&&(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")]})]}),B&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>N(z=>!z),children:t(R?"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:v,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:R?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ia(l.text)}})]})]})}function Qt({t,onOpen:l,all:c,onAllChange:v,onMutate:g,active:i,visible:R}){let[N,B]=(0,n.useState)(null),[z,C]=(0,n.useState)(""),h=(0,n.useRef)(!1),y=(0,n.useRef)(0),E=(0,n.useRef)(t);E.current=t;let T=(0,n.useCallback)(async()=>{try{h.current=!1;let $=await(await fetch(`${W}/graph${c?"?all=1":""}`)).json();$.ok?(B($),C(""),h.current=!0):(B(null),C($.error||t("error")))}catch(j){C(String(j&&j.message?j.message:j))}},[c,t]);(0,n.useEffect)(()=>{if(!i||h.current)return;let j=!0;return fetch(`${W}/graph${c?"?all=1":""}`).then($=>$.json()).then($=>{j&&($.ok?(B($),C(""),h.current=!0):(B(null),C($.error||t("error"))))}).catch($=>{j&&C(String($&&$.message?$.message:$))}),()=>{j=!1}},[c,t,i]),(0,n.useEffect)(()=>{R&&N&&y.current++},[R,N]);let w=(0,n.useCallback)(async j=>{try{let V=await(await fetch(`${W}/delete?path=${encodeURIComponent(j)}`)).json();return V&&V.ok?(await T(),g&&g(),!0):!1}catch{return!1}},[T]),K=(0,n.useCallback)(async j=>{if(!j||j.length<2)return!1;try{let $=await fetch(`${W}/merge?paths=${encodeURIComponent(j.join(","))}`).then(V=>V.json());return $&&$.ok?(await T(),g&&g(),!0):!1}catch{return!1}},[T,g]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ce}),z&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",z]}),!N&&!z&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),N&&N.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),N&&N.nodes.length>0&&(0,e.jsx)(ta,{nodes:N.nodes,edges:N.edges,onOpen:l,onDelete:w,onMerge:K,t,all:c,onAllChange:v,countLabel:`${N.nodes.length} ${t("nodes")} \xB7 ${ea(N.edges)} ${t("edges")}`,fitTrigger:y.current})]})}function ea(t){let l=new Set;for(let c of t||[])l.add([c.source,c.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 ta({nodes:t,edges:l,onOpen:c,onDelete:v,onMerge:g,t:i,countLabel:R,all:N,onAllChange:B,fitTrigger:z}){let C=(0,n.useRef)(null),h=(0,n.useRef)(null),y=(0,n.useRef)(null),E=(0,n.useRef)(null),T=(0,n.useRef)(null),w=(0,n.useRef)(c);(0,n.useEffect)(()=>{w.current=c},[c]);let K=(0,n.useRef)(v);(0,n.useEffect)(()=>{K.current=v},[v]);let j=(0,n.useRef)(g);(0,n.useEffect)(()=>{j.current=g},[g]);let[$,V]=(0,n.useState)(""),[U,P]=(0,n.useState)(null),ce=(0,n.useRef)("");(0,n.useEffect)(()=>{ce.current=$.trim().toLowerCase()},[$]),(0,n.useEffect)(()=>{let r=y.current;if(!r)return;let o=$.trim().toLowerCase();if(!o)return;let I=r.nodes.find(d=>(d.name||"").toLowerCase().includes(o));I&&(y.current.selectedId=I.id,P(I.id),r.panX=r.w/2-I.x*r.zoom,r.panY=r.h/2-I.y*r.zoom,r.render&&r.render())},[$]);let[J,pe]=(0,n.useState)("all"),[b,u]=(0,n.useState)(!1),k=(0,n.useRef)("all"),[H,X]=(0,n.useState)(""),le=(0,n.useRef)(""),[Z,_]=(0,n.useState)(!1),ye=(0,n.useRef)(!1),[re,ie]=(0,n.useState)(null);(0,n.useEffect)(()=>{k.current=J},[J]),(0,n.useEffect)(()=>{le.current=H},[H]),(0,n.useEffect)(()=>{ye.current=Z},[Z]);let Ae=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let I of o.tags||[]){let d=String(I).trim();d&&r.set(d,(r.get(d)||0)+1)}return[...r.entries()].sort((o,I)=>I[1]-o[1]).slice(0,24).map(([o,I])=>({tag:o,n:I}))},[t]),Ye=(()=>{let r=$.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(Te[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[$]),(0,n.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[J,H,Z]);let he=(0,n.useRef)(null),[te,se]=(0,n.useState)([]),[p,O]=(0,n.useState)(null),[q,ae]=(0,n.useState)(!1),[xe,Ie]=(0,n.useState)(null),[Ne,ve]=(0,n.useState)(""),Le=(0,n.useRef)(null),je=(0,n.useRef)(null),ne=(r,o=!0)=>{Le.current&&clearTimeout(Le.current),Ie({msg:r,ok:o}),Le.current=setTimeout(()=>Ie(null),1900)},$e=r=>{ve(r),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>ve(""),1600)};(0,n.useEffect)(()=>()=>{Le.current&&clearTimeout(Le.current),je.current&&clearTimeout(je.current)},[]);let we=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=C.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let I=Math.max(1,window.devicePixelRatio||1),d=()=>document.documentElement.getAttribute("data-theme")==="dark",S={};l.forEach(s=>{S[s.source]=(S[s.source]||0)+1,S[s.target]=(S[s.target]||0)+1});let A=Math.max(1,...Object.values(S)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(S[s.id]||0)/A*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:I,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,x)=>(s[x.id]=x,s),{}),a.nodes.forEach((s,x)=>{let f=x/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let me=[...new Set(a.nodes.map(s=>s.type))];a.clustered=me.length>1,a.typeCenters={},me.forEach((s,x)=>{let f=x/me.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),y.current=a;let Be=0,Pe=0,Ze=()=>{let s=r.clientWidth,x=r.clientHeight;a.w=s,a.h=x,r.width=s*I,r.height=x*I,o.setTransform(I,0,0,I,0,0),(Be===0||Pe===0)&&s>0&&x>0&&a.tickCount>0&&requestAnimationFrame(()=>Ve()),Be=s,Pe=x};Ze();let qe=new ResizeObserver(Ze);qe.observe(r.parentElement);let De=(s,x)=>s&&s.length>x?s.slice(0,x)+"\u2026":s,Xe=(s,x,f,M)=>{if(o.beginPath(),M==="rect")o.rect(s-f,x-f*.75,f*2,f*1.5);else if(M==="diamond")o.moveTo(s,x-f),o.lineTo(s+f,x),o.lineTo(s,x+f),o.lineTo(s-f,x),o.closePath();else if(M==="hexagon"){for(let L=0;L<6;L++){let G=Math.PI/3*L-Math.PI/2,Y=s+f*Math.cos(G),ue=x+f*Math.sin(G);L===0?o.moveTo(Y,ue):o.lineTo(Y,ue)}o.closePath()}else o.arc(s,x,f,0,Math.PI*2)},Ve=()=>{if(!a.nodes.length)return;let s=1/0,x=-1/0,f=1/0,M=-1/0;a.nodes.forEach(m=>{s=Math.min(s,m.x),x=Math.max(x,m.x),f=Math.min(f,m.y),M=Math.max(M,m.y)});let L=20,G=x-s+L*2,Y=M-f+L*2,ue=Math.min(a.w/G,a.h/Y);a.zoom=Math.max(.35,Math.min(1.8,ue)),a.panX=a.w/2-(s+x)/2*a.zoom,a.panY=a.h/2-(f+M)/2*a.zoom};E.current=Ve;let ct=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=ce.current,a.kindFilter=k.current,a.timeMode=ye.current,a.tagFilter=le.current;let s=a.tagFilter,x=a.kindFilter,f=m=>String(m||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=d()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let m=0;m<a.w;m+=24)o.beginPath(),o.moveTo(m,0),o.lineTo(m,a.h),o.stroke();for(let m=0;m<a.h;m+=24)o.beginPath(),o.moveTo(0,m),o.lineTo(a.w,m),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let M={};a.nodes.forEach(m=>M[m.id]=m);let L=a.nodes.length>40,G=L?1.5:.55,Y=a.selectedId||a.hoverId;a.edges.forEach(m=>{let Q=M[m.sourceNodeId],D=M[m.targetNodeId];if(!Q||!D)return;if(x!=="all"){let at=a.domainById[m.sourceNodeId]&&a.domainById[m.sourceNodeId].kind,be=a.domainById[m.targetNodeId]&&a.domainById[m.targetNodeId].kind;if(at!==x&&be!==x)return}if(s){let at=a.domainById[m.sourceNodeId]&&(a.domainById[m.sourceNodeId].tags||[]).includes(s),be=a.domainById[m.targetNodeId]&&(a.domainById[m.targetNodeId].tags||[]).includes(s);if(!at&&!be)return}let F=D.x-Q.x,ee=D.y-Q.y,oe=Math.sqrt(F*F+ee*ee)||1,de=L?12:18,ge=-ee/oe*de,fe=F/oe*de,Se=(Q.x+D.x)/2+ge,Me=(Q.y+D.y)/2+fe,ze=_e.colors[a.domainById[Q.id]&&a.domainById[Q.id].kind||"other"],Fe=Y&&(m.sourceNodeId===Y||m.targetNodeId===Y),lt=Y?Fe?.6:.08:L?.14:.24,rt=parseInt(ze.slice(1,3),16),Je=parseInt(ze.slice(3,5),16),tt=parseInt(ze.slice(5,7),16);o.strokeStyle="rgba("+rt+","+Je+","+tt+","+lt+")",o.lineWidth=Fe?1.6+(m.weight||1):.8+(m.weight||1)*.5,o.beginPath(),o.moveTo(Q.x,Q.y),o.quadraticCurveTo(Se,Me,D.x,D.y),o.stroke()});let ue=[];if(a.nodes.forEach(m=>{let Q=a.domainById[m.id]||{},D=Q.kind||"other",F=a.timeMode?aa(Q.updated):_e.colors[D],ee=_e.shapes[D],oe=a.selectedId===m.id,de=a.hoverId===m.id,ge=a.searchTerm||"",fe=!ge||(m.name||"").toLowerCase().includes(ge)||String(Te[D]||"").toLowerCase().includes(ge)||String(D).toLowerCase().includes(ge),Se=x==="all"||D===x,Me=!s||(Q.tags||[]).includes(s),ze=Y&&m.id!==Y&&!a.edges.some(be=>be.sourceNodeId===Y&&be.targetNodeId===m.id||be.targetNodeId===Y&&be.sourceNodeId===m.id)||ge&&!fe||!Se||!Me;o.save(),o.globalAlpha=ze?.08:1,(oe||de)&&(o.shadowColor=F,o.shadowBlur=oe?20:14),Xe(m.x,m.y,m.r,ee);let Fe=parseInt(F.slice(1,3),16),lt=parseInt(F.slice(3,5),16),rt=parseInt(F.slice(5,7),16),Je=o.createRadialGradient(m.x-m.r*.3,m.y-m.r*.3,0,m.x,m.y,m.r*1.2);Je.addColorStop(0,"rgba("+Math.min(255,Fe+70)+","+Math.min(255,lt+70)+","+Math.min(255,rt+70)+",0.95)"),Je.addColorStop(1,F),o.fillStyle=Je,o.fill(),o.restore(),oe?(o.save(),Xe(m.x,m.y,m.r+3,ee),o.strokeStyle=F,o.lineWidth=3,o.shadowColor=F,o.shadowBlur=12,o.stroke(),o.restore()):de?(o.save(),Xe(m.x,m.y,m.r+2,ee),o.strokeStyle=F,o.lineWidth=2,o.stroke(),o.restore()):ge&&fe?(o.save(),Xe(m.x,m.y,m.r+2,ee),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(m.id)>=0&&(o.save(),Xe(m.x,m.y,m.r+2,ee),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let tt=De(m.name,16);if((oe||de||a.zoom>G||!L&&a.zoom>.6)&&Se&&Me){let be=1/a.zoom;o.font="500 "+(12*be).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Re=o.measureText(tt).width+16*be,nt=18*be,Ee=m.y+m.r+8*be,vt=!0;for(let Oe of ue)if(m.x-Re/2<Oe.x+Oe.w&&m.x+Re/2>Oe.x&&Ee<Oe.y+Oe.h&&Ee+nt>Oe.y){vt=!1;break}if(!vt&&!oe&&!de)return;ue.push({x:m.x-Re/2,y:Ee,w:Re,h:nt}),o.fillStyle=d()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(m.x-Re/2,Ee,Re,nt,4*be):o.rect(m.x-Re/2,Ee,Re,nt),o.fill(),o.strokeStyle=d()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*be,o.stroke(),o.fillStyle=d()?oe||de?"#eee":"#bbb":oe||de?"#111":"#444",o.textAlign="center",o.fillText(tt,m.x,Ee+13*be)}}),o.restore(),a.marquee){let m=a.marquee,Q=Math.min(m.sx,m.ex),D=Math.min(m.sy,m.ey),F=Math.abs(m.ex-m.sx),ee=Math.abs(m.ey-m.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(Q,D,F,ee),o.strokeRect(Q,D,F,ee),o.restore()}if(a.hoverId&&he.current){let m=a.domainById[a.hoverId],Q=a.nodes.find(function(D){return D.id===a.hoverId});if(m&&Q){let D=a.edges.filter(function(oe){return oe.sourceNodeId===m.id||oe.targetNodeId===m.id}).length,F=Q.x*a.zoom+a.panX,ee=Q.y*a.zoom+a.panY;he.current.style.display="block",he.current.style.left=F+14+"px",he.current.style.top=ee-6+"px",he.current.innerHTML="<b>"+f(m.title||m.name||"")+'</b><br/><span style="opacity:.8">'+f(m.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",D)+"</span>"}}else he.current&&(he.current.style.display="none")},ke=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(mt))};a.wake=ke,a.render=ct;let pt=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),M=s>1e3?3e3:s>100?2e3:s>50?1200:800,L=s>100?.002:.005,G=s>1e3?.012:s>100?.005:.01,Y=s>1e3?6:s>200?12:24,ue={};a.nodes.forEach(D=>ue[D.id]=D);for(let D=0;D<s;D++){if(a.dragNode===a.nodes[D])continue;let F=a.nodes[D],ee=0,oe=0;for(let fe=0;fe<s;fe++){if(D===fe)continue;let Se=F.x-a.nodes[fe].x,Me=F.y-a.nodes[fe].y,ze=Math.sqrt(Se*Se+Me*Me)||1,Fe=M/(ze*ze);ee+=Se/ze*Fe,oe+=Me/ze*Fe}if(a.clustered&&a.typeCenters[F.type]){let fe=a.typeCenters[F.type];ee+=(fe.x-F.x)*.006,oe+=(fe.y-F.y)*.006}else ee-=F.x*G,oe-=F.y*G;let de=(F.vx+ee)*f,ge=(F.vy+oe)*f;de=Math.max(-Y,Math.min(Y,de)),ge=Math.max(-Y,Math.min(Y,ge)),F.vx=de,F.vy=ge}a.edges.forEach(D=>{let F=ue[D.sourceNodeId],ee=ue[D.targetNodeId];if(!F||!ee)return;let oe=ee.x-F.x,de=ee.y-F.y,ge=Math.sqrt(oe*oe+de*de)||1,fe=(ge-100)*L,Se=oe/ge*fe,Me=de/ge*fe;a.dragNode!==F&&(F.vx+=Se,F.vy+=Me),a.dragNode!==ee&&(ee.vx-=Se,ee.vy-=Me)});let m=0;a.nodes.forEach(D=>{a.dragNode!==D&&(D.x+=D.vx,D.y+=D.vy,m+=D.vx*D.vx+D.vy*D.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ve()),(s?Math.sqrt(m/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},mt=()=>{if(a.running){try{pt(),ct()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(mt)}},Ge=(s,x)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(x-f.top-a.panY)/a.zoom}},Qe=s=>{let x=a.domainById[s];return!(!x||k.current!=="all"&&x.kind!==k.current||le.current&&!(x.tags||[]).includes(le.current))},et=(s,x,f)=>Math.max(x,Math.min(f,s)),ut=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let x=Ge(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let L=a.nodes[M];if(!Qe(L.id))continue;let G=L.x-x.x,Y=L.y-x.y;if(G*G+Y*Y<L.r*L.r+36){f=L.id;break}}f!==a.hoverId&&(a.hoverId=f,ke())},gt=s=>{if(s.button!==0)return;let x=Ge(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let L=a.nodes[M];if(!Qe(L.id))continue;let G=L.x-x.x,Y=L.y-x.y;if(G*G+Y*Y<L.r*L.r+25){f=L;break}}if(s.shiftKey){if(f){a.shiftClick=f.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=f||null,f&&(a.dragOffset={dx:f.x-x.x,dy:f.y-x.y})},ft=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ke();return}if(!a.dragStart)return;let x=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(x)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let M=Ge(s.clientX,s.clientY);a.dragNode.x=M.x+a.dragOffset.dx,a.dragNode.y=M.y+a.dragOffset.dy,ke()}else a.dragging&&(a.panX=et(a.dragStart.px+x,-1e5,1e5),a.panY=et(a.dragStart.py+f,-1e5,1e5),ke())},bt=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let M=r.getBoundingClientRect(),L=Math.min(f.sx,f.ex)-M.left,G=Math.max(f.sx,f.ex)-M.left,Y=Math.min(f.sy,f.ey)-M.top,ue=Math.max(f.sy,f.ey)-M.top,m=a.nodes.filter(Q=>{let D=Q.x*a.zoom+a.panX,F=Q.y*a.zoom+a.panY;return D>=L&&D<=G&&F>=Y&&F<=ue}).map(Q=>Q.id);a.multi=m,se(m),ke();return}let x=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let M=Array.isArray(a.multi)?a.multi.slice():[];M.includes(f)||M.push(f),a.multi=M,se(M),ke();return}if(x){let f=Ge(s.clientX,s.clientY),M=null;for(let L=a.nodes.length-1;L>=0;L--){let G=a.nodes[L];if(!Qe(G.id))continue;let Y=G.x-f.x,ue=G.y-f.y;if(Y*Y+ue*ue<G.r*G.r+20){M=G;break}}M?(a.selectedId=M.id,P(M.id),ke()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],se([])),P(null),ke())}a.dragStart=null,a.dragging=!1,a.dragNode=null},yt=s=>{s.preventDefault();let x=Ge(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let L=a.nodes[M];if(!Qe(L.id))continue;let G=L.x-x.x,Y=L.y-x.y;if(G*G+Y*Y<L.r*L.r+25){f=L;break}}if(f){let M=a.domainById[f.id];M&&ie({x:s.clientX,y:s.clientY,id:f.id,path:M.id,title:M.title})}else ie(null)},ht=s=>{s.preventDefault();let x=r.getBoundingClientRect(),f=(s.clientX-x.left-a.panX)/a.zoom,M=(s.clientY-x.top-a.panY)/a.zoom,L=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=et(a.panX+f*(a.zoom-L),-1e5,1e5),a.panY=et(a.panY+M*(a.zoom-L),-1e5,1e5),a.zoom=L,ke()};r.addEventListener("mousemove",ut),r.addEventListener("mousedown",gt),window.addEventListener("mousemove",ft),window.addEventListener("mouseup",bt),r.addEventListener("wheel",ht,{passive:!1}),r.addEventListener("contextmenu",yt),T.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],se([]),Ve(),ke()};for(let s=0;s<200;s++)pt();Ve(),ke();let xt=()=>u(!1);return window.addEventListener("mousedown",xt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),qe.disconnect(),r.removeEventListener("mousemove",ut),r.removeEventListener("mousedown",gt),window.removeEventListener("mousemove",ft),window.removeEventListener("mouseup",bt),r.removeEventListener("wheel",ht),r.removeEventListener("contextmenu",yt),window.removeEventListener("mousedown",xt)}},[t,l]),(0,n.useEffect)(()=>{z!==void 0&&E.current&&requestAnimationFrame(()=>E.current())},[z]),(0,e.jsxs)("div",{className:"me-graph",ref:h,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:$,onChange:r=>V(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>u(r=>!r),"aria-expanded":b,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",J!=="all"||Z||H?"\u25CF":"\u25BE"]}),b&&(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${J==="all"&&!Z?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{pe("all"),_(!1)},children:i("all")}),Object.keys(Ue).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${J===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>pe(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e.colors[r]||Ue[r]}}),i(Te[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${Z?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>_(r=>!r),children:["\u23F1 ",i("timeDim")]}),Ae.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:Ae.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${H===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>X(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(J!=="all"||Z||H)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{pe("all"),_(!1),X("")},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:!!N,onChange:r=>B&&B(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${Z?" me-on":""}`,onClick:()=>_(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=C.current;if(r)try{r.toBlob(o=>{o&&O({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>E.current&&E.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{P(null),pe("all"),T.current&&T.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:C,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:he,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)"}}),Ye&&(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")}),re&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ie(null)}),re&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:re.x,top:re.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{w.current({path:re.path,title:re.title}),ie(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{re.id&&(y.current.selectedId=re.id,P(re.id)),ie(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(re.title||"")}catch{}ie(null),ne(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],I=re.id;if(I&&!o.includes(I)&&o.push(I),ie(null),o.length<2){ne(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let d=j.current&&j.current(o);d&&d.then?d.then(S=>S?ne(i("merged")):ne(i("mergeFail"),!1)).catch(()=>ne(i("mergeFail"),!1)):d&&ne(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=re.path;ie(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(K.current?await K.current(r):!1)?ne(i("deleted")):ne(i("deleteFail"),!1)}catch{ne(i("deleteFail"),!1)}})()},children:i("delete")})]}),te.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:[te.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=te.map(A=>we[A]).filter(Boolean).map(A=>A.title||A.name).join(`
|
|
227
|
-
`),
|
|
226
|
+
`));let lt=new Blob([he],{type:He}),Fe=await ia(lt,Re,!1);if(!Fe.ok){C({ok:!1,msg:t("exportFail")}),Y(!1);return}C({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(W){C({ok:!1,msg:t("exportFail")+" \xB7 "+(W.message||"")})}finally{Y(!1)}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>C(null),2600)},L=async m=>{let a=m.target.files&&m.target.files[0];if(m.target.value="",!!a){try{let W=await a.text(),he=await(await fetch(`${E}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:W})).json();he.ok?(await me(),C({ok:!0,msg:t("importedVault")+"\uFF1A"+(he.imported||0)+(he.skipped?t("importedSkipped")+he.skipped:"")})):C({ok:!1,msg:he.error||t("importFail")})}catch{C({ok:!1,msg:t("importFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>C(null),2400)}},J=(0,n.useMemo)(()=>{let m=M.slice();return le!=="all"&&(m=m.filter(a=>We(a.submittedBy)===le)),$!=="all"&&(m=m.filter(a=>(a.status||"approved")===$)),b==="title"?m.sort((a,W)=>String(a.title||"").localeCompare(String(W.title||""))):b==="hot"?m.sort((a,W)=>(W.weight||W.links||0)-(a.weight||a.links||0)):m.sort((a,W)=>new Date(W.updated||0).getTime()-new Date(a.updated||0).getTime()),m},[M,b,le,$]),ce=(0,n.useMemo)(()=>[...new Set(M.map(m=>We(m.submittedBy)))],[M]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ne}),g&&(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 "+(g.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:g.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:g.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:g.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)(Lt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),v&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:v,"aria-label":t(u?"exitFull":"fullscreen"),children:u?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),y&&y.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[y.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:y.since?Qe(new Date(y.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${ve?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>ke(m=>!m),"aria-label":t(ve?"collapse":"expand"),title:t(ve?"collapse":"expand"),children:ve?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="cards"?" active":""}`,onClick:()=>se("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="graph"?" active":""}`,onClick:()=>se("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="stats"?" active":""}`,onClick:()=>se("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="audit"?" active":""}`,onClick:()=>se("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="optimize"?" active":""}`,onClick:()=>se("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${F==="config"?" active":""}`,onClick:()=>se("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),ve&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Xe,children:[F==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ye,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Ye,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Ye,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Ye,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Ye,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Ye,{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:k,onChange:m=>Ve(m.target.value)}),(0,e.jsx)("input",{ref:ee,type:"file",accept:".json,application/json",style:{display:"none"},onChange:L}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ee.current&&ee.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>pe({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:X,onClick:()=>o("md"),children:t(X?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:X,onClick:()=>o("json"),children:t(X?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>me(),children:t("refresh")})]}),F==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ct.map(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${I===m?" active":""}`,onClick:()=>Ce(m),children:t(m==="all"?"all":je[m])},m)),(0,e.jsxs)("select",{value:le,onChange:m=>Q(m.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")]}),It(ce).map(m=>(0,e.jsx)("option",{value:m,children:m},m))]}),(0,e.jsxs)("select",{value:$,onChange:m=>ze(m.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(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${b===m.key?" active":""}`,onClick:()=>oe(m.key),children:m.label},m.key))]}),H&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",H]}),(0,e.jsx)("div",{style:{display:F==="cards"?"contents":"none"},children:z?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):H?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",H," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>me(),children:t("retry")})]}):M.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:J.slice(0,we).map(m=>(0,e.jsx)(Gt,{card:m,t,query:k.trim(),onOpen:r,onDelete:ie},m.path))}),J.length>we&&(0,e.jsx)("div",{ref:De,style:{height:1}})]})}),(0,e.jsx)("div",{style:{display:F==="graph"?"flex":"none",flex:1,minHeight:0},children:(0,e.jsx)(ea,{t,onOpen:r,all:xe,onAllChange:Ee,onMutate:K,active:!0,visible:F==="graph"})}),(0,e.jsx)("div",{style:{display:F==="config"?"contents":"none"},children:(0,e.jsx)(Tt,{t,onReload:()=>me(),version:c})}),(0,e.jsx)("div",{style:{display:F==="stats"?"contents":"none"},children:(0,e.jsx)(Jt,{t,tab:"stats",onReload:()=>me(),version:c})}),(0,e.jsx)("div",{style:{display:F==="audit"?"contents":"none"},children:(0,e.jsx)(Xt,{t,onReload:()=>me(),version:c})}),(0,e.jsx)("div",{style:{display:F==="optimize"?"contents":"none"},children:(0,e.jsx)(Vt,{t,onReload:()=>me(),version:c})}),q&&(0,e.jsx)(Qt,{t,card:q,query:k.trim(),onClose:()=>G(null),onDelete:m=>{G(null),ie(m)},onFeedback:m=>{let a=q.path;fetch(`${E}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:k.trim(),path:a,useful:m})}).then(()=>C({ok:!0,msg:t(m?"fbUseful":"fbIrr")})).catch(()=>{}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>C(null),2e3)}}),(0,e.jsx)(Zt,{t,newCard:de,setNewCard:pe,onCreated:()=>{me(),K(),C({ok:!0,msg:t("created")}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>C(null),2e3)}})]})]})]})}var Ye=({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 Tt({t,onReload:l,version:d,compact:v}){let[u,i]=(0,n.useState)(null),[A,M]=(0,n.useState)(0),[T,z]=(0,n.useState)(null),[w,y]=(0,n.useState)(null),[x,H]=(0,n.useState)(!1),[R,I]=(0,n.useState)(null),[O,k]=(0,n.useState)(null),[j,le]=(0,n.useState)(""),[Q,$]=(0,n.useState)(""),[ze,F]=(0,n.useState)(""),[se,b]=(0,n.useState)(""),[oe,g]=(0,n.useState)(null),C=(0,n.useRef)(null),N=(c,_=!0)=>{C.current&&clearTimeout(C.current),g({msg:c,ok:_}),C.current=setTimeout(()=>g(null),1900)},ee=(c,_)=>Object.keys(_).reduce((K,ne)=>K.split("{"+ne+"}").join(_[ne]),t(c)),X=(0,n.useCallback)(async()=>{try{let[c,_,K]=await Promise.all([fetch(`${E}/config`).then(ne=>ne.json()).catch(()=>null),fetch(`${E}/setup-status`).then(ne=>ne.json()).catch(()=>null),fetch(`${E}/budget`).then(ne=>ne.json()).catch(()=>null)]);c&&c.ok?(i(c),M(c.revision??0),z(c.schema??null),y({...c.config??{}}),I(c.dsh??null),H(c.writable===!1),le("")):K&&K.ok?(y({...K}),H(!0),le(t("configNeedsDsh"))):le(t("adminLoadFail")),_&&_.ok&&k(_),F("")}catch{le(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{X()},[d,X]);let Y=(c,_)=>y(K=>({...K??{},[c]:_})),q=c=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[c]||c,G=async()=>{if(w){if(x){N(t("editInSetting"),!1);return}$("save");try{let c=await fetch(`${E}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:w,expectedRevision:A})}),_=await c.json();if(_&&_.ok)F(t("savedOk")+(_.note?` \xB7 ${t("restartHint")}`:"")),N(t("savedOk")),await X();else{let K=c.status===409?t("conflictRefresh"):_?.error||t("saveFail");le(K),N(K,!1)}}catch{le(t("saveFail")),N(t("saveFail"),!1)}finally{$("")}}},xe=()=>{y({...u?.config??{}}),F("")},Ee={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}},ve=async c=>{let _=Ee[c];_&&y(K=>({...K??{},..._}))},ke=async(c,_)=>{$(c+_);try{let ne=await(await fetch(`${E}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:c,action:_})})).json();ne&&ne.ok?N(ee(_==="install"?"mcpInstalled":"mcpUninstalled",{agent:c})):N(ee("mcpActionFail",{agent:c,error:ne?.error||""}),!1);try{let we=await fetch(`${E}/setup-status`).then(Te=>Te.json());we&&we.ok&&k(we)}catch{}}catch{N(t("mergeFail"),!1)}finally{$("")}},de=({k:c,label:_,type:K="text",step:ne,min:we,max:Te})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:_||c}),(0,e.jsx)("input",{type:K,step:ne,min:we,max:Te,value:w?w[c]??"":"",onChange:De=>Y(c,K==="number"?Number(De.target.value):De.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}})]}),pe=({k:c,label:_})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(w&&w[c]),onChange:K=>Y(c,K.target.checked)}),(0,e.jsx)("span",{children:_||c})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:v?"0 0 auto":1,minHeight:0,maxHeight:v?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ne}),oe&&(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 "+(oe.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:oe.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:oe.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:oe.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[j&&(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 ",j]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:X,children:["\u21BB ",t("retry")]})]}),x&&(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")]}),ze&&(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 ",ze]}),u&&(u.version||u.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:t("dshHostLabel")}),u.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",u.version]}),u.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",u.dsh.vaultDir]})]}),O&&O.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:O.agents.map(c=>(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:c.isDsh?t("dshHostLabel"):c.name}),c.isDsh&&c.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",c.version]}),!c.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),c.installed&&c.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),c.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),c.mcpConfigured===!0&&c.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),c.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",c.recallTool?t("enabled"):t("disabled"),")"]})]}),c.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",c.hook]}),!c.isDsh&&c.installed&&c.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!Q,onClick:()=>ke(c.name,"install"),children:t("installMcp")}),!c.isDsh&&c.installed&&c.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!Q,onClick:()=>{window.confirm(t("uninstallConfirm"))&&ke(c.name,"uninstall")},children:t("uninstallMcp")})]},c.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),se&&(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:se})})]}),w?(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(c=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ve(c),disabled:!!Q,children:[c==="A"?"\u{1F7E2} ":c==="B"?"\u{1F4B0} ":"\u2B50 ",Ee[c].label]},c))})]}),(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)(pe,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(pe,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(de,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(de,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(de,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(de,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(de,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(pe,{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)(pe,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(pe,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(de,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(de,{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:w.auditMode??"all",onChange:c=>Y("auditMode",c.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)(St,{label:t("auditExemptAgents"),value:w.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(O?.agents||[]).filter(c=>!c.isDsh).map(c=>({value:c.name,label:c.name}))],onChange:c=>Y("auditExemptAgents",c)}),(0,e.jsx)(St,{label:t("auditExemptKinds"),value:w.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...ct.filter(c=>c!=="all").map(c=>({value:c,label:t(je[c])}))],onChange:c=>Y("auditExemptKinds",c)}),(0,e.jsx)(de,{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)(pe,{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:w.autoWebMode??"init",onChange:c=>Y("autoWebMode",c.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)(de,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(de,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(de,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(pe,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(pe,{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:!!Q,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:G,disabled:!!Q||Q==="save"||x,children:Q==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Xt({t,onReload:l,version:d}){let[v,u]=(0,n.useState)([]),[i,A]=(0,n.useState)([]),[M,T]=(0,n.useState)("all"),[z,w]=(0,n.useState)("all"),[y,x]=(0,n.useState)(""),[H,R]=(0,n.useState)(new Set),[I,O]=(0,n.useState)(""),[k,j]=(0,n.useState)("pending"),le=[...new Set([...v,...i].map(b=>b.submittedBy).filter(Boolean))],Q=(0,n.useCallback)(async()=>{try{let b=await fetch(`${E}/audit/list`).then(oe=>oe.json());b.ok&&(u(b.pending||[]),A(b.rejected||[]),R(new Set))}catch{}},[]);(0,n.useEffect)(()=>{Q()},[d,Q]);let $=(k==="pending"?v:i).filter(b=>{if(M!=="all"&&b.kind!==M||z!=="all"&&We(b.submittedBy)!==z)return!1;if(y){let oe=(b.created||"").slice(0,10);if(oe&&oe!==y)return!1}return!0}),ze=b=>R(oe=>{let g=new Set(oe);return g.has(b)?g.delete(b):g.add(b),g}),F=async(b,oe)=>{O("apply");try{for(let g of oe||[...H])await fetch(`${E}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${b==="delete"?"&permanent=0":""}`);await Q(),l&&l()}catch{}finally{O("")}},se=[...H];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:Ne}),(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:M,onChange:b=>T(b.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")}),ct.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(je[b])},b))]}),(0,e.jsxs)("select",{value:z,onChange:b=>w(b.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")}),It(le).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>x(b.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${k==="pending"?" me-on":""}`,onClick:()=>j("pending"),children:[t("pending"),"\uFF08",v.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${k==="rejected"?" me-on":""}`,onClick:()=>j("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:$.length>0&&se.length===$.length,onChange:b=>{b.target.checked?R(new Set($.map(oe=>oe.path))):R(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!se.length||!!I,onClick:()=>F("approved"),children:["\u2713 ",t(k==="rejected"?"restore":"approve")]}),k==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!se.length||!!I,onClick:()=>F("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!se.length||!!I,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&F("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),$.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:$.map(b=>(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:H.has(b.path),onChange:()=>ze(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:$e[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:We(b.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.created?b.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:b.severity==="high"?"#f87171":"#9ca3af"},children:b.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.reason||"-"}),k==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>F("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>F("rejected",[b.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:()=>F("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&F("delete",[b.path])},children:"\u{1F5D1}"})]})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Vt({t,onReload:l,version:d}){let[v,u]=(0,n.useState)([]),[i,A]=(0,n.useState)(""),M=(0,n.useCallback)(async()=>{try{let z=await fetch(`${E}/recycle/list`).then(w=>w.json());z.ok&&u(z.items||[])}catch{}},[]);(0,n.useEffect)(()=>{M()},[d,M]);let T=async(z,w)=>{A(z+w);try{z==="restore"?await fetch(`${E}/recycle/restore?path=${encodeURIComponent(w)}`):z==="purge"&&await fetch(`${E}/recycle/purge?path=${encodeURIComponent(w)}`),await M(),l&&l()}catch{}finally{A("")}};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:Ne}),(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()=>{A("purgeAll");try{await fetch(`${E}/recycle/purge-expired?days=0`),await M()}catch{}finally{A("")}},children:t("emptyRecycle")})]}),v.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:v.map(z=>(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:$e[z.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(z.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>T("restore",z.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"))&&T("purge",z.path)},children:t("purge")})]},z.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Gt=({card:t,t:l,onOpen:d,query:v,onDelete:u})=>(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:$e[t.kind]||$e.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:Ct[t.kind]||"\u{1F4CE}"}),v?Mt(t.title,v):t.title,oa(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",l("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",l("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",l("statusApproved")]})]}),(0,e.jsx)("p",{children:v?Mt(t.summary||"",v):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[Ct[t.kind]||"\u{1F4CE}"," ",l(je[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",We(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",Qe(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"))&&u&&u(t.path)},children:"\u{1F5D1}"})]})]});function Jt({t,tab:l,onReload:d,version:v}){let[u,i]=(0,n.useState)(null),[A,M]=(0,n.useState)(""),[T,z]=(0,n.useState)(null),[w,y]=(0,n.useState)(null),[x,H]=(0,n.useState)(null),[R,I]=(0,n.useState)([]),[O,k]=(0,n.useState)(""),[j,le]=(0,n.useState)(!1),Q=(0,n.useCallback)(async()=>{if(!(!T||!T.merge||!T.merge.length)&&window.confirm(t("mergeAllConfirm"))){k("merge");try{let g={},C=q=>g[q]===void 0?q:g[q]=C(g[q]),N=(q,G)=>{g[C(q)]=C(G)},ee=new Set;for(let q of T.merge)ee.add(q.a.path),ee.add(q.b.path),N(q.a.path,q.b.path);let X={};for(let q of ee){let G=C(q);(X[G]=X[G]||[]).push(q)}let Y=0;for(let q of Object.values(X)){if(q.length<2)continue;(await fetch(`${E}/merge?paths=${encodeURIComponent(q.join(","))}`).then(xe=>xe.json())).ok&&Y++}await $(),d&&d()}catch{}k("")}},[T,$,d,t]);async function $(){try{let g=await Promise.all([fetch(`${E}/stats`),fetch(`${E}/budget`),fetch(`${E}/capture-log`),fetch(`${E}/cards?status=all&limit=500`)]),[C,N,ee,X]=await Promise.all(g.map(Y=>Y.json()));C.ok&&i(C),N.ok&&y(N),ee.ok&&H(ee),X.ok&&I((X.cards||[]).filter(Y=>We(Y.submittedBy)===Ze).sort((Y,q)=>String(q.updated||"").localeCompare(String(Y.updated||""))).slice(0,30)),M(C.ok?"":t("adminLoadFail"))}catch{M(t("adminLoadFail"))}}let ze=(0,n.useCallback)(async()=>{k("scan");try{let g=await fetch(`${E}/optimize`).then(C=>C.json());g.ok&&z(g)}catch{M(t("adminLoadFail"))}finally{k("")}},[t]);(0,n.useEffect)(()=>{$()},[v]);let F=async(g,C)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${E}/merge?paths=${encodeURIComponent(g+","+C)}`).then(ee=>ee.json())).ok&&(await $(),d&&d())}catch{}},se=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${E}/delete?path=${encodeURIComponent(g)}`).then(N=>N.json())).ok&&(await $(),d&&d())}catch{}},b=["project","knowledge","content","prompt","business","tool","mistake"],oe=({title:g,kind:C,updated:N,path:ee})=>(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:qe.colors[C]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:Qe(N)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>se(ee),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:Ne}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[A&&(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 ",A]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:$,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",t("captureLog")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("captureLogHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>$(),children:["\u21BB ",t("refresh")]})]}),x?x.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(x.entries||[]).length===0?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogEmpty")}):(0,e.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,e.jsx)("tbody",{children:(x.entries||[]).map((g,C)=>{let N=Wt[g.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:Qe(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:N[1],fontWeight:600},children:[N[0]," ",g.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:g.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.preview||"",children:g.preview||""})]},C)})})})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("loading")})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",t("captureAgentCards"),"\uFF08",R.length,"\uFF09"]}),R.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:R.map(g=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:$e[g.kind]||$e.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:Qe(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),u&&(0,e.jsxs)(e.Fragment,{children:[u.trend&&u.trend.length>0&&(()=>{let g=u.trend,C=Math.max(...g.map(Y=>Y.count),1),N=260,ee=50,X=N/g.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:N,height:ee,style:{display:"block",width:"100%",height:50},children:g.map((Y,q)=>{let G=Math.round(Y.count/C*(ee-4));return(0,e.jsx)("rect",{x:q*X+1,y:ee-G,width:Math.max(X-2,2),height:G,rx:1.5,fill:Y.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:Y.count>0?.85:.35},Y.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.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:b.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:qe.colors[g]||"#666"}}),t(je[g]),": ",u.byKind?.[g]||0]},g))})]}),w&&(w.budgetChars||w.recallLimit||w.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:w.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:w.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",w.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",u.todayCards?.length||0,"\uFF09"]}),u.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:u.todayCards.map(g=>(0,e.jsx)(oe,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.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:!!O,onClick:ze,children:O==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),T&&T.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!O,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){k("oneclick");try{let g=JSON.stringify({cleanupStale:j}),N=await(await fetch(`${E}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();N&&N.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${N.plan.merged} ${t("optimizedMerged")}${j?` \xB7 ${N.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await $(),d&&d(),z(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{k("")}}},children:O==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),T&&T.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:j,onChange:g=>le(g.target.checked)}),t("oneClickAlsoStale")]})]}),!T&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),T&&(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}}),T.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!O,onClick:Q,children:t(O==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),T.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:T.merge.map((g,C)=>(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:[g.a.title," \u21C4 ",g.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(g.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>F(g.a.path,g.b.path),children:t("mergeNow")})]},C))}):(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",T.stale?.length||0,"\uFF09"]}),T.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!O,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;k("clean");let g=0;for(let C of T.stale)try{await fetch(`${E}/delete?path=${encodeURIComponent(C.path)}`),g++}catch{}k(""),notify(`${g} ${t("deletedStale")}`),await $(),d&&d()},children:t("cleanStale")})}),T.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:T.stale.map(g=>(0,e.jsx)(oe,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var dt=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function Zt({t,newCard:l,setNewCard:d,onCreated:v}){if(!l)return null;let u=dt.find(y=>y.key===l.template),i=l.body||(u?t(u.bodyKey):""),A=l.kind||(u?u.kind:"knowledge"),M=l.tags||(u?t(u.tagKey):""),T=l._creating,z=y=>{let x=dt.find(H=>H.key===y);d(H=>({...H,template:y,kind:x?x.kind:H.kind,body:x?t(x.bodyKey):H.body,tags:x?t(x.tagKey):H.tags}))},w=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${E}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:A,tags:M.split(",").map(x=>x.trim()).filter(Boolean),body:i,source:"manual"})}).then(x=>x.json())).ok?(d(null),v&&v()):d(x=>({...x,_creating:!1}))}catch{d(x=>({...x,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ne}),(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:[dt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>z(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:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:A,onChange:y=>d(x=>({...x,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(x=>({...x,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:M,onChange:y=>d(x=>({...x,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(x=>({...x,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:T,onClick:w,children:t(T?"exporting":"createCard")})})]})]})]})}function Qt({t,card:l,query:d,onClose:v,onDelete:u,onFeedback:i}){(0,n.useEffect)(()=>{let z=w=>{w.key==="Escape"&&v()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[v]);let[A,M]=(0,n.useState)(!1),T=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:v,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",onClick:z=>z.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")]})]}),T&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>M(z=>!z),children:t(A?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&u&&u(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:v,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:A?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:la(l.text)}})]})]})}function ea({t,onOpen:l,all:d,onAllChange:v,onMutate:u,active:i,visible:A}){let[M,T]=(0,n.useState)(null),[z,w]=(0,n.useState)(""),y=(0,n.useRef)(!1),x=(0,n.useRef)(0),H=(0,n.useRef)(t);H.current=t;let R=(0,n.useCallback)(async()=>{try{y.current=!1;let j=await(await fetch(`${E}/graph${d?"?all=1":""}`)).json();j.ok?(T(j),w(""),y.current=!0):(T(null),w(j.error||t("error")))}catch(k){w(String(k&&k.message?k.message:k))}},[d,t]);(0,n.useEffect)(()=>{if(!i||y.current)return;let k=!0;return fetch(`${E}/graph${d?"?all=1":""}`).then(j=>j.json()).then(j=>{k&&(j.ok?(T(j),w(""),y.current=!0):(T(null),w(j.error||t("error"))))}).catch(j=>{k&&w(String(j&&j.message?j.message:j))}),()=>{k=!1}},[d,t,i]),(0,n.useEffect)(()=>{A&&M&&x.current++},[A,M]);let I=(0,n.useCallback)(async k=>{try{let le=await(await fetch(`${E}/delete?path=${encodeURIComponent(k)}`)).json();return le&&le.ok?(await R(),u&&u(),!0):!1}catch{return!1}},[R]),O=(0,n.useCallback)(async k=>{if(!k||k.length<2)return!1;try{let j=await fetch(`${E}/merge?paths=${encodeURIComponent(k.join(","))}`).then(le=>le.json());return j&&j.ok?(await R(),u&&u(),!0):!1}catch{return!1}},[R,u]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ne}),z&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",z]}),!M&&!z&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),M&&M.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),M&&M.nodes.length>0&&(0,e.jsx)(aa,{nodes:M.nodes,edges:M.edges,onOpen:l,onDelete:I,onMerge:O,t,all:d,onAllChange:v,countLabel:`${M.nodes.length} ${t("nodes")} \xB7 ${ta(M.edges)} ${t("edges")}`,fitTrigger:x.current})]})}function ta(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var qe={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 aa({nodes:t,edges:l,onOpen:d,onDelete:v,onMerge:u,t:i,countLabel:A,all:M,onAllChange:T,fitTrigger:z}){let w=(0,n.useRef)(null),y=(0,n.useRef)(null),x=(0,n.useRef)(null),H=(0,n.useRef)(null),R=(0,n.useRef)(null),I=(0,n.useRef)(d);(0,n.useEffect)(()=>{I.current=d},[d]);let O=(0,n.useRef)(v);(0,n.useEffect)(()=>{O.current=v},[v]);let k=(0,n.useRef)(u);(0,n.useEffect)(()=>{k.current=u},[u]);let[j,le]=(0,n.useState)(""),[Q,$]=(0,n.useState)(null),ze=(0,n.useRef)("");(0,n.useEffect)(()=>{ze.current=j.trim().toLowerCase()},[j]),(0,n.useEffect)(()=>{let r=x.current;if(!r)return;let o=j.trim().toLowerCase();if(!o)return;let L=r.nodes.find(J=>(J.name||"").toLowerCase().includes(o));L&&(x.current.selectedId=L.id,$(L.id),r.panX=r.w/2-L.x*r.zoom,r.panY=r.h/2-L.y*r.zoom,r.render&&r.render())},[j]);let[F,se]=(0,n.useState)("all"),[b,oe]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[C,N]=(0,n.useState)(""),ee=(0,n.useRef)(""),[X,Y]=(0,n.useState)(!1),q=(0,n.useRef)(!1),[G,xe]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=F},[F]),(0,n.useEffect)(()=>{ee.current=C},[C]),(0,n.useEffect)(()=>{q.current=X},[X]);let Ee=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let L of o.tags||[]){let J=String(L).trim();J&&r.set(J,(r.get(J)||0)+1)}return[...r.entries()].sort((o,L)=>L[1]-o[1]).slice(0,24).map(([o,L])=>({tag:o,n:L}))},[t]),ve=(()=>{let r=j.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(je[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=x.current;r&&r.wake&&r.wake()},[j]),(0,n.useEffect)(()=>{let r=x.current;r&&r.render&&r.render()},[F,C,X]);let ke=(0,n.useRef)(null),[de,pe]=(0,n.useState)([]),[c,_]=(0,n.useState)(null),[K,ne]=(0,n.useState)(!1),[we,Te]=(0,n.useState)(null),[De,Xe]=(0,n.useState)(""),Ae=(0,n.useRef)(null),me=(0,n.useRef)(null),ie=(r,o=!0)=>{Ae.current&&clearTimeout(Ae.current),Te({msg:r,ok:o}),Ae.current=setTimeout(()=>Te(null),1900)},Ve=r=>{Xe(r),me.current&&clearTimeout(me.current),me.current=setTimeout(()=>Xe(""),1600)};(0,n.useEffect)(()=>()=>{Ae.current&&clearTimeout(Ae.current),me.current&&clearTimeout(me.current)},[]);let Ce=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=w.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let L=Math.max(1,window.devicePixelRatio||1),J=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(s=>{ce[s.source]=(ce[s.source]||0)+1,ce[s.target]=(ce[s.target]||0)+1});let m=Math.max(1,...Object.values(ce)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(ce[s.id]||0)/m*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:L,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,h)=>(s[h.id]=h,s),{}),a.nodes.forEach((s,h)=>{let f=h/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let W=[...new Set(a.nodes.map(s=>s.type))];a.clustered=W.length>1,a.typeCenters={},W.forEach((s,h)=>{let f=h/W.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),x.current=a;let V=0,he=0,Re=()=>{let s=r.clientWidth,h=r.clientHeight;a.w=s,a.h=h,r.width=s*L,r.height=h*L,o.setTransform(L,0,0,L,0,0),(V===0||he===0)&&s>0&&h>0&&a.tickCount>0&&requestAnimationFrame(()=>Se()),V=s,he=h};Re();let He=new ResizeObserver(Re);He.observe(r.parentElement);let lt=(s,h)=>s&&s.length>h?s.slice(0,h)+"\u2026":s,Fe=(s,h,f,S)=>{if(o.beginPath(),S==="rect")o.rect(s-f,h-f*.75,f*2,f*1.5);else if(S==="diamond")o.moveTo(s,h-f),o.lineTo(s+f,h),o.lineTo(s,h+f),o.lineTo(s-f,h),o.closePath();else if(S==="hexagon"){for(let B=0;B<6;B++){let Z=Math.PI/3*B-Math.PI/2,U=s+f*Math.cos(Z),ge=h+f*Math.sin(Z);B===0?o.moveTo(U,ge):o.lineTo(U,ge)}o.closePath()}else o.arc(s,h,f,0,Math.PI*2)},Se=()=>{if(!a.nodes.length)return;let s=1/0,h=-1/0,f=1/0,S=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),h=Math.max(h,p.x),f=Math.min(f,p.y),S=Math.max(S,p.y)});let B=20,Z=h-s+B*2,U=S-f+B*2,ge=Math.min(a.w/Z,a.h/U);a.zoom=Math.max(.35,Math.min(1.8,ge)),a.panX=a.w/2-(s+h)/2*a.zoom,a.panY=a.h/2-(f+S)/2*a.zoom};H.current=Se;let pt=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=ze.current,a.kindFilter=g.current,a.timeMode=q.current,a.tagFilter=ee.current;let s=a.tagFilter,h=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=J()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let p=0;p<a.w;p+=24)o.beginPath(),o.moveTo(p,0),o.lineTo(p,a.h),o.stroke();for(let p=0;p<a.h;p+=24)o.beginPath(),o.moveTo(0,p),o.lineTo(a.w,p),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let S={};a.nodes.forEach(p=>S[p.id]=p);let B=a.nodes.length>40,Z=B?1.5:.55,U=a.selectedId||a.hoverId;a.edges.forEach(p=>{let te=S[p.sourceNodeId],D=S[p.targetNodeId];if(!te||!D)return;if(h!=="all"){let nt=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,ye=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(nt!==h&&ye!==h)return}if(s){let nt=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),ye=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!nt&&!ye)return}let P=D.x-te.x,ae=D.y-te.y,re=Math.sqrt(P*P+ae*ae)||1,ue=B?12:18,fe=-ae/re*ue,be=P/re*ue,Ie=(te.x+D.x)/2+fe,Le=(te.y+D.y)/2+be,Be=qe.colors[a.domainById[te.id]&&a.domainById[te.id].kind||"other"],Oe=U&&(p.sourceNodeId===U||p.targetNodeId===U),rt=U?Oe?.6:.08:B?.14:.24,st=parseInt(Be.slice(1,3),16),Je=parseInt(Be.slice(3,5),16),at=parseInt(Be.slice(5,7),16);o.strokeStyle="rgba("+st+","+Je+","+at+","+rt+")",o.lineWidth=Oe?1.6+(p.weight||1):.8+(p.weight||1)*.5,o.beginPath(),o.moveTo(te.x,te.y),o.quadraticCurveTo(Ie,Le,D.x,D.y),o.stroke()});let ge=[];if(a.nodes.forEach(p=>{let te=a.domainById[p.id]||{},D=te.kind||"other",P=a.timeMode?na(te.updated):qe.colors[D],ae=qe.shapes[D],re=a.selectedId===p.id,ue=a.hoverId===p.id,fe=a.searchTerm||"",be=!fe||(p.name||"").toLowerCase().includes(fe)||String(je[D]||"").toLowerCase().includes(fe)||String(D).toLowerCase().includes(fe),Ie=h==="all"||D===h,Le=!s||(te.tags||[]).includes(s),Be=U&&p.id!==U&&!a.edges.some(ye=>ye.sourceNodeId===U&&ye.targetNodeId===p.id||ye.targetNodeId===U&&ye.sourceNodeId===p.id)||fe&&!be||!Ie||!Le;o.save(),o.globalAlpha=Be?.08:1,(re||ue)&&(o.shadowColor=P,o.shadowBlur=re?20:14),Fe(p.x,p.y,p.r,ae);let Oe=parseInt(P.slice(1,3),16),rt=parseInt(P.slice(3,5),16),st=parseInt(P.slice(5,7),16),Je=o.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);Je.addColorStop(0,"rgba("+Math.min(255,Oe+70)+","+Math.min(255,rt+70)+","+Math.min(255,st+70)+",0.95)"),Je.addColorStop(1,P),o.fillStyle=Je,o.fill(),o.restore(),re?(o.save(),Fe(p.x,p.y,p.r+3,ae),o.strokeStyle=P,o.lineWidth=3,o.shadowColor=P,o.shadowBlur=12,o.stroke(),o.restore()):ue?(o.save(),Fe(p.x,p.y,p.r+2,ae),o.strokeStyle=P,o.lineWidth=2,o.stroke(),o.restore()):fe&&be?(o.save(),Fe(p.x,p.y,p.r+2,ae),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(p.id)>=0&&(o.save(),Fe(p.x,p.y,p.r+2,ae),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let at=lt(p.name,16);if((re||ue||a.zoom>Z||!B&&a.zoom>.6)&&Ie&&Le){let ye=1/a.zoom;o.font="500 "+(12*ye).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Pe=o.measureText(at).width+16*ye,ot=18*ye,_e=p.y+p.r+8*ye,wt=!0;for(let Ue of ge)if(p.x-Pe/2<Ue.x+Ue.w&&p.x+Pe/2>Ue.x&&_e<Ue.y+Ue.h&&_e+ot>Ue.y){wt=!1;break}if(!wt&&!re&&!ue)return;ge.push({x:p.x-Pe/2,y:_e,w:Pe,h:ot}),o.fillStyle=J()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(p.x-Pe/2,_e,Pe,ot,4*ye):o.rect(p.x-Pe/2,_e,Pe,ot),o.fill(),o.strokeStyle=J()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*ye,o.stroke(),o.fillStyle=J()?re||ue?"#eee":"#bbb":re||ue?"#111":"#444",o.textAlign="center",o.fillText(at,p.x,_e+13*ye)}}),o.restore(),a.marquee){let p=a.marquee,te=Math.min(p.sx,p.ex),D=Math.min(p.sy,p.ey),P=Math.abs(p.ex-p.sx),ae=Math.abs(p.ey-p.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(te,D,P,ae),o.strokeRect(te,D,P,ae),o.restore()}if(a.hoverId&&ke.current){let p=a.domainById[a.hoverId],te=a.nodes.find(function(D){return D.id===a.hoverId});if(p&&te){let D=a.edges.filter(function(re){return re.sourceNodeId===p.id||re.targetNodeId===p.id}).length,P=te.x*a.zoom+a.panX,ae=te.y*a.zoom+a.panY;ke.current.style.display="block",ke.current.style.left=P+14+"px",ke.current.style.top=ae-6+"px",ke.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",D)+"</span>"}}else ke.current&&(ke.current.style.display="none")},Me=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(ut))};a.wake=Me,a.render=pt;let mt=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),S=s>1e3?3e3:s>100?2e3:s>50?1200:800,B=s>100?.002:.005,Z=s>1e3?.012:s>100?.005:.01,U=s>1e3?6:s>200?12:24,ge={};a.nodes.forEach(D=>ge[D.id]=D);for(let D=0;D<s;D++){if(a.dragNode===a.nodes[D])continue;let P=a.nodes[D],ae=0,re=0;for(let be=0;be<s;be++){if(D===be)continue;let Ie=P.x-a.nodes[be].x,Le=P.y-a.nodes[be].y,Be=Math.sqrt(Ie*Ie+Le*Le)||1,Oe=S/(Be*Be);ae+=Ie/Be*Oe,re+=Le/Be*Oe}if(a.clustered&&a.typeCenters[P.type]){let be=a.typeCenters[P.type];ae+=(be.x-P.x)*.006,re+=(be.y-P.y)*.006}else ae-=P.x*Z,re-=P.y*Z;let ue=(P.vx+ae)*f,fe=(P.vy+re)*f;ue=Math.max(-U,Math.min(U,ue)),fe=Math.max(-U,Math.min(U,fe)),P.vx=ue,P.vy=fe}a.edges.forEach(D=>{let P=ge[D.sourceNodeId],ae=ge[D.targetNodeId];if(!P||!ae)return;let re=ae.x-P.x,ue=ae.y-P.y,fe=Math.sqrt(re*re+ue*ue)||1,be=(fe-100)*B,Ie=re/fe*be,Le=ue/fe*be;a.dragNode!==P&&(P.vx+=Ie,P.vy+=Le),a.dragNode!==ae&&(ae.vx-=Ie,ae.vy-=Le)});let p=0;a.nodes.forEach(D=>{a.dragNode!==D&&(D.x+=D.vx,D.y+=D.vy,p+=D.vx*D.vx+D.vy*D.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Se()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},ut=()=>{if(a.running){try{mt(),pt()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(ut)}},Ge=(s,h)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(h-f.top-a.panY)/a.zoom}},et=s=>{let h=a.domainById[s];return!(!h||g.current!=="all"&&h.kind!==g.current||ee.current&&!(h.tags||[]).includes(ee.current))},tt=(s,h,f)=>Math.max(h,Math.min(f,s)),gt=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let h=Ge(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let B=a.nodes[S];if(!et(B.id))continue;let Z=B.x-h.x,U=B.y-h.y;if(Z*Z+U*U<B.r*B.r+36){f=B.id;break}}f!==a.hoverId&&(a.hoverId=f,Me())},ft=s=>{if(s.button!==0)return;let h=Ge(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let B=a.nodes[S];if(!et(B.id))continue;let Z=B.x-h.x,U=B.y-h.y;if(Z*Z+U*U<B.r*B.r+25){f=B;break}}if(s.shiftKey){if(f){a.shiftClick=f.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=f||null,f&&(a.dragOffset={dx:f.x-h.x,dy:f.y-h.y})},bt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,Me();return}if(!a.dragStart)return;let h=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let S=Ge(s.clientX,s.clientY);a.dragNode.x=S.x+a.dragOffset.dx,a.dragNode.y=S.y+a.dragOffset.dy,Me()}else a.dragging&&(a.panX=tt(a.dragStart.px+h,-1e5,1e5),a.panY=tt(a.dragStart.py+f,-1e5,1e5),Me())},yt=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let S=r.getBoundingClientRect(),B=Math.min(f.sx,f.ex)-S.left,Z=Math.max(f.sx,f.ex)-S.left,U=Math.min(f.sy,f.ey)-S.top,ge=Math.max(f.sy,f.ey)-S.top,p=a.nodes.filter(te=>{let D=te.x*a.zoom+a.panX,P=te.y*a.zoom+a.panY;return D>=B&&D<=Z&&P>=U&&P<=ge}).map(te=>te.id);a.multi=p,pe(p),Me();return}let h=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let S=Array.isArray(a.multi)?a.multi.slice():[];S.includes(f)||S.push(f),a.multi=S,pe(S),Me();return}if(h){let f=Ge(s.clientX,s.clientY),S=null;for(let B=a.nodes.length-1;B>=0;B--){let Z=a.nodes[B];if(!et(Z.id))continue;let U=Z.x-f.x,ge=Z.y-f.y;if(U*U+ge*ge<Z.r*Z.r+20){S=Z;break}}S?(a.selectedId=S.id,$(S.id),Me()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],pe([])),$(null),Me())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ht=s=>{s.preventDefault();let h=Ge(s.clientX,s.clientY),f=null;for(let S=a.nodes.length-1;S>=0;S--){let B=a.nodes[S];if(!et(B.id))continue;let Z=B.x-h.x,U=B.y-h.y;if(Z*Z+U*U<B.r*B.r+25){f=B;break}}if(f){let S=a.domainById[f.id];S&&xe({x:s.clientX,y:s.clientY,id:f.id,path:S.id,title:S.title})}else xe(null)},xt=s=>{s.preventDefault();let h=r.getBoundingClientRect(),f=(s.clientX-h.left-a.panX)/a.zoom,S=(s.clientY-h.top-a.panY)/a.zoom,B=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=tt(a.panX+f*(a.zoom-B),-1e5,1e5),a.panY=tt(a.panY+S*(a.zoom-B),-1e5,1e5),a.zoom=B,Me()};r.addEventListener("mousemove",gt),r.addEventListener("mousedown",ft),window.addEventListener("mousemove",bt),window.addEventListener("mouseup",yt),r.addEventListener("wheel",xt,{passive:!1}),r.addEventListener("contextmenu",ht),R.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],pe([]),Se(),Me()};for(let s=0;s<200;s++)mt();Se(),Me();let vt=()=>oe(!1);return window.addEventListener("mousedown",vt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),He.disconnect(),r.removeEventListener("mousemove",gt),r.removeEventListener("mousedown",ft),window.removeEventListener("mousemove",bt),window.removeEventListener("mouseup",yt),r.removeEventListener("wheel",xt),r.removeEventListener("contextmenu",ht),window.removeEventListener("mousedown",vt)}},[t,l]),(0,n.useEffect)(()=>{z!==void 0&&H.current&&requestAnimationFrame(()=>H.current())},[z]),(0,e.jsxs)("div",{className:"me-graph",ref:y,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:j,onChange:r=>le(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>oe(r=>!r),"aria-expanded":b,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",F!=="all"||X||C?"\u25CF":"\u25BE"]}),b&&(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${F==="all"&&!X?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{se("all"),Y(!1)},children:i("all")}),Object.keys($e).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${F===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>se(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:qe.colors[r]||$e[r]}}),i(je[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${X?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>Y(r=>!r),children:["\u23F1 ",i("timeDim")]}),Ee.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:Ee.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${C===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>N(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(F!=="all"||X||C)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{se("all"),Y(!1),N("")},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:!!M,onChange:r=>T&&T(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${X?" me-on":""}`,onClick:()=>Y(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=w.current;if(r)try{r.toBlob(o=>{o&&_({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>H.current&&H.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{$(null),se("all"),R.current&&R.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:w,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ke,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)"}}),ve&&(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")}),G&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),G&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:G.x,top:G.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{I.current({path:G.path,title:G.title}),xe(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.id&&(x.current.selectedId=G.id,$(G.id)),xe(null);let r=x.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(G.title||"")}catch{}xe(null),ie(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=x.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],L=G.id;if(L&&!o.includes(L)&&o.push(L),xe(null),o.length<2){ie(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let J=k.current&&k.current(o);J&&J.then?J.then(ce=>ce?ie(i("merged")):ie(i("mergeFail"),!1)).catch(()=>ie(i("mergeFail"),!1)):J&&ie(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=G.path;xe(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(O.current?await O.current(r):!1)?ie(i("deleted")):ie(i("deleteFail"),!1)}catch{ie(i("deleteFail"),!1)}})()},children:i("delete")})]}),de.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:[de.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=de.map(m=>Ce[m]).filter(Boolean).map(m=>m.title||m.name).join(`
|
|
227
|
+
`),L=new Blob([o],{type:"text/plain;charset=utf-8"}),J=URL.createObjectURL(L),ce=document.createElement("a");ce.href=J,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(J),1e3),ie(de.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(de.length<2){ie(i("mergeNeed"),!1);return}let r=de.map(L=>Ce[L]?Ce[L].id:L);if(!window.confirm(i("mergeConfirm")))return;pe([]);let o=x.current;o&&(o.multi=[]),fetch(`${E}/merge?paths=${encodeURIComponent(r.join(","))}`).then(L=>L.json()).then(L=>{L&&L.ok?ie(i("merged")):ie(i("mergeFail"),!1)}).catch(()=>ie(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=de.map(L=>Ce[L]?Ce[L].id:L);pe([]);let o=x.current;o&&(o.multi=[]),(async()=>{let L=0;for(let J of r)try{(O.current?await O.current(J):!1)&&L++}catch{}ie(L+i("deletedSelected"),L>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=x.current;r&&(r.multi=[]),pe([]);let o=x.current;o&&o.render&&o.render()},children:i("clearSelection")})]}),Q&&(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:Ce[Q]?Ce[Q].title||Ce[Q].name:Q}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:Ce[Q]?i(je[Ce[Q].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===Q||r.target===Q)||[]).slice(0,8).map((r,o)=>{let L=r.source===Q?r.target:r.source,J=Ce[L];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let m=x.current;m&&(m.selectedId=L,m.hoverId=L,m.wake&&m.wake()),$(L)},children:J?(J.title||J.name).slice(0,28):L},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),we&&(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 "+(we.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:we.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:we.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:we.msg})]}),c&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),_(null),ne(!1)},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:K?"100vw":900,width:K?"100vw":"92vw",maxHeight:K?"100vh":"90vh",height:K?"100vh":void 0,borderRadius:K?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:c.url,download:"memory-graph.png",onClick:()=>{Ve("download"),ie(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(De==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ve("full"),ne(r=>!r),ie(i("fullscreen"))},children:i(De==="full"?"done":K?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=c.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{Ve("copy"),ie(i("copied"))}).catch(()=>{ie(i("copyFail"),!1)}):ie(i("copyFail"),!1)},children:i(De==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),_(null),ne(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:K?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:c.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:K?"calc(100vh - 64px)":"70vh",borderRadius:K?0:8,cursor:"zoom-in"},onClick:()=>ne(r=>!r)})})]})]})]})}function na(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 St({label:t,value:l=[],options:d,onChange:v,placeholder:u,z:i=20}){let[A,M]=(0,n.useState)(!1),T=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!A)return;let I=O=>{T.current&&!T.current.contains(O.target)&&M(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[A]);let z=Array.isArray(l)?l:[],w=z.includes("__all__"),y=w?d.find(I=>I.value==="__all__")?.label||"":z.length?z.map(I=>d.find(O=>O.value===I)?.label||I).join("\u3001"):"",x=(I,O)=>{if(I.value==="__all__"){v(O?["__all__"]:[]);return}let k=new Set(z);k.has("__all__")&&k.delete("__all__"),O?k.add(I.value):k.delete(I.value),v([...k])},H=d.find(I=>I.value==="__all__"),R=d.filter(I=>I.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:T,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>M(I=>!I),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||u||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),A&&(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:[H&&(0,e.jsxs)("label",{onClick:I=>I.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:w,onChange:I=>x(H,I.target.checked)}),(0,e.jsx)("span",{children:H.label})]}),R.map(I=>(0,e.jsxs)("label",{onClick:O=>O.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:z.includes(I.value),onChange:O=>x(I,O.target.checked)}),(0,e.jsx)("span",{children:I.label})]},I.value))]})]})]})}function oa(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function ia(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),A=await i.createWritable();return await A.write(t),await A.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 v=URL.createObjectURL(t),u=document.createElement("a");return u.href=v,u.download=l,document.body.appendChild(u),u.click(),document.body.removeChild(u),setTimeout(()=>URL.revokeObjectURL(v),1e3),{ok:!0,picked:!1,name:l}}function Mt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),v=l.toLowerCase(),u=[],i=0;for(;i<t.length;){let A=d.indexOf(v,i);if(A<0){u.push(t.slice(i));break}A>i&&u.push(t.slice(i,A)),u.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(A,A+v.length)},A)),i=A+v.length}return u}function la(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(v,u,i){return d.push("<pre><code>"+i+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(v,u,i){return"<h"+u.length+">"+i+"</h"+u.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(v,u,i){return/^(https?:|\/)/.test(i)?'<a href="'+i+'" target="_blank" rel="noopener noreferrer">'+u+"</a>":u}),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(v,u){return d[u]}),l}function Qe(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,v=l.toDateString()===d.toDateString(),u=A=>String(A).padStart(2,"0"),i=`${u(l.getHours())}:${u(l.getMinutes())}`;return v?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
|
|
228
228
|
|
|
229
229
|
return module.exports;
|
|
230
230
|
},
|