memory-eternal 0.9.12 → 0.9.14

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 CHANGED
@@ -3,17 +3,17 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
- var Ht=Object.create;var ut=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty;var Vt=(t,l)=>{for(var r in l)ut(t,r,{get:l[r],enumerable:!0})},Lt=(t,l,r,y)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of Ut(l))!Yt.call(t,u)&&u!==r&&ut(t,u,{get:()=>l[u],enumerable:!(y=_t(l,u))||y.enumerable});return t};var qt=(t,l,r)=>(r=t!=null?Ht(Kt(t)):{},Lt(l||!t||!t.__esModule?ut(r,"default",{value:t,enumerable:!0}):r,t)),Xt=t=>Lt(ut({},"__esModule",{value:!0}),t);var za={};Vt(za,{EN:()=>Ft,MemoryLibrary:()=>ma,ZH:()=>jt,apply:()=>sa,inject:()=>ia});module.exports=Xt(za);var n=qt(require("react"),1);var Gt={"&":"&amp;","<":"&lt;",">":"&gt;"},yt=t=>String(t).replace(/[&<>]/g,l=>Gt[l]),Jt=[[/结论|总结|tl;?dr|summary|takeaway/i,"\u2705","ok"],[/风险|注意|警告|禁止|坑|踩坑|务必/i,"\u26A0\uFE0F","warn"],[/根因|原因|为什么|定位|复现/i,"\u{1F50D}","info"],[/修复|解决|变更|fix/i,"\u{1F527}","ok"],[/验证|测试|实测|回归/i,"\u{1F9EA}","ok"],[/方案|做法|实现|设计|思路|架构/i,"\u{1F6E0}\uFE0F","plan"],[/步骤|流程|操作|用法|命令/i,"\u{1F9E9}","plan"],[/背景|由来|context/i,"\u{1F9ED}","info"],[/目标|需求|要解决/i,"\u{1F3AF}","plan"],[/环境|依赖|前置|安装/i,"\u{1F4E6}","info"],[/收益|效果|性能|指标|数据|统计/i,"\u{1F4C8}","ok"],[/示例|例子|样例|demo/i,"\u{1F4A1}","idea"],[/参考|链接|相关/i,"\u{1F517}","info"]],Zt=["\u2728","info"],Qt=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],ea=t=>{let l=String(t);for(let[r,y,u]of Jt)if(r.test(l))return[y,u];return Zt},ta=t=>{let l=t.join(" ");for(let[r,y,u]of Qt)if(r.test(l))return[y,u];return["\u{1F4CC}","info"]};function Qe(t){let l=String(t),r=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(l);if(r&&!/[是为有了吗呢着过把被和与或于]/.test(r[1]))return'<span class="md-kv"><span class="md-k">'+yt(r[1])+'</span><span class="md-v">'+Qe(r[2])+"</span></span>";let y=yt(l);return y=y.replace(/^\[([ xX])\](?=\s|$)\s*/,(u,o)=>'<span class="md-task">'+(o.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),y=y.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),y=y.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),y=y.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),y=y.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(u,o,v)=>/^(https?:|\/|#)/i.test(v)?'<a class="md-link" href="'+v+'" target="_blank" rel="noopener noreferrer">'+o+"</a>":o),y}function ht(t){let l=String(t||"").replace(/\r\n?/g,`
7
- `),r=/^---\n([\s\S]*?)\n---\n?/.exec(l);if(!r)return{meta:[],body:l};let y=[];for(let u of r[1].split(`
8
- `)){let o=u.indexOf(":");if(o<=0)continue;let v=u.slice(0,o).trim(),k=u.slice(o+1).trim().replace(/^["']|["']$/g,"");v&&y.push([v,k])}return{meta:y,body:l.slice(r[0].length)}}function Dt(t){let l=String(t||"").trim().replace(/^\[|\]$/g,"");return l?l.split(",").map(r=>r.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function Tt(t){let l=ht(String(t||"").replace(/\r\n?/g,`
9
- `)).body;if(!l.trim())return"";let r=[],y=l.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(m,A,C)=>(r.push('<pre class="md-pre"><code>'+yt(C.replace(/\n$/,""))+"</code></pre>"),"\0F"+(r.length-1)+"\0")),u=[],o=[],v=null,k=null,N=()=>{o.length&&(u.push('<p class="md-p">'+o.join("<br/>")+"</p>"),o=[])},I=()=>{if(!v)return;let m=v.type;u.push("<"+m+' class="md-'+m+'">'+v.items.map(A=>"<li>"+A+"</li>").join("")+"</"+m+">"),v=null},h=()=>{if(!k)return;let[m,A]=ta(k);u.push('<div class="md-callout md-c-'+A+'"><span class="md-ico">'+m+"</span>"+k.join("<br/>")+"</div>"),k=null},b=()=>{N(),I(),h()};for(let m of y.split(`
10
- `)){let A=m.trim();if(!A){b();continue}let C=/^\u0000F(\d+)\u0000$/.exec(A);if(C){b(),u.push(r[Number(C[1])]);continue}let w;if(w=/^(#{1,6})\s+(.+)$/.exec(A)){b();let[D,M]=ea(w[2]);u.push('<div class="md-h md-h-'+(w[1].length<=2?"h1":"h2")+" md-c-"+M+'"><span class="md-ico">'+D+'</span><span class="md-hx">'+Qe(w[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(A)){b(),u.push('<hr class="md-hr"/>');continue}if(w=/^>\s?(.*)$/.exec(A)){N(),I(),k=k||[],k.push(Qe(w[1]));continue}if(w=/^[-*+]\s+(.+)$/.exec(A)){N(),h(),(!v||v.type!=="ul")&&(I(),v={type:"ul",items:[]}),v.items.push(Qe(w[1]));continue}if(w=/^\d+[.)]\s+(.+)$/.exec(A)){N(),h(),(!v||v.type!=="ol")&&(I(),v={type:"ol",items:[]}),v.items.push(Qe(w[1]));continue}I(),h(),o.push(Qe(A))}return b(),u.join(`
11
- `)}function At(t={}){let l=t.repo||"EternalNight996/memory-eternal",r=String(t.title||"[Bug] ").slice(0,120),y=Array.isArray(t.labels)?t.labels:["bug"],u=Number(t.maxLength)>500?Number(t.maxLength):7e3,o=N=>{let I=new URLSearchParams;return I.set("title",r),I.set("body",N),y.length&&I.set("labels",y.join(",")),"https://github.com/"+l+"/issues/new?"+I.toString()},v=String(t.body||""),k=o(v);if(k.length>u){let N=`
12
-
13
- > \u5185\u5BB9\u8FC7\u957F\u5DF2\u622A\u65AD\uFF1A\u5B8C\u6574\u8BCA\u65AD\u8BF7\u5728\u63D2\u4EF6\u91CC\u70B9\u300C\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u300D\uFF0C\u518D\u8865\u5230 issue \u8BC4\u8BBA\u91CC\u3002`,I=h=>o(v.slice(0,h)+N);if(I(0).length>u)v=N;else{let h=0,b=v.length;for(;h<b;){let m=Math.ceil((h+b)/2);I(m).length<=u?h=m:b=m-1}v=v.slice(0,h)+N}k=o(v)}return k}function Bt(t={}){return["## \u73B0\u8C61",String(t.description||"").trim()||"\uFF08\u8BF7\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF09","","## \u590D\u73B0\u6B65\u9AA4","1. ","2. ","","## \u671F\u671B\u884C\u4E3A","","## \u5B9E\u9645\u884C\u4E3A","","## \u73AF\u5883","- \u63D2\u4EF6\u7248\u672C: "+(t.version||"\uFF08\u89C1\u8BCA\u65AD\u4FE1\u606F\uFF09"),"",t.diagnostics||"","","---","> \u7531 memory-eternal \u63D2\u4EF6\u5185\u300C\u53CD\u9988\u5F02\u5E38\u300D\u751F\u6210\uFF08\u8BCA\u65AD\u4FE1\u606F\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E\u5404\u7C7B key/token \u5DF2\u66FF\u6362\uFF09\u3002"].join(`
14
- `)}var xt="https://github.com/EternalNight996/memory-eternal",aa=["\u6211\u5728\u4F7F\u7528 memory-eternal\uFF08DeepSeek Harness \u7684\u8BB0\u5FC6\u63D2\u4EF6\uFF09\u65F6\u9047\u5230\u4E86\u95EE\u9898\uFF0C\u8BF7\u4F60\u5E2E\u6211\u628A\u8FD9\u4E2A\u95EE\u9898\u63D0\u4EA4\u5230 GitHub\u3002","","\u4ED3\u5E93\uFF1A"+xt,"","\u8BF7\u6309\u8FD9\u4E2A\u6D41\u7A0B\u505A\uFF1A","","1. \u5148\u8DD1 `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50`\uFF0C\u770B\u662F\u5426\u5DF2\u6709\u76F8\u540C\u95EE\u9898\uFF1A"," - \u5DF2\u6709 \u2192 \u7528 `gh issue comment <\u7F16\u53F7> --body-file <\u6587\u4EF6>` \u8865\u5145\u73B0\u8C61\uFF0C\u4E0D\u8981\u91CD\u590D\u5F00\u65B0 issue\uFF1B"," - \u6CA1\u6709 \u2192 \u7EE7\u7EED\u7B2C 2 \u6B65\u3002",'2. \u628A\u6B63\u6587\u5199\u6210\u6587\u4EF6\uFF0C\u7136\u540E `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <\u4E00\u53E5\u8BDD\u6982\u62EC>" --body-file <\u6587\u4EF6>`\uFF1B\u6B63\u6587\u7528\u8FD9\u4E2A\u7ED3\u6784\uFF1A'," \u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A / \u5B9E\u9645\u884C\u4E3A / \u73AF\u5883\uFF08\u63D2\u4EF6\u7248\u672C / DSH \u7248\u672C / \u64CD\u4F5C\u7CFB\u7EDF / Node\uFF09/ \u8BCA\u65AD\u4FE1\u606F\u3002","3. \u5982\u679C `gh` \u6CA1\u767B\u5F55\u6216\u4E0D\u53EF\u7528\uFF0C\u4E0D\u8981\u5C1D\u8BD5\u63D0\u4EA4\uFF0C\u6539\u4E3A\u8F93\u51FA\u4E00\u6761\u300C\u6807\u9898\u4E0E\u6B63\u6587\u90FD\u5DF2\u9884\u586B\u300D\u7684 GitHub \u65B0\u5EFA issue \u94FE\u63A5\u7ED9\u6211\uFF0C\u6211\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002","4. \u63D0\u4EA4\u6210\u529F\u540E\uFF0C\u628A issue \u94FE\u63A5\u53D1\u7ED9\u6211\u3002","","\u6CE8\u610F\uFF1A\u6211\u7684\u95EE\u9898\u63CF\u8FF0\u8BF7\u539F\u6837\u7167\u5F55\uFF0C\u4E0D\u8981\u66FF\u6211\u7F8E\u5316\u6216\u7701\u7565\u7EC6\u8282\uFF1B\u8BCA\u65AD\u4FE1\u606F\u539F\u6837\u653E\u8FDB\u300C\u8BCA\u65AD\u4FE1\u606F\u300D\u4E00\u8282\u3002","","\u6211\u7684\u95EE\u9898\u63CF\u8FF0\uFF1A","<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>","","\u8BCA\u65AD\u4FE1\u606F\uFF1A","<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>"].join(`
15
- `),na=["I hit a problem while using memory-eternal (a DeepSeek Harness memory plugin). Please file it on GitHub for me.","","Repo: "+xt,"","Workflow:","","1. Run `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50` first: if a matching issue exists, add a comment with `gh issue comment <n> --body-file <file>` instead of opening a duplicate.",'2. Otherwise create it with `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <one-line summary>" --body-file <file>`, using sections: Symptoms / Steps to reproduce / Expected / Actual / Environment (plugin, DSH, OS, Node) / Diagnostics.',"3. If `gh` is not authenticated or unavailable, do NOT try to submit: output a GitHub new-issue link with the title and body pre-filled instead, and I will click submit myself.","4. Report the resulting issue URL back to me.","","Keep my description verbatim - do not rewrite or summarise it. Put the diagnostics under the Diagnostics section as-is.","","My description:","<write your problem here>","","Diagnostics:","<paste the diagnostics copied from the in-app Report-a-bug dialog>"].join(`
16
- `);function Rt(t={}){let l=t.lang==="en"?"en":"zh",r=l==="en"?na:aa,y=t.repo||"EternalNight996/memory-eternal";return r=r.split(xt).join("https://github.com/"+y),t.description&&(r=r.replace(l==="en"?"<write your problem here>":"<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>",String(t.description).trim())),t.diagnostics&&(r=r.replace(l==="en"?"<paste the diagnostics copied from the in-app Report-a-bug dialog>":"<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>",String(t.diagnostics).trim())),r}var e=require("react/jsx-runtime"),et="memory-eternal",U="/memory-eternal/api",oa=100,ia=["slots","locale"],jt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",vaultMulti:"\u591A\u5E93\uFF08\u6309\u9879\u76EE\u9694\u79BB\uFF09",vaultMultiHint:"\u7559\u7A7A\u5373\u5355\u5E93\uFF0C\u8001\u914D\u7F6E\u4E0D\u53D7\u5F71\u54CD",vaultNow:"\u5F53\u524D\u751F\u6548",vaultSource:"\u6765\u6E90",vaultWorkspace:"\u5F53\u524D workspace",vaultNamePh:"\u5E93\u540D\uFF0C\u5982 work",vaultPathPh:"\u76EE\u5F55\uFF0C\u5982 D:/vaults/work",vaultMatchPh:"\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u6309 workspace \u81EA\u52A8\u9009\u5E93\uFF09",vaultAdd:"\u6DFB\u52A0\u4E00\u4E2A\u5E93",vaultActive:"\u6FC0\u6D3B\u5E93",vaultActiveNone:"\u9ED8\u8BA4\u5E93\uFF08\u4E0D\u6307\u5B9A\uFF09",vaultSrcEnv:"\u73AF\u5883\u53D8\u91CF MEMORY_VAULT_DIR",vaultSrcProfile:"\u6FC0\u6D3B\u5E93\u914D\u7F6E",vaultSrcWorkspace:"\u6309\u9879\u76EE\u76EE\u5F55\u81EA\u52A8\u547D\u4E2D",vaultSrcVaultDir:"\u5355\u5E93\u914D\u7F6E vaultDir",vaultSrcDefault:"\u9ED8\u8BA4\u76EE\u5F55",fbNav:"\u53CD\u9988\u5F02\u5E38",fbTitle:"\u53CD\u9988\u5F02\u5E38\uFF08\u63D0\u4EA4\u5230 GitHub\uFF09",fbDesc:"\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF08\u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A\uFF09",fbDiag:"\u8BCA\u65AD\u4FE1\u606F\uFF08\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E key/token \u5DF2\u66FF\u6362\uFF09",fbCopyDiag:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",fbOpenIssue:"\u5728 GitHub \u63D0\u4EA4\uFF08\u5DF2\u9884\u586B\uFF09",fbCopyPrompt:"\u590D\u5236\u7ED9 AI \u7684\u63D0\u793A\u8BCD",fbCopiedDiag:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",fbCopiedPrompt:"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB AI \u5BF9\u8BDD\u6846\u5373\u53EF",fbCopyFail:"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u590D\u5236",fbWhy:"GitHub \u4E0D\u5141\u8BB8\u533F\u540D\u521B\u5EFA issue\uFF0C\u63D2\u4EF6\u91CC\u4E5F\u4E0D\u5E94\u5185\u7F6E token\uFF1A\u6240\u4EE5\u8FD9\u91CC\u628A\u6807\u9898 / \u6B63\u6587 / \u8BCA\u65AD\u90FD\u9884\u586B\u597D\uFF0C\u4F60\u53EA\u9700\u518D\u70B9\u4E00\u6B21 Submit\u3002",fbNeedDesc:"\u8BF7\u5148\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898",fbLoading:"\u6B63\u5728\u6536\u96C6\u8BCA\u65AD\u4FE1\u606F\u2026",fbDiagFail:"\u8BCA\u65AD\u63A5\u53E3\u4E0D\u53EF\u7528\uFF08\u72EC\u7ACB web \u6216\u65E7\u7248\u5BBF\u4E3B\uFF09\uFF0C\u8BF7\u624B\u52A8\u8865\u5145\u73AF\u5883\u4FE1\u606F",fbOr:"\u6216\u8005",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
6
+ var Da=Object.create;var Ft=Object.defineProperty;var Ta=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,Ba=Object.prototype.hasOwnProperty;var Ra=(t,n)=>{for(var i in n)Ft(t,i,{get:n[i],enumerable:!0})},la=(t,n,i,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of La(n))!Ba.call(t,p)&&p!==i&&Ft(t,p,{get:()=>n[p],enumerable:!(u=Ta(n,p))||u.enumerable});return t};var Pa=(t,n,i)=>(i=t!=null?Da(Aa(t)):{},la(n||!t||!t.__esModule?Ft(i,"default",{value:t,enumerable:!0}):i,t)),Ea=t=>la(Ft({},"__esModule",{value:!0}),t);var hn={};Ra(hn,{EN:()=>ka,MemoryLibrary:()=>nn,ZH:()=>wa,apply:()=>Za,inject:()=>Xa});module.exports=Ea(hn);var o=Pa(require("react"),1);var Fa={"&":"&amp;","<":"&lt;",">":"&gt;"},_t=t=>String(t).replace(/[&<>]/g,n=>Fa[n]),ja=[[/结论|总结|tl;?dr|summary|takeaway/i,"\u2705","ok"],[/风险|注意|警告|禁止|坑|踩坑|务必/i,"\u26A0\uFE0F","warn"],[/根因|原因|为什么|定位|复现/i,"\u{1F50D}","info"],[/修复|解决|变更|fix/i,"\u{1F527}","ok"],[/验证|测试|实测|回归/i,"\u{1F9EA}","ok"],[/方案|做法|实现|设计|思路|架构/i,"\u{1F6E0}\uFE0F","plan"],[/步骤|流程|操作|用法|命令/i,"\u{1F9E9}","plan"],[/背景|由来|context/i,"\u{1F9ED}","info"],[/目标|需求|要解决/i,"\u{1F3AF}","plan"],[/环境|依赖|前置|安装/i,"\u{1F4E6}","info"],[/收益|效果|性能|指标|数据|统计/i,"\u{1F4C8}","ok"],[/示例|例子|样例|demo/i,"\u{1F4A1}","idea"],[/参考|链接|相关/i,"\u{1F517}","info"]],Oa=["\u2728","info"],Ha=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],Wa=t=>{let n=String(t);for(let[i,u,p]of ja)if(i.test(n))return[u,p];return Oa},$a=t=>{let n=t.join(" ");for(let[i,u,p]of Ha)if(i.test(n))return[u,p];return["\u{1F4CC}","info"]};function gt(t){let n=String(t),i=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(n);if(i&&!/[是为有了吗呢着过把被和与或于]/.test(i[1]))return'<span class="md-kv"><span class="md-k">'+_t(i[1])+'</span><span class="md-v">'+gt(i[2])+"</span></span>";let u=_t(n);return u=u.replace(/^\[([ xX])\](?=\s|$)\s*/,(p,l)=>'<span class="md-task">'+(l.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),u=u.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),u=u.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),u=u.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),u=u.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(p,l,h)=>/^(https?:|\/|#)/i.test(h)?'<a class="md-link" href="'+h+'" target="_blank" rel="noopener noreferrer">'+l+"</a>":l),u}function Ut(t){let n=String(t||"").replace(/\r\n?/g,`
7
+ `),i=/^---\n([\s\S]*?)\n---\n?/.exec(n);if(!i)return{meta:[],body:n};let u=[];for(let p of i[1].split(`
8
+ `)){let l=p.indexOf(":");if(l<=0)continue;let h=p.slice(0,l).trim(),w=p.slice(l+1).trim().replace(/^["']|["']$/g,"");h&&u.push([h,w])}return{meta:u,body:n.slice(i[0].length)}}function ra(t){let n=String(t||"").trim().replace(/^\[|\]$/g,"");return n?n.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function sa(t){let n=Ut(String(t||"").replace(/\r\n?/g,`
9
+ `)).body;if(!n.trim())return"";let i=[],u=n.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(g,D,T)=>(i.push('<pre class="md-pre"><code>'+_t(T.replace(/\n$/,""))+"</code></pre>"),"\0F"+(i.length-1)+"\0")),p=[],l=[],h=null,w=null,x=()=>{l.length&&(p.push('<p class="md-p">'+l.join("<br/>")+"</p>"),l=[])},A=()=>{if(!h)return;let g=h.type;p.push("<"+g+' class="md-'+g+'">'+h.items.map(D=>"<li>"+D+"</li>").join("")+"</"+g+">"),h=null},S=()=>{if(!w)return;let[g,D]=$a(w);p.push('<div class="md-callout md-c-'+D+'"><span class="md-ico">'+g+"</span>"+w.join("<br/>")+"</div>"),w=null},y=()=>{x(),A(),S()};for(let g of u.split(`
10
+ `)){let D=g.trim();if(!D){y();continue}let T=/^\u0000F(\d+)\u0000$/.exec(D);if(T){y(),p.push(i[Number(T[1])]);continue}let k;if(k=/^(#{1,6})\s+(.+)$/.exec(D)){y();let[L,I]=Wa(k[2]);p.push('<div class="md-h md-h-'+(k[1].length<=2?"h1":"h2")+" md-c-"+I+'"><span class="md-ico">'+L+'</span><span class="md-hx">'+gt(k[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(D)){y(),p.push('<hr class="md-hr"/>');continue}if(k=/^>\s?(.*)$/.exec(D)){x(),A(),w=w||[],w.push(gt(k[1]));continue}if(k=/^[-*+]\s+(.+)$/.exec(D)){x(),S(),(!h||h.type!=="ul")&&(A(),h={type:"ul",items:[]}),h.items.push(gt(k[1]));continue}if(k=/^\d+[.)]\s+(.+)$/.exec(D)){x(),S(),(!h||h.type!=="ol")&&(A(),h={type:"ol",items:[]}),h.items.push(gt(k[1]));continue}A(),S(),l.push(gt(D))}return y(),p.join(`
11
+ `)}function da(t={}){let n=t.repo||"EternalNight996/memory-eternal",i=String(t.title||"[Bug] ").slice(0,120),u=Array.isArray(t.labels)?t.labels:["bug"],p=Number(t.maxLength)>500?Number(t.maxLength):7e3,l=x=>{let A=new URLSearchParams;return A.set("title",i),A.set("body",x),u.length&&A.set("labels",u.join(",")),"https://github.com/"+n+"/issues/new?"+A.toString()},h=String(t.body||""),w=l(h);if(w.length>p){let x=`
12
+
13
+ > \u5185\u5BB9\u8FC7\u957F\u5DF2\u622A\u65AD\uFF1A\u5B8C\u6574\u8BCA\u65AD\u8BF7\u5728\u63D2\u4EF6\u91CC\u70B9\u300C\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u300D\uFF0C\u518D\u8865\u5230 issue \u8BC4\u8BBA\u91CC\u3002`,A=S=>l(h.slice(0,S)+x);if(A(0).length>p)h=x;else{let S=0,y=h.length;for(;S<y;){let g=Math.ceil((S+y)/2);A(g).length<=p?S=g:y=g-1}h=h.slice(0,S)+x}w=l(h)}return w}function ca(t={}){return["## \u73B0\u8C61",String(t.description||"").trim()||"\uFF08\u8BF7\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF09","","## \u590D\u73B0\u6B65\u9AA4","1. ","2. ","","## \u671F\u671B\u884C\u4E3A","","## \u5B9E\u9645\u884C\u4E3A","","## \u73AF\u5883","- \u63D2\u4EF6\u7248\u672C: "+(t.version||"\uFF08\u89C1\u8BCA\u65AD\u4FE1\u606F\uFF09"),"",t.diagnostics||"","","---","> \u7531 memory-eternal \u63D2\u4EF6\u5185\u300C\u53CD\u9988\u5F02\u5E38\u300D\u751F\u6210\uFF08\u8BCA\u65AD\u4FE1\u606F\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E\u5404\u7C7B key/token \u5DF2\u66FF\u6362\uFF09\u3002"].join(`
14
+ `)}var Kt="https://github.com/EternalNight996/memory-eternal",_a=["\u6211\u5728\u4F7F\u7528 memory-eternal\uFF08DeepSeek Harness \u7684\u8BB0\u5FC6\u63D2\u4EF6\uFF09\u65F6\u9047\u5230\u4E86\u95EE\u9898\uFF0C\u8BF7\u4F60\u5E2E\u6211\u628A\u8FD9\u4E2A\u95EE\u9898\u63D0\u4EA4\u5230 GitHub\u3002","","\u4ED3\u5E93\uFF1A"+Kt,"","\u8BF7\u6309\u8FD9\u4E2A\u6D41\u7A0B\u505A\uFF1A","","1. \u5148\u8DD1 `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50`\uFF0C\u770B\u662F\u5426\u5DF2\u6709\u76F8\u540C\u95EE\u9898\uFF1A"," - \u5DF2\u6709 \u2192 \u7528 `gh issue comment <\u7F16\u53F7> --body-file <\u6587\u4EF6>` \u8865\u5145\u73B0\u8C61\uFF0C\u4E0D\u8981\u91CD\u590D\u5F00\u65B0 issue\uFF1B"," - \u6CA1\u6709 \u2192 \u7EE7\u7EED\u7B2C 2 \u6B65\u3002",'2. \u628A\u6B63\u6587\u5199\u6210\u6587\u4EF6\uFF0C\u7136\u540E `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <\u4E00\u53E5\u8BDD\u6982\u62EC>" --body-file <\u6587\u4EF6>`\uFF1B\u6B63\u6587\u7528\u8FD9\u4E2A\u7ED3\u6784\uFF1A'," \u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A / \u5B9E\u9645\u884C\u4E3A / \u73AF\u5883\uFF08\u63D2\u4EF6\u7248\u672C / DSH \u7248\u672C / \u64CD\u4F5C\u7CFB\u7EDF / Node\uFF09/ \u8BCA\u65AD\u4FE1\u606F\u3002","3. \u5982\u679C `gh` \u6CA1\u767B\u5F55\u6216\u4E0D\u53EF\u7528\uFF0C\u4E0D\u8981\u5C1D\u8BD5\u63D0\u4EA4\uFF0C\u6539\u4E3A\u8F93\u51FA\u4E00\u6761\u300C\u6807\u9898\u4E0E\u6B63\u6587\u90FD\u5DF2\u9884\u586B\u300D\u7684 GitHub \u65B0\u5EFA issue \u94FE\u63A5\u7ED9\u6211\uFF0C\u6211\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002","4. \u63D0\u4EA4\u6210\u529F\u540E\uFF0C\u628A issue \u94FE\u63A5\u53D1\u7ED9\u6211\u3002","","\u6CE8\u610F\uFF1A\u6211\u7684\u95EE\u9898\u63CF\u8FF0\u8BF7\u539F\u6837\u7167\u5F55\uFF0C\u4E0D\u8981\u66FF\u6211\u7F8E\u5316\u6216\u7701\u7565\u7EC6\u8282\uFF1B\u8BCA\u65AD\u4FE1\u606F\u539F\u6837\u653E\u8FDB\u300C\u8BCA\u65AD\u4FE1\u606F\u300D\u4E00\u8282\u3002","","\u6211\u7684\u95EE\u9898\u63CF\u8FF0\uFF1A","<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>","","\u8BCA\u65AD\u4FE1\u606F\uFF1A","<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>"].join(`
15
+ `),Ua=["I hit a problem while using memory-eternal (a DeepSeek Harness memory plugin). Please file it on GitHub for me.","","Repo: "+Kt,"","Workflow:","","1. Run `gh issue list --repo EternalNight996/memory-eternal --state open --limit 50` first: if a matching issue exists, add a comment with `gh issue comment <n> --body-file <file>` instead of opening a duplicate.",'2. Otherwise create it with `gh issue create --repo EternalNight996/memory-eternal --title "[Bug] <one-line summary>" --body-file <file>`, using sections: Symptoms / Steps to reproduce / Expected / Actual / Environment (plugin, DSH, OS, Node) / Diagnostics.',"3. If `gh` is not authenticated or unavailable, do NOT try to submit: output a GitHub new-issue link with the title and body pre-filled instead, and I will click submit myself.","4. Report the resulting issue URL back to me.","","Keep my description verbatim - do not rewrite or summarise it. Put the diagnostics under the Diagnostics section as-is.","","My description:","<write your problem here>","","Diagnostics:","<paste the diagnostics copied from the in-app Report-a-bug dialog>"].join(`
16
+ `);function pa(t={}){let n=t.lang==="en"?"en":"zh",i=n==="en"?Ua:_a,u=t.repo||"EternalNight996/memory-eternal";return i=i.split(Kt).join("https://github.com/"+u),t.description&&(i=i.replace(n==="en"?"<write your problem here>":"<\u5728\u8FD9\u91CC\u5199\u4F60\u7684\u95EE\u9898>",String(t.description).trim())),t.diagnostics&&(i=i.replace(n==="en"?"<paste the diagnostics copied from the in-app Report-a-bug dialog>":"<\u628A\u300C\u53CD\u9988\u5F02\u5E38\u300D\u5F39\u7A97\u91CC\u590D\u5236\u7684\u8BCA\u65AD\u4FE1\u606F\u7C98\u5230\u8FD9\u91CC>",String(t.diagnostics).trim())),i}function ua({panX:t=0,panY:n=0,zoom:i=1,w:u=0,h:p=0,margin:l=60}={}){let h=i||1;return{x0:(0-t)/h-l,y0:(0-n)/h-l,x1:(u-t)/h+l,y1:(p-n)/h+l}}function jt(t,n,i,u){return u?t+i>=u.x0&&t-i<=u.x1&&n+i>=u.y0&&n-i<=u.y1:!0}function ma(t){let n=Number(t)||0;return n<=120?1/0:n<=300?160:n<=600?90:60}function ga(t,n={}){let i=Number.isFinite(n.limit)?n.limit:1/0,u=new Set,p=x=>{x&&u.size<i&&u.add(x)};if(p(n.focusId),p(n.hoverId),n.searchHits)for(let x of n.searchHits){if(u.size>=i)break;u.add(x)}let l=n.degree||{},h=x=>Number(l[x])||0,w=[];for(let x of Array.isArray(t)?t:[])x&&x.id&&!u.has(x.id)&&w.push(x);w.sort((x,A)=>h(A.id)-h(x.id));for(let x of w){if(u.size>=i)break;u.add(x.id)}return u}var Ka=Math.SQRT2;function Ya(t,n=Ka){let i=Number(t)>0?Number(t):1;return Math.max(0,Math.round(Math.log(i)/Math.log(n)))}function Va(t){return Math.max(1,Math.round(Number(t)||1))}function fa({kind:t="other",radius:n=9,zoom:i=1,dark:u=!1}={}){return t+"|"+Va(n)+"|"+Ya(i)+"|"+(u?"d":"l")}function ba({text:t="",fontPx:n=12,dark:i=!1}={}){return t+"|"+Math.round(Number(n)||12)+"|"+(i?"d":"l")}var Mt=class{constructor({createCanvas:n,max:i=400}={}){this.createCanvas=n,this.max=i,this.map=new Map,this.hits=0,this.misses=0}get(n,i,u,p){let l=this.map.get(n);if(l&&l.w===i&&l.h===u)return this.hits++,this.map.delete(n),this.map.set(n,l),l;this.misses++;let h=this.createCanvas(Math.max(1,Math.ceil(i)),Math.max(1,Math.ceil(u))),w=h.getContext("2d");p(w,h.width,h.height);let x={canvas:h,w:i,h:u,ctx:w};if(this.map.delete(n),this.map.set(n,x),this.map.size>this.max){let A=this.map.keys().next().value;this.map.delete(A)}return x}clear(){this.map.clear(),this.hits=0,this.misses=0}get size(){return this.map.size}};function ya({panX:t=0,panY:n=0,zoom:i=1,w:u=0,h:p=0,dpr:l=1,tick:h=0,filter:w="",dark:x=!1,dataVersion:A=0}={}){return[t,n,i,u,p,l,h,w,x?"d":"l",A].join("|")}var e=require("react/jsx-runtime"),ft="memory-eternal",q="/memory-eternal/api",qa=100,Xa=["slots","locale"],wa={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",vaultMulti:"\u591A\u5E93\uFF08\u6309\u9879\u76EE\u9694\u79BB\uFF09",vaultMultiHint:"\u7559\u7A7A\u5373\u5355\u5E93\uFF0C\u8001\u914D\u7F6E\u4E0D\u53D7\u5F71\u54CD",vaultNow:"\u5F53\u524D\u751F\u6548",vaultSource:"\u6765\u6E90",vaultWorkspace:"\u5F53\u524D workspace",vaultNamePh:"\u5E93\u540D\uFF0C\u5982 work",vaultPathPh:"\u76EE\u5F55\uFF0C\u5982 D:/vaults/work",vaultMatchPh:"\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u6309 workspace \u81EA\u52A8\u9009\u5E93\uFF09",vaultAdd:"\u6DFB\u52A0\u4E00\u4E2A\u5E93",vaultActive:"\u6FC0\u6D3B\u5E93",vaultActiveNone:"\u9ED8\u8BA4\u5E93\uFF08\u4E0D\u6307\u5B9A\uFF09",vaultSrcEnv:"\u73AF\u5883\u53D8\u91CF MEMORY_VAULT_DIR",vaultSrcProfile:"\u6FC0\u6D3B\u5E93\u914D\u7F6E",vaultSrcWorkspace:"\u6309\u9879\u76EE\u76EE\u5F55\u81EA\u52A8\u547D\u4E2D",vaultSrcVaultDir:"\u5355\u5E93\u914D\u7F6E vaultDir",vaultSrcDefault:"\u9ED8\u8BA4\u76EE\u5F55",fbNav:"\u53CD\u9988\u5F02\u5E38",fbTitle:"\u53CD\u9988\u5F02\u5E38\uFF08\u63D0\u4EA4\u5230 GitHub\uFF09",fbDesc:"\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898\uFF08\u73B0\u8C61 / \u590D\u73B0\u6B65\u9AA4 / \u671F\u671B\u884C\u4E3A\uFF09",fbDiag:"\u8BCA\u65AD\u4FE1\u606F\uFF08\u5DF2\u81EA\u52A8\u8131\u654F\uFF1Ahome \u76EE\u5F55\u4E0E key/token \u5DF2\u66FF\u6362\uFF09",fbCopyDiag:"\u590D\u5236\u8BCA\u65AD\u4FE1\u606F",fbOpenIssue:"\u5728 GitHub \u63D0\u4EA4\uFF08\u5DF2\u9884\u586B\uFF09",fbCopyPrompt:"\u590D\u5236\u7ED9 AI \u7684\u63D0\u793A\u8BCD",fbCopiedDiag:"\u8BCA\u65AD\u4FE1\u606F\u5DF2\u590D\u5236",fbCopiedPrompt:"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB AI \u5BF9\u8BDD\u6846\u5373\u53EF",fbCopyFail:"\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u590D\u5236",fbWhy:"GitHub \u4E0D\u5141\u8BB8\u533F\u540D\u521B\u5EFA issue\uFF0C\u63D2\u4EF6\u91CC\u4E5F\u4E0D\u5E94\u5185\u7F6E token\uFF1A\u6240\u4EE5\u8FD9\u91CC\u628A\u6807\u9898 / \u6B63\u6587 / \u8BCA\u65AD\u90FD\u9884\u586B\u597D\uFF0C\u4F60\u53EA\u9700\u518D\u70B9\u4E00\u6B21 Submit\u3002",fbNeedDesc:"\u8BF7\u5148\u63CF\u8FF0\u4F60\u9047\u5230\u7684\u95EE\u9898",fbLoading:"\u6B63\u5728\u6536\u96C6\u8BCA\u65AD\u4FE1\u606F\u2026",fbDiagFail:"\u8BCA\u65AD\u63A5\u53E3\u4E0D\u53EF\u7528\uFF08\u72EC\u7ACB web \u6216\u65E7\u7248\u5BBF\u4E3B\uFF09\uFF0C\u8BF7\u624B\u52A8\u8865\u5145\u73AF\u5883\u4FE1\u606F",fbOr:"\u6216\u8005",fbSelectAll:"\u5168\u9009",toastApproved:"\u5DF2\u6279\u51C6",toastRejected:"\u5DF2\u9A73\u56DE",toastCardDeleted:"\u5DF2\u5220\u9664",toastRestored:"\u5DF2\u6062\u590D",toastPurged:"\u5DF2\u5F7B\u5E95\u5220\u9664",toastPurgedExpired:"\u5DF2\u6E05\u7406\u8FC7\u671F\u56DE\u6536\u7AD9",toastFailed:"\u64CD\u4F5C\u5931\u8D25",noSelection:"\u8BF7\u5148\u9009\u62E9\u8981\u5904\u7406\u7684\u5361\u7247",actionRunning:"\u5904\u7406\u4E2D\u2026",recycleEmptyHint:"\u56DE\u6536\u7AD9\u4E3A\u7A7A\uFF1A\u5220\u6389\u7684\u5361\u7247\u4F1A\u5148\u653E\u5230\u8FD9\u91CC\uFF0C\u4FDD\u7559 {days} \u5929\u540E\u81EA\u52A8\u6E05\u7406\u3002",recyclePurgeAll:"\u6E05\u7A7A\u56DE\u6536\u7AD9",fbCopyManual:"\u81EA\u52A8\u590D\u5236\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u5DF2\u628A\u5185\u5BB9\u653E\u5728\u4E0B\u9762\uFF1A\u70B9\u300C\u5168\u9009\u300D\u518D\u6309 Ctrl+C",vcLoaded:"\u8FD0\u884C\u4E2D\uFF08\u5BBF\u4E3B\u52A0\u8F7D\uFF09",vcOnDisk:"\u78C1\u76D8\u5B89\u88C5",vcLatest:"npm \u6700\u65B0",vcStale:"\u78C1\u76D8\u5DF2\u5B89\u88C5 {disk}\uFF0C\u4F46\u5F53\u524D DSH \u8FDB\u7A0B\u4ECD\u52A0\u8F7D {loaded} \u2014\u2014 \u91CD\u542F\u684C\u9762\u7248 / DSH \u540E\u624D\u751F\u6548",vcOutdated:"\u6709\u65B0\u7248\u672C",vcUpToDate:"\u5DF2\u662F\u6700\u65B0",vcCheck:"\u68C0\u67E5\u66F4\u65B0",checking:"\u68C0\u67E5\u4E2D\u2026",vcCheckFail:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25",saving:"\u4FDD\u5B58\u4E2D\u2026",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
17
17
 
18
18
  ## \u80CC\u666F
19
19
  - \u95EE\u9898\u63CF\u8FF0
@@ -58,7 +58,7 @@ var Ht=Object.create;var ut=Object.defineProperty;var _t=Object.getOwnPropertyDe
58
58
  -
59
59
 
60
60
  ## \u98CE\u9669/\u963B\u585E
61
- - `},Ft={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",vaultMulti:"Multiple vaults (per project)",vaultMultiHint:"Empty = single vault; existing setups unaffected",vaultNow:"Active now",vaultSource:"Source",vaultWorkspace:"Current workspace",vaultNamePh:"Name, e.g. work",vaultPathPh:"Directory, e.g. D:/vaults/work",vaultMatchPh:"Project dir (optional, auto-select by workspace)",vaultAdd:"Add a vault",vaultActive:"Active vault",vaultActiveNone:"Default vault (unset)",vaultSrcEnv:"env MEMORY_VAULT_DIR",vaultSrcProfile:"activeVault profile",vaultSrcWorkspace:"matched by project dir",vaultSrcVaultDir:"vaultDir setting",vaultSrcDefault:"default directory",fbNav:"Report a bug",fbTitle:"Report a bug (files on GitHub)",fbDesc:"Describe the problem (symptoms / steps / expected)",fbDiag:"Diagnostics (auto-redacted: home dir and keys/tokens replaced)",fbCopyDiag:"Copy diagnostics",fbOpenIssue:"Open prefilled issue on GitHub",fbCopyPrompt:"Copy AI prompt",fbCopiedDiag:"Diagnostics copied",fbCopiedPrompt:"Prompt copied \u2014 paste it into your AI chat",fbCopyFail:"Copy failed; please select and copy manually",fbWhy:"GitHub does not allow anonymous issue creation and the plugin must not ship a token: so the title, body and diagnostics are pre-filled \u2014 you just click Submit.",fbNeedDesc:"Please describe the problem first",fbLoading:"Collecting diagnostics\u2026",fbDiagFail:"Diagnostics endpoint unavailable (standalone web or older host); please add environment info manually",fbOr:"or",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
61
+ - `},ka={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",vaultMulti:"Multiple vaults (per project)",vaultMultiHint:"Empty = single vault; existing setups unaffected",vaultNow:"Active now",vaultSource:"Source",vaultWorkspace:"Current workspace",vaultNamePh:"Name, e.g. work",vaultPathPh:"Directory, e.g. D:/vaults/work",vaultMatchPh:"Project dir (optional, auto-select by workspace)",vaultAdd:"Add a vault",vaultActive:"Active vault",vaultActiveNone:"Default vault (unset)",vaultSrcEnv:"env MEMORY_VAULT_DIR",vaultSrcProfile:"activeVault profile",vaultSrcWorkspace:"matched by project dir",vaultSrcVaultDir:"vaultDir setting",vaultSrcDefault:"default directory",fbNav:"Report a bug",fbTitle:"Report a bug (files on GitHub)",fbDesc:"Describe the problem (symptoms / steps / expected)",fbDiag:"Diagnostics (auto-redacted: home dir and keys/tokens replaced)",fbCopyDiag:"Copy diagnostics",fbOpenIssue:"Open prefilled issue on GitHub",fbCopyPrompt:"Copy AI prompt",fbCopiedDiag:"Diagnostics copied",fbCopiedPrompt:"Prompt copied \u2014 paste it into your AI chat",fbCopyFail:"Copy failed; please select and copy manually",fbWhy:"GitHub does not allow anonymous issue creation and the plugin must not ship a token: so the title, body and diagnostics are pre-filled \u2014 you just click Submit.",fbNeedDesc:"Please describe the problem first",fbLoading:"Collecting diagnostics\u2026",fbDiagFail:"Diagnostics endpoint unavailable (standalone web or older host); please add environment info manually",fbOr:"or",fbSelectAll:"Select all",toastApproved:"approved",toastRejected:"rejected",toastCardDeleted:"deleted",toastRestored:"restored",toastPurged:"permanently deleted",toastPurgedExpired:"expired recycle entries purged",toastFailed:"Action failed",noSelection:"Select the cards to act on first",actionRunning:"Working\u2026",recycleEmptyHint:"Recycle bin is empty: deleted cards land here first and are purged automatically after {days} days.",recyclePurgeAll:"Empty recycle bin",fbCopyManual:"Auto-copy was blocked by the browser \u2014 the text is below: click Select all, then Ctrl+C",vcLoaded:"running (loaded by host)",vcOnDisk:"on disk",vcLatest:"npm latest",vcStale:"{disk} is installed on disk but the running DSH process still has {loaded} loaded \u2014 restart the desktop app / DSH to apply",vcOutdated:"update available",vcUpToDate:"up to date",vcCheck:"Check for updates",checking:"Checking\u2026",vcCheckFail:"Update check failed",saving:"Saving\u2026",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
62
62
 
63
63
  ## Background
64
64
  - Problem
@@ -103,7 +103,7 @@ Option A, because:
103
103
  -
104
104
 
105
105
  ## Risks/blockers
106
- - `},wt=["all","project","knowledge","content","prompt","business","tool","mistake"],_e={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},mt={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},Fe={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},st="deepseek-harness",ot=t=>{let l=String(t||""),r=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||r.startsWith("claude-code")?r.startsWith("claude-code")?"claude":st:r==="deepseek harness"?st:l.split(":")[0]||st},la=[st,"claude","codex","cursor","codex-desktop"],Ot=(t=[])=>[...new Set([...la,...(t||[]).map(ot)])],ra={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},De=`
106
+ - `},Vt=["all","project","knowledge","content","prompt","business","tool","mistake"],Ze={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Ot={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},We={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Nt="deepseek-harness",xt=t=>{let n=String(t||""),i=n.toLowerCase();return!n||n==="agent"||n==="unknown"||n.startsWith("session:")||i.startsWith("claude-code")?i.startsWith("claude-code")?"claude":Nt:i==="deepseek harness"?Nt:n.split(":")[0]||Nt},Ga=[Nt,"claude","codex","cursor","codex-desktop"],Ca=(t=[])=>[...new Set([...Ga,...(t||[]).map(xt)])],Ja={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Ae=`
107
107
  .memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
108
108
  .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; }
109
109
  .mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
@@ -295,13 +295,13 @@ Option A, because:
295
295
  height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
296
296
  max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
297
297
  }
298
- `;function sa(t){t.effect(()=>t.locale.register(et,{zh:jt,en:Ft}),"memory-eternal: locale");let l=t.locale.bind(et);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:et,order:25,label:()=>l("nav"),locale:et,inject:()=>({})},()=>n.default.createElement(ca,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${et}:footer`,order:100,label:()=>l("nav"),locale:et,inject:()=>({})},r=>n.default.createElement(pa,{t:l,locale:t.locale,wide:!(r&&r.wide===!1)}))),"memory-eternal: sidebar footer action")}function da(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(r=>r.json()).then(r=>{r&&r.ok&&r.url&&l(r.url.endsWith("/")?r.url:r.url+"/")}).catch(()=>{})},[]),t}function ca({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:De}),(0,e.jsx)(Wt,{t,onReload:()=>{},version:0})]})}function pa({t,locale:l,wide:r}){let[y,u]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${r?"":" rail"}`,children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>u(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)($t,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),y&&(0,e.jsx)(ua,{t,locale:l,onClose:()=>u(!1)})]})}function ua({t,locale:l,onClose:r,tab:y}){let[u,o]=(0,n.useState)(!1),v=(0,n.useRef)(null),k=da(),N=(0,n.useCallback)(C=>l&&typeof l.subscribe=="function"?l.subscribe(C):()=>{},[l]),I=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),h=(0,n.useSyncExternalStore)(N,I),b=h&&(h.active==="zh"||h.active==="en")?h.active:null,m=(0,n.useRef)(null);m.current===null&&b&&(m.current=b);let A=(0,n.useMemo)(()=>{let C=m.current?`lang=${m.current}`:"";return y==="config"?`${U}/ui/config?tab=config${C?`&${C}`:""}`:y?`${k.replace(/\/$/,"")}/?tab=${y}${C?`&${C}`:""}`:C?`${k}${k.endsWith("/")?"":"/"}?${C}`:k},[k,y]);return(0,n.useEffect)(()=>{let C=v.current&&v.current.contentWindow;C&&b&&C.postMessage({source:"memory-eternal",type:"locale",lang:b},"*")},[b]),(0,n.useEffect)(()=>{let C=w=>{w.key==="Escape"&&r()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:r,children:[(0,e.jsx)("style",{children:De}),(0,e.jsx)("div",{className:"me-modal"+(u?" me-modal-full":""),onClick:C=>C.stopPropagation(),children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>o(C=>!C),"aria-label":t(u?"exitFullscreen":"enterFullscreen"),title:t(u?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:u?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:r,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{ref:v,src:A,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function $t(){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 ma({t,inModal:l,onClose:r,onFull:y,full:u}){let[o,v]=(0,n.useState)(null),[k,N]=(0,n.useState)([]),[I,h]=(0,n.useState)(!0),[b,m]=(0,n.useState)(null),[A,C]=(0,n.useState)(""),[w,D]=(0,n.useState)("all"),[M,j]=(0,n.useState)(""),[oe,te]=(0,n.useState)("all"),[W,Z]=(0,n.useState)("all"),[T,ve]=(0,n.useState)(()=>{try{let f=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),P={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(f&&P[f])return P[f]}catch{}return"cards"}),[z,ie]=(0,n.useState)(()=>new Set([T])),g=(0,n.useCallback)(f=>{ie(P=>P.has(f)?P:new Set(P).add(f)),ve(f)},[]),[R,Y]=(0,n.useState)("recent"),[Q,H]=(0,n.useState)(null),_=(0,n.useRef)(null),ne=(0,n.useRef)(null),[ae,we]=(0,n.useState)(!1),[Ue,Te]=(0,n.useState)(null),[Me,Ae]=(0,n.useState)(!1),[Be,ke]=(0,n.useState)(!1),[fe,Ie]=(0,n.useState)(!0),[Oe,pe]=(0,n.useState)(null),[be,d]=(0,n.useState)(0),F=(0,n.useCallback)(()=>d(f=>f+1),[]),O=(0,n.useRef)(null),[K,G]=(0,n.useState)(0),[ye,ue]=(0,n.useState)(!1),s=(0,n.useRef)(null),i=(0,n.useRef)(null),B=(0,n.useCallback)(async(f=w,P=M,X=W,Le={})=>{let me=Le.append===!0;try{me?ue(!0):(h(!0),C(""));let ge=new URLSearchParams;f&&f!=="all"&&ge.set("kind",f),P.trim()&&ge.set("q",P.trim()),ge.set("status",X||"all"),ge.set("limit",String(oa)),ge.set("offset",String(Le.offset||0)),R==="title"&&ge.set("sort","title");let Ke=await(await fetch(`${U}/cards?${ge.toString()}`)).json();if(Ke.ok){let $e=Ke.cards||[];N(Se=>me?[...Se,...$e.filter(Je=>!Se.some(Ze=>Ze.path===Je.path))]:$e),G(Number(Ke.total)||$e.length)}}catch(ge){C(String(ge&&ge.message?ge.message:ge))}finally{me?ue(!1):h(!1)}},[w,M,W,R]),V=(0,n.useCallback)(async()=>{try{let[f,P]=await Promise.all([fetch(`${U}/overview`).then(X=>X.json()),fetch(`${U}/capture-log`).then(X=>X.json()).catch(()=>null)]);f.ok&&v(f),m(P&&P.ok&&P.available&&P.health||null)}catch(f){C(String(f&&f.message?f.message:f))}finally{h(!1)}},[]),se=async f=>{try{let X=await(await fetch(`${U}/delete?path=${encodeURIComponent(f)}`)).json();X.ok?(H({ok:!0,msg:t("deleted")}),await V(),F()):H({ok:!1,msg:X.error||t("deleteFail")})}catch{H({ok:!1,msg:t("deleteFail")})}_.current&&clearTimeout(_.current),_.current=setTimeout(()=>H(null),2e3)};(0,n.useEffect)(()=>(V(),()=>{O.current&&clearTimeout(O.current)}),[V]);let ze=f=>{j(f),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>B(w,f,W),280)},a=f=>{D(f),B(f,M,W)};(0,n.useEffect)(()=>{T==="cards"&&B(w,M,W)},[W,T,be,R]),(0,n.useEffect)(()=>{if(T!=="cards"||I||ye||k.length>=K)return;let f=s.current,P=i.current;if(!f)return;let X=new IntersectionObserver(Le=>{Le[0]&&Le[0].isIntersecting&&B(w,M,W,{append:!0,offset:k.length})},{root:P||null,rootMargin:"400px"});return X.observe(f),()=>X.disconnect()},[T,k,K,I,ye,w,M,W,B]);let Ge=async f=>{try{let X=await(await fetch(`${U}/card?path=${encodeURIComponent(f.path||f.id)}`)).json();X.ok&&Te({path:X.path,title:f.title,text:X.text})}catch(P){C(String(P&&P.message?P.message:P))}},it=async(f,P)=>{we(!0);try{let X=await fetch(`${U}/export`);if(!X.ok)throw new Error("HTTP "+X.status);let Le=await X.json();if(!Le.ok)throw new Error(Le.error||"export failed");let me,ge,he;f==="json"?(ge="memory-vault.json",he="application/json",me=JSON.stringify(Le.cards.map(Se=>({path:Se.path,title:Se.title,kind:Se.kind,text:Se.text})),null,2)):(ge="memory-vault.md",he="text/markdown;charset=utf-8",me=Le.cards.map(Se=>Se.text.trim()).filter(Boolean).join(`
298
+ `;function Za(t){t.effect(()=>t.locale.register(ft,{zh:wa,en:ka}),"memory-eternal: locale");let n=t.locale.bind(ft);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:ft,order:25,label:()=>n("nav"),locale:ft,inject:()=>({})},()=>o.default.createElement(en,{t:n}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${ft}:footer`,order:100,label:()=>n("nav"),locale:ft,inject:()=>({})},i=>o.default.createElement(tn,{t:n,locale:t.locale,wide:!(i&&i.wide===!1)}))),"memory-eternal: sidebar footer action")}function Qa(){let[t,n]=(0,o.useState)("http://127.0.0.1:7999/");return(0,o.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(i=>i.json()).then(i=>{i&&i.ok&&i.url&&n(i.url.endsWith("/")?i.url:i.url+"/")}).catch(()=>{})},[]),t}function en({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsx)(Na,{t,onReload:()=>{},version:0})]})}function tn({t,locale:n,wide:i}){let[u,p]=(0,o.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${i?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>p(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Sa,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),u&&(0,e.jsx)(an,{t,locale:n,onClose:()=>p(!1)})]})}function an({t,locale:n,onClose:i,tab:u}){let[p,l]=(0,o.useState)(!1),h=(0,o.useRef)(null),w=Qa(),x=(0,o.useCallback)(T=>n&&typeof n.subscribe=="function"?n.subscribe(T):()=>{},[n]),A=(0,o.useCallback)(()=>n&&typeof n.getSnapshot=="function"?n.getSnapshot():null,[n]),S=(0,o.useSyncExternalStore)(x,A),y=S&&(S.active==="zh"||S.active==="en")?S.active:null,g=(0,o.useRef)(null);g.current===null&&y&&(g.current=y);let D=(0,o.useMemo)(()=>{let T=g.current?`lang=${g.current}`:"";return u==="config"?`${q}/ui/config?tab=config${T?`&${T}`:""}`:u?`${w.replace(/\/$/,"")}/?tab=${u}${T?`&${T}`:""}`:T?`${w}${w.endsWith("/")?"":"/"}?${T}`:w},[w,u]);return(0,o.useEffect)(()=>{let T=h.current&&h.current.contentWindow;T&&y&&T.postMessage({source:"memory-eternal",type:"locale",lang:y},"*")},[y]),(0,o.useEffect)(()=>{let T=k=>{k.key==="Escape"&&i()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:i,children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsx)("div",{className:"me-modal"+(p?" me-modal-full":""),onClick:T=>T.stopPropagation(),children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[(0,e.jsxs)("div",{style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4,padding:"4px 6px",background:"var(--dsw-alias-bg-overlay, rgba(17,24,39,0.45))",borderRadius:8,backdropFilter:"blur(4px)"},children:[(0,e.jsx)("button",{type:"button",onClick:()=>l(T=>!T),"aria-label":t(p?"exitFullscreen":"enterFullscreen"),title:t(p?"exitFullscreen":"enterFullscreen"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:14,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:p?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:i,"aria-label":t("close"),title:t("close"),style:{width:26,height:26,borderRadius:6,border:"1px solid rgba(255,255,255,0.18)",background:"rgba(255,255,255,0.08)",color:"#fff",cursor:"pointer",fontSize:16,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),(0,e.jsx)("iframe",{ref:h,src:D,title:"memory-eternal",allow:"clipboard-write; clipboard-read",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Sa(){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 nn({t,inModal:n,onClose:i,onFull:u,full:p}){let[l,h]=(0,o.useState)(null),[w,x]=(0,o.useState)([]),[A,S]=(0,o.useState)(!0),[y,g]=(0,o.useState)(null),[D,T]=(0,o.useState)(""),[k,L]=(0,o.useState)("all"),[I,j]=(0,o.useState)(""),[J,ne]=(0,o.useState)("all"),[H,ye]=(0,o.useState)("all"),[$,Z]=(0,o.useState)(()=>{try{let v=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),O={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(v&&O[v])return O[v]}catch{}return"cards"}),[be,W]=(0,o.useState)(()=>new Set([$])),b=(0,o.useCallback)(v=>{W(O=>O.has(v)?O:new Set(O).add(v)),Z(v)},[]),[f,E]=(0,o.useState)("recent"),[K,_]=(0,o.useState)(null),B=(0,o.useRef)(null),te=(0,o.useRef)(null),[Q,le]=(0,o.useState)(!1),[tt,at]=(0,o.useState)(null),[Be,Ee]=(0,o.useState)(!1),[he,xe]=(0,o.useState)(!1),[me,Ne]=(0,o.useState)(!0),[$e,ze]=(0,o.useState)(null),[Fe,nt]=(0,o.useState)(0),Ye=(0,o.useCallback)(()=>nt(v=>v+1),[]),re=(0,o.useRef)(null),[ue,d]=(0,o.useState)(0),[R,P]=(0,o.useState)(!1),r=(0,o.useRef)(null),s=(0,o.useRef)(null),M=(0,o.useCallback)(async(v=k,O=I,X=H,Se={})=>{let ve=Se.append===!0;try{ve?P(!0):(S(!0),T(""));let ce=new URLSearchParams;v&&v!=="all"&&ce.set("kind",v),O.trim()&&ce.set("q",O.trim()),ce.set("status",X||"all"),ce.set("limit",String(qa)),ce.set("offset",String(Se.offset||0)),f==="title"&&ce.set("sort","title");let ot=await(await fetch(`${q}/cards?${ce.toString()}`)).json();if(ot.ok){let Qe=ot.cards||[];x(Re=>ve?[...Re,...Qe.filter(qe=>!Re.some(Tt=>Tt.path===qe.path))]:Qe),d(Number(ot.total)||Qe.length)}}catch(ce){T(String(ce&&ce.message?ce.message:ce))}finally{ve?P(!1):S(!1)}},[k,I,H,f]),Y=(0,o.useCallback)(async()=>{try{let[v,O]=await Promise.all([fetch(`${q}/overview`).then(X=>X.json()),fetch(`${q}/capture-log`).then(X=>X.json()).catch(()=>null)]);v.ok&&h(v),g(O&&O.ok&&O.available&&O.health||null)}catch(v){T(String(v&&v.message?v.message:v))}finally{S(!1)}},[]),de=async v=>{try{let X=await(await fetch(`${q}/delete?path=${encodeURIComponent(v)}`)).json();X.ok?(_({ok:!0,msg:t("deleted")}),await Y(),Ye()):_({ok:!1,msg:X.error||t("deleteFail")})}catch{_({ok:!1,msg:t("deleteFail")})}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>_(null),2e3)};(0,o.useEffect)(()=>(Y(),()=>{re.current&&clearTimeout(re.current)}),[Y]);let Ce=v=>{j(v),re.current&&clearTimeout(re.current),re.current=setTimeout(()=>M(k,v,H),280)},a=v=>{L(v),M(v,I,H)};(0,o.useEffect)(()=>{$==="cards"&&M(k,I,H)},[H,$,Fe,f]),(0,o.useEffect)(()=>{if($!=="cards"||A||R||w.length>=ue)return;let v=r.current,O=s.current;if(!v)return;let X=new IntersectionObserver(Se=>{Se[0]&&Se[0].isIntersecting&&M(k,I,H,{append:!0,offset:w.length})},{root:O||null,rootMargin:"400px"});return X.observe(v),()=>X.disconnect()},[$,w,ue,A,R,k,I,H,M]);let ct=async v=>{try{let X=await(await fetch(`${q}/card?path=${encodeURIComponent(v.path||v.id)}`)).json();X.ok&&at({path:X.path,title:v.title,text:X.text})}catch(O){T(String(O&&O.message?O.message:O))}},vt=async(v,O)=>{le(!0);try{let X=await fetch(`${q}/export`);if(!X.ok)throw new Error("HTTP "+X.status);let Se=await X.json();if(!Se.ok)throw new Error(Se.error||"export failed");let ve,ce,Ve;v==="json"?(ce="memory-vault.json",Ve="application/json",ve=JSON.stringify(Se.cards.map(Re=>({path:Re.path,title:Re.title,kind:Re.kind,text:Re.text})),null,2)):(ce="memory-vault.md",Ve="text/markdown;charset=utf-8",ve=Se.cards.map(Re=>Re.text.trim()).filter(Boolean).join(`
299
299
 
300
300
  ---
301
301
 
302
- `));let Ke=new Blob([me],{type:he}),$e=await Ma(Ke,ge,!1);if(!$e.ok){H({ok:!1,msg:t("exportFail")}),we(!1);return}H({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+$e.name})}catch(X){H({ok:!1,msg:t("exportFail")+" \xB7 "+(X.message||"")})}finally{we(!1)}_.current&&clearTimeout(_.current),_.current=setTimeout(()=>H(null),2600)},dt=async f=>{let P=f.target.files&&f.target.files[0];if(f.target.value="",!!P){try{let X=await P.text(),me=await(await fetch(`${U}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:X})).json();me.ok?(await V(),H({ok:!0,msg:t("importedVault")+"\uFF1A"+(me.imported||0)+(me.skipped?t("importedSkipped")+me.skipped:"")})):H({ok:!1,msg:me.error||t("importFail")})}catch{H({ok:!1,msg:t("importFail")})}_.current&&clearTimeout(_.current),_.current=setTimeout(()=>H(null),2400)}},ct=(0,n.useMemo)(()=>{let f=k.slice();return oe!=="all"&&(f=f.filter(P=>ot(P.submittedBy)===oe)),W!=="all"&&(f=f.filter(P=>(P.status||"approved")===W)),R==="title"?f.sort((P,X)=>String(P.title||"").localeCompare(String(X.title||""))):R==="hot"?f.sort((P,X)=>(X.weight||X.links||0)-(P.weight||P.links||0)):f.sort((P,X)=>new Date(X.updated||0).getTime()-new Date(P.updated||0).getTime()),f},[k,R,oe,W]),pt=(0,n.useMemo)(()=>[...new Set(k.map(f=>ot(f.submittedBy)))],[k]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:De}),Q&&(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 "+(Q.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Q.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Q.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:Q.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)($t,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),y&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:y,"aria-label":t(u?"exitFull":"fullscreen"),children:u?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:r,"aria-label":t("close"),children:"\u2715"})]}),b&&b.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[b.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:b.since?nt(new Date(b.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${fe?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ie(f=>!f),"aria-label":t(fe?"collapse":"expand"),title:t(fe?"collapse":"expand"),children:fe?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${T==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]}),(0,e.jsxs)("button",{type:"button",className:"mc-railbtn",onClick:()=>ke(!0),title:t("fbNav"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F41E}"}),fe&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("fbNav")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:i,children:[T==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(tt,{label:t("total"),value:o?o.total:"\u2014"}),(0,e.jsx)(tt,{label:t("recent"),value:o?o.recent:"\u2014"}),(0,e.jsx)(tt,{label:t("tags"),value:o?o.tags:"\u2014"}),(0,e.jsx)(tt,{label:t("pending"),value:o?.status?.pending??0}),(0,e.jsx)(tt,{label:t("rejected"),value:o?.status?.rejected??0}),(0,e.jsx)(tt,{label:t("cardCount"),value:o?o.byKind?.knowledge??0:"\u2014"})]}),T==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:M,onChange:f=>ze(f.target.value)}),(0,e.jsx)("input",{ref:ne,type:"file",accept:".json,application/json",style:{display:"none"},onChange:dt}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ne.current&&ne.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>pe({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:ae,onClick:()=>it("md"),children:t(ae?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:ae,onClick:()=>it("json"),children:t(ae?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>V(),children:t("refresh")})]}),T==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[wt.map(f=>(0,e.jsx)("button",{type:"button",className:`mc-chip${w===f?" active":""}`,onClick:()=>a(f),children:t(f==="all"?"all":Fe[f])},f)),(0,e.jsxs)("select",{value:oe,onChange:f=>te(f.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Ot(pt).map(f=>(0,e.jsx)("option",{value:f,children:f},f))]}),(0,e.jsxs)("select",{value:W,onChange:f=>Z(f.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(f=>(0,e.jsx)("button",{type:"button",className:`mc-chip${R===f.key?" active":""}`,onClick:()=>Y(f.key),children:f.label},f.key))]}),A&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",A]}),(0,e.jsx)("div",{style:{display:T==="cards"?"contents":"none"},children:I?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):A?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",A," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>V(),children:t("retry")})]}):k.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:ct.map(f=>(0,e.jsx)(ba,{card:f,t,query:M.trim(),onOpen:Ge,onDelete:se},f.path))}),k.length<K&&(0,e.jsx)("div",{ref:s,style:{height:1}}),ye&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",k.length," / ",K,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:T==="graph"?"flex":"none",flex:1,minHeight:0},children:z.has("graph")&&(0,e.jsx)(wa,{t,onOpen:Ge,all:Me,onAllChange:Ae,onMutate:F,active:T==="graph",visible:T==="graph"})}),(0,e.jsx)("div",{style:{display:T==="config"?"contents":"none"},children:z.has("config")&&(0,e.jsx)(Wt,{t,onReload:()=>V(),version:be})}),(0,e.jsx)("div",{style:{display:T==="stats"?"contents":"none"},children:z.has("stats")&&(0,e.jsx)(ya,{t,tab:"stats",onReload:()=>V(),version:be})}),(0,e.jsx)("div",{style:{display:T==="audit"?"contents":"none"},children:z.has("audit")&&(0,e.jsx)(ga,{t,onReload:()=>V(),version:be})}),(0,e.jsx)("div",{style:{display:T==="optimize"?"contents":"none"},children:z.has("optimize")&&(0,e.jsx)(fa,{t,onReload:()=>V(),version:be})}),Be&&(0,e.jsx)(xa,{t,onClose:()=>ke(!1)}),Ue&&(0,e.jsx)(va,{t,card:Ue,query:M.trim(),onClose:()=>Te(null),onDelete:f=>{Te(null),se(f)},onFeedback:f=>{let P=Ue.path;fetch(`${U}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:M.trim(),path:P,useful:f})}).then(()=>H({ok:!0,msg:t(f?"fbUseful":"fbIrr")})).catch(()=>{}),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>H(null),2e3)}}),(0,e.jsx)(ha,{t,newCard:Oe,setNewCard:pe,onCreated:()=>{V(),F(),H({ok:!0,msg:t("created")}),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>H(null),2e3)}})]})]})]})}var tt=({label:t,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:t})]});function Wt({t,onReload:l,version:r,compact:y}){let[u,o]=(0,n.useState)(null),[v,k]=(0,n.useState)(0),[N,I]=(0,n.useState)(null),[h,b]=(0,n.useState)(null),[m,A]=(0,n.useState)(!1),[C,w]=(0,n.useState)(null),[D,M]=(0,n.useState)(null),[j,oe]=(0,n.useState)(""),[te,W]=(0,n.useState)(""),[Z,T]=(0,n.useState)(""),[ve,z]=(0,n.useState)(""),[ie,g]=(0,n.useState)(null),R=(0,n.useRef)(null),Y=(d,F=!0)=>{R.current&&clearTimeout(R.current),g({msg:d,ok:F}),R.current=setTimeout(()=>g(null),1900)},Q=(d,F)=>Object.keys(F).reduce((O,K)=>O.split("{"+K+"}").join(F[K]),t(d)),H=(0,n.useCallback)(async()=>{try{let[d,F,O]=await Promise.all([fetch(`${U}/config`).then(K=>K.json()).catch(()=>null),fetch(`${U}/setup-status`).then(K=>K.json()).catch(()=>null),fetch(`${U}/budget`).then(K=>K.json()).catch(()=>null)]);d&&d.ok?(o(d),k(d.revision??0),I(d.schema??null),b({...d.config??{}}),w(d.dsh??null),A(d.writable===!1),oe("")):O&&O.ok?(b({...O}),A(!0),oe(t("configNeedsDsh"))):oe(t("adminLoadFail")),F&&F.ok&&M(F),T("")}catch{oe(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{H()},[r,H]);let _=(d,F)=>b(O=>({...O??{},[d]:F})),ne=d=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[d]||d,ae=async()=>{if(h){if(m){Y(t("editInSetting"),!1);return}W("save");try{let d={...h};Array.isArray(d.vaultProfiles)&&(d.vaultProfiles=d.vaultProfiles.filter(K=>K&&(String(K.name||"").trim()||String(K.path||"").trim())));let F=await fetch(`${U}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:d,expectedRevision:v})}),O=await F.json();if(O&&O.ok)T(t("savedOk")+(O.note?` \xB7 ${t("restartHint")}`:"")),Y(t("savedOk")),await H();else{let K=F.status===409?t("conflictRefresh"):O?.error||t("saveFail");oe(K),Y(K,!1)}}catch{oe(t("saveFail")),Y(t("saveFail"),!1)}finally{W("")}}},we=()=>{b({...u?.config??{}}),T("")},Ue={env:"vaultSrcEnv",profile:"vaultSrcProfile",workspace:"vaultSrcWorkspace",vaultDir:"vaultSrcVaultDir",default:"vaultSrcDefault"},Te=d=>Array.isArray(d?.vaultProfiles)?d.vaultProfiles:[],Me=(d,F,O)=>b(K=>{let G=Te(K).map(ue=>({...ue||{}})),ye={...G[d]||{}};return F==="match"?String(O).trim()?ye.match={...ye.match||{},workspace:O}:delete ye.match:ye[F]=O,G[d]=ye,{...K??{},vaultProfiles:G}}),Ae=()=>b(d=>({...d??{},vaultProfiles:[...Te(d),{name:"",path:""}]})),Be=d=>b(F=>({...F??{},vaultProfiles:Te(F).filter((O,K)=>K!==d)})),ke={padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:12,minWidth:0},fe={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},Ie=async d=>{let F=fe[d];F&&b(O=>({...O??{},...F}))},Oe=async(d,F)=>{W(d+F);try{let K=await(await fetch(`${U}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:d,action:F})})).json();K&&K.ok?Y(Q(F==="install"?"mcpInstalled":"mcpUninstalled",{agent:d})):Y(Q("mcpActionFail",{agent:d,error:K?.error||""}),!1);try{let G=await fetch(`${U}/setup-status`).then(ye=>ye.json());G&&G.ok&&M(G)}catch{}}catch{Y(t("mergeFail"),!1)}finally{W("")}},pe=({k:d,label:F,type:O="text",step:K,min:G,max:ye})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:F||d}),(0,e.jsx)("input",{type:O,step:K,min:G,max:ye,value:h?h[d]??"":"",onChange:ue=>_(d,O==="number"?Number(ue.target.value):ue.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),be=({k:d,label:F})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(h&&h[d]),onChange:O=>_(d,O.target.checked)}),(0,e.jsx)("span",{children:F||d})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:y?"0 0 auto":1,minHeight:0,maxHeight:y?"52vh":void 0},children:[(0,e.jsx)("style",{children:De}),ie&&(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 "+(ie.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ie.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ie.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ie.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[j&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",j]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:H,children:["\u21BB ",t("retry")]})]}),m&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),Z&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",Z]}),u&&(u.version||u.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:t("dshHostLabel")}),u.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",u.version]}),u.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",u.dsh.vaultDir]})]}),D&&D.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:D.agents.map(d=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:d.isDsh?t("dshHostLabel"):d.name}),d.isDsh&&d.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",d.version]}),!d.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),d.installed&&d.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),d.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),d.mcpConfigured===!0&&d.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),d.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",d.recallTool?t("enabled"):t("disabled"),")"]})]}),d.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",d.hook]}),!d.isDsh&&d.installed&&d.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!te,onClick:()=>Oe(d.name,"install"),children:t("installMcp")}),!d.isDsh&&d.installed&&d.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!te,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Oe(d.name,"uninstall")},children:t("uninstallMcp")})]},d.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),ve&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:ve})})]}),h?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(d=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Ie(d),disabled:!!te,children:[d==="A"?"\u{1F7E2} ":d==="B"?"\u{1F4B0} ":"\u2B50 ",fe[d].label]},d))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(be,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(be,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(pe,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(pe,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(pe,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(pe,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(pe,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(be,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #06b6d4"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5C2}\uFE0F ",t("vaultMulti")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("vaultMultiHint")})]}),(0,e.jsxs)("div",{style:{fontSize:11.5,opacity:.85,marginBottom:8,lineHeight:1.7},children:[t("vaultNow"),"\uFF1A",(0,e.jsx)("code",{children:C?.vaultDir||"\u2014"}),C?.vaultName?`\uFF08${C.vaultName}\uFF09`:""," \xB7 ",t("vaultSource"),"\uFF1A",t(Ue[C?.vaultSource]||"vaultSrcDefault"),C?.workspace?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),t("vaultWorkspace"),"\uFF1A",(0,e.jsx)("code",{children:C.workspace})]}):null]}),Te(h).map((d,F)=>(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.6fr 1.5fr auto",gap:6,marginBottom:6},children:[(0,e.jsx)("input",{value:d.name||"",placeholder:t("vaultNamePh"),onChange:O=>Me(F,"name",O.target.value),style:ke,disabled:m}),(0,e.jsx)("input",{value:d.path||"",placeholder:t("vaultPathPh"),onChange:O=>Me(F,"path",O.target.value),style:ke,disabled:m}),(0,e.jsx)("input",{value:d.match&&d.match.workspace||"",placeholder:t("vaultMatchPh"),onChange:O=>Me(F,"match",O.target.value),style:ke,disabled:m}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Be(F),disabled:m,title:t("delete"),children:"\u2715"})]},F)),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginTop:4},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Ae,disabled:m,children:["\uFF0B ",t("vaultAdd")]}),(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("vaultActive")}),(0,e.jsxs)("select",{value:h.activeVault||"",onChange:d=>_("activeVault",d.target.value),disabled:m,style:ke,children:[(0,e.jsx)("option",{value:"",children:t("vaultActiveNone")}),Te(h).filter(d=>d&&d.name).map(d=>(0,e.jsx)("option",{value:d.name,children:d.name},d.name))]})]})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(be,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(be,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(pe,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(pe,{k:"recallMinScore",label:t("recallMinScore"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:h.auditMode??"all",onChange:d=>_("auditMode",d.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(Pt,{label:t("auditExemptAgents"),value:h.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(D?.agents||[]).filter(d=>!d.isDsh).map(d=>({value:d.name,label:d.name}))],onChange:d=>_("auditExemptAgents",d)}),(0,e.jsx)(Pt,{label:t("auditExemptKinds"),value:h.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...wt.filter(d=>d!=="all").map(d=>({value:d,label:t(Fe[d])}))],onChange:d=>_("auditExemptKinds",d)}),(0,e.jsx)(pe,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(be,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:h.autoWebMode??"init",onChange:d=>_("autoWebMode",d.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(pe,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(pe,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(pe,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(be,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(be,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:we,disabled:!!te,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:ae,disabled:!!te||te==="save"||m,children:te==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function ga({t,onReload:l,version:r}){let[y,u]=(0,n.useState)([]),[o,v]=(0,n.useState)([]),[k,N]=(0,n.useState)("all"),[I,h]=(0,n.useState)("all"),[b,m]=(0,n.useState)(""),[A,C]=(0,n.useState)(new Set),[w,D]=(0,n.useState)(""),[M,j]=(0,n.useState)("pending"),oe=[...new Set([...y,...o].map(z=>z.submittedBy).filter(Boolean))],te=(0,n.useCallback)(async()=>{try{let z=await fetch(`${U}/audit/list`).then(ie=>ie.json());z.ok&&(u(z.pending||[]),v(z.rejected||[]),C(new Set))}catch{}},[]);(0,n.useEffect)(()=>{te()},[r,te]);let W=(M==="pending"?y:o).filter(z=>{if(k!=="all"&&z.kind!==k||I!=="all"&&ot(z.submittedBy)!==I)return!1;if(b){let ie=(z.created||"").slice(0,10);if(ie&&ie!==b)return!1}return!0}),Z=z=>C(ie=>{let g=new Set(ie);return g.has(z)?g.delete(z):g.add(z),g}),T=async(z,ie)=>{D("apply");try{for(let g of ie||[...A])await fetch(`${U}/${z==="approved"?"audit/approve":z==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${z==="delete"?"&permanent=0":""}`);await te(),l&&l()}catch{}finally{D("")}},ve=[...A];return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:k,onChange:z=>N(z.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),wt.filter(z=>z!=="all").map(z=>(0,e.jsx)("option",{value:z,children:t(Fe[z])},z))]}),(0,e.jsxs)("select",{value:I,onChange:z=>h(z.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),Ot(oe).map(z=>(0,e.jsx)("option",{value:z,children:z},z))]}),(0,e.jsx)("input",{type:"date",value:b,onChange:z=>m(z.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${M==="pending"?" me-on":""}`,onClick:()=>j("pending"),children:[t("pending"),"\uFF08",y.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${M==="rejected"?" me-on":""}`,onClick:()=>j("rejected"),children:[t("rejected"),"\uFF08",o.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:W.length>0&&ve.length===W.length,onChange:z=>{z.target.checked?C(new Set(W.map(ie=>ie.path))):C(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!ve.length||!!w,onClick:()=>T("approved"),children:["\u2713 ",t(M==="rejected"?"restore":"approve")]}),M==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!ve.length||!!w,onClick:()=>T("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!ve.length||!!w,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&T("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),W.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:W.map(z=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:A.has(z.path),onChange:()=>Z(z.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[z.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:ot(z.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:z.created?z.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:z.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:z.severity==="high"?"#f87171":"#9ca3af"},children:z.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.reason||"-"}),M==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>T("approved",[z.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>T("rejected",[z.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>T("approved",[z.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&T("delete",[z.path])},children:"\u{1F5D1}"})]})]},z.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function fa({t,onReload:l,version:r}){let[y,u]=(0,n.useState)([]),[o,v]=(0,n.useState)(""),k=(0,n.useCallback)(async()=>{try{let I=await fetch(`${U}/recycle/list`).then(h=>h.json());I.ok&&u(I.items||[])}catch{}},[]);(0,n.useEffect)(()=>{k()},[r,k]);let N=async(I,h)=>{v(I+h);try{I==="restore"?await fetch(`${U}/recycle/restore?path=${encodeURIComponent(h)}`):I==="purge"&&await fetch(`${U}/recycle/purge?path=${encodeURIComponent(h)}`),await k(),l&&l()}catch{}finally{v("")}};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:De}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!o,onClick:async()=>{v("purgeAll");try{await fetch(`${U}/recycle/purge-expired?days=0`),await k()}catch{}finally{v("")}},children:t("emptyRecycle")})]}),y.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:y.map(I=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[I.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(I.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!o,onClick:()=>N("restore",I.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!o,onClick:()=>{window.confirm(t("purgeConfirm"))&&N("purge",I.path)},children:t("purge")})]},I.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var ba=({card:t,t:l,onOpen:r,query:y,onDelete:u})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>r(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[t.kind]||_e.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:mt[t.kind]||"\u{1F4CE}"}),y?Et(t.title,y):t.title,Na(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",l("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",l("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",l("statusApproved")]})]}),(0,e.jsx)("p",{children:y?Et(t.summary||"",y):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(o=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",o]},o))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[mt[t.kind]||"\u{1F4CE}"," ",l(Fe[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",ot(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",nt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:o=>{o.stopPropagation(),window.confirm(l("deleteConfirm"))&&u&&u(t.path)},children:"\u{1F5D1}"})]})]});function ya({t,tab:l,onReload:r,version:y}){let[u,o]=(0,n.useState)(null),[v,k]=(0,n.useState)(""),[N,I]=(0,n.useState)(null),[h,b]=(0,n.useState)(null),[m,A]=(0,n.useState)(null),[C,w]=(0,n.useState)([]),[D,M]=(0,n.useState)(""),[j,oe]=(0,n.useState)(!1),te=(0,n.useCallback)(async()=>{if(!(!N||!N.merge||!N.merge.length)&&window.confirm(t("mergeAllConfirm"))){M("merge");try{let g={},R=ne=>g[ne]===void 0?ne:g[ne]=R(g[ne]),Y=(ne,ae)=>{g[R(ne)]=R(ae)},Q=new Set;for(let ne of N.merge)Q.add(ne.a.path),Q.add(ne.b.path),Y(ne.a.path,ne.b.path);let H={};for(let ne of Q){let ae=R(ne);(H[ae]=H[ae]||[]).push(ne)}let _=0;for(let ne of Object.values(H)){if(ne.length<2)continue;(await fetch(`${U}/merge?paths=${encodeURIComponent(ne.join(","))}`).then(we=>we.json())).ok&&_++}await W(),r&&r()}catch{}M("")}},[N,W,r,t]);async function W(){try{let g=await Promise.all([fetch(`${U}/stats`),fetch(`${U}/budget`),fetch(`${U}/capture-log`),fetch(`${U}/cards?status=all&limit=30&agent=${st}`)]),[R,Y,Q,H]=await Promise.all(g.map(_=>_.json()));R&&R.ok&&o(R),Y&&Y.ok&&b(Y),Q&&Q.ok&&A(Q),H&&H.ok&&w(H.cards||[]),k(!R||!R.ok?t("adminLoadFail"):"")}catch{k(t("adminLoadFail"))}}let Z=(0,n.useCallback)(async()=>{M("scan");try{let g=await fetch(`${U}/optimize`).then(R=>R.json());g.ok&&I(g)}catch{k(t("adminLoadFail"))}finally{M("")}},[t]);(0,n.useEffect)(()=>{W()},[y]);let T=async(g,R)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${U}/merge?paths=${encodeURIComponent(g+","+R)}`).then(Q=>Q.json())).ok&&(await W(),r&&r())}catch{}},ve=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${U}/delete?path=${encodeURIComponent(g)}`).then(Y=>Y.json())).ok&&(await W(),r&&r())}catch{}},z=["project","knowledge","content","prompt","business","tool","mistake"],ie=({title:g,kind:R,updated:Y,path:Q})=>(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:at.colors[R]||"#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:nt(Y)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ve(Q),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:De}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[v&&(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 ",v]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:W,children:["\u21BB ",t("retry")]})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",t("captureLog")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("captureLogHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>W(),children:["\u21BB ",t("refresh")]})]}),m?m.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(m.entries||[]).length===0?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogEmpty")}):(0,e.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,e.jsx)("tbody",{children:(m.entries||[]).map((g,R)=>{let Y=ra[g.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:nt(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:Y[1],fontWeight:600},children:[Y[0]," ",g.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:g.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:g.preview||"",children:g.preview||""})]},R)})})})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("loading")})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",t("captureAgentCards"),"\uFF08",C.length,"\uFF09"]}),C.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:C.map(g=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[g.kind]||_e.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),u&&(0,e.jsxs)(e.Fragment,{children:[u.trend&&u.trend.length>0&&(()=>{let g=u.trend,R=Math.max(...g.map(_=>_.count),1),Y=260,Q=50,H=Y/g.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:Y,height:Q,style:{display:"block",width:"100%",height:50},children:g.map((_,ne)=>{let ae=Math.round(_.count/R*(Q-4));return(0,e.jsx)("rect",{x:ne*H+1,y:Q-ae,width:Math.max(H-2,2),height:ae,rx:1.5,fill:_.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:_.count>0?.85:.35},_.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:u.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:z.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:at.colors[g]||"#666"}}),t(Fe[g]),": ",u.byKind?.[g]||0]},g))})]}),h&&(h.budgetChars||h.recallLimit||h.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:h.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:h.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",h.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",u.todayCards?.length||0,"\uFF09"]}),u.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:u.todayCards.map(g=>(0,e.jsx)(ie,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!D,onClick:Z,children:D==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),N&&N.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!D,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){M("oneclick");try{let g=JSON.stringify({cleanupStale:j}),Y=await(await fetch(`${U}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();Y&&Y.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${Y.plan.merged} ${t("optimizedMerged")}${j?` \xB7 ${Y.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await W(),r&&r(),I(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{M("")}}},children:D==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),N&&N.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:j,onChange:g=>oe(g.target.checked)}),t("oneClickAlsoStale")]})]}),!N&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),N&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),N.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!D,onClick:te,children:t(D==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),N.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:N.merge.map((g,R)=>(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:()=>T(g.a.path,g.b.path),children:t("mergeNow")})]},R))}):(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",N.stale?.length||0,"\uFF09"]}),N.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!D,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;M("clean");let g=0;for(let R of N.stale)try{await fetch(`${U}/delete?path=${encodeURIComponent(R.path)}`),g++}catch{}M(""),notify(`${g} ${t("deletedStale")}`),await W(),r&&r()},children:t("cleanStale")})}),N.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:N.stale.map(g=>(0,e.jsx)(ie,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var vt=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function ha({t,newCard:l,setNewCard:r,onCreated:y}){if(!l)return null;let u=vt.find(b=>b.key===l.template),o=l.body||(u?t(u.bodyKey):""),v=l.kind||(u?u.kind:"knowledge"),k=l.tags||(u?t(u.tagKey):""),N=l._creating,I=b=>{let m=vt.find(A=>A.key===b);r(A=>({...A,template:b,kind:m?m.kind:A.kind,body:m?t(m.bodyKey):A.body,tags:m?t(m.tagKey):A.tags}))},h=async()=>{if(!(!l.title&&!o)){r(b=>({...b,_creating:!0}));try{(await fetch(`${U}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:v,tags:k.split(",").map(m=>m.trim()).filter(Boolean),body:o,source:"manual"})}).then(m=>m.json())).ok?(r(null),y&&y()):r(m=>({...m,_creating:!1}))}catch{r(m=>({...m,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>r(null),children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:b=>b.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>r(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[vt.map(b=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===b.key?" me-on":""}`,onClick:()=>I(b.key),children:t(b.label)},b.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>r(b=>({...b,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:v,onChange:b=>r(m=>({...m,kind:b.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(b=>(0,e.jsx)("option",{value:b,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:b},b))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:b=>r(m=>({...m,title:b.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:k,onChange:b=>r(m=>({...m,tags:b.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:o,onChange:b=>r(m=>({...m,body:b.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:N,onClick:h,children:t(N?"exporting":"createCard")})})]})]})]})}function xa({t,onClose:l}){let[r,y]=(0,n.useState)(""),[u,o]=(0,n.useState)(""),[v,k]=(0,n.useState)(""),[N,I]=(0,n.useState)(!0),[h,b]=(0,n.useState)(!1),[m,A]=(0,n.useState)(""),C=(0,n.useRef)(null),w=Z=>{A(Z),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>A(""),2400)};(0,n.useEffect)(()=>{let Z=!0;return fetch(U+"/diagnostics").then(T=>T.json()).then(T=>{Z&&(T&&T.ok?(o(String(T.diagnostics||"")),k(String(T.version||""))):b(!0))}).catch(()=>{Z&&b(!0)}).finally(()=>{Z&&I(!1)}),()=>{Z=!1}},[]),(0,n.useEffect)(()=>{let Z=T=>{T.key==="Escape"&&l()};return window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z),C.current&&clearTimeout(C.current)}},[l]);let D=(()=>{try{return String(navigator.language||"").toLowerCase().startsWith("en")?"en":"zh"}catch{return"zh"}})(),M=()=>{let Z=r.trim().split(`
303
- `)[0]||"",T=At({title:"[Bug] "+(Z.slice(0,60)||"memory-eternal \u95EE\u9898"),body:Bt({description:r,diagnostics:u,version:v})});try{window.open(T,"_blank","noopener")}catch{w(t("fbCopyFail"))}},j=async()=>{try{await navigator.clipboard.writeText(u),w(t("fbCopiedDiag"))}catch{w(t("fbCopyFail"))}},oe=async()=>{let Z=Rt({lang:D,description:r,diagnostics:u});try{await navigator.clipboard.writeText(Z),w(t("fbCopiedPrompt"))}catch{w(t("fbCopyFail"))}},te={width:"100%",resize:"vertical",padding:"8px 10px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:13},W={margin:0,maxHeight:170,overflow:"auto",fontSize:11.5,lineHeight:1.55,padding:"8px 10px",borderRadius:10,background:"var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.08))",whiteSpace:"pre-wrap"};return(0,e.jsxs)("div",{className:"me-overlay",onClick:l,children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720},onClick:Z=>Z.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:["\u{1F41E} ",t("fbTitle")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:l,children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsx)("div",{style:{fontSize:12,opacity:.72,lineHeight:1.6},children:t("fbWhy")}),(0,e.jsx)("textarea",{value:r,onChange:Z=>y(Z.target.value),placeholder:t("fbDesc"),rows:5,style:te}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("fbDiag")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:j,disabled:!u,children:t("fbCopyDiag")})]}),(0,e.jsx)("pre",{style:W,children:N?t("fbLoading"):h?t("fbDiagFail"):u})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>{if(!r.trim()){w(t("fbNeedDesc"));return}M()},style:{borderColor:"var(--dsw-alias-brand-primary, #3b82f6)",color:"var(--dsw-alias-brand-primary, #3b82f6)",fontWeight:600},children:["\u{1F680} ",t("fbOpenIssue")]}),(0,e.jsx)("span",{style:{opacity:.5,fontSize:12},children:t("fbOr")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:oe,children:["\u{1F916} ",t("fbCopyPrompt")]})]}),m&&(0,e.jsx)("div",{style:{fontSize:12,color:"var(--dsw-alias-brand-primary, #3b82f6)"},children:m})]})]})]})}function va({t,card:l,query:r,onClose:y,onDelete:u,onFeedback:o}){(0,n.useEffect)(()=>{let D=M=>{M.key==="Escape"&&y()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[y]);let{meta:v,body:k}=(0,n.useMemo)(()=>ht(l.text||""),[l.text]),N=D=>{let M=v.find(([j])=>String(j).toLowerCase()===D);return M?M[1]:""},I=Dt(N("tags")),h=N("kind")||"knowledge",b=(N("status")||"approved").toLowerCase(),m=_e[h]||"#6B7280",A=(k||"").length>460,[C,w]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:y,children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("div",{className:"me-dialog",onClick:D=>D.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:[(0,e.jsx)("span",{style:{marginRight:6},children:mt[h]||"\u{1F4CE}"}),l.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[r&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>o&&o(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>o&&o(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),A&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":C,onClick:()=>w(D=>!D),children:t(C?"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:y,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:m,borderColor:m+"59",background:m+"1a"},children:[mt[h]||"\u{1F4CE}"," ",t(Fe[h]||"kindKnowledge")]}),(0,e.jsxs)("span",{className:"md-chip "+(b==="approved"?"md-chip-st-ok":b==="pending"?"md-chip-st-warn":"md-chip-st-bad"),children:[b==="approved"?"\u2705":b==="pending"?"\u23F3":"\u26D4"," ",t(b==="approved"?"statusApproved":b==="pending"?"statusPending":"statusRejected")]}),I.slice(0,8).map(D=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",D]},D)),!!N("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",nt(N("updated"))]}),!!N("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",N("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:C?{}:{maxHeight:300,overflow:"hidden"},onClick:C?void 0:D=>{D.stopPropagation(),w(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:Tt(k)}})}),!C&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:D=>{D.stopPropagation(),w(!0)},children:[t("expand")," \u2304"]})]})]})}function wa({t,onOpen:l,all:r,onAllChange:y,onMutate:u,active:o,visible:v}){let[k,N]=(0,n.useState)(null),[I,h]=(0,n.useState)(""),b=(0,n.useRef)(!1),m=(0,n.useRef)(0),A=(0,n.useRef)(t);A.current=t;let C=(0,n.useCallback)(async()=>{try{b.current=!1;let j=await(await fetch(`${U}/graph${r?"?all=1":""}`)).json();j.ok?(N(j),h(""),b.current=!0):(N(null),h(j.error||t("error")))}catch(M){h(String(M&&M.message?M.message:M))}},[r,t]);(0,n.useEffect)(()=>{if(!o||b.current)return;let M=!0;return fetch(`${U}/graph${r?"?all=1":""}`).then(j=>j.json()).then(j=>{M&&(j.ok?(N(j),h(""),b.current=!0):(N(null),h(j.error||t("error"))))}).catch(j=>{M&&h(String(j&&j.message?j.message:j))}),()=>{M=!1}},[r,t,o]),(0,n.useEffect)(()=>{v&&k&&m.current++},[v,k]);let w=(0,n.useCallback)(async M=>{try{let oe=await(await fetch(`${U}/delete?path=${encodeURIComponent(M)}`)).json();return oe&&oe.ok?(await C(),u&&u(),!0):!1}catch{return!1}},[C]),D=(0,n.useCallback)(async M=>{if(!M||M.length<2)return!1;try{let j=await fetch(`${U}/merge?paths=${encodeURIComponent(M.join(","))}`).then(oe=>oe.json());return j&&j.ok?(await C(),u&&u(),!0):!1}catch{return!1}},[C,u]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:De}),I&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",I]}),!k&&!I&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),k&&k.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),k&&k.nodes.length>0&&(0,e.jsx)(Ca,{nodes:k.nodes,edges:k.edges,onOpen:l,onDelete:w,onMerge:D,t,all:r,onAllChange:y,countLabel:`${k.nodes.length} ${t("nodes")} \xB7 ${ka(k.edges)} ${t("edges")}`,fitTrigger:m.current})]})}function ka(t){let l=new Set;for(let r of t||[])l.add([r.source,r.target].sort().join("|"));return l.size}var at={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 Ca({nodes:t,edges:l,onOpen:r,onDelete:y,onMerge:u,t:o,countLabel:v,all:k,onAllChange:N,fitTrigger:I}){let h=(0,n.useRef)(null),b=(0,n.useRef)(null),m=(0,n.useRef)(null),A=(0,n.useRef)(null),C=(0,n.useRef)(null),w=(0,n.useRef)(r);(0,n.useEffect)(()=>{w.current=r},[r]);let D=(0,n.useRef)(y);(0,n.useEffect)(()=>{D.current=y},[y]);let M=(0,n.useRef)(u);(0,n.useEffect)(()=>{M.current=u},[u]);let[j,oe]=(0,n.useState)(""),[te,W]=(0,n.useState)(null),Z=(0,n.useRef)("");(0,n.useEffect)(()=>{Z.current=j.trim().toLowerCase()},[j]),(0,n.useEffect)(()=>{let s=m.current;if(!s)return;let i=j.trim().toLowerCase();if(!i)return;let B=s.nodes.find(V=>(V.name||"").toLowerCase().includes(i));B&&(m.current.selectedId=B.id,W(B.id),s.panX=s.w/2-B.x*s.zoom,s.panY=s.h/2-B.y*s.zoom,s.render&&s.render())},[j]);let[T,ve]=(0,n.useState)("all"),[z,ie]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[R,Y]=(0,n.useState)(""),Q=(0,n.useRef)(""),[H,_]=(0,n.useState)(!1),ne=(0,n.useRef)(!1),[ae,we]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=T},[T]),(0,n.useEffect)(()=>{Q.current=R},[R]),(0,n.useEffect)(()=>{ne.current=H},[H]);let Ue=(0,n.useMemo)(()=>{let s=new Map;for(let i of t)for(let B of i.tags||[]){let V=String(B).trim();V&&s.set(V,(s.get(V)||0)+1)}return[...s.entries()].sort((i,B)=>B[1]-i[1]).slice(0,24).map(([i,B])=>({tag:i,n:B}))},[t]),Te=(()=>{let s=j.trim().toLowerCase();return!!s&&!t.some(i=>(i.title||i.name||"").toLowerCase().includes(s)||String(i.kind||"").toLowerCase().includes(s)||String(Fe[i.kind]||"").toLowerCase().includes(s))})();(0,n.useEffect)(()=>{let s=m.current;s&&s.wake&&s.wake()},[j]),(0,n.useEffect)(()=>{let s=m.current;s&&s.render&&s.render()},[T,R,H]);let Me=(0,n.useRef)(null),[Ae,Be]=(0,n.useState)([]),[ke,fe]=(0,n.useState)(null),[Ie,Oe]=(0,n.useState)(!1),[pe,be]=(0,n.useState)(null),[d,F]=(0,n.useState)(""),O=(0,n.useRef)(null),K=(0,n.useRef)(null),G=(s,i=!0)=>{O.current&&clearTimeout(O.current),be({msg:s,ok:i}),O.current=setTimeout(()=>be(null),1900)},ye=s=>{F(s),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>F(""),1600)};(0,n.useEffect)(()=>()=>{O.current&&clearTimeout(O.current),K.current&&clearTimeout(K.current)},[]);let ue=(0,n.useMemo)(()=>t.reduce((s,i)=>(s[i.id]=i,s),{}),[t]);return(0,n.useEffect)(()=>{let s=h.current;if(!s||t.length===0)return;let i=s.getContext("2d");if(!i)return;let B=Math.max(1,window.devicePixelRatio||1),V=()=>document.documentElement.getAttribute("data-theme")==="dark",se={};l.forEach(c=>{se[c.source]=(se[c.source]||0)+1,se[c.target]=(se[c.target]||0)+1});let ze=Math.max(1,...Object.values(se)),a={nodes:t.map(c=>({id:c.id,name:c.title||"",type:c.kind||"other",r:9+Math.min(10,(se[c.id]||0)/ze*8),x:0,y:0,vx:0,vy:0})),edges:l.map(c=>({sourceNodeId:c.source,targetNodeId:c.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:i,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((c,S)=>(c[S.id]=S,c),{}),a.nodes.forEach((c,S)=>{let x=S/a.nodes.length*Math.PI*2-Math.PI/2;c.x=Math.cos(x)*60,c.y=Math.sin(x)*60});let Ge=[...new Set(a.nodes.map(c=>c.type))];a.clustered=Ge.length>1,a.typeCenters={},Ge.forEach((c,S)=>{let x=S/Ge.length*Math.PI*2-Math.PI/2;a.typeCenters[c]={x:Math.cos(x)*160,y:Math.sin(x)*160}}),m.current=a;let it=0,dt=0,ct=()=>{let c=s.clientWidth,S=s.clientHeight;a.w=c,a.h=S,s.width=c*B,s.height=S*B,i.setTransform(B,0,0,B,0,0),(it===0||dt===0)&&c>0&&S>0&&a.tickCount>0&&requestAnimationFrame(()=>me()),it=c,dt=S};ct();let pt=new ResizeObserver(ct);pt.observe(s.parentElement);let f=(c,S)=>c&&c.length>S?c.slice(0,S)+"\u2026":c,P=(c,S,x,L)=>{if(i.beginPath(),L==="rect")i.rect(c-x,S-x*.75,x*2,x*1.5);else if(L==="diamond")i.moveTo(c,S-x),i.lineTo(c+x,S),i.lineTo(c,S+x),i.lineTo(c-x,S),i.closePath();else if(L==="hexagon"){for(let E=0;E<6;E++){let ee=Math.PI/3*E-Math.PI/2,q=c+x*Math.cos(ee),xe=S+x*Math.sin(ee);E===0?i.moveTo(q,xe):i.lineTo(q,xe)}i.closePath()}else i.arc(c,S,x,0,Math.PI*2)},X=new Map,Le=(c,S)=>{let x=c+"|"+Math.round(S),L=X.get(x);if(!L){let E=parseInt(c.slice(1,3),16),ee=parseInt(c.slice(3,5),16),q=parseInt(c.slice(5,7),16);L=i.createRadialGradient(-S*.3,-S*.3,0,0,0,S*1.2),L.addColorStop(0,"rgba("+Math.min(255,E+70)+","+Math.min(255,ee+70)+","+Math.min(255,q+70)+",0.95)"),L.addColorStop(1,c),X.set(x,L)}return L},me=()=>{if(!a.nodes.length)return;let c=1/0,S=-1/0,x=1/0,L=-1/0;a.nodes.forEach(Ce=>{c=Math.min(c,Ce.x),S=Math.max(S,Ce.x),x=Math.min(x,Ce.y),L=Math.max(L,Ce.y)});let E=20,ee=S-c+E*2,q=L-x+E*2,xe=Math.min(a.w/ee,a.h/q);a.zoom=Math.max(.35,Math.min(1.8,xe)),a.panX=a.w/2-(c+S)/2*a.zoom,a.panY=a.h/2-(x+L)/2*a.zoom};A.current=me;let ge=()=>{i.clearRect(0,0,a.w,a.h),a.searchTerm=Z.current,a.kindFilter=g.current,a.timeMode=ne.current,a.tagFilter=Q.current;let c=a.tagFilter,S=a.kindFilter,x=p=>String(p||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");i.save(),i.strokeStyle=V()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",i.lineWidth=.5;for(let p=0;p<a.w;p+=24)i.beginPath(),i.moveTo(p,0),i.lineTo(p,a.h),i.stroke();for(let p=0;p<a.h;p+=24)i.beginPath(),i.moveTo(0,p),i.lineTo(a.w,p),i.stroke();i.restore(),i.save(),i.translate(a.panX,a.panY),i.scale(a.zoom,a.zoom);let L={};a.nodes.forEach(p=>L[p.id]=p);let E=a.nodes.length>40,ee=E?1.5:.55,q=a.selectedId||a.hoverId,xe=new Map;a.edges.forEach(p=>{let $=L[p.sourceNodeId],J=L[p.targetNodeId];if(!$||!J)return;if(S!=="all"){let je=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,bt=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(je!==S&&bt!==S)return}if(c){let je=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(c),bt=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(c);if(!je&&!bt)return}let le=J.x-$.x,re=J.y-$.y,de=Math.sqrt(le*le+re*re)||1,ce=E?12:18,Ne=-re/de*ce,Re=le/de*ce,We=($.x+J.x)/2+Ne,qe=($.y+J.y)/2+Re,lt=at.colors[a.domainById[$.id]&&a.domainById[$.id].kind||"other"],rt=q&&(p.sourceNodeId===q||p.targetNodeId===q),gt=q?rt?.6:.08:E?.14:.24,Ee=parseInt(lt.slice(1,3),16),ft=parseInt(lt.slice(3,5),16),Pe=parseInt(lt.slice(5,7),16),Xe=rt?1.6+(p.weight||1):.8+(p.weight||1)*.5,He=Ee+","+ft+","+Pe+","+gt+","+Xe,Ve=xe.get(He);Ve||(Ve={path:new Path2D,stroke:"rgba("+Ee+","+ft+","+Pe+","+gt+")",width:Xe},xe.set(He,Ve)),Ve.path.moveTo($.x,$.y),Ve.path.quadraticCurveTo(We,qe,J.x,J.y)}),xe.forEach(p=>{i.strokeStyle=p.stroke,i.lineWidth=p.width,i.stroke(p.path)});let Ce=null;q&&(Ce=new Set,a.edges.forEach(p=>{p.sourceNodeId===q?Ce.add(p.targetNodeId):p.targetNodeId===q&&Ce.add(p.sourceNodeId)}));let Ye=[];if(a.nodes.forEach(p=>{let $=a.domainById[p.id]||{},J=$.kind||"other",le=a.timeMode?Sa($.updated):at.colors[J],re=at.shapes[J],de=a.selectedId===p.id,ce=a.hoverId===p.id,Ne=a.searchTerm||"",Re=!Ne||(p.name||"").toLowerCase().includes(Ne)||String(Fe[J]||"").toLowerCase().includes(Ne)||String(J).toLowerCase().includes(Ne),We=S==="all"||J===S,qe=!c||($.tags||[]).includes(c),lt=q&&p.id!==q&&!(Ce&&Ce.has(p.id))||Ne&&!Re||!We||!qe;i.save(),i.globalAlpha=lt?.08:1,(de||ce)&&(i.shadowColor=le,i.shadowBlur=de?20:14),i.translate(p.x,p.y),P(0,0,p.r,re),i.fillStyle=Le(le,p.r),i.fill(),i.restore(),de?(i.save(),P(p.x,p.y,p.r+3,re),i.strokeStyle=le,i.lineWidth=3,i.shadowColor=le,i.shadowBlur=12,i.stroke(),i.restore()):ce?(i.save(),P(p.x,p.y,p.r+2,re),i.strokeStyle=le,i.lineWidth=2,i.stroke(),i.restore()):Ne&&Re?(i.save(),P(p.x,p.y,p.r+2,re),i.strokeStyle="#e11d48",i.lineWidth=2,i.stroke(),i.restore()):a.multi.indexOf(p.id)>=0&&(i.save(),P(p.x,p.y,p.r+2,re),i.strokeStyle="#60a5fa",i.lineWidth=2,i.shadowColor="#60a5fa",i.shadowBlur=8,i.stroke(),i.restore());let rt=f(p.name,16);if((de||ce||a.zoom>ee||!E&&a.zoom>.6)&&We&&qe){let Ee=1/a.zoom;i.font="500 "+(12*Ee).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Pe=i.measureText(rt).width+16*Ee,Xe=18*Ee,He=p.y+p.r+8*Ee,Ve=!0;for(let je of Ye)if(p.x-Pe/2<je.x+je.w&&p.x+Pe/2>je.x&&He<je.y+je.h&&He+Xe>je.y){Ve=!1;break}if(!Ve&&!de&&!ce)return;Ye.push({x:p.x-Pe/2,y:He,w:Pe,h:Xe}),i.fillStyle=V()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",i.beginPath(),i.roundRect?i.roundRect(p.x-Pe/2,He,Pe,Xe,4*Ee):i.rect(p.x-Pe/2,He,Pe,Xe),i.fill(),i.strokeStyle=V()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",i.lineWidth=1*Ee,i.stroke(),i.fillStyle=V()?de||ce?"#eee":"#bbb":de||ce?"#111":"#444",i.textAlign="center",i.fillText(rt,p.x,He+13*Ee)}}),i.restore(),a.marquee){let p=a.marquee,$=Math.min(p.sx,p.ex),J=Math.min(p.sy,p.ey),le=Math.abs(p.ex-p.sx),re=Math.abs(p.ey-p.sy);i.save(),i.setLineDash([4,4]),i.strokeStyle="rgba(96,165,250,0.9)",i.lineWidth=1,i.fillStyle="rgba(96,165,250,0.12)",i.fillRect($,J,le,re),i.strokeRect($,J,le,re),i.restore()}if(a.hoverId&&Me.current){let p=a.domainById[a.hoverId],$=a.nodes.find(function(J){return J.id===a.hoverId});if(p&&$){let J=a.edges.filter(function(de){return de.sourceNodeId===p.id||de.targetNodeId===p.id}).length,le=$.x*a.zoom+a.panX,re=$.y*a.zoom+a.panY;Me.current.style.display="block",Me.current.style.left=le+14+"px",Me.current.style.top=re-6+"px",Me.current.innerHTML="<b>"+x(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+x(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",J)+"</span>"}}else Me.current&&(Me.current.style.display="none")},he=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame($e))};a.wake=he,a.render=ge;let Ke=()=>{let c=a.nodes.length;a.tickCount++;let x=.9-Math.min(.4,a.tickCount/1500),L=c>1e3?3e3:c>100?2e3:c>50?1200:800,E=c>100?.002:.005,ee=c>1e3?.012:c>100?.005:.01,q=c>1e3?6:c>200?12:24,xe={};a.nodes.forEach(p=>xe[p.id]=p);for(let p=0;p<c;p++){if(a.dragNode===a.nodes[p])continue;let $=a.nodes[p],J=0,le=0;for(let ce=0;ce<c;ce++){if(p===ce)continue;let Ne=$.x-a.nodes[ce].x,Re=$.y-a.nodes[ce].y,We=Math.sqrt(Ne*Ne+Re*Re)||1,qe=L/(We*We);J+=Ne/We*qe,le+=Re/We*qe}if(a.clustered&&a.typeCenters[$.type]){let ce=a.typeCenters[$.type];J+=(ce.x-$.x)*.006,le+=(ce.y-$.y)*.006}else J-=$.x*ee,le-=$.y*ee;let re=($.vx+J)*x,de=($.vy+le)*x;re=Math.max(-q,Math.min(q,re)),de=Math.max(-q,Math.min(q,de)),$.vx=re,$.vy=de}a.edges.forEach(p=>{let $=xe[p.sourceNodeId],J=xe[p.targetNodeId];if(!$||!J)return;let le=J.x-$.x,re=J.y-$.y,de=Math.sqrt(le*le+re*re)||1,ce=(de-100)*E,Ne=le/de*ce,Re=re/de*ce;a.dragNode!==$&&($.vx+=Ne,$.vy+=Re),a.dragNode!==J&&(J.vx-=Ne,J.vy-=Re)});let Ce=0;a.nodes.forEach(p=>{a.dragNode!==p&&(p.x+=p.vx,p.y+=p.vy,Ce+=p.vx*p.vx+p.vy*p.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,me()),(c?Math.sqrt(Ce/c):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},$e=()=>{if(a.running){try{Ke(),ge()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame($e)}},Se=(c,S)=>{let x=s.getBoundingClientRect();return{x:(c-x.left-a.panX)/a.zoom,y:(S-x.top-a.panY)/a.zoom}},Je=c=>{let S=a.domainById[c];return!(!S||g.current!=="all"&&S.kind!==g.current||Q.current&&!(S.tags||[]).includes(Q.current))},Ze=(c,S,x)=>Math.max(S,Math.min(x,c)),kt=c=>{a.mouseX=c.clientX,a.mouseY=c.clientY;let S=Se(c.clientX,c.clientY),x=null;for(let L=a.nodes.length-1;L>=0;L--){let E=a.nodes[L];if(!Je(E.id))continue;let ee=E.x-S.x,q=E.y-S.y;if(ee*ee+q*q<E.r*E.r+36){x=E.id;break}}x!==a.hoverId&&(a.hoverId=x,he())},Ct=c=>{if(c.button!==0)return;let S=Se(c.clientX,c.clientY),x=null;for(let L=a.nodes.length-1;L>=0;L--){let E=a.nodes[L];if(!Je(E.id))continue;let ee=E.x-S.x,q=E.y-S.y;if(ee*ee+q*q<E.r*E.r+25){x=E;break}}if(c.shiftKey){if(x){a.shiftClick=x.id;return}a.marquee={sx:c.clientX,sy:c.clientY,ex:c.clientX,ey:c.clientY};return}a.dragStart={x:c.clientX,y:c.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=x||null,x&&(a.dragOffset={dx:x.x-S.x,dy:x.y-S.y})},St=c=>{if(a.marquee){a.marquee.ex=c.clientX,a.marquee.ey=c.clientY,he();return}if(!a.dragStart)return;let S=c.clientX-a.dragStart.x,x=c.clientY-a.dragStart.y;if(Math.abs(S)+Math.abs(x)>3&&(a.dragging=!0),a.dragNode){let L=Se(c.clientX,c.clientY);a.dragNode.x=L.x+a.dragOffset.dx,a.dragNode.y=L.y+a.dragOffset.dy,he()}else a.dragging&&(a.panX=Ze(a.dragStart.px+S,-1e5,1e5),a.panY=Ze(a.dragStart.py+x,-1e5,1e5),he())},Nt=c=>{if(a.marquee){let x=a.marquee;a.marquee=null;let L=s.getBoundingClientRect(),E=Math.min(x.sx,x.ex)-L.left,ee=Math.max(x.sx,x.ex)-L.left,q=Math.min(x.sy,x.ey)-L.top,xe=Math.max(x.sy,x.ey)-L.top,Ce=a.nodes.filter(Ye=>{let p=Ye.x*a.zoom+a.panX,$=Ye.y*a.zoom+a.panY;return p>=E&&p<=ee&&$>=q&&$<=xe}).map(Ye=>Ye.id);a.multi=Ce,Be(Ce),he();return}let S=a.dragStart&&!a.dragging;if(a.shiftClick){let x=a.shiftClick;a.shiftClick=null;let L=Array.isArray(a.multi)?a.multi.slice():[];L.includes(x)||L.push(x),a.multi=L,Be(L),he();return}if(S){let x=Se(c.clientX,c.clientY),L=null;for(let E=a.nodes.length-1;E>=0;E--){let ee=a.nodes[E];if(!Je(ee.id))continue;let q=ee.x-x.x,xe=ee.y-x.y;if(q*q+xe*xe<ee.r*ee.r+20){L=ee;break}}L?(a.selectedId=L.id,W(L.id),he()):(a.selectedId=null,a.hoverId=null,c.shiftKey||(a.multi=[],Be([])),W(null),he())}a.dragStart=null,a.dragging=!1,a.dragNode=null},Mt=c=>{c.preventDefault();let S=Se(c.clientX,c.clientY),x=null;for(let L=a.nodes.length-1;L>=0;L--){let E=a.nodes[L];if(!Je(E.id))continue;let ee=E.x-S.x,q=E.y-S.y;if(ee*ee+q*q<E.r*E.r+25){x=E;break}}if(x){let L=a.domainById[x.id];L&&we({x:c.clientX,y:c.clientY,id:x.id,path:L.id,title:L.title})}else we(null)},zt=c=>{c.preventDefault();let S=s.getBoundingClientRect(),x=(c.clientX-S.left-a.panX)/a.zoom,L=(c.clientY-S.top-a.panY)/a.zoom,E=Math.max(.3,Math.min(3,a.zoom*(c.deltaY<0?1.1:1/1.1)));a.panX=Ze(a.panX+x*(a.zoom-E),-1e5,1e5),a.panY=Ze(a.panY+L*(a.zoom-E),-1e5,1e5),a.zoom=E,he()};s.addEventListener("mousemove",kt),s.addEventListener("mousedown",Ct),window.addEventListener("mousemove",St),window.addEventListener("mouseup",Nt),s.addEventListener("wheel",zt,{passive:!1}),s.addEventListener("contextmenu",Mt),C.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Be([]),me(),he()};for(let c=0;c<200;c++)Ke();me(),he();let It=()=>ie(!1);return window.addEventListener("mousedown",It),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),pt.disconnect(),s.removeEventListener("mousemove",kt),s.removeEventListener("mousedown",Ct),window.removeEventListener("mousemove",St),window.removeEventListener("mouseup",Nt),s.removeEventListener("wheel",zt),s.removeEventListener("contextmenu",Mt),window.removeEventListener("mousedown",It)}},[t,l]),(0,n.useEffect)(()=>{I!==void 0&&A.current&&requestAnimationFrame(()=>A.current())},[I]),(0,e.jsxs)("div",{className:"me-graph",ref:b,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",o("nodes")," \xB7 ",l.length," ",o("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:o("search"),value:j,onChange:s=>oe(s.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ie(s=>!s),"aria-expanded":z,title:o("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",o("filterLabel")," ",T!=="all"||H||R?"\u25CF":"\u25BE"]}),z&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:s=>s.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${T==="all"&&!H?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{ve("all"),_(!1)},children:o("all")}),Object.keys(_e).map(s=>(0,e.jsxs)("button",{type:"button",className:`lg${T===s?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ve(i=>i===s?"all":s),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:at.colors[s]||_e[s]}}),o(Fe[s])]},s)),(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${H?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>_(s=>!s),children:["\u23F1 ",o("timeDim")]}),Ue.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:Ue.map(s=>(0,e.jsxs)("button",{type:"button",className:`lg${R===s.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>Y(i=>i===s.tag?"":s.tag),title:s.tag,children:["#",s.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:s.n})]},s.tag))})]}),(T!=="all"||H||R)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{ve("all"),_(!1),Y("")},children:[o("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!k,onChange:s=>N&&N(s.target.checked)}),o("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${H?" me-on":""}`,onClick:()=>_(s=>!s),children:o("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=h.current;if(s)try{s.toBlob(i=>{i&&fe({url:URL.createObjectURL(i),blob:i})},"image/png")}catch{}},children:o("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>A.current&&A.current(),children:o("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{W(null),ve("all"),C.current&&C.current()},children:o("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:h,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)"}}),Te&&(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:o("noMatch")}),ae&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>we(null)}),ae&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:ae.x,top:ae.y,zIndex:31},onMouseDown:s=>s.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{w.current({path:ae.path,title:ae.title}),we(null)},children:o("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{ae.id&&(m.current.selectedId=ae.id,W(ae.id)),we(null);let s=m.current;s&&s.wake&&s.wake()},children:o("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(ae.title||"")}catch{}we(null),G(o("copied"))},children:o("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let s=m.current,i=s&&Array.isArray(s.multi)?s.multi.slice():[],B=ae.id;if(B&&!i.includes(B)&&i.push(B),we(null),i.length<2){G(o("mergeNeed"),!1);return}if(!window.confirm(o("mergeConfirm")))return;let V=M.current&&M.current(i);V&&V.then?V.then(se=>se?G(o("merged")):G(o("mergeFail"),!1)).catch(()=>G(o("mergeFail"),!1)):V&&G(o("merged"))},children:o("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let s=ae.path;we(null),window.confirm(o("deleteConfirm"))&&(async()=>{try{(D.current?await D.current(s):!1)?G(o("deleted")):G(o("deleteFail"),!1)}catch{G(o("deleteFail"),!1)}})()},children:o("delete")})]}),Ae.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:[Ae.length," ",o("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let i=Ae.map(ze=>ue[ze]).filter(Boolean).map(ze=>ze.title||ze.name).join(`
304
- `),B=new Blob([i],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(B),se=document.createElement("a");se.href=V,se.download="memory-selected.txt",document.body.appendChild(se),se.click(),document.body.removeChild(se),setTimeout(()=>URL.revokeObjectURL(V),1e3),G(Ae.length+o("exportedSel"))},children:o("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(Ae.length<2){G(o("mergeNeed"),!1);return}let s=Ae.map(B=>ue[B]?ue[B].id:B);if(!window.confirm(o("mergeConfirm")))return;Be([]);let i=m.current;i&&(i.multi=[]),fetch(`${U}/merge?paths=${encodeURIComponent(s.join(","))}`).then(B=>B.json()).then(B=>{B&&B.ok?G(o("merged")):G(o("mergeFail"),!1)}).catch(()=>G(o("mergeFail"),!1))},children:o("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(o("deleteConfirm")))return;let s=Ae.map(B=>ue[B]?ue[B].id:B);Be([]);let i=m.current;i&&(i.multi=[]),(async()=>{let B=0;for(let V of s)try{(D.current?await D.current(V):!1)&&B++}catch{}G(B+o("deletedSelected"),B>0)})()},children:o("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=m.current;s&&(s.multi=[]),Be([]);let i=m.current;i&&i.render&&i.render()},children:o("clearSelection")})]}),te&&(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:ue[te]?ue[te].title||ue[te].name:te}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ue[te]?o(Fe[ue[te].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:o("graphHint")}),(l.filter(s=>s.source===te||s.target===te)||[]).slice(0,8).map((s,i)=>{let B=s.source===te?s.target:s.source,V=ue[B];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:se=>{se.preventDefault();let ze=m.current;ze&&(ze.selectedId=B,ze.hoverId=B,ze.wake&&ze.wake()),W(B)},children:V?(V.title||V.name).slice(0,28):B},i)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:o("graphTip")}),pe&&(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 "+(pe.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:pe.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:pe.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:pe.msg})]}),ke&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{ke.url&&URL.revokeObjectURL(ke.url),fe(null),Oe(!1)},children:[(0,e.jsx)("style",{children:De}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:Ie?"100vw":900,width:Ie?"100vw":"92vw",maxHeight:Ie?"100%":"90vh",height:Ie?"100%":void 0,borderRadius:Ie?0:14},onClick:s=>s.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:o("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:ke.url,download:"memory-graph.png",onClick:()=>{ye("download"),G(o("downloaded")+" \xB7 "+o("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:o(d==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ye("full"),Oe(s=>!s),G(o("fullscreen"))},children:o(d==="full"?"done":Ie?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=ke.blob;s&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":s})]).then(()=>{ye("copy"),G(o("copied"))}).catch(()=>{G(o("copyFail"),!1)}):G(o("copyFail"),!1)},children:o(d==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ke.url&&URL.revokeObjectURL(ke.url),fe(null),Oe(!1)},children:o("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:Ie?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:ke.url,alt:o("exportGraph"),style:{maxWidth:"100%",maxHeight:Ie?"calc(100% - 64px)":"70vh",borderRadius:Ie?0:8,cursor:"zoom-in"},onClick:()=>Oe(s=>!s)})})]})]})]})}function Sa(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let r=(Date.now()-l)/864e5;return r<3?"#10b981":r<14?"#f59e0b":r<30?"#f97316":"#94a3b8"}function Pt({label:t,value:l=[],options:r,onChange:y,placeholder:u,z:o=20}){let[v,k]=(0,n.useState)(!1),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!v)return;let w=D=>{N.current&&!N.current.contains(D.target)&&k(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[v]);let I=Array.isArray(l)?l:[],h=I.includes("__all__"),b=h?r.find(w=>w.value==="__all__")?.label||"":I.length?I.map(w=>r.find(D=>D.value===w)?.label||w).join("\u3001"):"",m=(w,D)=>{if(w.value==="__all__"){y(D?["__all__"]:[]);return}let M=new Set(I);M.has("__all__")&&M.delete("__all__"),D?M.add(w.value):M.delete(w.value),y([...M])},A=r.find(w=>w.value==="__all__"),C=r.filter(w=>w.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t}),(0,e.jsxs)("div",{ref:N,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>k(w=>!w),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b||u||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),v&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:o,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[A&&(0,e.jsxs)("label",{onClick:w=>w.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("input",{type:"checkbox",checked:h,onChange:w=>m(A,w.target.checked)}),(0,e.jsx)("span",{children:A.label})]}),C.map(w=>(0,e.jsxs)("label",{onClick:D=>D.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:I.includes(w.value),onChange:D=>m(w,D.target.checked)}),(0,e.jsx)("span",{children:w.label})]},w.value))]})]})]})}function Na(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function Ma(t,l,r){if(r&&typeof window.showSaveFilePicker=="function")try{let o=await window.showSaveFilePicker({suggestedName:l}),v=await o.createWritable();return await v.write(t),await v.close(),{ok:!0,picked:!0,name:o.name}}catch(o){return o&&o.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(o.message||o)}}let y=URL.createObjectURL(t),u=document.createElement("a");return u.href=y,u.download=l,document.body.appendChild(u),u.click(),document.body.removeChild(u),setTimeout(()=>URL.revokeObjectURL(y),1e3),{ok:!0,picked:!1,name:l}}function Et(t,l){if(!l||!t)return t;let r=t.toLowerCase(),y=l.toLowerCase(),u=[],o=0;for(;o<t.length;){let v=r.indexOf(y,o);if(v<0){u.push(t.slice(o));break}v>o&&u.push(t.slice(o,v)),u.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(v,v+y.length)},v)),o=v+y.length}return u}function nt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let r=new Date,y=l.toDateString()===r.toDateString(),u=v=>String(v).padStart(2,"0"),o=`${u(l.getHours())}:${u(l.getMinutes())}`;return y?o:`${l.getMonth()+1}-${l.getDate()} ${o}`}
302
+ `));let ot=new Blob([ve],{type:Ve}),Qe=await yn(ot,ce,!1);if(!Qe.ok){_({ok:!1,msg:t("exportFail")}),le(!1);return}_({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Qe.name})}catch(X){_({ok:!1,msg:t("exportFail")+" \xB7 "+(X.message||"")})}finally{le(!1)}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>_(null),2600)},zt=async v=>{let O=v.target.files&&v.target.files[0];if(v.target.value="",!!O){try{let X=await O.text(),ve=await(await fetch(`${q}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:X})).json();ve.ok?(await Y(),_({ok:!0,msg:t("importedVault")+"\uFF1A"+(ve.imported||0)+(ve.skipped?t("importedSkipped")+ve.skipped:"")})):_({ok:!1,msg:ve.error||t("importFail")})}catch{_({ok:!1,msg:t("importFail")})}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>_(null),2400)}},It=(0,o.useMemo)(()=>{let v=w.slice();return J!=="all"&&(v=v.filter(O=>xt(O.submittedBy)===J)),H!=="all"&&(v=v.filter(O=>(O.status||"approved")===H)),f==="title"?v.sort((O,X)=>String(O.title||"").localeCompare(String(X.title||""))):f==="hot"?v.sort((O,X)=>(X.weight||X.links||0)-(O.weight||O.links||0)):v.sort((O,X)=>new Date(X.updated||0).getTime()-new Date(O.updated||0).getTime()),v},[w,f,J,H]),Dt=(0,o.useMemo)(()=>[...new Set(w.map(v=>xt(v.submittedBy)))],[w]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ae}),K&&(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 "+(K.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:K.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:K.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:K.msg})]}),n&&(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)(Sa,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),u&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:u,"aria-label":t(p?"exitFull":"fullscreen"),children:p?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:i,"aria-label":t("close"),children:"\u2715"})]}),y&&y.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[y.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:y.since?ht(new Date(y.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${me?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Ne(v=>!v),"aria-label":t(me?"collapse":"expand"),title:t(me?"collapse":"expand"),children:me?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="cards"?" active":""}`,onClick:()=>b("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="graph"?" active":""}`,onClick:()=>b("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="stats"?" active":""}`,onClick:()=>b("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="audit"?" active":""}`,onClick:()=>b("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="optimize"?" active":""}`,onClick:()=>b("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${$==="config"?" active":""}`,onClick:()=>b("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]}),(0,e.jsxs)("button",{type:"button",className:"mc-railbtn",onClick:()=>xe(!0),title:t("fbNav"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F41E}"}),me&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("fbNav")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:s,children:[$==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(bt,{label:t("total"),value:l?l.total:"\u2014"}),(0,e.jsx)(bt,{label:t("recent"),value:l?l.recent:"\u2014"}),(0,e.jsx)(bt,{label:t("tags"),value:l?l.tags:"\u2014"}),(0,e.jsx)(bt,{label:t("pending"),value:l?.status?.pending??0}),(0,e.jsx)(bt,{label:t("rejected"),value:l?.status?.rejected??0}),(0,e.jsx)(bt,{label:t("cardCount"),value:l?l.byKind?.knowledge??0:"\u2014"})]}),$==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:I,onChange:v=>Ce(v.target.value)}),(0,e.jsx)("input",{ref:te,type:"file",accept:".json,application/json",style:{display:"none"},onChange:zt}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>te.current&&te.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ze({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Q,onClick:()=>vt("md"),children:t(Q?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Q,onClick:()=>vt("json"),children:t(Q?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Y(),children:t("refresh")})]}),$==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Vt.map(v=>(0,e.jsx)("button",{type:"button",className:`mc-chip${k===v?" active":""}`,onClick:()=>a(v),children:t(v==="all"?"all":We[v])},v)),(0,e.jsxs)("select",{value:J,onChange:v=>ne(v.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Ca(Dt).map(v=>(0,e.jsx)("option",{value:v,children:v},v))]}),(0,e.jsxs)("select",{value:H,onChange:v=>ye(v.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(v=>(0,e.jsx)("button",{type:"button",className:`mc-chip${f===v.key?" active":""}`,onClick:()=>E(v.key),children:v.label},v.key))]}),D&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",D]}),(0,e.jsx)("div",{style:{display:$==="cards"?"contents":"none"},children:A?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):D?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",D," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Y(),children:t("retry")})]}):w.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:It.map(v=>(0,e.jsx)(rn,{card:v,t,query:I.trim(),onOpen:ct,onDelete:de},v.path))}),w.length<ue&&(0,e.jsx)("div",{ref:r,style:{height:1}}),R&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",w.length," / ",ue,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:$==="graph"?"flex":"none",flex:1,minHeight:0},children:be.has("graph")&&(0,e.jsx)(un,{t,onOpen:ct,all:Be,onAllChange:Ee,onMutate:Ye,active:$==="graph",visible:$==="graph"})}),(0,e.jsx)("div",{style:{display:$==="config"?"contents":"none"},children:be.has("config")&&(0,e.jsx)(Na,{t,onReload:()=>Y(),version:Fe})}),(0,e.jsx)("div",{style:{display:$==="stats"?"contents":"none"},children:be.has("stats")&&(0,e.jsx)(sn,{t,tab:"stats",onReload:()=>Y(),version:Fe})}),(0,e.jsx)("div",{style:{display:$==="audit"?"contents":"none"},children:be.has("audit")&&(0,e.jsx)(on,{t,onReload:()=>Y(),version:Fe})}),(0,e.jsx)("div",{style:{display:$==="optimize"?"contents":"none"},children:be.has("optimize")&&(0,e.jsx)(ln,{t,onReload:()=>Y(),version:Fe})}),he&&(0,e.jsx)(cn,{t,onClose:()=>xe(!1)}),tt&&(0,e.jsx)(pn,{t,card:tt,query:I.trim(),onClose:()=>at(null),onDelete:v=>{at(null),de(v)},onFeedback:v=>{let O=tt.path;fetch(`${q}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:I.trim(),path:O,useful:v})}).then(()=>_({ok:!0,msg:t(v?"fbUseful":"fbIrr")})).catch(()=>{}),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>_(null),2e3)}}),(0,e.jsx)(dn,{t,newCard:$e,setNewCard:ze,onCreated:()=>{Y(),Ye(),_({ok:!0,msg:t("created")}),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>_(null),2e3)}})]})]})]})}var Ma=({toast:t})=>t?(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"8px 12px",fontSize:12,borderLeft:"4px solid "+(t.ok?"#10b981":"#ef4444"),background:t.ok?"rgba(16,185,129,0.08)":"rgba(239,68,68,0.08)"},children:[t.ok?"\u2705":"\u26A0"," ",t.msg]}):null,bt=({label:t,value:n})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:n}),(0,e.jsx)("span",{children:t})]});function Na({t,onReload:n,version:i,compact:u}){let[p,l]=(0,o.useState)(null),[h,w]=(0,o.useState)(0),[x,A]=(0,o.useState)(null),[S,y]=(0,o.useState)(null),[g,D]=(0,o.useState)(!1),[T,k]=(0,o.useState)(null),[L,I]=(0,o.useState)(null),[j,J]=(0,o.useState)(""),[ne,H]=(0,o.useState)(""),[ye,$]=(0,o.useState)(""),[Z,be]=(0,o.useState)(null),W=(0,o.useCallback)(async d=>{H("version");try{let R=await fetch(q+"/version-check"+(d?"?force=1":"")).then(P=>P.json());R&&R.ok?(be(R),d&&B(R.updateAvailable?t("vcLatest")+" v"+R.latest:t("vcUpToDate"))):d&&B(t("vcCheckFail"),!1)}catch{d&&B(t("vcCheckFail"),!1)}finally{H("")}},[t]);(0,o.useEffect)(()=>{W(!1)},[i,W]);let[b,f]=(0,o.useState)(""),[E,K]=(0,o.useState)(null),_=(0,o.useRef)(null),B=(d,R=!0)=>{_.current&&clearTimeout(_.current),K({msg:d,ok:R}),_.current=setTimeout(()=>K(null),1900)},te=(d,R)=>Object.keys(R).reduce((P,r)=>P.split("{"+r+"}").join(R[r]),t(d)),Q=(0,o.useCallback)(async()=>{try{let[d,R,P]=await Promise.all([fetch(`${q}/config`).then(r=>r.json()).catch(()=>null),fetch(`${q}/setup-status`).then(r=>r.json()).catch(()=>null),fetch(`${q}/budget`).then(r=>r.json()).catch(()=>null)]);d&&d.ok?(l(d),w(d.revision??0),A(d.schema??null),y({...d.config??{}}),k(d.dsh??null),D(d.writable===!1),J("")):P&&P.ok?(y({...P}),D(!0),J(t("configNeedsDsh"))):J(t("adminLoadFail")),R&&R.ok&&I(R),$("")}catch{J(t("adminLoadFail"))}},[t]);(0,o.useEffect)(()=>{Q()},[i,Q]);let le=(d,R)=>y(P=>({...P??{},[d]:R})),tt=d=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[d]||d,at=async()=>{if(S){if(g){B(t("editInSetting"),!1);return}H("save");try{let d={...S};Array.isArray(d.vaultProfiles)&&(d.vaultProfiles=d.vaultProfiles.filter(r=>r&&(String(r.name||"").trim()||String(r.path||"").trim())));let R=await fetch(`${q}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:d,expectedRevision:h})}),P=await R.json();if(P&&P.ok)$(t("savedOk")+(P.note?` \xB7 ${t("restartHint")}`:"")),B(t("savedOk")),await Q();else{let r=R.status===409?t("conflictRefresh"):P?.error||t("saveFail");J(r),B(r,!1)}}catch{J(t("saveFail")),B(t("saveFail"),!1)}finally{H("")}}},Be=()=>{y({...p?.config??{}}),$("")},Ee={env:"vaultSrcEnv",profile:"vaultSrcProfile",workspace:"vaultSrcWorkspace",vaultDir:"vaultSrcVaultDir",default:"vaultSrcDefault"},he=d=>Array.isArray(d?.vaultProfiles)?d.vaultProfiles:[],xe=(d,R,P)=>y(r=>{let s=he(r).map(Y=>({...Y||{}})),M={...s[d]||{}};return R==="match"?String(P).trim()?M.match={...M.match||{},workspace:P}:delete M.match:M[R]=P,s[d]=M,{...r??{},vaultProfiles:s}}),me=()=>y(d=>({...d??{},vaultProfiles:[...he(d),{name:"",path:""}]})),Ne=d=>y(R=>({...R??{},vaultProfiles:he(R).filter((P,r)=>r!==d)})),$e={fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},ze={padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:12,minWidth:0},Fe={A:{label:t("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:t("planB"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!1,dedupByLLM:!1,captureMaxTokens:500,recallMinScore:3,recallLimit:3,recallSummaryLen:80,recallIncludeBody:!1,captureMinChars:300,maxCardsPerDay:40,captureCooldownMs:3e5},C:{label:t("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},nt=async d=>{let R=Fe[d];R&&y(P=>({...P??{},...R}))},Ye=async(d,R)=>{H(d+R);try{let r=await(await fetch(`${q}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:d,action:R})})).json();r&&r.ok?B(te(R==="install"?"mcpInstalled":"mcpUninstalled",{agent:d})):B(te("mcpActionFail",{agent:d,error:r?.error||""}),!1);try{let s=await fetch(`${q}/setup-status`).then(M=>M.json());s&&s.ok&&I(s)}catch{}}catch{B(t("mergeFail"),!1)}finally{H("")}},re=({k:d,label:R,type:P="text",step:r,min:s,max:M})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:R||d}),(0,e.jsx)("input",{type:P,step:r,min:s,max:M,value:S?S[d]??"":"",onChange:Y=>le(d,P==="number"?Number(Y.target.value):Y.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),ue=({k:d,label:R})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(S&&S[d]),onChange:P=>le(d,P.target.checked)}),(0,e.jsx)("span",{children:R||d})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:u?"0 0 auto":1,minHeight:0,maxHeight:u?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ae}),E&&(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 "+(E.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:E.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:E.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:E.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[j&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",j]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",t("retry")]})]}),g&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),ye&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #10b981",background:"rgba(16,185,129,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#059669"},children:["\u2713 ",ye]}),p&&(p.version||p.dsh?.vaultDir)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",t("pluginInfo")]}),(0,e.jsx)("span",{style:{fontSize:12,opacity:.7},children:t("dshHostLabel")}),p.version&&(0,e.jsxs)("code",{style:$e,children:[t("vcLoaded")," v",p.version]}),Z&&Z.onDisk&&(0,e.jsxs)("code",{style:$e,children:[t("vcOnDisk")," v",Z.onDisk]}),Z&&Z.latest&&(0,e.jsxs)("code",{style:$e,children:[t("vcLatest")," v",Z.latest]}),p.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",p.dsh.vaultDir]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:ne==="version",onClick:()=>W(!0),children:ne==="version"?t("checking"):"\u{1F504} "+t("vcCheck")})]}),Z&&Z.stale&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"6px 10px"},children:["\u26A0\uFE0F ",te("vcStale",{disk:Z.onDisk,loaded:Z.loaded})]}),Z&&Z.updateAvailable&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,opacity:.88},children:["\u2B06 ",t("vcOutdated")," \u2192 ",(0,e.jsx)("code",{children:Z.updateCommand})]}),Z&&Z.checkError&&(0,e.jsxs)("div",{style:{marginTop:8,fontSize:11.5,color:"#b91c1c"},children:[t("vcCheckFail"),"\uFF1A",Z.checkError]})]}),L&&L.agents&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",t("mcpSetupStatus")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("mcpManageHint")})]}),(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:L.agents.map(d=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:d.isDsh?t("dshHostLabel"):d.name}),d.isDsh&&d.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",d.version]}),!d.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),d.installed&&d.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),d.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),d.mcpConfigured===!0&&d.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),d.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",d.recallTool?t("enabled"):t("disabled"),")"]})]}),d.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",d.hook]}),!d.isDsh&&d.installed&&d.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ne,onClick:()=>Ye(d.name,"install"),children:t("installMcp")}),!d.isDsh&&d.installed&&d.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ne,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Ye(d.name,"uninstall")},children:t("uninstallMcp")})]},d.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),b&&(0,e.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,e.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:b})})]}),S?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(d=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>nt(d),disabled:!!ne,children:[d==="A"?"\u{1F7E2} ":d==="B"?"\u{1F4B0} ":"\u2B50 ",Fe[d].label]},d))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(ue,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(ue,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(re,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(re,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(re,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(re,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(re,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(ue,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #06b6d4"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5C2}\uFE0F ",t("vaultMulti")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("vaultMultiHint")})]}),(0,e.jsxs)("div",{style:{fontSize:11.5,opacity:.85,marginBottom:8,lineHeight:1.7},children:[t("vaultNow"),"\uFF1A",(0,e.jsx)("code",{children:T?.vaultDir||"\u2014"}),T?.vaultName?`\uFF08${T.vaultName}\uFF09`:""," \xB7 ",t("vaultSource"),"\uFF1A",t(Ee[T?.vaultSource]||"vaultSrcDefault"),T?.workspace?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),t("vaultWorkspace"),"\uFF1A",(0,e.jsx)("code",{children:T.workspace})]}):null]}),he(S).map((d,R)=>(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.6fr 1.5fr auto",gap:6,marginBottom:6},children:[(0,e.jsx)("input",{value:d.name||"",placeholder:t("vaultNamePh"),onChange:P=>xe(R,"name",P.target.value),style:ze,disabled:g}),(0,e.jsx)("input",{value:d.path||"",placeholder:t("vaultPathPh"),onChange:P=>xe(R,"path",P.target.value),style:ze,disabled:g}),(0,e.jsx)("input",{value:d.match&&d.match.workspace||"",placeholder:t("vaultMatchPh"),onChange:P=>xe(R,"match",P.target.value),style:ze,disabled:g}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Ne(R),disabled:g,title:t("delete"),children:"\u2715"})]},R)),(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap",marginTop:4},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:me,disabled:g,children:["\uFF0B ",t("vaultAdd")]}),(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("vaultActive")}),(0,e.jsxs)("select",{value:S.activeVault||"",onChange:d=>le("activeVault",d.target.value),disabled:g,style:ze,children:[(0,e.jsx)("option",{value:"",children:t("vaultActiveNone")}),he(S).filter(d=>d&&d.name).map(d=>(0,e.jsx)("option",{value:d.name,children:d.name},d.name))]})]})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(ue,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(ue,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(re,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(re,{k:"recallMinScore",label:t("recallMinScore"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:S.auditMode??"all",onChange:d=>le("auditMode",d.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(xa,{label:t("auditExemptAgents"),value:S.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(L?.agents||[]).filter(d=>!d.isDsh).map(d=>({value:d.name,label:d.name}))],onChange:d=>le("auditExemptAgents",d)}),(0,e.jsx)(xa,{label:t("auditExemptKinds"),value:S.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...Vt.filter(d=>d!=="all").map(d=>({value:d,label:t(We[d])}))],onChange:d=>le("auditExemptKinds",d)}),(0,e.jsx)(re,{k:"recycleRetentionDays",label:t("recycleDays"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",t("serviceConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(ue,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:S.autoWebMode??"init",onChange:d=>le("autoWebMode",d.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(re,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(re,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(re,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(ue,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(ue,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",alignItems:"center",marginBottom:10,flexWrap:"wrap"},children:[ne==="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,opacity:.75},children:["\u23F3 ",t("saving")]}),ye&&ne!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#10b981"},children:["\u2705 ",ye]}),j&&ne!=="save"&&(0,e.jsxs)("span",{style:{fontSize:11.5,color:"#b91c1c"},children:["\u26A0 ",j]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:Be,disabled:!!ne,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:at,disabled:!!ne||g,children:ne==="save"?"\u23F3 "+t("saving"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function on({t,onReload:n,version:i}){let[u,p]=(0,o.useState)([]),[l,h]=(0,o.useState)([]),[w,x]=(0,o.useState)("all"),[A,S]=(0,o.useState)("all"),[y,g]=(0,o.useState)(""),[D,T]=(0,o.useState)(new Set),[k,L]=(0,o.useState)(""),[I,j]=(0,o.useState)(null),[J,ne]=(0,o.useState)("pending"),H=(f,E=!0)=>{j({msg:f,ok:E}),setTimeout(()=>j(null),3e3)},ye=[...new Set([...u,...l].map(f=>f.submittedBy).filter(Boolean))],$=(0,o.useCallback)(async()=>{try{let f=await fetch(`${q}/audit/list`).then(E=>E.json());f.ok&&(p(f.pending||[]),h(f.rejected||[]),T(new Set))}catch{}},[]);(0,o.useEffect)(()=>{$()},[i,$]);let Z=(J==="pending"?u:l).filter(f=>{if(w!=="all"&&f.kind!==w||A!=="all"&&xt(f.submittedBy)!==A)return!1;if(y){let E=(f.created||"").slice(0,10);if(E&&E!==y)return!1}return!0}),be=f=>T(E=>{let K=new Set(E);return K.has(f)?K.delete(f):K.add(f),K}),W=async(f,E)=>{let K=E||[...D];if(!K.length){H(t("noSelection"),!1);return}L("apply");let _=t(f==="approved"?"toastApproved":f==="rejected"?"toastRejected":"toastCardDeleted");try{let B=0;for(let te of K){let Q=f==="approved"?"audit/approve":f==="rejected"?"audit/reject":"delete";try{(await fetch(q+"/"+Q+"?path="+encodeURIComponent(te)+(f==="delete"?"&permanent=0":""))).ok||B++}catch{B++}}await $(),n&&n(),B?H(t("toastFailed")+"\uFF08"+B+"/"+K.length+"\uFF09",!1):H(_+" "+K.length+" \u5F20")}catch(B){H(t("toastFailed")+": "+String(B&&B.message||B),!1)}finally{L("")}},b=[...D];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:Ae}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(Ma,{toast:I}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("tabAudit")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("select",{value:w,onChange:f=>x(f.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("all")}),Vt.filter(f=>f!=="all").map(f=>(0,e.jsx)("option",{value:f,children:t(We[f])},f))]}),(0,e.jsxs)("select",{value:A,onChange:f=>S(f.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allAgents")}),Ca(ye).map(f=>(0,e.jsx)("option",{value:f,children:f},f))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:f=>g(f.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"}})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("button",{type:"button",className:`mc-btn${J==="pending"?" me-on":""}`,onClick:()=>ne("pending"),children:[t("pending"),"\uFF08",u.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${J==="rejected"?" me-on":""}`,onClick:()=>ne("rejected"),children:[t("rejected"),"\uFF08",l.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:Z.length>0&&b.length===Z.length,onChange:f=>{f.target.checked?T(new Set(Z.map(E=>E.path))):T(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!b.length||!!k,onClick:()=>W("approved"),children:["\u2713 ",t(J==="rejected"?"restore":"approve")]}),J==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!b.length||!!k,onClick:()=>W("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!b.length||!!k,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&W("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),Z.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:Z.map(f=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:D.has(f.path),onChange:()=>be(f.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze[f.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:xt(f.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:f.created?f.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:f.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:f.severity==="high"?"#f87171":"#9ca3af"},children:f.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.reason||"-"}),J==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>W("approved",[f.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>W("rejected",[f.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>W("approved",[f.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&W("delete",[f.path])},children:"\u{1F5D1}"})]})]},f.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function ln({t,onReload:n,version:i}){let[u,p]=(0,o.useState)([]),[l,h]=(0,o.useState)(""),[w,x]=(0,o.useState)(null),A=(g,D=!0)=>{x({msg:g,ok:D}),setTimeout(()=>x(null),3200)},S=(0,o.useCallback)(async()=>{try{let g=await fetch(`${q}/recycle/list`).then(D=>D.json());g.ok&&p(g.items||[])}catch{}},[]);(0,o.useEffect)(()=>{S()},[i,S]);let y=async(g,D)=>{let T=(u.find(k=>k.path===D)||{}).title||D;h(g+D);try{let L=await fetch(q+(g==="restore"?"/recycle/restore":"/recycle/purge")+"?path="+encodeURIComponent(D)),I=await L.json().catch(()=>null);await S(),n&&n(),L.ok&&(!I||I.ok!==!1)?A(t(g==="restore"?"toastRestored":"toastPurged")+"\uFF1A"+T):A(t("toastFailed")+"\uFF1A"+(I&&I.error||"HTTP "+L.status),!1)}catch(k){A(t("toastFailed")+"\uFF1A"+String(k&&k.message||k),!1)}finally{h("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsx)(Ma,{toast:w}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!l||u.length===0,title:u.length?"":t("emptyRecycle"),onClick:async()=>{h("purgeAll");try{let g=await fetch(q+"/recycle/purge-expired?days=0"),D=await g.json().catch(()=>null);await S(),A(g.ok?t("toastPurgedExpired")+(D&&D.purged!=null?"\uFF08"+D.purged+"\uFF09":""):t("toastFailed"),g.ok)}catch(g){A(t("toastFailed")+"\uFF1A"+String(g&&g.message||g),!1)}finally{h("")}},children:t("emptyRecycle")})]}),u.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:u.map(g=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze[g.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(g.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!l,onClick:()=>y("restore",g.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!l,onClick:()=>{window.confirm(t("purgeConfirm"))&&y("purge",g.path)},children:t("purge")})]},g.path))}):(0,e.jsxs)("div",{className:"mc-card",style:{padding:18,fontSize:12.5,opacity:.78,textAlign:"center",lineHeight:1.9},children:["\u{1F5D1}\uFE0F ",t("emptyRecycle"),(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{fontSize:11.5},children:t("recycleEmptyHint").split("{days}").join("30")})]})]})]})}var rn=({card:t,t:n,onOpen:i,query:u,onDelete:p})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>i(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze[t.kind]||Ze.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:Ot[t.kind]||"\u{1F4CE}"}),u?va(t.title,u):t.title,bn(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:n("newBadge")}),t.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",n("statusPending")]}),t.status==="rejected"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",n("statusRejected")]}),(!t.status||t.status==="approved")&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",n("statusApproved")]})]}),(0,e.jsx)("p",{children:u?va(t.summary||"",u):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(l=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",l]},l))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[Ot[t.kind]||"\u{1F4CE}"," ",n(We[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",xt(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",ht(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:n("delete"),onClick:l=>{l.stopPropagation(),window.confirm(n("deleteConfirm"))&&p&&p(t.path)},children:"\u{1F5D1}"})]})]});function sn({t,tab:n,onReload:i,version:u}){let[p,l]=(0,o.useState)(null),[h,w]=(0,o.useState)(""),[x,A]=(0,o.useState)(null),[S,y]=(0,o.useState)(null),[g,D]=(0,o.useState)(null),[T,k]=(0,o.useState)([]),[L,I]=(0,o.useState)(""),[j,J]=(0,o.useState)(!1),ne=(0,o.useCallback)(async()=>{if(!(!x||!x.merge||!x.merge.length)&&window.confirm(t("mergeAllConfirm"))){I("merge");try{let b={},f=te=>b[te]===void 0?te:b[te]=f(b[te]),E=(te,Q)=>{b[f(te)]=f(Q)},K=new Set;for(let te of x.merge)K.add(te.a.path),K.add(te.b.path),E(te.a.path,te.b.path);let _={};for(let te of K){let Q=f(te);(_[Q]=_[Q]||[]).push(te)}let B=0;for(let te of Object.values(_)){if(te.length<2)continue;(await fetch(`${q}/merge?paths=${encodeURIComponent(te.join(","))}`).then(le=>le.json())).ok&&B++}await H(),i&&i()}catch{}I("")}},[x,H,i,t]);async function H(){try{let b=await Promise.all([fetch(`${q}/stats`),fetch(`${q}/budget`),fetch(`${q}/capture-log`),fetch(`${q}/cards?status=all&limit=30&agent=${Nt}`)]),[f,E,K,_]=await Promise.all(b.map(B=>B.json()));f&&f.ok&&l(f),E&&E.ok&&y(E),K&&K.ok&&D(K),_&&_.ok&&k(_.cards||[]),w(!f||!f.ok?t("adminLoadFail"):"")}catch{w(t("adminLoadFail"))}}let ye=(0,o.useCallback)(async()=>{I("scan");try{let b=await fetch(`${q}/optimize`).then(f=>f.json());b.ok&&A(b)}catch{w(t("adminLoadFail"))}finally{I("")}},[t]);(0,o.useEffect)(()=>{H()},[u]);let $=async(b,f)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${q}/merge?paths=${encodeURIComponent(b+","+f)}`).then(K=>K.json())).ok&&(await H(),i&&i())}catch{}},Z=async b=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${q}/delete?path=${encodeURIComponent(b)}`).then(E=>E.json())).ok&&(await H(),i&&i())}catch{}},be=["project","knowledge","content","prompt","business","tool","mistake"],W=({title:b,kind:f,updated:E,path:K})=>(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:yt.colors[f]||"#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:ht(E)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>Z(K),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:Ae}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[h&&(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 ",h]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:H,children:["\u21BB ",t("retry")]})]}),n==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",t("captureLog")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("captureLogHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>H(),children:["\u21BB ",t("refresh")]})]}),g?g.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(g.entries||[]).length===0?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogEmpty")}):(0,e.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,e.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,e.jsx)("tbody",{children:(g.entries||[]).map((b,f)=>{let E=Ja[b.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:ht(b.time?new Date(b.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:E[1],fontWeight:600},children:[E[0]," ",b.action]}),(0,e.jsx)("td",{style:{padding:"4px 6px"},children:b.reason||""}),(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:b.preview||"",children:b.preview||""})]},f)})})})}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("loading")})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",t("captureAgentCards"),"\uFF08",T.length,"\uFF09"]}),T.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:T.map(b=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze[b.kind]||Ze.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),b.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:ht(b.updated)})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),p&&(0,e.jsxs)(e.Fragment,{children:[p.trend&&p.trend.length>0&&(()=>{let b=p.trend,f=Math.max(...b.map(B=>B.count),1),E=260,K=50,_=E/b.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:E,height:K,style:{display:"block",width:"100%",height:50},children:b.map((B,te)=>{let Q=Math.round(B.count/f*(K-4));return(0,e.jsx)("rect",{x:te*_+1,y:K-Q,width:Math.max(_-2,2),height:Q,rx:1.5,fill:B.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:B.count>0?.85:.35},B.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:p.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(b=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:yt.colors[b]||"#666"}}),t(We[b]),": ",p.byKind?.[b]||0]},b))})]}),S&&(S.budgetChars||S.recallLimit||S.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:S.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:S.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",S.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",p.todayCards?.length||0,"\uFF09"]}),p.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:p.todayCards.map(b=>(0,e.jsx)(W,{title:b.title,kind:b.kind,updated:b.updated,path:b.path},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),n==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!L,onClick:ye,children:L==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),x&&x.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!L,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){I("oneclick");try{let b=JSON.stringify({cleanupStale:j}),E=await(await fetch(`${q}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:b})).json();E&&E.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${E.plan.merged} ${t("optimizedMerged")}${j?` \xB7 ${E.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await H(),i&&i(),A(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{I("")}}},children:L==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),x&&x.merge?.length>0&&(0,e.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,e.jsx)("input",{type:"checkbox",checked:j,onChange:b=>J(b.target.checked)}),t("oneClickAlsoStale")]})]}),!x&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),x&&(0,e.jsx)(e.Fragment,{children:(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("mergePairs")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),x.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!L,onClick:ne,children:t(L==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),x.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:x.merge.map((b,f)=>(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:()=>$(b.a.path,b.b.path),children:t("mergeNow")})]},f))}):(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",x.stale?.length||0,"\uFF09"]}),x.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!L,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;I("clean");let b=0;for(let f of x.stale)try{await fetch(`${q}/delete?path=${encodeURIComponent(f.path)}`),b++}catch{}I(""),notify(`${b} ${t("deletedStale")}`),await H(),i&&i()},children:t("cleanStale")})}),x.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:x.stale.map(b=>(0,e.jsx)(W,{title:b.title,kind:"other",updated:b.updated,path:b.path},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var Yt=[{key:"decision",label:"tplDecision",kind:"knowledge",tagKey:"tplDecisionTags",bodyKey:"tplDecisionBody"},{key:"bug",label:"tplBug",kind:"mistake",tagKey:"tplBugTags",bodyKey:"tplBugBody"},{key:"meeting",label:"tplMeeting",kind:"content",tagKey:"tplMeetingTags",bodyKey:"tplMeetingBody"},{key:"weekly",label:"tplWeekly",kind:"content",tagKey:"tplWeeklyTags",bodyKey:"tplWeeklyBody"}];function dn({t,newCard:n,setNewCard:i,onCreated:u}){if(!n)return null;let p=Yt.find(y=>y.key===n.template),l=n.body||(p?t(p.bodyKey):""),h=n.kind||(p?p.kind:"knowledge"),w=n.tags||(p?t(p.tagKey):""),x=n._creating,A=y=>{let g=Yt.find(D=>D.key===y);i(D=>({...D,template:y,kind:g?g.kind:D.kind,body:g?t(g.bodyKey):D.body,tags:g?t(g.tagKey):D.tags}))},S=async()=>{if(!(!n.title&&!l)){i(y=>({...y,_creating:!0}));try{(await fetch(`${q}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n.title||t("untitled"),kind:h,tags:w.split(",").map(g=>g.trim()).filter(Boolean),body:l,source:"manual"})}).then(g=>g.json())).ok?(i(null),u&&u()):i(g=>({...g,_creating:!1}))}catch{i(g=>({...g,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>i(null),children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>i(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[Yt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${n.template===y.key?" me-on":""}`,onClick:()=>A(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${n.template===""?" me-on":""}`,onClick:()=>i(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:h,onChange:y=>i(g=>({...g,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:n.title||"",onChange:y=>i(g=>({...g,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:w,onChange:y=>i(g=>({...g,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:l,onChange:y=>i(g=>({...g,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:x,onClick:S,children:t(x?"exporting":"createCard")})})]})]})]})}async function ha(t){let n=String(t||"");if(!n)return!1;try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(n),!0}catch{}try{let i=document.createElement("textarea");i.value=n,i.setAttribute("readonly",""),i.style.position="fixed",i.style.left="-9999px",i.style.top="0",document.body.appendChild(i),i.focus(),i.select();let u=!!(document.execCommand&&document.execCommand("copy"));return document.body.removeChild(i),u}catch{return!1}}function cn({t,onClose:n}){let[i,u]=(0,o.useState)(""),[p,l]=(0,o.useState)(""),[h,w]=(0,o.useState)(""),[x,A]=(0,o.useState)(!0),[S,y]=(0,o.useState)(!1),[g,D]=(0,o.useState)(""),[T,k]=(0,o.useState)(""),L=(0,o.useRef)(null),I=(0,o.useRef)(null),j=()=>{let W=L.current;if(W)try{W.focus(),W.select()}catch{}},J=W=>{D(W),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>D(""),2400)};(0,o.useEffect)(()=>{let W=!0;return fetch(q+"/diagnostics").then(b=>b.json()).then(b=>{W&&(b&&b.ok?(l(String(b.diagnostics||"")),w(String(b.version||""))):y(!0))}).catch(()=>{W&&y(!0)}).finally(()=>{W&&A(!1)}),()=>{W=!1}},[]),(0,o.useEffect)(()=>{let W=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W),I.current&&clearTimeout(I.current)}},[n]);let ne=(()=>{try{return String(navigator.language||"").toLowerCase().startsWith("en")?"en":"zh"}catch{return"zh"}})(),H=()=>{let W=i.trim().split(`
303
+ `)[0]||"",b=da({title:"[Bug] "+(W.slice(0,60)||"memory-eternal \u95EE\u9898"),body:ca({description:i,diagnostics:p,version:h})});try{window.open(b,"_blank","noopener")}catch{J(t("fbCopyFail"))}},ye=async()=>{await ha(p)?(k(""),J(t("fbCopiedDiag"))):(k(p),J(t("fbCopyManual")))},$=async()=>{let W=pa({lang:ne,description:i,diagnostics:p});await ha(W)?(k(""),J(t("fbCopiedPrompt"))):(k(W),J(t("fbCopyManual")))},Z={width:"100%",resize:"vertical",padding:"8px 10px",borderRadius:10,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"transparent",color:"inherit",font:"inherit",fontSize:13},be={margin:0,maxHeight:170,overflow:"auto",fontSize:11.5,lineHeight:1.55,padding:"8px 10px",borderRadius:10,background:"var(--dsw-alias-bg-layer-1, rgba(127,127,127,0.08))",whiteSpace:"pre-wrap"};return(0,e.jsxs)("div",{className:"me-overlay",onClick:n,children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:720},onClick:W=>W.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:["\u{1F41E} ",t("fbTitle")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:n,children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10},children:[(0,e.jsx)("div",{style:{fontSize:12,opacity:.72,lineHeight:1.6},children:t("fbWhy")}),(0,e.jsx)("textarea",{value:i,onChange:W=>u(W.target.value),placeholder:t("fbDesc"),rows:5,style:Z}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("fbDiag")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:ye,disabled:!p,children:t("fbCopyDiag")})]}),(0,e.jsx)("pre",{style:be,children:x?t("fbLoading"):S?t("fbDiagFail"):p})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",justifyContent:"flex-end"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>{if(!i.trim()){J(t("fbNeedDesc"));return}H()},style:{borderColor:"var(--dsw-alias-brand-primary, #3b82f6)",color:"var(--dsw-alias-brand-primary, #3b82f6)",fontWeight:600},children:["\u{1F680} ",t("fbOpenIssue")]}),(0,e.jsx)("span",{style:{opacity:.5,fontSize:12},children:t("fbOr")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:$,children:["\u{1F916} ",t("fbCopyPrompt")]})]}),g&&(0,e.jsx)("div",{style:{fontSize:12,color:"var(--dsw-alias-brand-primary, #3b82f6)"},children:g}),T&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12,color:"#b45309"},children:["\u26A0 ",t("fbCopyFail")]}),(0,e.jsx)("span",{style:{fontSize:11.5,opacity:.75},children:t("fbCopyManual")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:j,children:t("fbSelectAll")})]}),(0,e.jsx)("textarea",{ref:L,readOnly:!0,value:T,rows:7,style:Z})]})]})]})]})}function pn({t,card:n,query:i,onClose:u,onDelete:p,onFeedback:l}){(0,o.useEffect)(()=>{let L=I=>{I.key==="Escape"&&u()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[u]);let{meta:h,body:w}=(0,o.useMemo)(()=>Ut(n.text||""),[n.text]),x=L=>{let I=h.find(([j])=>String(j).toLowerCase()===L);return I?I[1]:""},A=ra(x("tags")),S=x("kind")||"knowledge",y=(x("status")||"approved").toLowerCase(),g=Ze[S]||"#6B7280",D=(w||"").length>460,[T,k]=(0,o.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:u,children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("div",{className:"me-dialog",onClick:L=>L.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsxs)("h3",{children:[(0,e.jsx)("span",{style:{marginRight:6},children:Ot[S]||"\u{1F4CE}"}),n.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[i&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>l&&l(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>l&&l(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),D&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":T,onClick:()=>k(L=>!L),children:t(T?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&p&&p(n.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:u,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:g,borderColor:g+"59",background:g+"1a"},children:[Ot[S]||"\u{1F4CE}"," ",t(We[S]||"kindKnowledge")]}),(0,e.jsxs)("span",{className:"md-chip "+(y==="approved"?"md-chip-st-ok":y==="pending"?"md-chip-st-warn":"md-chip-st-bad"),children:[y==="approved"?"\u2705":y==="pending"?"\u23F3":"\u26D4"," ",t(y==="approved"?"statusApproved":y==="pending"?"statusPending":"statusRejected")]}),A.slice(0,8).map(L=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",L]},L)),!!x("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",ht(x("updated"))]}),!!x("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",x("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:T?{}:{maxHeight:300,overflow:"hidden"},onClick:T?void 0:L=>{L.stopPropagation(),k(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:sa(w)}})}),!T&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:L=>{L.stopPropagation(),k(!0)},children:[t("expand")," \u2304"]})]})]})}function un({t,onOpen:n,all:i,onAllChange:u,onMutate:p,active:l,visible:h}){let[w,x]=(0,o.useState)(null),[A,S]=(0,o.useState)(""),y=(0,o.useRef)(!1),g=(0,o.useRef)(0),D=(0,o.useRef)(t);D.current=t;let T=(0,o.useCallback)(async()=>{try{y.current=!1;let j=await(await fetch(`${q}/graph${i?"?all=1":""}`)).json();j.ok?(x(j),S(""),y.current=!0):(x(null),S(j.error||t("error")))}catch(I){S(String(I&&I.message?I.message:I))}},[i,t]);(0,o.useEffect)(()=>{if(!l||y.current)return;let I=!0;return fetch(`${q}/graph${i?"?all=1":""}`).then(j=>j.json()).then(j=>{I&&(j.ok?(x(j),S(""),y.current=!0):(x(null),S(j.error||t("error"))))}).catch(j=>{I&&S(String(j&&j.message?j.message:j))}),()=>{I=!1}},[i,t,l]),(0,o.useEffect)(()=>{h&&w&&g.current++},[h,w]);let k=(0,o.useCallback)(async I=>{try{let J=await(await fetch(`${q}/delete?path=${encodeURIComponent(I)}`)).json();return J&&J.ok?(await T(),p&&p(),!0):!1}catch{return!1}},[T]),L=(0,o.useCallback)(async I=>{if(!I||I.length<2)return!1;try{let j=await fetch(`${q}/merge?paths=${encodeURIComponent(I.join(","))}`).then(J=>J.json());return j&&j.ok?(await T(),p&&p(),!0):!1}catch{return!1}},[T,p]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ae}),A&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",A]}),!w&&!A&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),w&&w.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),w&&w.nodes.length>0&&(0,e.jsx)(gn,{nodes:w.nodes,edges:w.edges,onOpen:n,onDelete:k,onMerge:L,t,all:i,onAllChange:u,countLabel:`${w.nodes.length} ${t("nodes")} \xB7 ${mn(w.edges)} ${t("edges")}`,fitTrigger:g.current})]})}function mn(t){let n=new Set;for(let i of t||[])n.add([i.source,i.target].sort().join("|"));return n.size}var yt={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 gn({nodes:t,edges:n,onOpen:i,onDelete:u,onMerge:p,t:l,countLabel:h,all:w,onAllChange:x,fitTrigger:A}){let S=(0,o.useRef)(null),y=(0,o.useRef)(null),g=(0,o.useRef)(null),D=(0,o.useRef)(null),T=(0,o.useRef)(null),k=(0,o.useRef)(i);(0,o.useEffect)(()=>{k.current=i},[i]);let L=(0,o.useRef)(u);(0,o.useEffect)(()=>{L.current=u},[u]);let I=(0,o.useRef)(p);(0,o.useEffect)(()=>{I.current=p},[p]);let[j,J]=(0,o.useState)(""),[ne,H]=(0,o.useState)(null),ye=(0,o.useRef)("");(0,o.useEffect)(()=>{ye.current=j.trim().toLowerCase()},[j]),(0,o.useEffect)(()=>{let r=g.current;if(!r)return;let s=j.trim().toLowerCase();if(!s)return;let M=r.nodes.find(Y=>(Y.name||"").toLowerCase().includes(s));M&&(g.current.selectedId=M.id,H(M.id),r.panX=r.w/2-M.x*r.zoom,r.panY=r.h/2-M.y*r.zoom,r.render&&r.render())},[j]);let[$,Z]=(0,o.useState)("all"),[be,W]=(0,o.useState)(!1),b=(0,o.useRef)("all"),[f,E]=(0,o.useState)(""),K=(0,o.useRef)(""),[_,B]=(0,o.useState)(!1),te=(0,o.useRef)(!1),[Q,le]=(0,o.useState)(null);(0,o.useEffect)(()=>{b.current=$},[$]),(0,o.useEffect)(()=>{K.current=f},[f]),(0,o.useEffect)(()=>{te.current=_},[_]);let tt=(0,o.useMemo)(()=>{let r=new Map;for(let s of t)for(let M of s.tags||[]){let Y=String(M).trim();Y&&r.set(Y,(r.get(Y)||0)+1)}return[...r.entries()].sort((s,M)=>M[1]-s[1]).slice(0,24).map(([s,M])=>({tag:s,n:M}))},[t]),at=(()=>{let r=j.trim().toLowerCase();return!!r&&!t.some(s=>(s.title||s.name||"").toLowerCase().includes(r)||String(s.kind||"").toLowerCase().includes(r)||String(We[s.kind]||"").toLowerCase().includes(r))})();(0,o.useEffect)(()=>{let r=g.current;r&&r.wake&&r.wake()},[j]),(0,o.useEffect)(()=>{let r=g.current;r&&r.render&&r.render()},[$,f,_]);let Be=(0,o.useRef)(null),[Ee,he]=(0,o.useState)([]),[xe,me]=(0,o.useState)(null),[Ne,$e]=(0,o.useState)(!1),[ze,Fe]=(0,o.useState)(null),[nt,Ye]=(0,o.useState)(""),re=(0,o.useRef)(null),ue=(0,o.useRef)(null),d=(r,s=!0)=>{re.current&&clearTimeout(re.current),Fe({msg:r,ok:s}),re.current=setTimeout(()=>Fe(null),1900)},R=r=>{Ye(r),ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>Ye(""),1600)};(0,o.useEffect)(()=>()=>{re.current&&clearTimeout(re.current),ue.current&&clearTimeout(ue.current)},[]);let P=(0,o.useMemo)(()=>t.reduce((r,s)=>(r[s.id]=s,r),{}),[t]);return(0,o.useEffect)(()=>{let r=S.current;if(!r||t.length===0)return;let s=r.getContext("2d");if(!s)return;let M=Math.max(1,window.devicePixelRatio||1),Y=()=>document.documentElement.getAttribute("data-theme")==="dark",de={};n.forEach(c=>{de[c.source]=(de[c.source]||0)+1,de[c.target]=(de[c.target]||0)+1});let Ce=Math.max(1,...Object.values(de)),a={nodes:t.map(c=>({id:c.id,name:c.title||"",type:c.kind||"other",r:9+Math.min(10,(de[c.id]||0)/Ce*8),x:0,y:0,vx:0,vy:0})),edges:n.map(c=>({sourceNodeId:c.source,targetNodeId:c.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:M,ctx:s,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((c,N)=>(c[N.id]=N,c),{}),a.nodes.forEach((c,N)=>{let C=N/a.nodes.length*Math.PI*2-Math.PI/2;c.x=Math.cos(C)*60,c.y=Math.sin(C)*60});let ct=[...new Set(a.nodes.map(c=>c.type))];a.clustered=ct.length>1,a.typeCenters={},ct.forEach((c,N)=>{let C=N/ct.length*Math.PI*2-Math.PI/2;a.typeCenters[c]={x:Math.cos(C)*160,y:Math.sin(C)*160}}),g.current=a;let vt=0,zt=0,It=()=>{let c=r.clientWidth,N=r.clientHeight;a.w=c,a.h=N,r.width=c*M,r.height=N*M,s.setTransform(M,0,0,M,0,0),(vt===0||zt===0)&&c>0&&N>0&&a.tickCount>0&&requestAnimationFrame(()=>ce()),vt=c,zt=N};It();let Dt=new ResizeObserver(It);Dt.observe(r.parentElement);let v=(c,N)=>c&&c.length>N?c.slice(0,N)+"\u2026":c,O=(c,N,C,z,F)=>{if(c.beginPath(),F==="rect")c.rect(N-z,C-z*.75,z*2,z*1.5);else if(F==="diamond")c.moveTo(N,C-z),c.lineTo(N+z,C),c.lineTo(N,C+z),c.lineTo(N-z,C),c.closePath();else if(F==="hexagon"){for(let oe=0;oe<6;oe++){let V=Math.PI/3*oe-Math.PI/2,ge=N+z*Math.cos(V),we=C+z*Math.sin(V);oe===0?c.moveTo(ge,we):c.lineTo(ge,we)}c.closePath()}else c.arc(N,C,z,0,Math.PI*2)},X=(c,N,C,z)=>O(s,c,N,C,z),Se=new Map,ve=(c,N)=>{let C=c+"|"+Math.round(N),z=Se.get(C);if(!z){let F=parseInt(c.slice(1,3),16),oe=parseInt(c.slice(3,5),16),V=parseInt(c.slice(5,7),16);z=s.createRadialGradient(-N*.3,-N*.3,0,0,0,N*1.2),z.addColorStop(0,"rgba("+Math.min(255,F+70)+","+Math.min(255,oe+70)+","+Math.min(255,V+70)+",0.95)"),z.addColorStop(1,c),Se.set(C,z)}return z},ce=()=>{if(!a.nodes.length)return;let c=1/0,N=-1/0,C=1/0,z=-1/0;a.nodes.forEach(we=>{c=Math.min(c,we.x),N=Math.max(N,we.x),C=Math.min(C,we.y),z=Math.max(z,we.y)});let F=20,oe=N-c+F*2,V=z-C+F*2,ge=Math.min(a.w/oe,a.h/V);a.zoom=Math.max(.35,Math.min(1.8,ge)),a.panX=a.w/2-(c+N)/2*a.zoom,a.panY=a.h/2-(C+z)/2*a.zoom};D.current=ce;let Ve=(c,N)=>{let C=document.createElement("canvas");return C.width=Math.max(1,Math.ceil(c)),C.height=Math.max(1,Math.ceil(N)),C},ot=new Mt({createCanvas:Ve,max:400}),Qe=new Mt({createCanvas:Ve,max:600}),Re=new Map,qe=Ve(1,1),Tt="";a.wheelUntil=0,a.createdAt=Date.now();let qt=()=>{s.clearRect(0,0,a.w,a.h),a.searchTerm=ye.current,a.kindFilter=b.current,a.timeMode=te.current,a.tagFilter=K.current;let c=a.tagFilter,N=a.kindFilter,C=m=>String(m||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");s.save(),s.strokeStyle=Y()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",s.lineWidth=.5;for(let m=0;m<a.w;m+=24)s.beginPath(),s.moveTo(m,0),s.lineTo(m,a.h),s.stroke();for(let m=0;m<a.h;m+=24)s.beginPath(),s.moveTo(0,m),s.lineTo(a.w,m),s.stroke();s.restore(),s.save(),s.translate(a.panX,a.panY),s.scale(a.zoom,a.zoom);let z={};a.nodes.forEach(m=>z[m.id]=m);let F=a.nodes.length>40,oe=F?1.5:.55,V=a.selectedId||a.hoverId,ge=ua({panX:a.panX,panY:a.panY,zoom:a.zoom,w:a.w,h:a.h,margin:80}),we=(()=>{let m=(a.searchTerm||"").toLowerCase();if(!m)return null;let G=[];for(let U of a.nodes){let pe=(a.domainById[U.id]||{}).kind||"other";if(((U.name||"").toLowerCase().includes(m)||String(We[pe]||"").toLowerCase().includes(m)||String(pe).toLowerCase().includes(m))&&G.push(U.id),G.length>200)break}return G})(),it=ga(a.nodes,{limit:ma(a.nodes.length),focusId:V,hoverId:a.hoverId,searchHits:we,degree:de}),ae=Date.now()-a.createdAt<800||a.dragging===!0||(a.wheelUntil||0)>Date.now(),ie=Y(),Ie=!a.timeMode&&!ae,_e=m=>{let G=parseInt(m.slice(1,3),16),U=parseInt(m.slice(3,5),16),ee=parseInt(m.slice(5,7),16);return"rgba("+Math.min(255,G+70)+","+Math.min(255,U+70)+","+Math.min(255,ee+70)+",0.95)"},Ue=new Map,et=(m,G)=>{let U=m+"|"+G,ee=Ue.get(U);return ee===void 0&&(s.font=m,ee=s.measureText(G).width,Ue.set(U,ee)),ee},De=a.nodes.length<=250,Xe=ya({panX:a.panX,panY:a.panY,zoom:a.zoom,w:a.w,h:a.h,dpr:M,tick:a.tickCount,filter:N+"|"+(c||"")+"|"+(a.timeMode?"t":"")+"|"+(ae?"fast":"full"),dark:ie,dataVersion:0}),Ge=qe.width!==Math.ceil(a.w*M)||qe.height!==Math.ceil(a.h*M),lt=ae||Ge||Xe!==Tt;lt&&(Tt=Xe,Ge&&(qe=Ve(a.w*M,a.h*M)));let Te=lt?qe.getContext("2d"):null;Te&&(Te.setTransform(1,0,0,1,0,0),Te.clearRect(0,0,qe.width,qe.height),Te.setTransform(M,0,0,M,0,0),Te.translate(a.panX,a.panY),Te.scale(a.zoom,a.zoom));let Ht=new Map,za=0;if(a.edges.forEach(m=>{let G=z[m.sourceNodeId],U=z[m.targetNodeId];if(!G||!U||ae&&za++%3!==0||!jt(G.x,G.y,10,ge)&&!jt(U.x,U.y,10,ge))return;if(N!=="all"){let Je=a.domainById[m.sourceNodeId]&&a.domainById[m.sourceNodeId].kind,Ke=a.domainById[m.targetNodeId]&&a.domainById[m.targetNodeId].kind;if(Je!==N&&Ke!==N)return}if(c){let Je=a.domainById[m.sourceNodeId]&&(a.domainById[m.sourceNodeId].tags||[]).includes(c),Ke=a.domainById[m.targetNodeId]&&(a.domainById[m.targetNodeId].tags||[]).includes(c);if(!Je&&!Ke)return}let ee=U.x-G.x,pe=U.y-G.y,fe=Math.sqrt(ee*ee+pe*pe)||1,je=F?12:18,Oe=-pe/fe*je,pt=ee/fe*je,ut=(G.x+U.x)/2+Oe,Bt=(G.y+U.y)/2+pt,Ct=yt.colors[a.domainById[G.id]&&a.domainById[G.id].kind||"other"],rt=V&&(m.sourceNodeId===V||m.targetNodeId===V),Wt=V?rt?.6:.08:F?.14:.24,ke=parseInt(Ct.slice(1,3),16),Me=parseInt(Ct.slice(3,5),16),st=parseInt(Ct.slice(5,7),16),dt=rt?1.6+(m.weight||1):.8+(m.weight||1)*.5,Le=ke+","+Me+","+st+","+Wt+","+dt,He=Ht.get(Le);He||(He={path:new Path2D,stroke:"rgba("+ke+","+Me+","+st+","+Wt+")",width:dt},Ht.set(Le,He)),He.path.moveTo(G.x,G.y),He.path.quadraticCurveTo(ut,Bt,U.x,U.y)}),Te&&Ht.forEach(m=>{Te.strokeStyle=m.stroke,Te.lineWidth=m.width,Te.stroke(m.path)}),s.setTransform(1,0,0,1,0,0),s.drawImage(qe,0,0),s.setTransform(M,0,0,M,0,0),V&&!ae){s.fillStyle=ie?"rgba(18,18,22,0.55)":"rgba(255,255,255,0.55)",s.fillRect(0,0,a.w,a.h);let m=new Path2D;a.edges.forEach(G=>{if(G.sourceNodeId!==V&&G.targetNodeId!==V)return;let U=z[G.sourceNodeId],ee=z[G.targetNodeId];if(!U||!ee)return;let pe=ee.x-U.x,fe=ee.y-U.y,je=Math.sqrt(pe*pe+fe*fe)||1,Oe=F?12:18,pt=-fe/je*Oe,ut=pe/je*Oe;m.moveTo(U.x,U.y),m.quadraticCurveTo((U.x+ee.x)/2+pt,(U.y+ee.y)/2+ut,ee.x,ee.y)}),s.save(),s.translate(a.panX,a.panY),s.scale(a.zoom,a.zoom),s.strokeStyle="rgba(96,165,250,0.65)",s.lineWidth=1.8,s.stroke(m),s.restore()}s.translate(a.panX,a.panY),s.scale(a.zoom,a.zoom);let kt=null;V&&(kt=new Set,a.edges.forEach(m=>{m.sourceNodeId===V?kt.add(m.targetNodeId):m.targetNodeId===V&&kt.add(m.sourceNodeId)}));let oa=[];if(a.nodes.forEach(m=>{if(!jt(m.x,m.y,m.r+2,ge))return;let G=a.domainById[m.id]||{},U=G.kind||"other",ee=a.timeMode?fn(G.updated):yt.colors[U],pe=yt.shapes[U],fe=a.selectedId===m.id,je=a.hoverId===m.id,Oe=a.searchTerm||"",pt=!Oe||(m.name||"").toLowerCase().includes(Oe)||String(We[U]||"").toLowerCase().includes(Oe)||String(U).toLowerCase().includes(Oe),ut=N==="all"||U===N,Bt=!c||(G.tags||[]).includes(c),Ct=V&&m.id!==V&&!(kt&&kt.has(m.id))||Oe&&!pt||!ut||!Bt;if(s.save(),s.globalAlpha=Ct?.08:1,(fe||je)&&De&&(s.shadowColor=ee,s.shadowBlur=fe?20:14),s.translate(m.x,m.y),ae)s.fillStyle=ee,s.beginPath(),s.arc(0,0,Math.max(2,m.r*.55),0,Math.PI*2),s.fill();else if(Ie){let ke=Math.ceil(m.r*2+6),Me=Math.max(1,Math.min(3,Math.round(a.zoom*M))),st=fa({kind:U,radius:m.r,zoom:a.zoom,dark:ie}),dt=ot.get(st,ke*Me,ke*Me,(Le,He)=>{let Je=He/ke,Ke=He/2;Le.setTransform(Je,0,0,Je,Ke,Ke),O(Le,0,0,m.r,pe);let St=Le.createRadialGradient(-m.r*.3,-m.r*.3,0,0,0,m.r*1.2);St.addColorStop(0,_e(ee)),St.addColorStop(1,ee),Le.fillStyle=St,Le.fill()});s.drawImage(dt.canvas,-ke/2,-ke/2,ke,ke)}else X(0,0,m.r,pe),s.fillStyle=ve(ee,m.r),s.fill();s.restore(),fe?(s.save(),X(m.x,m.y,m.r+3,pe),s.strokeStyle=ee,s.lineWidth=3,s.shadowColor=ee,s.shadowBlur=12,s.stroke(),s.restore()):je?(s.save(),X(m.x,m.y,m.r+2,pe),s.strokeStyle=ee,s.lineWidth=2,s.stroke(),s.restore()):Oe&&pt?(s.save(),X(m.x,m.y,m.r+2,pe),s.strokeStyle="#e11d48",s.lineWidth=2,s.stroke(),s.restore()):a.multi.indexOf(m.id)>=0&&(s.save(),X(m.x,m.y,m.r+2,pe),s.strokeStyle="#60a5fa",s.lineWidth=2,s.shadowColor="#60a5fa",s.shadowBlur=8,s.stroke(),s.restore());let rt=v(m.name,16);if(!ae&&(fe||je||it.has(m.id)&&a.zoom>oe||!F&&a.zoom>.6)&&ut&&Bt){let ke=1/a.zoom,Me=Math.max(1,Math.min(4,Math.round(ke*M))),st="500 "+(12*Me).toFixed(0)+"px -apple-system,Segoe UI,sans-serif",dt=rt+"|"+Me,Le=Re.get(dt);Le===void 0&&(s.font=st,Le=s.measureText(rt).width,Re.set(dt,Le));let He=Math.ceil(Le+16*Me),Je=Math.ceil(18*Me),Ke=fe||je,St=ba({text:rt,fontPx:12,dark:ie})+(Ke?"|sel":""),Ia=Qe.get(St,He,Je,(se,Pt,Et)=>{se.setTransform(1,0,0,1,0,0),se.clearRect(0,0,Pt,Et),se.font=st,se.textAlign="center",se.textBaseline="middle",se.fillStyle=ie?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",se.beginPath(),se.roundRect?se.roundRect(.5,.5,Pt-1,Et-1,4*Me):se.rect(.5,.5,Pt-1,Et-1),se.fill(),se.strokeStyle=ie?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",se.lineWidth=Math.max(1,Me),se.stroke(),se.fillStyle=ie?Ke?"#eee":"#bbb":Ke?"#111":"#444",se.fillText(rt,Pt/2,Et/2+.5)}),mt=He/Me*ke,$t=Je/Me*ke,Rt=m.y+m.r+8*ke,ia=!0;for(let se of oa)if(m.x-mt/2<se.x+se.w&&m.x+mt/2>se.x&&Rt<se.y+se.h&&Rt+$t>se.y){ia=!1;break}if(!ia&&!fe&&!je)return;oa.push({x:m.x-mt/2,y:Rt,w:mt,h:$t}),s.drawImage(Ia.canvas,m.x-mt/2,Rt,mt,$t)}}),s.restore(),a.marquee){let m=a.marquee,G=Math.min(m.sx,m.ex),U=Math.min(m.sy,m.ey),ee=Math.abs(m.ex-m.sx),pe=Math.abs(m.ey-m.sy);s.save(),s.setLineDash([4,4]),s.strokeStyle="rgba(96,165,250,0.9)",s.lineWidth=1,s.fillStyle="rgba(96,165,250,0.12)",s.fillRect(G,U,ee,pe),s.strokeRect(G,U,ee,pe),s.restore()}if(a.hoverId&&Be.current){let m=a.domainById[a.hoverId],G=a.nodes.find(function(U){return U.id===a.hoverId});if(m&&G){let U=a.edges.filter(function(fe){return fe.sourceNodeId===m.id||fe.targetNodeId===m.id}).length,ee=G.x*a.zoom+a.panX,pe=G.y*a.zoom+a.panY;Be.current.style.display="block",Be.current.style.left=ee+14+"px",Be.current.style.top=pe-6+"px",Be.current.innerHTML="<b>"+C(m.title||m.name||"")+'</b><br/><span style="opacity:.8">'+C(m.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",U)+"</span>"}}else Be.current&&(Be.current.style.display="none")},Pe=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Gt))};a.wake=Pe,a.render=qt;let Xt=()=>{let c=a.nodes.length;a.tickCount++;let C=.9-Math.min(.4,a.tickCount/1500),z=c>1e3?3e3:c>100?2e3:c>50?1200:800,F=c>100?.002:.005,oe=c>1e3?.012:c>100?.005:.01,V=c>1e3?6:c>200?12:24,ge={};a.nodes.forEach(ae=>ge[ae.id]=ae);for(let ae=0;ae<c;ae++){if(a.dragNode===a.nodes[ae])continue;let ie=a.nodes[ae],Ie=0,_e=0;for(let De=0;De<c;De++){if(ae===De)continue;let Xe=ie.x-a.nodes[De].x,Ge=ie.y-a.nodes[De].y,lt=Math.sqrt(Xe*Xe+Ge*Ge)||1,Te=z/(lt*lt);Ie+=Xe/lt*Te,_e+=Ge/lt*Te}if(a.clustered&&a.typeCenters[ie.type]){let De=a.typeCenters[ie.type];Ie+=(De.x-ie.x)*.006,_e+=(De.y-ie.y)*.006}else Ie-=ie.x*oe,_e-=ie.y*oe;let Ue=(ie.vx+Ie)*C,et=(ie.vy+_e)*C;Ue=Math.max(-V,Math.min(V,Ue)),et=Math.max(-V,Math.min(V,et)),ie.vx=Ue,ie.vy=et}a.edges.forEach(ae=>{let ie=ge[ae.sourceNodeId],Ie=ge[ae.targetNodeId];if(!ie||!Ie)return;let _e=Ie.x-ie.x,Ue=Ie.y-ie.y,et=Math.sqrt(_e*_e+Ue*Ue)||1,De=(et-100)*F,Xe=_e/et*De,Ge=Ue/et*De;a.dragNode!==ie&&(ie.vx+=Xe,ie.vy+=Ge),a.dragNode!==Ie&&(Ie.vx-=Xe,Ie.vy-=Ge)});let we=0;a.nodes.forEach(ae=>{a.dragNode!==ae&&(ae.x+=ae.vx,ae.y+=ae.vy,we+=ae.vx*ae.vx+ae.vy*ae.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,ce()),(c?Math.sqrt(we/c):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Gt=()=>{if(a.running){try{Xt(),qt()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Gt)}},wt=(c,N)=>{let C=r.getBoundingClientRect();return{x:(c-C.left-a.panX)/a.zoom,y:(N-C.top-a.panY)/a.zoom}},Lt=c=>{let N=a.domainById[c];return!(!N||b.current!=="all"&&N.kind!==b.current||K.current&&!(N.tags||[]).includes(K.current))},At=(c,N,C)=>Math.max(N,Math.min(C,c)),Jt=c=>{a.mouseX=c.clientX,a.mouseY=c.clientY;let N=wt(c.clientX,c.clientY),C=null;for(let z=a.nodes.length-1;z>=0;z--){let F=a.nodes[z];if(!Lt(F.id))continue;let oe=F.x-N.x,V=F.y-N.y;if(oe*oe+V*V<F.r*F.r+36){C=F.id;break}}C!==a.hoverId&&(a.hoverId=C,Pe())},Zt=c=>{if(c.button!==0)return;let N=wt(c.clientX,c.clientY),C=null;for(let z=a.nodes.length-1;z>=0;z--){let F=a.nodes[z];if(!Lt(F.id))continue;let oe=F.x-N.x,V=F.y-N.y;if(oe*oe+V*V<F.r*F.r+25){C=F;break}}if(c.shiftKey){if(C){a.shiftClick=C.id;return}a.marquee={sx:c.clientX,sy:c.clientY,ex:c.clientX,ey:c.clientY};return}a.dragStart={x:c.clientX,y:c.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=C||null,C&&(a.dragOffset={dx:C.x-N.x,dy:C.y-N.y})},Qt=c=>{if(a.marquee){a.marquee.ex=c.clientX,a.marquee.ey=c.clientY,Pe();return}if(!a.dragStart)return;let N=c.clientX-a.dragStart.x,C=c.clientY-a.dragStart.y;if(Math.abs(N)+Math.abs(C)>3&&(a.dragging=!0),a.dragNode){let z=wt(c.clientX,c.clientY);a.dragNode.x=z.x+a.dragOffset.dx,a.dragNode.y=z.y+a.dragOffset.dy,Pe()}else a.dragging&&(a.panX=At(a.dragStart.px+N,-1e5,1e5),a.panY=At(a.dragStart.py+C,-1e5,1e5),Pe())},ea=c=>{if(a.marquee){let C=a.marquee;a.marquee=null;let z=r.getBoundingClientRect(),F=Math.min(C.sx,C.ex)-z.left,oe=Math.max(C.sx,C.ex)-z.left,V=Math.min(C.sy,C.ey)-z.top,ge=Math.max(C.sy,C.ey)-z.top,we=a.nodes.filter(it=>{let ae=it.x*a.zoom+a.panX,ie=it.y*a.zoom+a.panY;return ae>=F&&ae<=oe&&ie>=V&&ie<=ge}).map(it=>it.id);a.multi=we,he(we),Pe();return}let N=a.dragStart&&!a.dragging;if(a.shiftClick){let C=a.shiftClick;a.shiftClick=null;let z=Array.isArray(a.multi)?a.multi.slice():[];z.includes(C)||z.push(C),a.multi=z,he(z),Pe();return}if(N){let C=wt(c.clientX,c.clientY),z=null;for(let F=a.nodes.length-1;F>=0;F--){let oe=a.nodes[F];if(!Lt(oe.id))continue;let V=oe.x-C.x,ge=oe.y-C.y;if(V*V+ge*ge<oe.r*oe.r+20){z=oe;break}}z?(a.selectedId=z.id,H(z.id),Pe()):(a.selectedId=null,a.hoverId=null,c.shiftKey||(a.multi=[],he([])),H(null),Pe())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ta=c=>{c.preventDefault();let N=wt(c.clientX,c.clientY),C=null;for(let z=a.nodes.length-1;z>=0;z--){let F=a.nodes[z];if(!Lt(F.id))continue;let oe=F.x-N.x,V=F.y-N.y;if(oe*oe+V*V<F.r*F.r+25){C=F;break}}if(C){let z=a.domainById[C.id];z&&le({x:c.clientX,y:c.clientY,id:C.id,path:z.id,title:z.title})}else le(null)},aa=c=>{c.preventDefault(),a.wheelUntil=Date.now()+160;let N=r.getBoundingClientRect(),C=(c.clientX-N.left-a.panX)/a.zoom,z=(c.clientY-N.top-a.panY)/a.zoom,F=Math.max(.3,Math.min(3,a.zoom*(c.deltaY<0?1.1:1/1.1)));a.panX=At(a.panX+C*(a.zoom-F),-1e5,1e5),a.panY=At(a.panY+z*(a.zoom-F),-1e5,1e5),a.zoom=F,Pe()};r.addEventListener("mousemove",Jt),r.addEventListener("mousedown",Zt),window.addEventListener("mousemove",Qt),window.addEventListener("mouseup",ea),r.addEventListener("wheel",aa,{passive:!1}),r.addEventListener("contextmenu",ta),T.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],he([]),ce(),Pe()};for(let c=0;c<200;c++)Xt();ce(),Pe();let na=()=>W(!1);return window.addEventListener("mousedown",na),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),Dt.disconnect(),r.removeEventListener("mousemove",Jt),r.removeEventListener("mousedown",Zt),window.removeEventListener("mousemove",Qt),window.removeEventListener("mouseup",ea),r.removeEventListener("wheel",aa),r.removeEventListener("contextmenu",ta),window.removeEventListener("mousedown",na)}},[t,n]),(0,o.useEffect)(()=>{A!==void 0&&D.current&&requestAnimationFrame(()=>D.current())},[A]),(0,e.jsxs)("div",{className:"me-graph",ref:y,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",l("nodes")," \xB7 ",n.length," ",l("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:l("search"),value:j,onChange:r=>J(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>W(r=>!r),"aria-expanded":be,title:l("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",l("filterLabel")," ",$!=="all"||_||f?"\u25CF":"\u25BE"]}),be&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${$==="all"&&!_?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{Z("all"),B(!1)},children:l("all")}),Object.keys(Ze).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${$===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>Z(s=>s===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:yt.colors[r]||Ze[r]}}),l(We[r])]},r)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${_?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>B(r=>!r),children:["\u23F1 ",l("timeDim")]}),tt.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:tt.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${f===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>E(s=>s===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),($!=="all"||_||f)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{Z("all"),B(!1),E("")},children:[l("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:l("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!w,onChange:r=>x&&x(r.target.checked)}),l("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${_?" me-on":""}`,onClick:()=>B(r=>!r),children:l("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=S.current;if(r)try{r.toBlob(s=>{s&&me({url:URL.createObjectURL(s),blob:s})},"image/png")}catch{}},children:l("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>D.current&&D.current(),children:l("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{H(null),Z("all"),T.current&&T.current()},children:l("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:S,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Be,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)"}}),at&&(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:l("noMatch")}),Q&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>le(null)}),Q&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:Q.x,top:Q.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{k.current({path:Q.path,title:Q.title}),le(null)},children:l("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Q.id&&(g.current.selectedId=Q.id,H(Q.id)),le(null);let r=g.current;r&&r.wake&&r.wake()},children:l("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(Q.title||"")}catch{}le(null),d(l("copied"))},children:l("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=g.current,s=r&&Array.isArray(r.multi)?r.multi.slice():[],M=Q.id;if(M&&!s.includes(M)&&s.push(M),le(null),s.length<2){d(l("mergeNeed"),!1);return}if(!window.confirm(l("mergeConfirm")))return;let Y=I.current&&I.current(s);Y&&Y.then?Y.then(de=>de?d(l("merged")):d(l("mergeFail"),!1)).catch(()=>d(l("mergeFail"),!1)):Y&&d(l("merged"))},children:l("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Q.path;le(null),window.confirm(l("deleteConfirm"))&&(async()=>{try{(L.current?await L.current(r):!1)?d(l("deleted")):d(l("deleteFail"),!1)}catch{d(l("deleteFail"),!1)}})()},children:l("delete")})]}),Ee.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:[Ee.length," ",l("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let s=Ee.map(Ce=>P[Ce]).filter(Boolean).map(Ce=>Ce.title||Ce.name).join(`
304
+ `),M=new Blob([s],{type:"text/plain;charset=utf-8"}),Y=URL.createObjectURL(M),de=document.createElement("a");de.href=Y,de.download="memory-selected.txt",document.body.appendChild(de),de.click(),document.body.removeChild(de),setTimeout(()=>URL.revokeObjectURL(Y),1e3),d(Ee.length+l("exportedSel"))},children:l("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(Ee.length<2){d(l("mergeNeed"),!1);return}let r=Ee.map(M=>P[M]?P[M].id:M);if(!window.confirm(l("mergeConfirm")))return;he([]);let s=g.current;s&&(s.multi=[]),fetch(`${q}/merge?paths=${encodeURIComponent(r.join(","))}`).then(M=>M.json()).then(M=>{M&&M.ok?d(l("merged")):d(l("mergeFail"),!1)}).catch(()=>d(l("mergeFail"),!1))},children:l("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(l("deleteConfirm")))return;let r=Ee.map(M=>P[M]?P[M].id:M);he([]);let s=g.current;s&&(s.multi=[]),(async()=>{let M=0;for(let Y of r)try{(L.current?await L.current(Y):!1)&&M++}catch{}d(M+l("deletedSelected"),M>0)})()},children:l("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=g.current;r&&(r.multi=[]),he([]);let s=g.current;s&&s.render&&s.render()},children:l("clearSelection")})]}),ne&&(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:P[ne]?P[ne].title||P[ne].name:ne}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:P[ne]?l(We[P[ne].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:l("graphHint")}),(n.filter(r=>r.source===ne||r.target===ne)||[]).slice(0,8).map((r,s)=>{let M=r.source===ne?r.target:r.source,Y=P[M];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:de=>{de.preventDefault();let Ce=g.current;Ce&&(Ce.selectedId=M,Ce.hoverId=M,Ce.wake&&Ce.wake()),H(M)},children:Y?(Y.title||Y.name).slice(0,28):M},s)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:l("graphTip")}),ze&&(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 "+(ze.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ze.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ze.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ze.msg})]}),xe&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{xe.url&&URL.revokeObjectURL(xe.url),me(null),$e(!1)},children:[(0,e.jsx)("style",{children:Ae}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:Ne?"100vw":900,width:Ne?"100vw":"92vw",maxHeight:Ne?"100%":"90vh",height:Ne?"100%":void 0,borderRadius:Ne?0:14},onClick:r=>r.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:xe.url,download:"memory-graph.png",onClick:()=>{R("download"),d(l("downloaded")+" \xB7 "+l("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:l(nt==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{R("full"),$e(r=>!r),d(l("fullscreen"))},children:l(nt==="full"?"done":Ne?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=xe.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{R("copy"),d(l("copied"))}).catch(()=>{d(l("copyFail"),!1)}):d(l("copyFail"),!1)},children:l(nt==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{xe.url&&URL.revokeObjectURL(xe.url),me(null),$e(!1)},children:l("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:Ne?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:xe.url,alt:l("exportGraph"),style:{maxWidth:"100%",maxHeight:Ne?"calc(100% - 64px)":"70vh",borderRadius:Ne?0:8,cursor:"zoom-in"},onClick:()=>$e(r=>!r)})})]})]})]})}function fn(t){let n=new Date(t||0).getTime();if(!n)return"#94a3b8";let i=(Date.now()-n)/864e5;return i<3?"#10b981":i<14?"#f59e0b":i<30?"#f97316":"#94a3b8"}function xa({label:t,value:n=[],options:i,onChange:u,placeholder:p,z:l=20}){let[h,w]=(0,o.useState)(!1),x=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!h)return;let k=L=>{x.current&&!x.current.contains(L.target)&&w(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[h]);let A=Array.isArray(n)?n:[],S=A.includes("__all__"),y=S?i.find(k=>k.value==="__all__")?.label||"":A.length?A.map(k=>i.find(L=>L.value===k)?.label||k).join("\u3001"):"",g=(k,L)=>{if(k.value==="__all__"){u(L?["__all__"]:[]);return}let I=new Set(A);I.has("__all__")&&I.delete("__all__"),L?I.add(k.value):I.delete(k.value),u([...I])},D=i.find(k=>k.value==="__all__"),T=i.filter(k=>k.value!=="__all__");return(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t}),(0,e.jsxs)("div",{ref:x,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>w(k=>!k),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||p||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),h&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:l,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[D&&(0,e.jsxs)("label",{onClick:k=>k.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("input",{type:"checkbox",checked:S,onChange:k=>g(D,k.target.checked)}),(0,e.jsx)("span",{children:D.label})]}),T.map(k=>(0,e.jsxs)("label",{onClick:L=>L.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:A.includes(k.value),onChange:L=>g(k,L.target.checked)}),(0,e.jsx)("span",{children:k.label})]},k.value))]})]})]})}function bn(t){let n=new Date(t||0).getTime();return!!n&&(Date.now()-n)/864e5<3}async function yn(t,n,i){if(i&&typeof window.showSaveFilePicker=="function")try{let l=await window.showSaveFilePicker({suggestedName:n}),h=await l.createWritable();return await h.write(t),await h.close(),{ok:!0,picked:!0,name:l.name}}catch(l){return l&&l.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(l.message||l)}}let u=URL.createObjectURL(t),p=document.createElement("a");return p.href=u,p.download=n,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(u),1e3),{ok:!0,picked:!1,name:n}}function va(t,n){if(!n||!t)return t;let i=t.toLowerCase(),u=n.toLowerCase(),p=[],l=0;for(;l<t.length;){let h=i.indexOf(u,l);if(h<0){p.push(t.slice(l));break}h>l&&p.push(t.slice(l,h)),p.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(h,h+u.length)},h)),l=h+u.length}return p}function ht(t){if(!t)return"";let n=new Date(t);if(Number.isNaN(n.getTime()))return"";let i=new Date,u=n.toDateString()===i.toDateString(),p=h=>String(h).padStart(2,"0"),l=`${p(n.getHours())}:${p(n.getMinutes())}`;return u?l:`${n.getMonth()+1}-${n.getDate()} ${l}`}
305
305
 
306
306
  return module.exports;
307
307
  },