dsh-memory-eternal 0.4.25 → 0.4.27

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.
Files changed (2) hide show
  1. package/lib/client.js +5 -5
  2. package/package.json +1 -1
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 Ct=Object.create;var Qe=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var St=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var zt=(t,s)=>{for(var d in s)Qe(t,d,{get:s[d],enumerable:!0})},ht=(t,s,d,y)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of Mt(s))!It.call(t,u)&&u!==d&&Qe(t,u,{get:()=>s[u],enumerable:!(y=Nt(s,u))||y.enumerable});return t};var Tt=(t,s,d)=>(d=t!=null?Ct(St(t)):{},ht(s||!t||!t.__esModule?Qe(d,"default",{value:t,enumerable:!0}):d,t)),Lt=t=>ht(Qe({},"__esModule",{value:!0}),t);var Vt={};zt(Vt,{apply:()=>Et,inject:()=>Bt});module.exports=Lt(Vt);var c=Tt(require("react"),1),e=require("react/jsx-runtime"),De="memory-eternal",P="/memory-eternal/api",Bt=["settingsScope","slots","locale","connection","remote"],$t={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",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}",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"},jt={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",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}",mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},Ft=["all","project","knowledge","content","prompt","business","tool","mistake"],tt={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},$e={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Se=`
6
+ var wt=Object.create;var Ve=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var St=(t,s)=>{for(var p in s)Ve(t,p,{get:s[p],enumerable:!0})},gt=(t,s,p,k)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of Ct(s))!Mt.call(t,d)&&d!==p&&Ve(t,d,{get:()=>s[d],enumerable:!(k=kt(s,d))||k.enumerable});return t};var It=(t,s,p)=>(p=t!=null?wt(Nt(t)):{},gt(s||!t||!t.__esModule?Ve(p,"default",{value:t,enumerable:!0}):p,t)),zt=t=>gt(Ve({},"__esModule",{value:!0}),t);var Kt={};St(Kt,{apply:()=>jt,inject:()=>Tt});module.exports=zt(Kt);var c=It(require("react"),1),e=require("react/jsx-runtime"),Fe="memory-eternal",U="/memory-eternal/api",Tt=["settingsScope","slots","locale","connection","remote"],Lt={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",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}",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"},Bt={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",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}",mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},Ft=["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"},ze={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Ne=`
7
7
  .memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
8
8
  .mc-card { background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 12px; padding: 14px 16px; }
9
9
  .mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
@@ -119,11 +119,11 @@ var Ct=Object.create;var Qe=Object.defineProperty;var Nt=Object.getOwnPropertyDe
119
119
  .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; }
