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