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