120
120
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
121
121
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
122
- `;function Et(t){t.effect(()=>t.locale.register(De,{zh:$t,en:jt}),"memory-eternal: locale");let s=t.locale.bind(De);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:De,order:25,label:()=>s("nav"),locale:De,inject:()=>({})},()=>c.default.createElement(wt,{t:s,inModal:!1}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${De}:footer`,order:100,label:()=>s("nav"),locale:De,inject:()=>({})},d=>c.default.createElement(Rt,{t:s,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function Rt({t,wide:s}){let[d,y]=(0,c.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:Se}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>y(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(vt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(Dt,{t,onClose:()=>y(!1)})]})}function vt(){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 Dt({t,onClose:s}){let[d,y]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let u=r=>{r.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:Se}),(0,e.jsx)("div",{className:"me-modal",onClick:u=>u.stopPropagation(),style:d?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(wt,{t,inModal:!0,onClose:s,onFull:()=>y(u=>!u),full:d})})]})}function wt({t,inModal:s,onClose:d,onFull:y,full:u}){let[r,L]=(0,c.useState)(null),[I,K]=(0,c.useState)([]),[O,se]=(0,c.useState)(!0),[m,x]=(0,c.useState)(""),[D,ve]=(0,c.useState)("all"),[J,Ie]=(0,c.useState)(""),[B,ke]=(0,c.useState)("cards"),[H,he]=(0,c.useState)("recent"),[me,p]=(0,c.useState)(null),N=(0,c.useRef)(null),A=(0,c.useRef)(null),[U,V]=(0,c.useState)(!1),[X,j]=(0,c.useState)(null),[oe,ce]=(0,c.useState)(!1),[le,Ye]=(0,c.useState)(!0),[re,ue]=(0,c.useState)(null),Ce=(0,c.useRef)(null),[qe,de]=(0,c.useState)(24),ye=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(B!=="cards")return;let f=ye.current;if(!f)return;let z=new IntersectionObserver(C=>{C[0]&&C[0].isIntersecting&&de(ie=>ie+24)},{rootMargin:"400px"});return z.observe(f),()=>z.disconnect()},[B,I,D,J]);let we=(0,c.useCallback)(async(f=D,z=J)=>{try{se(!0),x("");let C=new URLSearchParams;f&&f!=="all"&&C.set("kind",f),z.trim()&&C.set("q",z.trim());let S=await(await fetch(`${P}/cards?${C.toString()}`)).json();S.ok&&(K(S.cards||[]),de(24))}catch(C){x(String(C&&C.message?C.message:C))}finally{se(!1)}},[D,J]),G=(0,c.useCallback)(async()=>{try{let[f,z]=await Promise.all([fetch(`${P}/overview`).then(C=>C.json()),fetch(`${P}/cards`).then(C=>C.json())]);f.ok&&L(f),z.ok&&(K(z.cards||[]),de(24))}catch(f){x(String(f&&f.message?f.message:f))}finally{se(!1)}},[]),je=async f=>{try{let C=await(await fetch(`${P}/delete?path=${encodeURIComponent(f)}`)).json();C.ok?(p({ok:!0,msg:t("deleted")}),await G()):p({ok:!1,msg:C.error||t("deleteFail")})}catch{p({ok:!1,msg:t("deleteFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)};(0,c.useEffect)(()=>(G(),()=>{Ce.current&&clearTimeout(Ce.current)}),[G]);let Xe=f=>{Ie(f),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>we(D,f),280)},Ke=f=>{ve(f),we(f,J)},pe=async f=>{try{let C=await(await fetch(`${P}/card?path=${encodeURIComponent(f.path||f.id)}`)).json();C.ok&&j({path:C.path,title:f.title,text:C.text})}catch(z){x(String(z&&z.message?z.message:z))}},ze=async(f,z)=>{V(!0);try{let C=await fetch(`${P}/export`);if(!C.ok)throw new Error("HTTP "+C.status);let ie=await C.json();if(!ie.ok)throw new Error(ie.error||"export failed");let S,Le,ne;f==="json"?(Le="memory-vault.json",ne="application/json",S=JSON.stringify(ie.cards.map(b=>({path:b.path,title:b.title,kind:b.kind,text:b.text})),null,2)):(Le="memory-vault.md",ne="text/markdown;charset=utf-8",S=ie.cards.map(b=>b.text.trim()).filter(Boolean).join(`
122
+ `;function jt(t){t.effect(()=>t.locale.register(Fe,{zh:Lt,en:Bt}),"memory-eternal: locale");let s=t.locale.bind(Fe);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Fe,order:25,label:()=>s("nav"),locale:Fe,inject:()=>({})},()=>c.default.createElement(yt,{t:s,inModal:!1}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Fe}:footer`,order:100,label:()=>s("nav"),locale:Fe,inject:()=>({})},p=>c.default.createElement($t,{t:s,wide:!(p&&p.wide===!1)}))),"memory-eternal: sidebar footer action")}function $t({t,wide:s}){let[p,k]=(0,c.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>k(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(ht,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),p&&(0,e.jsx)(Et,{t,onClose:()=>k(!1)})]})}function ht(){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 Et({t,onClose:s}){let[p,k]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let d=r=>{r.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("div",{className:"me-modal",onClick:d=>d.stopPropagation(),style:p?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(yt,{t,inModal:!0,onClose:s,onFull:()=>k(d=>!d),full:p})})]})}function yt({t,inModal:s,onClose:p,onFull:k,full:d}){let[r,z]=(0,c.useState)(null),[q,S]=(0,c.useState)([]),[Y,X]=(0,c.useState)(!0),[y,h]=(0,c.useState)(""),[N,ie]=(0,c.useState)("all"),[K,Me]=(0,c.useState)(""),[P,oe]=(0,c.useState)("cards"),[G,be]=(0,c.useState)("recent"),[he,B]=(0,c.useState)(null),m=(0,c.useRef)(null),T=(0,c.useRef)(null),[R,D]=(0,c.useState)(!1),[H,te]=(0,c.useState)(null),[j,V]=(0,c.useState)(!1),[ae,We]=(0,c.useState)(!0),[ne,pe]=(0,c.useState)(null),[$e,Je]=(0,c.useState)(0),me=(0,c.useCallback)(()=>Je(u=>u+1),[]),se=(0,c.useRef)(null),[ve,ce]=(0,c.useState)(24),Te=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(P!=="cards")return;let u=Te.current;if(!u)return;let C=new IntersectionObserver(o=>{o[0]&&o[0].isIntersecting&&ce(n=>n+24)},{rootMargin:"400px"});return C.observe(u),()=>C.disconnect()},[P,q,N,K]);let de=(0,c.useCallback)(async(u=N,C=K)=>{try{X(!0),h("");let o=new URLSearchParams;u&&u!=="all"&&o.set("kind",u),C.trim()&&o.set("q",C.trim());let f=await(await fetch(`${U}/cards?${o.toString()}`)).json();f.ok&&(S(f.cards||[]),ce(24))}catch(o){h(String(o&&o.message?o.message:o))}finally{X(!1)}},[N,K]),le=(0,c.useCallback)(async()=>{try{let[u,C]=await Promise.all([fetch(`${U}/overview`).then(o=>o.json()),fetch(`${U}/cards`).then(o=>o.json())]);u.ok&&z(u),C.ok&&(S(C.cards||[]),ce(24))}catch(u){h(String(u&&u.message?u.message:u))}finally{X(!1)}},[]),we=async u=>{try{let o=await(await fetch(`${U}/delete?path=${encodeURIComponent(u)}`)).json();o.ok?(B({ok:!0,msg:t("deleted")}),await le()):B({ok:!1,msg:o.error||t("deleteFail")})}catch{B({ok:!1,msg:t("deleteFail")})}m.current&&clearTimeout(m.current),m.current=setTimeout(()=>B(null),2e3)};(0,c.useEffect)(()=>(le(),()=>{se.current&&clearTimeout(se.current)}),[le]);let Ae=u=>{Me(u),se.current&&clearTimeout(se.current),se.current=setTimeout(()=>de(N,u),280)},Ee=u=>{ie(u),de(u,K)},Re=async u=>{try{let o=await(await fetch(`${U}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();o.ok&&te({path:o.path,title:u.title,text:o.text})}catch(C){h(String(C&&C.message?C.message:C))}},ke=async(u,C)=>{D(!0);try{let o=await fetch(`${U}/export`);if(!o.ok)throw new Error("HTTP "+o.status);let n=await o.json();if(!n.ok)throw new Error(n.error||"export failed");let f,L,W;u==="json"?(L="memory-vault.json",W="application/json",f=JSON.stringify(n.cards.map(ye=>({path:ye.path,title:ye.title,kind:ye.kind,text:ye.text})),null,2)):(L="memory-vault.md",W="text/markdown;charset=utf-8",f=n.cards.map(ye=>ye.text.trim()).filter(Boolean).join(`
123
123
 
124
124
  ---
125
125
 
126
- `));let n=new Blob([S],{type:ne}),o=await Kt(n,Le,!1);if(!o.ok){p({ok:!1,msg:t("exportFail")}),V(!1);return}p({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+o.name})}catch(C){p({ok:!1,msg:t("exportFail")+" \xB7 "+(C.message||"")})}finally{V(!1)}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2600)},Te=async f=>{let z=f.target.files&&f.target.files[0];if(f.target.value="",!!z){try{let C=await z.text(),S=await(await fetch(`${P}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:C})).json();S.ok?(await G(),p({ok:!0,msg:t("importedVault")+"\uFF1A"+(S.imported||0)+(S.skipped?t("importedSkipped")+S.skipped:"")})):p({ok:!1,msg:S.error||t("importFail")})}catch{p({ok:!1,msg:t("importFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2400)}},Pe=(0,c.useMemo)(()=>{let f=I.slice();return H==="title"?f.sort((z,C)=>String(z.title||"").localeCompare(String(C.title||""))):H==="hot"?f.sort((z,C)=>(C.weight||C.links||0)-(z.weight||z.links||0)):f.sort((z,C)=>new Date(C.updated||0).getTime()-new Date(z.updated||0).getTime()),f},[I,H]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Se}),me&&(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 "+(me.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:me.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:me.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:me.msg})]}),s&&(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)(vt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),y&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:y,"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"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${le?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ye(f=>!f),"aria-label":t(le?"collapse":"expand"),title:t(le?"collapse":"expand"),children:le?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${B==="cards"?" active":""}`,onClick:()=>ke("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),le&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${B==="graph"?" active":""}`,onClick:()=>ke("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),le&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${B==="stats"?" active":""}`,onClick:()=>ke("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),le&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${B==="optimize"?" active":""}`,onClick:()=>ke("optimize"),title:t("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),le&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabOptimize")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[B==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(et,{label:t("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(et,{label:t("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(et,{label:t("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(et,{label:t("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),B==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:J,onChange:f=>Xe(f.target.value)}),(0,e.jsx)("input",{ref:A,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Te}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>A.current&&A.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ue({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:U,onClick:()=>ze("md"),children:t(U?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:U,onClick:()=>ze("json"),children:t(U?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>G(),children:t("refresh")})]}),B==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Ft.map(f=>(0,e.jsx)("button",{type:"button",className:`mc-chip${D===f?" active":""}`,onClick:()=>Ke(f),children:t(f==="all"?"all":$e[f])},f)),(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(f=>(0,e.jsx)("button",{type:"button",className:`mc-chip${H===f.key?" active":""}`,onClick:()=>he(f.key),children:f.label},f.key))]}),m&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",m]}),B==="cards"?O&&!I.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):I.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:Pe.slice(0,qe).map(f=>(0,e.jsx)(Ot,{card:f,t,query:J.trim(),onOpen:pe,onDelete:je},f.path))}),Pe.length>qe&&(0,e.jsx)("div",{ref:ye,style:{height:1}})]}):B==="graph"?(0,e.jsx)(At,{t,onOpen:pe,all:oe,onAllChange:ce}):B==="stats"?(0,e.jsx)(yt,{t,tab:"stats",onReload:()=>G()}):(0,e.jsx)(yt,{t,tab:"optimize",onReload:()=>G()}),X&&(0,e.jsx)(Wt,{t,card:X,query:J.trim(),onClose:()=>j(null),onDelete:f=>{j(null),je(f)},onFeedback:f=>{let z=X.path;fetch(`${P}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:J.trim(),path:z,useful:f})}).then(()=>p({ok:!0,msg:t(f?"fbUseful":"fbIrr")})).catch(()=>{}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)}}),(0,e.jsx)(Pt,{t,newCard:re,setNewCard:ue,onCreated:()=>{G(),p({ok:!0,msg:t("created")}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)}})]})]})]})}var et=({label:t,value:s})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:s}),(0,e.jsx)("span",{children:t})]}),Ot=({card:t,t:s,onOpen:d,query:y,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:tt[t.kind]||tt.other}}),y?xt(t.title,y):t.title,Xt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:s("newBadge")})]}),(0,e.jsx)("p",{children:y?xt(t.summary||"",y):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(r=>(0,e.jsx)("span",{className:"mc-tag",children:r},r))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:s($e[t.kind])}),(0,e.jsx)("span",{children:kt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:s("delete"),onClick:r=>{r.stopPropagation(),window.confirm(s("deleteConfirm"))&&u&&u(t.path)},children:"\u2715"})]})]});function yt({t,tab:s,onReload:d}){let[y,u]=(0,c.useState)(null),[r,L]=(0,c.useState)(""),[I,K]=(0,c.useState)(null),[O,se]=(0,c.useState)(null),[m,x]=(0,c.useState)(""),[D,ve]=(0,c.useState)(""),J=(0,c.useCallback)(async()=>{if(m){x("");return}try{let p=await fetch(`${P}/todayBrief`).then(N=>N.json());x(p.ok&&p.brief||"")}catch{}},[m]),Ie=(0,c.useCallback)(async()=>{if(!(!I||!I.merge||!I.merge.length)&&window.confirm(t("mergeAllConfirm"))){ve("merge");try{let p={},N=j=>p[j]===void 0?j:p[j]=N(p[j]),A=(j,oe)=>{p[N(j)]=N(oe)},U=new Set;for(let j of I.merge)U.add(j.a.path),U.add(j.b.path),A(j.a.path,j.b.path);let V={};for(let j of U){let oe=N(j);(V[oe]=V[oe]||[]).push(j)}let X=0;for(let j of Object.values(V)){if(j.length<2)continue;(await fetch(`${P}/merge?paths=${encodeURIComponent(j.join(","))}`).then(ce=>ce.json())).ok&&X++}await B(),d&&d()}catch{}ve("")}},[I,B,d,t]);async function B(){try{let p=await Promise.all([fetch(`${P}/stats`),fetch(`${P}/optimize`),fetch(`${P}/budget`)]),[N,A,U]=await Promise.all(p.map(V=>V.json()));N.ok&&u(N),A.ok&&K(A),U.ok&&se(U),L(N.ok&&A.ok?"":t("adminLoadFail"))}catch{L(t("adminLoadFail"))}}(0,c.useEffect)(()=>{B()},[]);let ke=async(p,N)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${P}/merge?paths=${encodeURIComponent(p+","+N)}`).then(U=>U.json())).ok&&(await B(),d&&d())}catch{}},H=async p=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${P}/delete?path=${encodeURIComponent(p)}`).then(A=>A.json())).ok&&(await B(),d&&d())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],me=({title:p,kind:N,updated:A,path:U})=>(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:Oe.colors[N]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:kt(A)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>H(U),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:Se}),(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:B,children:["\u21BB ",t("retry")]})]}),s==="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:J,children:m?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),m&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:m})]}),y&&(0,e.jsxs)(e.Fragment,{children:[y.trend&&y.trend.length>0&&(()=>{let p=y.trend,N=Math.max(...p.map(X=>X.count),1),A=260,U=50,V=A/p.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:A,height:U,style:{display:"block",width:"100%",height:50},children:p.map((X,j)=>{let oe=Math.round(X.count/N*(U-4));return(0,e.jsx)("rect",{x:j*V+1,y:U-oe,width:Math.max(V-2,2),height:oe,rx:1.5,fill:X.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:X.count>0?.85:.35},X.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:he.map(p=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe.colors[p]||"#666"}}),t($e[p]),": ",y.byKind?.[p]||0]},p))})]}),O&&(O.budgetChars||O.recallLimit||O.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:O.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:O.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",O.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",y.todayCards?.length||0,"\uFF09"]}),y.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:y.todayCards.map(p=>(0,e.jsx)(me,{title:p.title,kind:p.kind,updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),s==="optimize"&&(0,e.jsx)("div",{children:I&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:I.merge?.length?t("mergePairs"):t("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),I.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!D,onClick:Ie,children:t(D==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),I.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:I.merge.map((p,N)=>(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:[p.a.title," \u21C4 ",p.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(p.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ke(p.a.path,p.b.path),children:t("mergeNow")})]},N))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",I.stale?.length||0,"\uFF09"]}),I.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!D,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;ve("clean");let p=0;for(let N of I.stale)try{await fetch(`${P}/delete?path=${encodeURIComponent(N.path)}`),p++}catch{}ve(""),notify(`${p} ${t("deletedStale")}`),await B(),d&&d()},children:t("cleanStale")})}),I.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:I.stale.map(p=>(0,e.jsx)(me,{title:p.title,kind:"other",updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})}var rt=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
126
+ `));let re=new Blob([f],{type:W}),a=await qt(re,L,!1);if(!a.ok){B({ok:!1,msg:t("exportFail")}),D(!1);return}B({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+a.name})}catch(o){B({ok:!1,msg:t("exportFail")+" \xB7 "+(o.message||"")})}finally{D(!1)}m.current&&clearTimeout(m.current),m.current=setTimeout(()=>B(null),2600)},Se=async u=>{let C=u.target.files&&u.target.files[0];if(u.target.value="",!!C){try{let o=await C.text(),f=await(await fetch(`${U}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:o})).json();f.ok?(await le(),B({ok:!0,msg:t("importedVault")+"\uFF1A"+(f.imported||0)+(f.skipped?t("importedSkipped")+f.skipped:"")})):B({ok:!1,msg:f.error||t("importFail")})}catch{B({ok:!1,msg:t("importFail")})}m.current&&clearTimeout(m.current),m.current=setTimeout(()=>B(null),2400)}},O=(0,c.useMemo)(()=>{let u=q.slice();return G==="title"?u.sort((C,o)=>String(C.title||"").localeCompare(String(o.title||""))):G==="hot"?u.sort((C,o)=>(o.weight||o.links||0)-(C.weight||C.links||0)):u.sort((C,o)=>new Date(o.updated||0).getTime()-new Date(C.updated||0).getTime()),u},[q,G]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ne}),he&&(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 "+(he.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:he.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:he.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:he.msg})]}),s&&(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)(ht,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),k&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:k,"aria-label":t(d?"exitFull":"fullscreen"),children:d?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:p,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${ae?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>We(u=>!u),"aria-label":t(ae?"collapse":"expand"),title:t(ae?"collapse":"expand"),children:ae?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="cards"?" active":""}`,onClick:()=>oe("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),ae&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="graph"?" active":""}`,onClick:()=>oe("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),ae&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="stats"?" active":""}`,onClick:()=>oe("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),ae&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="optimize"?" active":""}`,onClick:()=>oe("optimize"),title:t("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),ae&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabOptimize")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[P==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ge,{label:t("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(Ge,{label:t("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(Ge,{label:t("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(Ge,{label:t("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:K,onChange:u=>Ae(u.target.value)}),(0,e.jsx)("input",{ref:T,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Se}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>T.current&&T.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:R,onClick:()=>ke("md"),children:t(R?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:R,onClick:()=>ke("json"),children:t(R?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>le(),children:t("refresh")})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Ft.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${N===u?" active":""}`,onClick:()=>Ee(u),children:t(u==="all"?"all":ze[u])},u)),(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(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${G===u.key?" active":""}`,onClick:()=>be(u.key),children:u.label},u.key))]}),y&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",y]}),P==="cards"?Y&&!q.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):q.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,ve).map(u=>(0,e.jsx)(Rt,{card:u,t,query:K.trim(),onOpen:Re,onDelete:we},u.path))}),O.length>ve&&(0,e.jsx)("div",{ref:Te,style:{height:1}})]}):P==="graph"?(0,e.jsx)(Pt,{t,onOpen:Re,all:j,onAllChange:V,onMutate:me}):P==="stats"?(0,e.jsx)(ft,{t,tab:"stats",onReload:()=>le(),version:$e}):(0,e.jsx)(ft,{t,tab:"optimize",onReload:()=>le(),version:$e}),H&&(0,e.jsx)(Ot,{t,card:H,query:K.trim(),onClose:()=>te(null),onDelete:u=>{te(null),we(u)},onFeedback:u=>{let C=H.path;fetch(`${U}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:K.trim(),path:C,useful:u})}).then(()=>B({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>B(null),2e3)}}),(0,e.jsx)(Dt,{t,newCard:ne,setNewCard:pe,onCreated:()=>{le(),me(),B({ok:!0,msg:t("created")}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>B(null),2e3)}})]})]})]})}var Ge=({label:t,value:s})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:s}),(0,e.jsx)("span",{children:t})]}),Rt=({card:t,t:s,onOpen:p,query:k,onDelete:d})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>p(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[t.kind]||_e.other}}),k?bt(t.title,k):t.title,Yt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:s("newBadge")})]}),(0,e.jsx)("p",{children:k?bt(t.summary||"",k):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(r=>(0,e.jsx)("span",{className:"mc-tag",children:r},r))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:s(ze[t.kind])}),(0,e.jsx)("span",{children:xt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:s("delete"),onClick:r=>{r.stopPropagation(),window.confirm(s("deleteConfirm"))&&d&&d(t.path)},children:"\u2715"})]})]});function ft({t,tab:s,onReload:p,version:k}){let[d,r]=(0,c.useState)(null),[z,q]=(0,c.useState)(""),[S,Y]=(0,c.useState)(null),[X,y]=(0,c.useState)(null),[h,N]=(0,c.useState)(""),[ie,K]=(0,c.useState)(""),Me=(0,c.useCallback)(async()=>{if(h){N("");return}try{let m=await fetch(`${U}/todayBrief`).then(T=>T.json());N(m.ok&&m.brief||"")}catch{}},[h]),P=(0,c.useCallback)(async()=>{if(!(!S||!S.merge||!S.merge.length)&&window.confirm(t("mergeAllConfirm"))){K("merge");try{let m={},T=j=>m[j]===void 0?j:m[j]=T(m[j]),R=(j,V)=>{m[T(j)]=T(V)},D=new Set;for(let j of S.merge)D.add(j.a.path),D.add(j.b.path),R(j.a.path,j.b.path);let H={};for(let j of D){let V=T(j);(H[V]=H[V]||[]).push(j)}let te=0;for(let j of Object.values(H)){if(j.length<2)continue;(await fetch(`${U}/merge?paths=${encodeURIComponent(j.join(","))}`).then(ae=>ae.json())).ok&&te++}await oe(),p&&p()}catch{}K("")}},[S,oe,p,t]);async function oe(){try{let m=await Promise.all([fetch(`${U}/stats`),fetch(`${U}/optimize`),fetch(`${U}/budget`)]),[T,R,D]=await Promise.all(m.map(H=>H.json()));T.ok&&r(T),R.ok&&Y(R),D.ok&&y(D),q(T.ok&&R.ok?"":t("adminLoadFail"))}catch{q(t("adminLoadFail"))}}(0,c.useEffect)(()=>{oe()},[k]);let G=async(m,T)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${U}/merge?paths=${encodeURIComponent(m+","+T)}`).then(D=>D.json())).ok&&(await oe(),p&&p())}catch{}},be=async m=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${U}/delete?path=${encodeURIComponent(m)}`).then(R=>R.json())).ok&&(await oe(),p&&p())}catch{}},he=["project","knowledge","content","prompt","business","tool","mistake"],B=({title:m,kind:T,updated:R,path:D})=>(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:je.colors[T]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:xt(R)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>be(D),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:[z&&(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 ",z]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:oe,children:["\u21BB ",t("retry")]})]}),s==="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:Me,children:h?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),h&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:h})]}),d&&(0,e.jsxs)(e.Fragment,{children:[d.trend&&d.trend.length>0&&(()=>{let m=d.trend,T=Math.max(...m.map(te=>te.count),1),R=260,D=50,H=R/m.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:R,height:D,style:{display:"block",width:"100%",height:50},children:m.map((te,j)=>{let V=Math.round(te.count/T*(D-4));return(0,e.jsx)("rect",{x:j*H+1,y:D-V,width:Math.max(H-2,2),height:V,rx:1.5,fill:te.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:te.count>0?.85:.35},te.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:d.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:he.map(m=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:je.colors[m]||"#666"}}),t(ze[m]),": ",d.byKind?.[m]||0]},m))})]}),X&&(X.budgetChars||X.recallLimit||X.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:X.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:X.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",X.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",d.todayCards?.length||0,"\uFF09"]}),d.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:d.todayCards.map(m=>(0,e.jsx)(B,{title:m.title,kind:m.kind,updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),s==="optimize"&&(0,e.jsx)("div",{children:S&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:S.merge?.length?t("mergePairs"):t("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),S.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!ie,onClick:P,children:t(ie==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),S.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:S.merge.map((m,T)=>(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:[m.a.title," \u21C4 ",m.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(m.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>G(m.a.path,m.b.path),children:t("mergeNow")})]},T))}):(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",S.stale?.length||0,"\uFF09"]}),S.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!ie,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;K("clean");let m=0;for(let T of S.stale)try{await fetch(`${U}/delete?path=${encodeURIComponent(T.path)}`),m++}catch{}K(""),notify(`${m} ${t("deletedStale")}`),await oe(),p&&p()},children:t("cleanStale")})}),S.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:S.stale.map(m=>(0,e.jsx)(B,{title:m.title,kind:"other",updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})}var et=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
127
127
 
128
128
  ## \u80CC\u666F
129
129
  - \u95EE\u9898\u63CF\u8FF0
@@ -168,8 +168,8 @@ var Ct=Object.create;var Qe=Object.defineProperty;var Nt=Object.getOwnPropertyDe
168
168
  -
169
169
 
170
170
  ## \u98CE\u9669/\u963B\u585E
171
- - `}];function Pt({t,newCard:s,setNewCard:d,onCreated:y}){if(!s)return null;let u=rt.find(m=>m.key===s.template),r=s.body||(u?u.body:""),L=s.kind||(u?u.kind:"knowledge"),I=s.tags||(u?u.tags.join(", "):""),K=s._creating,O=m=>{let x=rt.find(D=>D.key===m);d(D=>({...D,template:m,kind:x?x.kind:D.kind,body:x?x.body:D.body,tags:x?x.tags.join(", "):D.tags}))},se=async()=>{if(!(!s.title&&!r)){d(m=>({...m,_creating:!0}));try{(await fetch(`${P}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s.title||"\u65E0\u6807\u9898",kind:L,tags:I.split(",").map(x=>x.trim()).filter(Boolean),body:r,source:"manual"})}).then(x=>x.json())).ok?(d(null),y&&y()):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:Se}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:m=>m.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:[rt.map(m=>(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===m.key?" me-on":""}`,onClick:()=>O(m.key),children:t(m.label)},m.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===""?" me-on":""}`,onClick:()=>d(m=>({...m,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:L,onChange:m=>d(x=>({...x,kind:m.target.value})),style:{maxWidth:180},children:["project","knowledge","content","prompt","business","tool","mistake"].map(m=>(0,e.jsx)("option",{value:m,children:m},m))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:s.title||"",onChange:m=>d(x=>({...x,title:m.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:I,onChange:m=>d(x=>({...x,tags:m.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:r,onChange:m=>d(x=>({...x,body:m.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:K,onClick:se,children:t(K?"exporting":"createCard")})})]})]})]})}function Wt({t,card:s,query:d,onClose:y,onDelete:u,onFeedback:r}){(0,c.useEffect)(()=>{let O=se=>{se.key==="Escape"&&y()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[y]);let[L,I]=(0,c.useState)(!1),K=(s.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:y,children:[(0,e.jsx)("style",{children:Se}),(0,e.jsxs)("div",{className:"me-dialog",onClick:O=>O.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:s.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:()=>r&&r(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),K&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>I(O=>!O),children:t(L?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&u&&u(s.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:y,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:L?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Ht(s.text)}})]})]})}function At({t,onOpen:s,all:d,onAllChange:y}){let[u,r]=(0,c.useState)(null),[L,I]=(0,c.useState)(""),K=(0,c.useCallback)(async()=>{try{let x=await(await fetch(`${P}/graph${d?"?all=1":""}`)).json();x.ok?(r(x),I("")):(r(null),I(x.error||t("error")))}catch(m){I(String(m&&m.message?m.message:m))}},[d,t]);(0,c.useEffect)(()=>{let m=!0;return fetch(`${P}/graph${d?"?all=1":""}`).then(x=>x.json()).then(x=>{m&&(x.ok?(r(x),I("")):(r(null),I(x.error||t("error"))))}).catch(x=>{m&&I(String(x&&x.message?x.message:x))}),()=>{m=!1}},[d,t]);let O=(0,c.useCallback)(async m=>{try{let D=await(await fetch(`${P}/delete?path=${encodeURIComponent(m)}`)).json();return D&&D.ok?(await K(),!0):!1}catch{return!1}},[K]),se=(0,c.useCallback)(async m=>{if(!m||m.length<2)return!1;try{let x=await fetch(`${P}/merge?paths=${encodeURIComponent(m.join(","))}`).then(D=>D.json());return x&&x.ok?(await K(),!0):!1}catch{return!1}},[K]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Se}),L&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",L]}),!u&&!L&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),u&&u.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),u&&u.nodes.length>0&&(0,e.jsx)(Yt,{nodes:u.nodes,edges:u.edges,onOpen:s,onDelete:O,onMerge:se,t,all:d,onAllChange:y,countLabel:`${u.nodes.length} ${t("nodes")} \xB7 ${Ut(u.edges)} ${t("edges")}`})]})}function Ut(t){let s=new Set;for(let d of t||[])s.add([d.source,d.target].sort().join("|"));return s.size}var Oe={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 Yt({nodes:t,edges:s,onOpen:d,onDelete:y,onMerge:u,t:r,countLabel:L,all:I,onAllChange:K}){let O=(0,c.useRef)(null),se=(0,c.useRef)(null),m=(0,c.useRef)(null),x=(0,c.useRef)(null),D=(0,c.useRef)(null),ve=(0,c.useRef)(d);(0,c.useEffect)(()=>{ve.current=d},[d]);let J=(0,c.useRef)(y);(0,c.useEffect)(()=>{J.current=y},[y]);let Ie=(0,c.useRef)(u);(0,c.useEffect)(()=>{Ie.current=u},[u]);let[B,ke]=(0,c.useState)(""),[H,he]=(0,c.useState)(null),me=(0,c.useRef)("");(0,c.useEffect)(()=>{me.current=B.trim().toLowerCase()},[B]),(0,c.useEffect)(()=>{let n=m.current;if(!n)return;let o=B.trim().toLowerCase();if(!o)return;let b=n.nodes.find(F=>(F.name||"").toLowerCase().includes(o));b&&(m.current.selectedId=b.id,he(b.id),n.panX=n.w/2-b.x*n.zoom,n.panY=n.h/2-b.y*n.zoom,n.render&&n.render())},[B]);let[p,N]=(0,c.useState)("all"),[A,U]=(0,c.useState)(!1),V=(0,c.useRef)("all"),[X,j]=(0,c.useState)(""),oe=(0,c.useRef)(""),[ce,le]=(0,c.useState)(!1),Ye=(0,c.useRef)(!1),[re,ue]=(0,c.useState)(null);(0,c.useEffect)(()=>{V.current=p},[p]),(0,c.useEffect)(()=>{oe.current=X},[X]),(0,c.useEffect)(()=>{Ye.current=ce},[ce]);let Ce=(0,c.useMemo)(()=>{let n=new Map;for(let o of t)for(let b of o.tags||[]){let F=String(b).trim();F&&n.set(F,(n.get(F)||0)+1)}return[...n.entries()].sort((o,b)=>b[1]-o[1]).slice(0,24).map(([o,b])=>({tag:o,n:b}))},[t]),qe=(()=>{let n=B.trim().toLowerCase();return!!n&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(n)||String(o.kind||"").toLowerCase().includes(n)||String($e[o.kind]||"").toLowerCase().includes(n))})();(0,c.useEffect)(()=>{let n=m.current;n&&n.wake&&n.wake()},[B]),(0,c.useEffect)(()=>{let n=m.current;n&&n.render&&n.render()},[p,X,ce]);let de=(0,c.useRef)(null),[ye,we]=(0,c.useState)([]),[G,je]=(0,c.useState)(null),[Xe,Ke]=(0,c.useState)(!1),[pe,ze]=(0,c.useState)(!1),[Te,Pe]=(0,c.useState)(null),[f,z]=(0,c.useState)(""),C=(0,c.useRef)(null),ie=(0,c.useRef)(null),S=(n,o=!0)=>{C.current&&clearTimeout(C.current),Pe({msg:n,ok:o}),C.current=setTimeout(()=>Pe(null),1900)},Le=n=>{z(n),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>z(""),1600)};(0,c.useEffect)(()=>()=>{C.current&&clearTimeout(C.current),ie.current&&clearTimeout(ie.current)},[]);let ne=(0,c.useMemo)(()=>t.reduce((n,o)=>(n[o.id]=o,n),{}),[t]);return(0,c.useEffect)(()=>{let n=O.current;if(!n||t.length===0)return;let o=n.getContext("2d");if(!o)return;let b=Math.max(1,window.devicePixelRatio||1),F=()=>document.documentElement.getAttribute("data-theme")==="dark",Y={};s.forEach(i=>{Y[i.source]=(Y[i.source]||0)+1,Y[i.target]=(Y[i.target]||0)+1});let Z=Math.max(1,...Object.values(Y)),a={nodes:t.map(i=>({id:i.id,name:i.title||"",type:i.kind||"other",r:9+Math.min(10,(Y[i.id]||0)/Z*8),x:0,y:0,vx:0,vy:0})),edges:s.map(i=>({sourceNodeId:i.source,targetNodeId:i.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:b,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((i,h)=>(i[h.id]=h,i),{}),a.nodes.forEach((i,h)=>{let g=h/a.nodes.length*Math.PI*2-Math.PI/2;i.x=Math.cos(g)*60,i.y=Math.sin(g)*60});let Fe=[...new Set(a.nodes.map(i=>i.type))];a.clustered=Fe.length>1,a.typeCenters={},Fe.forEach((i,h)=>{let g=h/Fe.length*Math.PI*2-Math.PI/2;a.typeCenters[i]={x:Math.cos(g)*160,y:Math.sin(g)*160}}),m.current=a;let W=()=>{let i=n.clientWidth,h=n.clientHeight;a.w=i,a.h=h,n.width=i*b,n.height=h*b,o.setTransform(b,0,0,b,0,0)};W();let Ne=new ResizeObserver(W);Ne.observe(n.parentElement);let at=(i,h)=>i&&i.length>h?i.slice(0,h)+"\u2026":i,We=(i,h,g,v)=>{if(o.beginPath(),v==="rect")o.rect(i-g,h-g*.75,g*2,g*1.5);else if(v==="diamond")o.moveTo(i,h-g),o.lineTo(i+g,h),o.lineTo(i,h+g),o.lineTo(i-g,h),o.closePath();else if(v==="hexagon"){for(let w=0;w<6;w++){let $=Math.PI/3*w-Math.PI/2,T=i+g*Math.cos($),Q=h+g*Math.sin($);w===0?o.moveTo(T,Q):o.lineTo(T,Q)}o.closePath()}else o.arc(i,h,g,0,Math.PI*2)},He=()=>{if(!a.nodes.length)return;let i=1/0,h=-1/0,g=1/0,v=-1/0;a.nodes.forEach(l=>{i=Math.min(i,l.x),h=Math.max(h,l.x),g=Math.min(g,l.y),v=Math.max(v,l.y)});let w=20,$=h-i+w*2,T=v-g+w*2,Q=Math.min(a.w/$,a.h/T);a.zoom=Math.max(.35,Math.min(1.8,Q)),a.panX=a.w/2-(i+h)/2*a.zoom,a.panY=a.h/2-(g+v)/2*a.zoom};x.current=He;let it=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=me.current,a.kindFilter=V.current,a.timeMode=Ye.current,a.tagFilter=oe.current;let i=a.tagFilter,h=a.kindFilter,g=l=>String(l||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=F()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let l=0;l<a.w;l+=24)o.beginPath(),o.moveTo(l,0),o.lineTo(l,a.h),o.stroke();for(let l=0;l<a.h;l+=24)o.beginPath(),o.moveTo(0,l),o.lineTo(a.w,l),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let v={};a.nodes.forEach(l=>v[l.id]=l);let w=a.nodes.length>40,$=w?1.5:.55,T=a.selectedId||a.hoverId;a.edges.forEach(l=>{let E=v[l.sourceNodeId],k=v[l.targetNodeId];if(!E||!k)return;if(h!=="all"){let Je=a.domainById[l.sourceNodeId]&&a.domainById[l.sourceNodeId].kind,ae=a.domainById[l.targetNodeId]&&a.domainById[l.targetNodeId].kind;if(Je!==h&&ae!==h)return}if(i){let Je=a.domainById[l.sourceNodeId]&&(a.domainById[l.sourceNodeId].tags||[]).includes(i),ae=a.domainById[l.targetNodeId]&&(a.domainById[l.targetNodeId].tags||[]).includes(i);if(!Je&&!ae)return}let M=k.x-E.x,R=k.y-E.y,q=Math.sqrt(M*M+R*R)||1,_=w?12:18,ee=-R/q*_,te=M/q*_,fe=(E.x+k.x)/2+ee,be=(E.y+k.y)/2+te,xe=Oe.colors[a.domainById[E.id]&&a.domainById[E.id].kind||"other"],Be=T&&(l.sourceNodeId===T||l.targetNodeId===T),ot=T?Be?.6:.08:w?.14:.24,nt=parseInt(xe.slice(1,3),16),Ue=parseInt(xe.slice(3,5),16),_e=parseInt(xe.slice(5,7),16);o.strokeStyle="rgba("+nt+","+Ue+","+_e+","+ot+")",o.lineWidth=Be?1.6+(l.weight||1):.8+(l.weight||1)*.5,o.beginPath(),o.moveTo(E.x,E.y),o.quadraticCurveTo(fe,be,k.x,k.y),o.stroke()});let Q=[];if(a.nodes.forEach(l=>{let E=a.domainById[l.id]||{},k=E.kind||"other",M=a.timeMode?qt(E.updated):Oe.colors[k],R=Oe.shapes[k],q=a.selectedId===l.id,_=a.hoverId===l.id,ee=a.searchTerm||"",te=!ee||(l.name||"").toLowerCase().includes(ee)||String($e[k]||"").toLowerCase().includes(ee)||String(k).toLowerCase().includes(ee),fe=h==="all"||k===h,be=!i||(E.tags||[]).includes(i),xe=T&&l.id!==T&&!a.edges.some(ae=>ae.sourceNodeId===T&&ae.targetNodeId===l.id||ae.targetNodeId===T&&ae.sourceNodeId===l.id)||ee&&!te||!fe||!be;o.save(),o.globalAlpha=xe?.08:1,(q||_)&&(o.shadowColor=M,o.shadowBlur=q?20:14),We(l.x,l.y,l.r,R);let Be=parseInt(M.slice(1,3),16),ot=parseInt(M.slice(3,5),16),nt=parseInt(M.slice(5,7),16),Ue=o.createRadialGradient(l.x-l.r*.3,l.y-l.r*.3,0,l.x,l.y,l.r*1.2);Ue.addColorStop(0,"rgba("+Math.min(255,Be+70)+","+Math.min(255,ot+70)+","+Math.min(255,nt+70)+",0.95)"),Ue.addColorStop(1,M),o.fillStyle=Ue,o.fill(),o.restore(),q?(o.save(),We(l.x,l.y,l.r+3,R),o.strokeStyle=M,o.lineWidth=3,o.shadowColor=M,o.shadowBlur=12,o.stroke(),o.restore()):_?(o.save(),We(l.x,l.y,l.r+2,R),o.strokeStyle=M,o.lineWidth=2,o.stroke(),o.restore()):ee&&te?(o.save(),We(l.x,l.y,l.r+2,R),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(l.id)>=0&&(o.save(),We(l.x,l.y,l.r+2,R),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let _e=at(l.name,16);if((q||_||a.zoom>$||!w&&a.zoom>.6)&&fe&&be){let ae=1/a.zoom;o.font="500 "+(12*ae).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Me=o.measureText(_e).width+16*ae,Ze=18*ae,Ee=l.y+l.r+8*ae,bt=!0;for(let Re of Q)if(l.x-Me/2<Re.x+Re.w&&l.x+Me/2>Re.x&&Ee<Re.y+Re.h&&Ee+Ze>Re.y){bt=!1;break}if(!bt&&!q&&!_)return;Q.push({x:l.x-Me/2,y:Ee,w:Me,h:Ze}),o.fillStyle=F()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(l.x-Me/2,Ee,Me,Ze,4*ae):o.rect(l.x-Me/2,Ee,Me,Ze),o.fill(),o.strokeStyle=F()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*ae,o.stroke(),o.fillStyle=F()?q||_?"#eee":"#bbb":q||_?"#111":"#444",o.textAlign="center",o.fillText(_e,l.x,Ee+13*ae)}}),o.restore(),a.marquee){let l=a.marquee,E=Math.min(l.sx,l.ex),k=Math.min(l.sy,l.ey),M=Math.abs(l.ex-l.sx),R=Math.abs(l.ey-l.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(E,k,M,R),o.strokeRect(E,k,M,R),o.restore()}if(a.hoverId&&de.current){let l=a.domainById[a.hoverId],E=a.nodes.find(function(k){return k.id===a.hoverId});if(l&&E){let k=a.edges.filter(function(q){return q.sourceNodeId===l.id||q.targetNodeId===l.id}).length,M=E.x*a.zoom+a.panX,R=E.y*a.zoom+a.panY;de.current.style.display="block",de.current.style.left=M+14+"px",de.current.style.top=R-6+"px",de.current.innerHTML="<b>"+g(l.title||l.name||"")+'</b><br/><span style="opacity:.8">'+g(l.kind||"")+" \xB7 "+k+" \u8FDE\u63A5</span>"}}else de.current&&(de.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(lt))};a.wake=ge,a.render=it;let st=()=>{let i=a.nodes.length;a.tickCount++;let g=.9-Math.min(.4,a.tickCount/1500),v=i>1e3?3e3:i>100?2e3:i>50?1200:800,w=i>100?.002:.005,$=i>1e3?.012:i>100?.005:.01,T=i>1e3?6:i>200?12:24,Q={};a.nodes.forEach(k=>Q[k.id]=k);for(let k=0;k<i;k++){if(a.dragNode===a.nodes[k])continue;let M=a.nodes[k],R=0,q=0;for(let te=0;te<i;te++){if(k===te)continue;let fe=M.x-a.nodes[te].x,be=M.y-a.nodes[te].y,xe=Math.sqrt(fe*fe+be*be)||1,Be=v/(xe*xe);R+=fe/xe*Be,q+=be/xe*Be}if(a.clustered&&a.typeCenters[M.type]){let te=a.typeCenters[M.type];R+=(te.x-M.x)*.006,q+=(te.y-M.y)*.006}else R-=M.x*$,q-=M.y*$;let _=(M.vx+R)*g,ee=(M.vy+q)*g;_=Math.max(-T,Math.min(T,_)),ee=Math.max(-T,Math.min(T,ee)),M.vx=_,M.vy=ee}a.edges.forEach(k=>{let M=Q[k.sourceNodeId],R=Q[k.targetNodeId];if(!M||!R)return;let q=R.x-M.x,_=R.y-M.y,ee=Math.sqrt(q*q+_*_)||1,te=(ee-100)*w,fe=q/ee*te,be=_/ee*te;a.dragNode!==M&&(M.vx+=fe,M.vy+=be),a.dragNode!==R&&(R.vx-=fe,R.vy-=be)});let l=0;a.nodes.forEach(k=>{a.dragNode!==k&&(k.x+=k.vx,k.y+=k.vy,l+=k.vx*k.vx+k.vy*k.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,He()),(i?Math.sqrt(l/i):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},lt=()=>{if(a.running){try{st(),it()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(lt)}},Ae=(i,h)=>{let g=n.getBoundingClientRect();return{x:(i-g.left-a.panX)/a.zoom,y:(h-g.top-a.panY)/a.zoom}},Ve=i=>{let h=a.domainById[i];return!(!h||V.current!=="all"&&h.kind!==V.current||oe.current&&!(h.tags||[]).includes(oe.current))},Ge=(i,h,g)=>Math.max(h,Math.min(g,i)),ct=i=>{a.mouseX=i.clientX,a.mouseY=i.clientY;let h=Ae(i.clientX,i.clientY),g=null;for(let v=a.nodes.length-1;v>=0;v--){let w=a.nodes[v];if(!Ve(w.id))continue;let $=w.x-h.x,T=w.y-h.y;if($*$+T*T<w.r*w.r+36){g=w.id;break}}g!==a.hoverId&&(a.hoverId=g,ge())},dt=i=>{if(i.button!==0)return;let h=Ae(i.clientX,i.clientY),g=null;for(let v=a.nodes.length-1;v>=0;v--){let w=a.nodes[v];if(!Ve(w.id))continue;let $=w.x-h.x,T=w.y-h.y;if($*$+T*T<w.r*w.r+25){g=w;break}}if(i.shiftKey){a.marquee={sx:i.clientX,sy:i.clientY,ex:i.clientX,ey:i.clientY};return}a.dragStart={x:i.clientX,y:i.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=g||null,g&&(a.dragOffset={dx:g.x-h.x,dy:g.y-h.y})},pt=i=>{if(a.marquee){a.marquee.ex=i.clientX,a.marquee.ey=i.clientY,ge();return}if(!a.dragStart)return;let h=i.clientX-a.dragStart.x,g=i.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(g)>3&&(a.dragging=!0),a.dragNode){let v=Ae(i.clientX,i.clientY);a.dragNode.x=v.x+a.dragOffset.dx,a.dragNode.y=v.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=Ge(a.dragStart.px+h,-1e5,1e5),a.panY=Ge(a.dragStart.py+g,-1e5,1e5),ge())},mt=i=>{if(a.marquee){let g=a.marquee;a.marquee=null;let v=n.getBoundingClientRect(),w=Math.min(g.sx,g.ex)-v.left,$=Math.max(g.sx,g.ex)-v.left,T=Math.min(g.sy,g.ey)-v.top,Q=Math.max(g.sy,g.ey)-v.top,l=a.nodes.filter(E=>{let k=E.x*a.zoom+a.panX,M=E.y*a.zoom+a.panY;return k>=w&&k<=$&&M>=T&&M<=Q}).map(E=>E.id);a.multi=l,we(l),ge();return}if(a.dragStart&&!a.dragging){let g=Ae(i.clientX,i.clientY),v=null;for(let w=a.nodes.length-1;w>=0;w--){let $=a.nodes[w];if(!Ve($.id))continue;let T=$.x-g.x,Q=$.y-g.y;if(T*T+Q*Q<$.r*$.r+20){v=$;break}}v?(a.selectedId=v.id,he(v.id),ge()):(a.selectedId=null,a.hoverId=null,i.shiftKey||(a.multi=[],we([])),he(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ut=i=>{i.preventDefault();let h=Ae(i.clientX,i.clientY),g=null;for(let v=a.nodes.length-1;v>=0;v--){let w=a.nodes[v];if(!Ve(w.id))continue;let $=w.x-h.x,T=w.y-h.y;if($*$+T*T<w.r*w.r+25){g=w;break}}if(g){let v=a.domainById[g.id];v&&ue({x:i.clientX,y:i.clientY,id:g.id,path:v.id,title:v.title})}else ue(null)},gt=i=>{i.preventDefault();let h=n.getBoundingClientRect(),g=(i.clientX-h.left-a.panX)/a.zoom,v=(i.clientY-h.top-a.panY)/a.zoom,w=Math.max(.3,Math.min(3,a.zoom*(i.deltaY<0?1.1:1/1.1)));a.panX=Ge(a.panX+g*(a.zoom-w),-1e5,1e5),a.panY=Ge(a.panY+v*(a.zoom-w),-1e5,1e5),a.zoom=w,ge()};n.addEventListener("mousemove",ct),n.addEventListener("mousedown",dt),window.addEventListener("mousemove",pt),window.addEventListener("mouseup",mt),n.addEventListener("wheel",gt,{passive:!1}),n.addEventListener("contextmenu",ut),D.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],we([]),He(),ge()};for(let i=0;i<200;i++)st();He(),ge();let ft=()=>U(!1);return window.addEventListener("mousedown",ft),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Ne.disconnect(),n.removeEventListener("mousemove",ct),n.removeEventListener("mousedown",dt),window.removeEventListener("mousemove",pt),window.removeEventListener("mouseup",mt),n.removeEventListener("wheel",gt),n.removeEventListener("contextmenu",ut),window.removeEventListener("mousedown",ft)}},[t,s]),(0,e.jsxs)("div",{className:"me-graph",ref:se,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",r("nodes")," \xB7 ",s.length," ",r("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:r("search"),value:B,onChange:n=>ke(n.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>U(n=>!n),"aria-expanded":A,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",p!=="all"||ce||X?"\u25CF":"\u25BE"]}),A&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:n=>n.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${p==="all"&&!ce?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{N("all"),le(!1)},children:r("all")}),Object.keys(tt).map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${p===n?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>N(o=>o===n?"all":n),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe.colors[n]||tt[n]}}),r($e[n])]},n)),(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${ce?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>le(n=>!n),children:["\u23F1 ",r("timeDim")]}),Ce.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:Ce.map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${X===n.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>j(o=>o===n.tag?"":n.tag),title:n.tag,children:["#",n.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:n.n})]},n.tag))})]}),(p!=="all"||ce||X)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{N("all"),le(!1),j("")},children:[r("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:r("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!I,onChange:n=>K&&K(n.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${ce?" me-on":""}`,onClick:()=>le(n=>!n),children:r("timeDim")}),(0,e.jsxs)("button",{type:"button",disabled:Xe,onClick:async()=>{if(!Xe){Ke(!0);try{let n=await fetch(`${P}/optimize`).then(W=>W.json());if(!n.ok||!n.merge||!n.merge.length){S(r("noOptimize"));return}let o={},b=W=>o[W]===void 0?W:o[W]=b(o[W]),F=(W,Ne)=>{o[b(W)]=b(Ne)},Y=new Set;for(let W of n.merge)Y.add(W.a.path),Y.add(W.b.path),F(W.a.path,W.b.path);let Z={};for(let W of Y){let Ne=b(W);(Z[Ne]=Z[Ne]||[]).push(W)}let a=Object.values(Z).filter(W=>W.length>=2);if(!a.length){S(r("noOptimize"));return}if(!window.confirm(r("mergeAllConfirm")))return;let Fe=0;for(let W of a)(await fetch(`${P}/merge?paths=${encodeURIComponent(W.join(","))}`).then(at=>at.json())).ok&&Fe++;S(`${Fe} ${r("mergeNow")}`)}catch{S(r("mergeFail"),!1)}Ke(!1)}},style:{background:"#f97316",color:"#fff",border:"none",fontWeight:700,boxShadow:"0 4px 14px rgba(249,115,22,0.35)"},children:["\u{1F500} ",r("mergeSimilar")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=O.current;if(n)try{n.toBlob(o=>{o&&je({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>x.current&&x.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{he(null),N("all"),D.current&&D.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:O,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:de,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)"}}),qe&&(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:r("noMatch")}),re&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ue(null)}),re&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:re.x,top:re.y,zIndex:31},onMouseDown:n=>n.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{ve.current({path:re.path,title:re.title}),ue(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{re.id&&(m.current.selectedId=re.id,he(re.id)),ue(null);let n=m.current;n&&n.wake&&n.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(re.title||"")}catch{}ue(null),S(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let n=m.current,o=n&&Array.isArray(n.multi)?n.multi.slice():[],b=re.id;if(b&&!o.includes(b)&&o.push(b),ue(null),o.length<2){S(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let F=Ie.current&&Ie.current(o);F&&F.then?F.then(Y=>Y?S(r("merged")):S(r("mergeFail"),!1)).catch(()=>S(r("mergeFail"),!1)):F&&S(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let n=re.path;ue(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(J.current?await J.current(n):!1)?S(r("deleted")):S(r("deleteFail"),!1)}catch{S(r("deleteFail"),!1)}})()},children:r("delete")})]}),ye.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:[ye.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=ye.map(Z=>ne[Z]).filter(Boolean).map(Z=>Z.title||Z.name).join(`
172
- `),b=new Blob([o],{type:"text/plain;charset=utf-8"}),F=URL.createObjectURL(b),Y=document.createElement("a");Y.href=F,Y.download="memory-selected.txt",document.body.appendChild(Y),Y.click(),document.body.removeChild(Y),setTimeout(()=>URL.revokeObjectURL(F),1e3),S(ye.length+r("exportedSel"))},children:r("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(ye.length<2){S(r("mergeNeed"),!1);return}let n=ye.map(b=>ne[b]?ne[b].id:b);if(!window.confirm(r("mergeConfirm")))return;we([]);let o=m.current;o&&(o.multi=[]),fetch(`${P}/merge?paths=${encodeURIComponent(n.join(","))}`).then(b=>b.json()).then(b=>{b&&b.ok?S(r("merged")):S(r("mergeFail"),!1)}).catch(()=>S(r("mergeFail"),!1))},children:r("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(r("deleteConfirm")))return;let n=ye.map(b=>ne[b]?ne[b].id:b);we([]);let o=m.current;o&&(o.multi=[]),(async()=>{let b=0;for(let F of n)try{(J.current?await J.current(F):!1)&&b++}catch{}S(b+r("deletedSelected"),b>0)})()},children:r("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=m.current;n&&(n.multi=[]),we([]);let o=m.current;o&&o.render&&o.render()},children:r("clearSelection")})]}),H&&(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:ne[H]?ne[H].title||ne[H].name:H}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ne[H]?r($e[ne[H].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:r("graphHint")}),(s.filter(n=>n.source===H||n.target===H)||[]).slice(0,8).map((n,o)=>{let b=n.source===H?n.target:n.source,F=ne[b];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:Y=>{Y.preventDefault();let Z=m.current;Z&&(Z.selectedId=b,Z.hoverId=b,Z.wake&&Z.wake()),he(b)},children:F?(F.title||F.name).slice(0,28):b},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:r("graphTip")}),Te&&(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 "+(Te.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Te.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Te.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Te.msg})]}),G&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{G.url&&URL.revokeObjectURL(G.url),je(null),ze(!1)},children:[(0,e.jsx)("style",{children:Se}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:pe?"100vw":900,width:pe?"100vw":"92vw",maxHeight:pe?"100vh":"90vh",height:pe?"100vh":void 0,borderRadius:pe?0:14},onClick:n=>n.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:r("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:G.url,download:"memory-graph.png",onClick:()=>{Le("download"),S(r("downloaded")+" \xB7 "+r("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:r(f==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Le("full"),ze(n=>!n),S(r("fullscreen"))},children:r(f==="full"?"done":pe?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=G.blob;n&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":n})]).then(()=>{Le("copy"),S(r("copied"))}).catch(()=>{S(r("copyFail"),!1)}):S(r("copyFail"),!1)},children:r(f==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{G.url&&URL.revokeObjectURL(G.url),je(null),ze(!1)},children:r("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:pe?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:G.url,alt:r("exportGraph"),style:{maxWidth:"100%",maxHeight:pe?"calc(100vh - 64px)":"70vh",borderRadius:pe?0:8,cursor:"zoom-in"},onClick:()=>ze(n=>!n)})})]})]})]})}function qt(t){let s=new Date(t||0).getTime();if(!s)return"#94a3b8";let d=(Date.now()-s)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function Xt(t){let s=new Date(t||0).getTime();return!!s&&(Date.now()-s)/864e5<3}async function Kt(t,s,d){if(d&&typeof window.showSaveFilePicker=="function")try{let r=await window.showSaveFilePicker({suggestedName:s}),L=await r.createWritable();return await L.write(t),await L.close(),{ok:!0,picked:!0,name:r.name}}catch(r){return r&&r.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(r.message||r)}}let y=URL.createObjectURL(t),u=document.createElement("a");return u.href=y,u.download=s,document.body.appendChild(u),u.click(),document.body.removeChild(u),setTimeout(()=>URL.revokeObjectURL(y),1e3),{ok:!0,picked:!1,name:s}}function xt(t,s){if(!s||!t)return t;let d=t.toLowerCase(),y=s.toLowerCase(),u=[],r=0;for(;r<t.length;){let L=d.indexOf(y,r);if(L<0){u.push(t.slice(r));break}L>r&&u.push(t.slice(r,L)),u.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(L,L+y.length)},L)),r=L+y.length}return u}function Ht(t){if(!t)return"";let s=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),d=[];return s=s.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(y,u,r){return d.push("<pre><code>"+r+"</code></pre>"),"\0"+(d.length-1)+"\0"}),s=s.replace(/^(#{1,3})\s+(.+)$/gm,function(y,u,r){return"<h"+u.length+">"+r+"</h"+u.length+">"}),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/`([^`\n]+)`/g,"<code>$1</code>"),s=s.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(y,u,r){return/^(https?:|\/)/.test(r)?'<a href="'+r+'" target="_blank" rel="noopener noreferrer">'+u+"</a>":u}),s=s.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),s=s.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),s=s.replace(/\n/g,"<br/>"),s=s.replace(/\u0000(\d+)\u0000/g,function(y,u){return d[u]}),s}function kt(t){if(!t)return"";let s=new Date(t);if(Number.isNaN(s.getTime()))return"";let d=new Date,y=s.toDateString()===d.toDateString(),u=L=>String(L).padStart(2,"0"),r=`${u(s.getHours())}:${u(s.getMinutes())}`;return y?r:`${s.getMonth()+1}-${s.getDate()} ${r}`}
171
+ - `}];function Dt({t,newCard:s,setNewCard:p,onCreated:k}){if(!s)return null;let d=et.find(y=>y.key===s.template),r=s.body||(d?d.body:""),z=s.kind||(d?d.kind:"knowledge"),q=s.tags||(d?d.tags.join(", "):""),S=s._creating,Y=y=>{let h=et.find(N=>N.key===y);p(N=>({...N,template:y,kind:h?h.kind:N.kind,body:h?h.body:N.body,tags:h?h.tags.join(", "):N.tags}))},X=async()=>{if(!(!s.title&&!r)){p(y=>({...y,_creating:!0}));try{(await fetch(`${U}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s.title||"\u65E0\u6807\u9898",kind:z,tags:q.split(",").map(h=>h.trim()).filter(Boolean),body:r,source:"manual"})}).then(h=>h.json())).ok?(p(null),k&&k()):p(h=>({...h,_creating:!1}))}catch{p(h=>({...h,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>p(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:()=>p(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:[et.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===y.key?" me-on":""}`,onClick:()=>Y(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===""?" me-on":""}`,onClick:()=>p(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:z,onChange:y=>p(h=>({...h,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:s.title||"",onChange:y=>p(h=>({...h,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:q,onChange:y=>p(h=>({...h,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:r,onChange:y=>p(h=>({...h,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:S,onClick:X,children:t(S?"exporting":"createCard")})})]})]})]})}function Ot({t,card:s,query:p,onClose:k,onDelete:d,onFeedback:r}){(0,c.useEffect)(()=>{let Y=X=>{X.key==="Escape"&&k()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[k]);let[z,q]=(0,c.useState)(!1),S=(s.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:k,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",onClick:Y=>Y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:s.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[p&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),S&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>q(Y=>!Y),children:t(z?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&d&&d(s.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:k,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:z?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Xt(s.text)}})]})]})}function Pt({t,onOpen:s,all:p,onAllChange:k,onMutate:d}){let[r,z]=(0,c.useState)(null),[q,S]=(0,c.useState)(""),Y=(0,c.useCallback)(async()=>{try{let N=await(await fetch(`${U}/graph${p?"?all=1":""}`)).json();N.ok?(z(N),S("")):(z(null),S(N.error||t("error")))}catch(h){S(String(h&&h.message?h.message:h))}},[p,t]);(0,c.useEffect)(()=>{let h=!0;return fetch(`${U}/graph${p?"?all=1":""}`).then(N=>N.json()).then(N=>{h&&(N.ok?(z(N),S("")):(z(null),S(N.error||t("error"))))}).catch(N=>{h&&S(String(N&&N.message?N.message:N))}),()=>{h=!1}},[p,t]);let X=(0,c.useCallback)(async h=>{try{let ie=await(await fetch(`${U}/delete?path=${encodeURIComponent(h)}`)).json();return ie&&ie.ok?(await Y(),d&&d(),!0):!1}catch{return!1}},[Y]),y=(0,c.useCallback)(async h=>{if(!h||h.length<2)return!1;try{let N=await fetch(`${U}/merge?paths=${encodeURIComponent(h.join(","))}`).then(ie=>ie.json());return N&&N.ok?(await Y(),d&&d(),!0):!1}catch{return!1}},[Y,d]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ne}),q&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",q]}),!r&&!q&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),r&&r.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),r&&r.nodes.length>0&&(0,e.jsx)(At,{nodes:r.nodes,edges:r.edges,onOpen:s,onDelete:X,onMerge:y,t,all:p,onAllChange:k,countLabel:`${r.nodes.length} ${t("nodes")} \xB7 ${Wt(r.edges)} ${t("edges")}`})]})}function Wt(t){let s=new Set;for(let p of t||[])s.add([p.source,p.target].sort().join("|"));return s.size}var je={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 At({nodes:t,edges:s,onOpen:p,onDelete:k,onMerge:d,t:r,countLabel:z,all:q,onAllChange:S}){let Y=(0,c.useRef)(null),X=(0,c.useRef)(null),y=(0,c.useRef)(null),h=(0,c.useRef)(null),N=(0,c.useRef)(null),ie=(0,c.useRef)(p);(0,c.useEffect)(()=>{ie.current=p},[p]);let K=(0,c.useRef)(k);(0,c.useEffect)(()=>{K.current=k},[k]);let Me=(0,c.useRef)(d);(0,c.useEffect)(()=>{Me.current=d},[d]);let[P,oe]=(0,c.useState)(""),[G,be]=(0,c.useState)(null),he=(0,c.useRef)("");(0,c.useEffect)(()=>{he.current=P.trim().toLowerCase()},[P]),(0,c.useEffect)(()=>{let o=y.current;if(!o)return;let n=P.trim().toLowerCase();if(!n)return;let f=o.nodes.find(L=>(L.name||"").toLowerCase().includes(n));f&&(y.current.selectedId=f.id,be(f.id),o.panX=o.w/2-f.x*o.zoom,o.panY=o.h/2-f.y*o.zoom,o.render&&o.render())},[P]);let[B,m]=(0,c.useState)("all"),[T,R]=(0,c.useState)(!1),D=(0,c.useRef)("all"),[H,te]=(0,c.useState)(""),j=(0,c.useRef)(""),[V,ae]=(0,c.useState)(!1),We=(0,c.useRef)(!1),[ne,pe]=(0,c.useState)(null);(0,c.useEffect)(()=>{D.current=B},[B]),(0,c.useEffect)(()=>{j.current=H},[H]),(0,c.useEffect)(()=>{We.current=V},[V]);let $e=(0,c.useMemo)(()=>{let o=new Map;for(let n of t)for(let f of n.tags||[]){let L=String(f).trim();L&&o.set(L,(o.get(L)||0)+1)}return[...o.entries()].sort((n,f)=>f[1]-n[1]).slice(0,24).map(([n,f])=>({tag:n,n:f}))},[t]),Je=(()=>{let o=P.trim().toLowerCase();return!!o&&!t.some(n=>(n.title||n.name||"").toLowerCase().includes(o)||String(n.kind||"").toLowerCase().includes(o)||String(ze[n.kind]||"").toLowerCase().includes(o))})();(0,c.useEffect)(()=>{let o=y.current;o&&o.wake&&o.wake()},[P]),(0,c.useEffect)(()=>{let o=y.current;o&&o.render&&o.render()},[B,H,V]);let me=(0,c.useRef)(null),[se,ve]=(0,c.useState)([]),[ce,Te]=(0,c.useState)(null),[de,le]=(0,c.useState)(!1),[we,Ae]=(0,c.useState)(null),[Ee,Re]=(0,c.useState)(""),ke=(0,c.useRef)(null),Se=(0,c.useRef)(null),O=(o,n=!0)=>{ke.current&&clearTimeout(ke.current),Ae({msg:o,ok:n}),ke.current=setTimeout(()=>Ae(null),1900)},u=o=>{Re(o),Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>Re(""),1600)};(0,c.useEffect)(()=>()=>{ke.current&&clearTimeout(ke.current),Se.current&&clearTimeout(Se.current)},[]);let C=(0,c.useMemo)(()=>t.reduce((o,n)=>(o[n.id]=n,o),{}),[t]);return(0,c.useEffect)(()=>{let o=Y.current;if(!o||t.length===0)return;let n=o.getContext("2d");if(!n)return;let f=Math.max(1,window.devicePixelRatio||1),L=()=>document.documentElement.getAttribute("data-theme")==="dark",W={};s.forEach(i=>{W[i.source]=(W[i.source]||0)+1,W[i.target]=(W[i.target]||0)+1});let re=Math.max(1,...Object.values(W)),a={nodes:t.map(i=>({id:i.id,name:i.title||"",type:i.kind||"other",r:9+Math.min(10,(W[i.id]||0)/re*8),x:0,y:0,vx:0,vy:0})),edges:s.map(i=>({sourceNodeId:i.source,targetNodeId:i.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:f,ctx:n,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((i,b)=>(i[b.id]=b,i),{}),a.nodes.forEach((i,b)=>{let g=b/a.nodes.length*Math.PI*2-Math.PI/2;i.x=Math.cos(g)*60,i.y=Math.sin(g)*60});let ye=[...new Set(a.nodes.map(i=>i.type))];a.clustered=ye.length>1,a.typeCenters={},ye.forEach((i,b)=>{let g=b/ye.length*Math.PI*2-Math.PI/2;a.typeCenters[i]={x:Math.cos(g)*160,y:Math.sin(g)*160}}),y.current=a;let tt=()=>{let i=o.clientWidth,b=o.clientHeight;a.w=i,a.h=b,o.width=i*f,o.height=b*f,n.setTransform(f,0,0,f,0,0)};tt();let at=new ResizeObserver(tt);at.observe(o.parentElement);let vt=(i,b)=>i&&i.length>b?i.slice(0,b)+"\u2026":i,De=(i,b,g,x)=>{if(n.beginPath(),x==="rect")n.rect(i-g,b-g*.75,g*2,g*1.5);else if(x==="diamond")n.moveTo(i,b-g),n.lineTo(i+g,b),n.lineTo(i,b+g),n.lineTo(i-g,b),n.closePath();else if(x==="hexagon"){for(let v=0;v<6;v++){let F=Math.PI/3*v-Math.PI/2,I=i+g*Math.cos(F),J=b+g*Math.sin(F);v===0?n.moveTo(I,J):n.lineTo(I,J)}n.closePath()}else n.arc(i,b,g,0,Math.PI*2)},Ue=()=>{if(!a.nodes.length)return;let i=1/0,b=-1/0,g=1/0,x=-1/0;a.nodes.forEach(l=>{i=Math.min(i,l.x),b=Math.max(b,l.x),g=Math.min(g,l.y),x=Math.max(x,l.y)});let v=20,F=b-i+v*2,I=x-g+v*2,J=Math.min(a.w/F,a.h/I);a.zoom=Math.max(.35,Math.min(1.8,J)),a.panX=a.w/2-(i+b)/2*a.zoom,a.panY=a.h/2-(g+x)/2*a.zoom};h.current=Ue;let ot=()=>{n.clearRect(0,0,a.w,a.h),a.searchTerm=he.current,a.kindFilter=D.current,a.timeMode=We.current,a.tagFilter=j.current;let i=a.tagFilter,b=a.kindFilter,g=l=>String(l||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");n.save(),n.strokeStyle=L()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",n.lineWidth=.5;for(let l=0;l<a.w;l+=24)n.beginPath(),n.moveTo(l,0),n.lineTo(l,a.h),n.stroke();for(let l=0;l<a.h;l+=24)n.beginPath(),n.moveTo(0,l),n.lineTo(a.w,l),n.stroke();n.restore(),n.save(),n.translate(a.panX,a.panY),n.scale(a.zoom,a.zoom);let x={};a.nodes.forEach(l=>x[l.id]=l);let v=a.nodes.length>40,F=v?1.5:.55,I=a.selectedId||a.hoverId;a.edges.forEach(l=>{let $=x[l.sourceNodeId],w=x[l.targetNodeId];if(!$||!w)return;if(b!=="all"){let Ke=a.domainById[l.sourceNodeId]&&a.domainById[l.sourceNodeId].kind,ee=a.domainById[l.targetNodeId]&&a.domainById[l.targetNodeId].kind;if(Ke!==b&&ee!==b)return}if(i){let Ke=a.domainById[l.sourceNodeId]&&(a.domainById[l.sourceNodeId].tags||[]).includes(i),ee=a.domainById[l.targetNodeId]&&(a.domainById[l.targetNodeId].tags||[]).includes(i);if(!Ke&&!ee)return}let M=w.x-$.x,E=w.y-$.y,A=Math.sqrt(M*M+E*E)||1,_=v?12:18,Z=-E/A*_,Q=M/A*_,ge=($.x+w.x)/2+Z,fe=($.y+w.y)/2+Q,xe=je.colors[a.domainById[$.id]&&a.domainById[$.id].kind||"other"],Ie=I&&(l.sourceNodeId===I||l.targetNodeId===I),Ze=I?Ie?.6:.08:v?.14:.24,Qe=parseInt(xe.slice(1,3),16),Pe=parseInt(xe.slice(3,5),16),Xe=parseInt(xe.slice(5,7),16);n.strokeStyle="rgba("+Qe+","+Pe+","+Xe+","+Ze+")",n.lineWidth=Ie?1.6+(l.weight||1):.8+(l.weight||1)*.5,n.beginPath(),n.moveTo($.x,$.y),n.quadraticCurveTo(ge,fe,w.x,w.y),n.stroke()});let J=[];if(a.nodes.forEach(l=>{let $=a.domainById[l.id]||{},w=$.kind||"other",M=a.timeMode?Ut($.updated):je.colors[w],E=je.shapes[w],A=a.selectedId===l.id,_=a.hoverId===l.id,Z=a.searchTerm||"",Q=!Z||(l.name||"").toLowerCase().includes(Z)||String(ze[w]||"").toLowerCase().includes(Z)||String(w).toLowerCase().includes(Z),ge=b==="all"||w===b,fe=!i||($.tags||[]).includes(i),xe=I&&l.id!==I&&!a.edges.some(ee=>ee.sourceNodeId===I&&ee.targetNodeId===l.id||ee.targetNodeId===I&&ee.sourceNodeId===l.id)||Z&&!Q||!ge||!fe;n.save(),n.globalAlpha=xe?.08:1,(A||_)&&(n.shadowColor=M,n.shadowBlur=A?20:14),De(l.x,l.y,l.r,E);let Ie=parseInt(M.slice(1,3),16),Ze=parseInt(M.slice(3,5),16),Qe=parseInt(M.slice(5,7),16),Pe=n.createRadialGradient(l.x-l.r*.3,l.y-l.r*.3,0,l.x,l.y,l.r*1.2);Pe.addColorStop(0,"rgba("+Math.min(255,Ie+70)+","+Math.min(255,Ze+70)+","+Math.min(255,Qe+70)+",0.95)"),Pe.addColorStop(1,M),n.fillStyle=Pe,n.fill(),n.restore(),A?(n.save(),De(l.x,l.y,l.r+3,E),n.strokeStyle=M,n.lineWidth=3,n.shadowColor=M,n.shadowBlur=12,n.stroke(),n.restore()):_?(n.save(),De(l.x,l.y,l.r+2,E),n.strokeStyle=M,n.lineWidth=2,n.stroke(),n.restore()):Z&&Q?(n.save(),De(l.x,l.y,l.r+2,E),n.strokeStyle="#e11d48",n.lineWidth=2,n.stroke(),n.restore()):a.multi.indexOf(l.id)>=0&&(n.save(),De(l.x,l.y,l.r+2,E),n.strokeStyle="#60a5fa",n.lineWidth=2,n.shadowColor="#60a5fa",n.shadowBlur=8,n.stroke(),n.restore());let Xe=vt(l.name,16);if((A||_||a.zoom>F||!v&&a.zoom>.6)&&ge&&fe){let ee=1/a.zoom;n.font="500 "+(12*ee).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ce=n.measureText(Xe).width+16*ee,He=18*ee,Le=l.y+l.r+8*ee,ut=!0;for(let Be of J)if(l.x-Ce/2<Be.x+Be.w&&l.x+Ce/2>Be.x&&Le<Be.y+Be.h&&Le+He>Be.y){ut=!1;break}if(!ut&&!A&&!_)return;J.push({x:l.x-Ce/2,y:Le,w:Ce,h:He}),n.fillStyle=L()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",n.beginPath(),n.roundRect?n.roundRect(l.x-Ce/2,Le,Ce,He,4*ee):n.rect(l.x-Ce/2,Le,Ce,He),n.fill(),n.strokeStyle=L()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",n.lineWidth=1*ee,n.stroke(),n.fillStyle=L()?A||_?"#eee":"#bbb":A||_?"#111":"#444",n.textAlign="center",n.fillText(Xe,l.x,Le+13*ee)}}),n.restore(),a.marquee){let l=a.marquee,$=Math.min(l.sx,l.ex),w=Math.min(l.sy,l.ey),M=Math.abs(l.ex-l.sx),E=Math.abs(l.ey-l.sy);n.save(),n.setLineDash([4,4]),n.strokeStyle="rgba(96,165,250,0.9)",n.lineWidth=1,n.fillStyle="rgba(96,165,250,0.12)",n.fillRect($,w,M,E),n.strokeRect($,w,M,E),n.restore()}if(a.hoverId&&me.current){let l=a.domainById[a.hoverId],$=a.nodes.find(function(w){return w.id===a.hoverId});if(l&&$){let w=a.edges.filter(function(A){return A.sourceNodeId===l.id||A.targetNodeId===l.id}).length,M=$.x*a.zoom+a.panX,E=$.y*a.zoom+a.panY;me.current.style.display="block",me.current.style.left=M+14+"px",me.current.style.top=E-6+"px",me.current.innerHTML="<b>"+g(l.title||l.name||"")+'</b><br/><span style="opacity:.8">'+g(l.kind||"")+" \xB7 "+w+" \u8FDE\u63A5</span>"}}else me.current&&(me.current.style.display="none")},ue=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(rt))};a.wake=ue,a.render=ot;let nt=()=>{let i=a.nodes.length;a.tickCount++;let g=.9-Math.min(.4,a.tickCount/1500),x=i>1e3?3e3:i>100?2e3:i>50?1200:800,v=i>100?.002:.005,F=i>1e3?.012:i>100?.005:.01,I=i>1e3?6:i>200?12:24,J={};a.nodes.forEach(w=>J[w.id]=w);for(let w=0;w<i;w++){if(a.dragNode===a.nodes[w])continue;let M=a.nodes[w],E=0,A=0;for(let Q=0;Q<i;Q++){if(w===Q)continue;let ge=M.x-a.nodes[Q].x,fe=M.y-a.nodes[Q].y,xe=Math.sqrt(ge*ge+fe*fe)||1,Ie=x/(xe*xe);E+=ge/xe*Ie,A+=fe/xe*Ie}if(a.clustered&&a.typeCenters[M.type]){let Q=a.typeCenters[M.type];E+=(Q.x-M.x)*.006,A+=(Q.y-M.y)*.006}else E-=M.x*F,A-=M.y*F;let _=(M.vx+E)*g,Z=(M.vy+A)*g;_=Math.max(-I,Math.min(I,_)),Z=Math.max(-I,Math.min(I,Z)),M.vx=_,M.vy=Z}a.edges.forEach(w=>{let M=J[w.sourceNodeId],E=J[w.targetNodeId];if(!M||!E)return;let A=E.x-M.x,_=E.y-M.y,Z=Math.sqrt(A*A+_*_)||1,Q=(Z-100)*v,ge=A/Z*Q,fe=_/Z*Q;a.dragNode!==M&&(M.vx+=ge,M.vy+=fe),a.dragNode!==E&&(E.vx-=ge,E.vy-=fe)});let l=0;a.nodes.forEach(w=>{a.dragNode!==w&&(w.x+=w.vx,w.y+=w.vy,l+=w.vx*w.vx+w.vy*w.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ue()),(i?Math.sqrt(l/i):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},rt=()=>{if(a.running){try{nt(),ot()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(rt)}},Oe=(i,b)=>{let g=o.getBoundingClientRect();return{x:(i-g.left-a.panX)/a.zoom,y:(b-g.top-a.panY)/a.zoom}},Ye=i=>{let b=a.domainById[i];return!(!b||D.current!=="all"&&b.kind!==D.current||j.current&&!(b.tags||[]).includes(j.current))},qe=(i,b,g)=>Math.max(b,Math.min(g,i)),it=i=>{a.mouseX=i.clientX,a.mouseY=i.clientY;let b=Oe(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!Ye(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+36){g=v.id;break}}g!==a.hoverId&&(a.hoverId=g,ue())},st=i=>{if(i.button!==0)return;let b=Oe(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!Ye(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+25){g=v;break}}if(i.shiftKey){a.marquee={sx:i.clientX,sy:i.clientY,ex:i.clientX,ey:i.clientY};return}a.dragStart={x:i.clientX,y:i.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=g||null,g&&(a.dragOffset={dx:g.x-b.x,dy:g.y-b.y})},lt=i=>{if(a.marquee){a.marquee.ex=i.clientX,a.marquee.ey=i.clientY,ue();return}if(!a.dragStart)return;let b=i.clientX-a.dragStart.x,g=i.clientY-a.dragStart.y;if(Math.abs(b)+Math.abs(g)>3&&(a.dragging=!0),a.dragNode){let x=Oe(i.clientX,i.clientY);a.dragNode.x=x.x+a.dragOffset.dx,a.dragNode.y=x.y+a.dragOffset.dy,ue()}else a.dragging&&(a.panX=qe(a.dragStart.px+b,-1e5,1e5),a.panY=qe(a.dragStart.py+g,-1e5,1e5),ue())},ct=i=>{if(a.marquee){let g=a.marquee;a.marquee=null;let x=o.getBoundingClientRect(),v=Math.min(g.sx,g.ex)-x.left,F=Math.max(g.sx,g.ex)-x.left,I=Math.min(g.sy,g.ey)-x.top,J=Math.max(g.sy,g.ey)-x.top,l=a.nodes.filter($=>{let w=$.x*a.zoom+a.panX,M=$.y*a.zoom+a.panY;return w>=v&&w<=F&&M>=I&&M<=J}).map($=>$.id);a.multi=l,ve(l),ue();return}if(a.dragStart&&!a.dragging){let g=Oe(i.clientX,i.clientY),x=null;for(let v=a.nodes.length-1;v>=0;v--){let F=a.nodes[v];if(!Ye(F.id))continue;let I=F.x-g.x,J=F.y-g.y;if(I*I+J*J<F.r*F.r+20){x=F;break}}x?(a.selectedId=x.id,be(x.id),ue()):(a.selectedId=null,a.hoverId=null,i.shiftKey||(a.multi=[],ve([])),be(null),ue())}a.dragStart=null,a.dragging=!1,a.dragNode=null},dt=i=>{i.preventDefault();let b=Oe(i.clientX,i.clientY),g=null;for(let x=a.nodes.length-1;x>=0;x--){let v=a.nodes[x];if(!Ye(v.id))continue;let F=v.x-b.x,I=v.y-b.y;if(F*F+I*I<v.r*v.r+25){g=v;break}}if(g){let x=a.domainById[g.id];x&&pe({x:i.clientX,y:i.clientY,id:g.id,path:x.id,title:x.title})}else pe(null)},pt=i=>{i.preventDefault();let b=o.getBoundingClientRect(),g=(i.clientX-b.left-a.panX)/a.zoom,x=(i.clientY-b.top-a.panY)/a.zoom,v=Math.max(.3,Math.min(3,a.zoom*(i.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+g*(a.zoom-v),-1e5,1e5),a.panY=qe(a.panY+x*(a.zoom-v),-1e5,1e5),a.zoom=v,ue()};o.addEventListener("mousemove",it),o.addEventListener("mousedown",st),window.addEventListener("mousemove",lt),window.addEventListener("mouseup",ct),o.addEventListener("wheel",pt,{passive:!1}),o.addEventListener("contextmenu",dt),N.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],ve([]),Ue(),ue()};for(let i=0;i<200;i++)nt();Ue(),ue();let mt=()=>R(!1);return window.addEventListener("mousedown",mt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),at.disconnect(),o.removeEventListener("mousemove",it),o.removeEventListener("mousedown",st),window.removeEventListener("mousemove",lt),window.removeEventListener("mouseup",ct),o.removeEventListener("wheel",pt),o.removeEventListener("contextmenu",dt),window.removeEventListener("mousedown",mt)}},[t,s]),(0,e.jsxs)("div",{className:"me-graph",ref:X,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",r("nodes")," \xB7 ",s.length," ",r("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:r("search"),value:P,onChange:o=>oe(o.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>R(o=>!o),"aria-expanded":T,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",B!=="all"||V||H?"\u25CF":"\u25BE"]}),T&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:o=>o.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${B==="all"&&!V?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{m("all"),ae(!1)},children:r("all")}),Object.keys(_e).map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${B===o?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>m(n=>n===o?"all":o),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:je.colors[o]||_e[o]}}),r(ze[o])]},o)),(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${V?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ae(o=>!o),children:["\u23F1 ",r("timeDim")]}),$e.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:$e.map(o=>(0,e.jsxs)("button",{type:"button",className:`lg${H===o.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>te(n=>n===o.tag?"":o.tag),title:o.tag,children:["#",o.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:o.n})]},o.tag))})]}),(B!=="all"||V||H)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{m("all"),ae(!1),te("")},children:[r("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:r("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!q,onChange:o=>S&&S(o.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${V?" me-on":""}`,onClick:()=>ae(o=>!o),children:r("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=Y.current;if(o)try{o.toBlob(n=>{n&&Te({url:URL.createObjectURL(n),blob:n})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h.current&&h.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{be(null),m("all"),N.current&&N.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:Y,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:me,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)"}}),Je&&(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:r("noMatch")}),ne&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>pe(null)}),ne&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:ne.x,top:ne.y,zIndex:31},onMouseDown:o=>o.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{ie.current({path:ne.path,title:ne.title}),pe(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{ne.id&&(y.current.selectedId=ne.id,be(ne.id)),pe(null);let o=y.current;o&&o.wake&&o.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(ne.title||"")}catch{}pe(null),O(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let o=y.current,n=o&&Array.isArray(o.multi)?o.multi.slice():[],f=ne.id;if(f&&!n.includes(f)&&n.push(f),pe(null),n.length<2){O(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let L=Me.current&&Me.current(n);L&&L.then?L.then(W=>W?O(r("merged")):O(r("mergeFail"),!1)).catch(()=>O(r("mergeFail"),!1)):L&&O(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let o=ne.path;pe(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(K.current?await K.current(o):!1)?O(r("deleted")):O(r("deleteFail"),!1)}catch{O(r("deleteFail"),!1)}})()},children:r("delete")})]}),se.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:[se.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=se.map(re=>C[re]).filter(Boolean).map(re=>re.title||re.name).join(`
172
+ `),f=new Blob([n],{type:"text/plain;charset=utf-8"}),L=URL.createObjectURL(f),W=document.createElement("a");W.href=L,W.download="memory-selected.txt",document.body.appendChild(W),W.click(),document.body.removeChild(W),setTimeout(()=>URL.revokeObjectURL(L),1e3),O(se.length+r("exportedSel"))},children:r("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(se.length<2){O(r("mergeNeed"),!1);return}let o=se.map(f=>C[f]?C[f].id:f);if(!window.confirm(r("mergeConfirm")))return;ve([]);let n=y.current;n&&(n.multi=[]),fetch(`${U}/merge?paths=${encodeURIComponent(o.join(","))}`).then(f=>f.json()).then(f=>{f&&f.ok?O(r("merged")):O(r("mergeFail"),!1)}).catch(()=>O(r("mergeFail"),!1))},children:r("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(r("deleteConfirm")))return;let o=se.map(f=>C[f]?C[f].id:f);ve([]);let n=y.current;n&&(n.multi=[]),(async()=>{let f=0;for(let L of o)try{(K.current?await K.current(L):!1)&&f++}catch{}O(f+r("deletedSelected"),f>0)})()},children:r("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=y.current;o&&(o.multi=[]),ve([]);let n=y.current;n&&n.render&&n.render()},children:r("clearSelection")})]}),G&&(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:C[G]?C[G].title||C[G].name:G}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:C[G]?r(ze[C[G].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:r("graphHint")}),(s.filter(o=>o.source===G||o.target===G)||[]).slice(0,8).map((o,n)=>{let f=o.source===G?o.target:o.source,L=C[f];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:W=>{W.preventDefault();let re=y.current;re&&(re.selectedId=f,re.hoverId=f,re.wake&&re.wake()),be(f)},children:L?(L.title||L.name).slice(0,28):f},n)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:r("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})]}),ce&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{ce.url&&URL.revokeObjectURL(ce.url),Te(null),le(!1)},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:de?"100vw":900,width:de?"100vw":"92vw",maxHeight:de?"100vh":"90vh",height:de?"100vh":void 0,borderRadius:de?0:14},onClick:o=>o.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:r("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:ce.url,download:"memory-graph.png",onClick:()=>{u("download"),O(r("downloaded")+" \xB7 "+r("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:r(Ee==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{u("full"),le(o=>!o),O(r("fullscreen"))},children:r(Ee==="full"?"done":de?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=ce.blob;o&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":o})]).then(()=>{u("copy"),O(r("copied"))}).catch(()=>{O(r("copyFail"),!1)}):O(r("copyFail"),!1)},children:r(Ee==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ce.url&&URL.revokeObjectURL(ce.url),Te(null),le(!1)},children:r("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:de?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:ce.url,alt:r("exportGraph"),style:{maxWidth:"100%",maxHeight:de?"calc(100vh - 64px)":"70vh",borderRadius:de?0:8,cursor:"zoom-in"},onClick:()=>le(o=>!o)})})]})]})]})}function Ut(t){let s=new Date(t||0).getTime();if(!s)return"#94a3b8";let p=(Date.now()-s)/864e5;return p<3?"#10b981":p<14?"#f59e0b":p<30?"#f97316":"#94a3b8"}function Yt(t){let s=new Date(t||0).getTime();return!!s&&(Date.now()-s)/864e5<3}async function qt(t,s,p){if(p&&typeof window.showSaveFilePicker=="function")try{let r=await window.showSaveFilePicker({suggestedName:s}),z=await r.createWritable();return await z.write(t),await z.close(),{ok:!0,picked:!0,name:r.name}}catch(r){return r&&r.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(r.message||r)}}let k=URL.createObjectURL(t),d=document.createElement("a");return d.href=k,d.download=s,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>URL.revokeObjectURL(k),1e3),{ok:!0,picked:!1,name:s}}function bt(t,s){if(!s||!t)return t;let p=t.toLowerCase(),k=s.toLowerCase(),d=[],r=0;for(;r<t.length;){let z=p.indexOf(k,r);if(z<0){d.push(t.slice(r));break}z>r&&d.push(t.slice(r,z)),d.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(z,z+k.length)},z)),r=z+k.length}return d}function Xt(t){if(!t)return"";let s=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),p=[];return s=s.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(k,d,r){return p.push("<pre><code>"+r+"</code></pre>"),"\0"+(p.length-1)+"\0"}),s=s.replace(/^(#{1,3})\s+(.+)$/gm,function(k,d,r){return"<h"+d.length+">"+r+"</h"+d.length+">"}),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/`([^`\n]+)`/g,"<code>$1</code>"),s=s.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(k,d,r){return/^(https?:|\/)/.test(r)?'<a href="'+r+'" target="_blank" rel="noopener noreferrer">'+d+"</a>":d}),s=s.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),s=s.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),s=s.replace(/\n/g,"<br/>"),s=s.replace(/\u0000(\d+)\u0000/g,function(k,d){return p[d]}),s}function xt(t){if(!t)return"";let s=new Date(t);if(Number.isNaN(s.getTime()))return"";let p=new Date,k=s.toDateString()===p.toDateString(),d=z=>String(z).padStart(2,"0"),r=`${d(s.getHours())}:${d(s.getMinutes())}`;return k?r:`${s.getMonth()+1}-${s.getDate()} ${r}`}
173
173
 
174
174
  return module.exports;
175
175
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-memory-eternal",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {