memory-eternal 0.9.8 → 0.9.10

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,12 +3,12 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
- var Et=Object.create;var pt=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var Ht=(t,l)=>{for(var s in l)pt(t,s,{get:l[s],enumerable:!0})},zt=(t,l,s,f)=>{if(l&&typeof l=="object"||typeof l=="function")for(let c of Pt(l))!Wt.call(t,c)&&c!==s&&pt(t,c,{get:()=>l[c],enumerable:!(f=$t(l,c))||f.enumerable});return t};var _t=(t,l,s)=>(s=t!=null?Et(Ot(t)):{},zt(l||!t||!t.__esModule?pt(s,"default",{value:t,enumerable:!0}):s,t)),Ut=t=>zt(pt({},"__esModule",{value:!0}),t);var xa={};Ht(xa,{EN:()=>Dt,MemoryLibrary:()=>la,ZH:()=>At,apply:()=>ta,inject:()=>Zt});module.exports=Ut(xa);var n=_t(require("react"),1);var Kt={"&":"&amp;","<":"&lt;",">":"&gt;"},ft=t=>String(t).replace(/[&<>]/g,l=>Kt[l]),Yt=[[/结论|总结|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"]],qt=["\u2728","info"],Xt=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],Vt=t=>{let l=String(t);for(let[s,f,c]of Yt)if(s.test(l))return[f,c];return qt},Gt=t=>{let l=t.join(" ");for(let[s,f,c]of Xt)if(s.test(l))return[f,c];return["\u{1F4CC}","info"]};function Ge(t){let l=String(t),s=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(l);if(s&&!/[是为有了吗呢着过把被和与或于]/.test(s[1]))return'<span class="md-kv"><span class="md-k">'+ft(s[1])+'</span><span class="md-v">'+Ge(s[2])+"</span></span>";let f=ft(l);return f=f.replace(/^\[([ xX])\](?=\s|$)\s*/,(c,i)=>'<span class="md-task">'+(i.toLowerCase()==="x"?"\u2611":"\u2610")+"</span> "),f=f.replace(/`([^`\n]+)`/g,'<code class="md-code">$1</code>'),f=f.replace(/\*\*([^*]+)\*\*/g,'<strong class="md-b">$1</strong>'),f=f.replace(/(^|[^*])\*([^*\n]+)\*/g,"$1<em>$2</em>"),f=f.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(c,i,k)=>/^(https?:|\/|#)/i.test(k)?'<a class="md-link" href="'+k+'" target="_blank" rel="noopener noreferrer">'+i+"</a>":i),f}function bt(t){let l=String(t||"").replace(/\r\n?/g,`
7
- `),s=/^---\n([\s\S]*?)\n---\n?/.exec(l);if(!s)return{meta:[],body:l};let f=[];for(let c of s[1].split(`
8
- `)){let i=c.indexOf(":");if(i<=0)continue;let k=c.slice(0,i).trim(),x=c.slice(i+1).trim().replace(/^["']|["']$/g,"");k&&f.push([k,x])}return{meta:f,body:l.slice(s[0].length)}}function It(t){let l=String(t||"").trim().replace(/^\[|\]$/g,"");return l?l.split(",").map(s=>s.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function Lt(t){let l=bt(String(t||"").replace(/\r\n?/g,`
9
- `)).body;if(!l.trim())return"";let s=[],f=l.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(y,B,z)=>(s.push('<pre class="md-pre"><code>'+ft(z.replace(/\n$/,""))+"</code></pre>"),"\0F"+(s.length-1)+"\0")),c=[],i=[],k=null,x=null,N=()=>{i.length&&(c.push('<p class="md-p">'+i.join("<br/>")+"</p>"),i=[])},L=()=>{if(!k)return;let y=k.type;c.push("<"+y+' class="md-'+y+'">'+k.items.map(B=>"<li>"+B+"</li>").join("")+"</"+y+">"),k=null},C=()=>{if(!x)return;let[y,B]=Gt(x);c.push('<div class="md-callout md-c-'+B+'"><span class="md-ico">'+y+"</span>"+x.join("<br/>")+"</div>"),x=null},b=()=>{N(),L(),C()};for(let y of f.split(`
10
- `)){let B=y.trim();if(!B){b();continue}let z=/^\u0000F(\d+)\u0000$/.exec(B);if(z){b(),c.push(s[Number(z[1])]);continue}let v;if(v=/^(#{1,6})\s+(.+)$/.exec(B)){b();let[I,S]=Vt(v[2]);c.push('<div class="md-h md-h-'+(v[1].length<=2?"h1":"h2")+" md-c-"+S+'"><span class="md-ico">'+I+'</span><span class="md-hx">'+Ge(v[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(B)){b(),c.push('<hr class="md-hr"/>');continue}if(v=/^>\s?(.*)$/.exec(B)){N(),L(),x=x||[],x.push(Ge(v[1]));continue}if(v=/^[-*+]\s+(.+)$/.exec(B)){N(),C(),(!k||k.type!=="ul")&&(L(),k={type:"ul",items:[]}),k.items.push(Ge(v[1]));continue}if(v=/^\d+[.)]\s+(.+)$/.exec(B)){N(),C(),(!k||k.type!=="ol")&&(L(),k={type:"ol",items:[]}),k.items.push(Ge(v[1]));continue}L(),C(),i.push(Ge(B))}return b(),c.join(`
11
- `)}var e=require("react/jsx-runtime"),Je="memory-eternal",_="/memory-eternal/api",Jt=100,Zt=["slots","locale"],At={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",enterFullscreen:"\u5168\u5C4F",exitFullscreen:"\u9000\u51FA\u5168\u5C4F",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",oneClickOptimize:"\u4E00\u952E\u4F18\u5316",oneClickOptimizeConfirm:"\u786E\u8BA4\u4E00\u952E\u4F18\u5316\uFF1F\u5C06\u5408\u5E76\u6240\u6709\u76F8\u4F3C\u5361\u5BF9\uFF08\u9ED8\u8BA4\u4E0D\u6E05\u7406\u9648\u65E7\u5361\uFF09\u3002",oneClickAlsoStale:"\u540C\u65F6\u6E05\u7406\u9648\u65E7\u5361",oneClickOptimizeDone:"\u4E00\u952E\u4F18\u5316\u5B8C\u6210",optimizedMerged:"\u5BF9\u5DF2\u5408\u5E76",optimizedStaleDeleted:"\u5F20\u9648\u65E7\u5361\u5DF2\u6E05\u7406",mcpSetupStatus:"Agent MCP \u6302\u8F7D\u72B6\u6001",rerunSetup:"\u8865\u5168 MCP",notInstalled:"\u672A\u5B89\u88C5",noMcpEntry:"\u914D\u7F6E\u7F3A\u5931",nodePathMismatch:"node \u8DEF\u5F84\u4E0D\u4E00\u81F4\uFF0C\u5EFA\u8BAE\u91CD\u8DD1 setup",nodePathNote:"node \u73AF\u5883\u4E0D\u540C\uFF08\u53EF\u7528\uFF09",healthy:"\u914D\u7F6E\u6B63\u5E38",mcpSetupHint:"\u300C\u81EA\u52A8\u6302\u8F7D MCP\u300D= \u8BA9 Claude Code / Codex / Cursor \u8FD9\u4E9B\u5DE5\u5177\u80FD\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002\u5F00\u542F\u540E\u81EA\u52A8\u628A\u5B83\u4EEC\u914D\u7F6E\u597D\uFF1B\u5173\u6389\u5C31\u4E0D\u52A8\u4F60\u7535\u8111\u4E0A\u4EFB\u4F55\u914D\u7F6E\u6587\u4EF6\uFF0C\u9700\u8981\u65F6\u624B\u52A8\u8DD1 dsh-memory setup\u3002",mcpManageHint:"\u6BCF\u4E2A agent \u7528\u4E0B\u65B9\u6309\u94AE\u5355\u72EC\u5B89\u88C5/\u5378\u8F7D MCP",tabConfig:"\u8BB0\u5FC6\u914D\u7F6E",tabAudit:"\u5BA1\u6838\u4E2D\u5FC3",statusApproved:"\u5DF2\u5BA1\u6838",statusPending:"\u5F85\u5BA1\u6838",statusRejected:"\u5DF2\u9A73\u56DE",allStatus:"\u5168\u90E8\u72B6\u6001",tabRecycle:"\u56DE\u6536\u4E2D\u5FC3",pending:"\u5F85\u5BA1\u6838",rejected:"\u5DF2\u9A73\u56DE",selectAll:"\u5168\u9009",approve:"\u6279\u51C6",reject:"\u9A73\u56DE",allAgents:"\u5168\u90E8\u667A\u80FD\u4F53",noAuditItems:"\u6682\u65E0\u5BA1\u6838\u9879\u76EE",deletedAt:"\u5220\u9664\u4E8E",restore:"\u6062\u590D",restoreDelete:"\u5220\u9664\u8FDB\u56DE\u6536\u7AD9",purge:"\u6C38\u4E45\u5220\u9664",emptyRecycle:"\u56DE\u6536\u7AD9\u4E3A\u7A7A",recycleHint:"\u5220\u9664\u7684\u5361\u7247\u5148\u8FDB\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF0C\u8D85\u671F\u81EA\u52A8\u6C38\u4E45\u5220\u9664",purgeConfirm:"\u786E\u5B9A\u6C38\u4E45\u5220\u9664\uFF1F\u4E0D\u53EF\u6062\u590D\u3002",recycleDeleteConfirm:"\u786E\u5B9A\u5220\u9664\u8FDB\u56DE\u6536\u7AD9\uFF1F30 \u5929\u5185\u53EF\u6062\u590D\u3002",modeInit:"\u542F\u52A8\u65F6\u62C9\u4E00\u6B21",modeInterval:"\u5468\u671F\u4FDD\u6D3B",modeManual:"\u4EC5\u624B\u52A8",serviceConfig:"\u670D\u52A1\u81EA\u7BA1\u7406\u914D\u7F6E",auditConfig:"\u81EA\u52A8\u5BA1\u6838\u914D\u7F6E",auditHint:"\u547D\u4E2D\u514D\u5BA1\u7684\u65B0\u5361\u76F4\u63A5\u5165\u5E93\uFF0C\u5176\u4F59\u8FDB\u5F85\u5BA1\u6838",auditMode:"\u5BA1\u6838\u6A21\u5F0F",auditAll:"\u5168\u90E8\u8981\u5BA1\u6838",auditNone:"\u5168\u90E8\u514D\u5BA1",auditExemptAgents:"\u514D\u5BA1\u667A\u80FD\u4F53",auditExemptKinds:"\u514D\u5BA1\u7C7B\u578B",allExempt:"\u5168\u90E8\u514D\u5BA1",recycleDays:"\u56DE\u6536\u4FDD\u7559\u5929\u6570",editInSetting:"\u7F16\u8F91\u8BF7\u5230 DSH \u8BBE\u7F6E \u2192 \u8BB0\u5FC6",setupRunInTerminal:"\u8BF7\u590D\u5236\u4EE5\u4E0B\u547D\u4EE4\u5230\u7EC8\u7AEF\u6267\u884C\uFF1A",dshMemoryConfig:"DSH \u8BB0\u5FC6\u914D\u7F6E",autoCapture:"\u81EA\u52A8\u6C89\u6DC0",autoRecall:"\u81EA\u52A8\u53EC\u56DE",captureMinChars:"\u6355\u83B7\u6700\u5C0F\u957F\u5EA6",maxCardsPerDay:"\u65E5\u914D\u989D",dedupThreshold:"\u53BB\u91CD\u9608\u503C",recallLimit:"\u53EC\u56DE\u6761\u6570",recallSummaryLen:"\u53EC\u56DE\u6458\u8981\u957F\u5EA6",recallBody:"\u53EC\u56DE\u542B\u6B63\u6587",autoWeb:"Web server",autoWebMode:"\u4FDD\u6D3B\u6A21\u5F0F",webPort:"Web \u7AEF\u53E3",webCheckIntervalMs:"\u63A2\u6D3B\u95F4\u9694(ms)",webMaxRestart:"\u6700\u5927\u91CD\u542F\u6B21\u6570",watchdogAutoSpawn:"\u770B\u95E8\u72D7\u8FDB\u7A0B",autoMcpSetup:"\u81EA\u52A8\u6302\u8F7D MCP",saveConfig:"\u4FDD\u5B58\u914D\u7F6E",saveFail:"\u4FDD\u5B58\u5931\u8D25",savedOk:"\u5DF2\u4FDD\u5B58",recallTool:"recall \u5DE5\u5177",costControl:"\u6210\u672C\u63A7\u5236",costHint:"\u7701 token\u3001\u63A7 LLM \u6D88\u8017",distillEnabled:"\u84B8\u998F\u77E5\u8BC6\u5361(\u5F00=LLM \u538B\u7F29, \u5173=\u539F\u6587\u5361\u96F6 LLM)",dedupByLLM:"\u8BED\u4E49\u53BB\u91CD\u5582 LLM(\u5173=\u7EAF\u8BCD\u6CD5\u66F4\u7701)",captureMaxTokens:"\u84B8\u998F\u8F93\u51FA\u4E0A\u9650(token)",recallMinScore:"\u53EC\u56DE\u76F8\u5173\u6027\u9608\u503C(\u8D8A\u9AD8\u8D8A\u7701)",configNeedsDsh:"\u914D\u7F6E\u7F16\u8F91\u9700\u5728 DSH \u5185\u6253\u5F00\uFF08\u672C\u9875\u53EF\u80FD\u53EA\u8BFB\u6216\u6709\u90E8\u5206\u7F3A\u5931\uFF09",installMcp:"\u5B89\u88C5 MCP",uninstallMcp:"\u5378\u8F7D MCP",uninstallConfirm:"\u786E\u8BA4\u5378\u8F7D\u8BE5\u667A\u80FD\u4F53\u7684 MCP\uFF1FClaude Code/Codex \u5C06\u65E0\u6CD5\u518D\u8C03\u7528\u8BB0\u5FC6\u5E93\u3002",presetConfig:"\u4E00\u952E\u63A8\u8350\u914D\u7F6E",presetHint:"\u70B9\u51FB\u586B\u5145\u5BF9\u5E94\u65B9\u6848\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548",planA:"A \u8F7B\u91CF\u7701\u5FC3",planB:"B \u6781\u81F4\u7701\u94B1",planC:"C \u9AD8\u8D28\u91CF",pluginInfo:"\u63D2\u4EF6\u4FE1\u606F",organizeTitle:"\u6574\u7406\u5EFA\u8BAE",scanAndOrganize:"\u4E00\u952E\u641C\u7D22\u548C\u6574\u7406",scanHint:"\u70B9\u300C\u{1F50D} \u4E00\u952E\u641C\u7D22\u548C\u6574\u7406\u300D\u626B\u63CF\u76F8\u4F3C\u5361/\u9648\u65E7\u5361\uFF0C\u518D\u7528\u300C\u26A1 \u4E00\u952E\u4F18\u5316\u300D\u6267\u884C\u3002",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",captureAlert:"\u81EA\u52A8\u6C89\u6DC0\u5F02\u5E38",captureAlertHint:"\u6253\u5F00\u5DE6\u680F\u300C\u7528\u91CF/\u4ECA\u65E5\u300D\u770B\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7\uFF1B\u82E5\u662F\u63A5\u53E3/\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u9700\u66F4\u65B0 memory-eternal \u63D2\u4EF6\u3002",captureLog:"\u81EA\u52A8\u6C89\u6DC0\u65E5\u5FD7",captureLogHint:"\u6BCF\u8F6E\u5BF9\u8BDD\u7ED3\u675F\u540E\u81EA\u52A8\u8DD1\uFF1A\u76D1\u542C \u2192 \u5224\u5B9A \u2192 \u5199\u5361\u3002\u8FD9\u91CC\u663E\u793A\u6700\u8FD1 100 \u6761\uFF0C\u7528\u6765\u6392\u67E5\u300C\u4E3A\u4EC0\u4E48\u6CA1\u5199\u5361\u300D\u3002",captureLogEmpty:"\u8FD8\u6CA1\u6709\u8BB0\u5F55\u3002\u8DDF Agent \u804A\u4E00\u8F6E\uFF08> \u6355\u83B7\u6700\u5C0F\u957F\u5EA6\uFF09\u540E\u518D\u56DE\u6765\u770B\u3002",captureLogUnavailable:"\u65E5\u5FD7\u4EC5\u5728 DSH \u5BBF\u4E3B\u5185\u53EF\u7528\uFF08\u72EC\u7ACB Web \u9875\u6CA1\u6709 host \u8FD0\u884C\u65F6\uFF09\u3002",captureAgentCards:"Agent \u81EA\u52A8\u6C89\u6DC0\u7684\u5361",noCards:"\u6682\u65E0",loadMore:"\u52A0\u8F7D\u66F4\u591A",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25",mcpInstalled:"\u2705 {agent} MCP \u5DF2\u5B89\u88C5",mcpUninstalled:"\u2705 {agent} MCP \u5DF2\u5378\u8F7D",mcpActionFail:"\u274C {agent} MCP \u64CD\u4F5C\u5931\u8D25\uFF1A{error}",dshHostLabel:"DeepSeek Harness\uFF08\u5F53\u524D\u5BBF\u4E3B\uFF09",restartHint:"\u5DF2\u4FDD\u5B58\u3002autoWebMode/watchdogAutoSpawn \u7B49\u9700\u91CD\u542F DSH \u751F\u6548",conflictRefresh:"\u914D\u7F6E\u5DF2\u88AB\u5916\u90E8\u4FEE\u6539\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5",untitled:"\u65E0\u6807\u9898",tplBlank:"\u{1F4C4} \u7A7A\u767D",tagsHint:"\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09",connCount:"{n} \u8FDE\u63A5",tplDecisionTags:"\u51B3\u7B56, \u65B9\u6848",tplBugTags:"\u8E29\u5751, \u6559\u8BAD",tplMeetingTags:"\u4F1A\u8BAE, \u7EAA\u8981",tplWeeklyTags:"\u5468\u62A5",tplDecisionBody:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
6
+ var Ft=Object.create;var ut=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty;var _t=(t,l)=>{for(var c in l)ut(t,c,{get:l[c],enumerable:!0})},It=(t,l,c,y)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of Ot(l))!Ht.call(t,u)&&u!==c&&ut(t,u,{get:()=>l[u],enumerable:!(y=$t(l,u))||y.enumerable});return t};var Ut=(t,l,c)=>(c=t!=null?Ft(Wt(t)):{},It(l||!t||!t.__esModule?ut(c,"default",{value:t,enumerable:!0}):c,t)),Kt=t=>It(ut({},"__esModule",{value:!0}),t);var va={};_t(va,{EN:()=>Rt,MemoryLibrary:()=>ra,ZH:()=>Dt,apply:()=>aa,inject:()=>Qt});module.exports=Kt(va);var n=Ut(require("react"),1);var Yt={"&":"&amp;","<":"&lt;",">":"&gt;"},yt=t=>String(t).replace(/[&<>]/g,l=>Yt[l]),Vt=[[/结论|总结|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"]],qt=["\u2728","info"],Xt=[[/风险|注意|警告|禁止|坑|务必/i,"\u26A0\uFE0F","warn"],[/提示|建议|tip|best practice/i,"\u{1F4A1}","idea"],[/结论|总结/i,"\u2705","ok"],[/错误|失败|报错/i,"\u2757","bad"]],Gt=t=>{let l=String(t);for(let[c,y,u]of Vt)if(c.test(l))return[y,u];return qt},Jt=t=>{let l=t.join(" ");for(let[c,y,u]of Xt)if(c.test(l))return[y,u];return["\u{1F4CC}","info"]};function Je(t){let l=String(t),c=/^([^::\s]{1,8})[::]\s*(.+)$/.exec(l);if(c&&!/[是为有了吗呢着过把被和与或于]/.test(c[1]))return'<span class="md-kv"><span class="md-k">'+yt(c[1])+'</span><span class="md-v">'+Je(c[2])+"</span></span>";let y=yt(l);return y=y.replace(/^\[([ xX])\](?=\s|$)\s*/,(u,i)=>'<span class="md-task">'+(i.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,i,S)=>/^(https?:|\/|#)/i.test(S)?'<a class="md-link" href="'+S+'" target="_blank" rel="noopener noreferrer">'+i+"</a>":i),y}function ht(t){let l=String(t||"").replace(/\r\n?/g,`
7
+ `),c=/^---\n([\s\S]*?)\n---\n?/.exec(l);if(!c)return{meta:[],body:l};let y=[];for(let u of c[1].split(`
8
+ `)){let i=u.indexOf(":");if(i<=0)continue;let S=u.slice(0,i).trim(),w=u.slice(i+1).trim().replace(/^["']|["']$/g,"");S&&y.push([S,w])}return{meta:y,body:l.slice(c[0].length)}}function Lt(t){let l=String(t||"").trim().replace(/^\[|\]$/g,"");return l?l.split(",").map(c=>c.trim().replace(/^["']|["']$/g,"")).filter(Boolean):[]}function Bt(t){let l=ht(String(t||"").replace(/\r\n?/g,`
9
+ `)).body;if(!l.trim())return"";let c=[],y=l.replace(/```([\w+#.-]*)\n([\s\S]*?)```/g,(f,T,N)=>(c.push('<pre class="md-pre"><code>'+yt(N.replace(/\n$/,""))+"</code></pre>"),"\0F"+(c.length-1)+"\0")),u=[],i=[],S=null,w=null,z=()=>{i.length&&(u.push('<p class="md-p">'+i.join("<br/>")+"</p>"),i=[])},B=()=>{if(!S)return;let f=S.type;u.push("<"+f+' class="md-'+f+'">'+S.items.map(T=>"<li>"+T+"</li>").join("")+"</"+f+">"),S=null},v=()=>{if(!w)return;let[f,T]=Jt(w);u.push('<div class="md-callout md-c-'+T+'"><span class="md-ico">'+f+"</span>"+w.join("<br/>")+"</div>"),w=null},b=()=>{z(),B(),v()};for(let f of y.split(`
10
+ `)){let T=f.trim();if(!T){b();continue}let N=/^\u0000F(\d+)\u0000$/.exec(T);if(N){b(),u.push(c[Number(N[1])]);continue}let k;if(k=/^(#{1,6})\s+(.+)$/.exec(T)){b();let[L,M]=Gt(k[2]);u.push('<div class="md-h md-h-'+(k[1].length<=2?"h1":"h2")+" md-c-"+M+'"><span class="md-ico">'+L+'</span><span class="md-hx">'+Je(k[2])+"</span></div>");continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(T)){b(),u.push('<hr class="md-hr"/>');continue}if(k=/^>\s?(.*)$/.exec(T)){z(),B(),w=w||[],w.push(Je(k[1]));continue}if(k=/^[-*+]\s+(.+)$/.exec(T)){z(),v(),(!S||S.type!=="ul")&&(B(),S={type:"ul",items:[]}),S.items.push(Je(k[1]));continue}if(k=/^\d+[.)]\s+(.+)$/.exec(T)){z(),v(),(!S||S.type!=="ol")&&(B(),S={type:"ol",items:[]}),S.items.push(Je(k[1]));continue}B(),v(),i.push(Je(T))}return b(),u.join(`
11
+ `)}var e=require("react/jsx-runtime"),Ze="memory-eternal",U="/memory-eternal/api",Zt=100,Qt=["slots","locale"],Dt={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",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]
12
12
 
13
13
  ## \u80CC\u666F
14
14
  - \u95EE\u9898\u63CF\u8FF0
@@ -53,7 +53,7 @@ var Et=Object.create;var pt=Object.defineProperty;var $t=Object.getOwnPropertyDe
53
53
  -
54
54
 
55
55
  ## \u98CE\u9669/\u963B\u585E
56
- - `},Dt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",enterFullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",oneClickOptimize:"One-click optimize",oneClickOptimizeConfirm:"Confirm one-click optimize? This will merge all similar pairs (stale cards are NOT deleted by default).",oneClickAlsoStale:"Also clean stale cards",oneClickOptimizeDone:"One-click optimize done",optimizedMerged:"pairs merged",optimizedStaleDeleted:"stale cards cleaned",mcpSetupStatus:"Agent MCP mount status",rerunSetup:"Re-run setup",notInstalled:"not installed",noMcpEntry:"no MCP entry",nodePathMismatch:"node path mismatch, consider re-running setup",nodePathNote:"different node env (usable)",healthy:"healthy",mcpSetupHint:'"Auto-mount MCP" = lets Claude Code / Codex / Cursor use the memory vault. On = auto-configures them; Off = never touches your machine config, run dsh-memory setup manually when needed.',mcpManageHint:"Use each agent row to install/uninstall MCP individually",tabConfig:"Memory Config",tabAudit:"Audit Center",statusApproved:"Approved",statusPending:"Pending",statusRejected:"Rejected",allStatus:"All statuses",tabRecycle:"Recycle Bin",pending:"Pending",rejected:"Rejected",selectAll:"Select all",approve:"Approve",reject:"Reject",allAgents:"All agents",noAuditItems:"No items to review",deletedAt:"deleted",restore:"Restore",restoreDelete:"Delete to recycle",purge:"Purge",emptyRecycle:"Recycle bin is empty",recycleHint:"Deleted cards go to the recycle bin \u2014 recover within 30 days, else auto-purged",purgeConfirm:"Permanently delete? This cannot be undone.",recycleDeleteConfirm:"Delete to recycle? Recoverable within 30 days.",modeInit:"Init once",modeInterval:"Interval keep-alive",modeManual:"Manual only",serviceConfig:"Service self-hosting config",auditConfig:"Auto-audit config",auditHint:"Cards matching an exemption go straight in; others await audit",auditMode:"Audit mode",auditAll:"Audit all",auditNone:"Skip all",auditExemptAgents:"Exempt agents",auditExemptKinds:"Exempt kinds",allExempt:"Exempt all",recycleDays:"Recycle retention days",editInSetting:"Edit in DSH Settings \u2192 Memory",setupRunInTerminal:"Copy this command to your terminal:",dshMemoryConfig:"DSH Memory Config",autoCapture:"Auto capture",autoRecall:"Auto recall",captureMinChars:"Min capture chars",maxCardsPerDay:"Daily quota",dedupThreshold:"Dedup threshold",recallLimit:"Recall limit",recallSummaryLen:"Recall summary len",recallBody:"Recall with body",autoWeb:"Web server",autoWebMode:"Keep-alive mode",webPort:"Web port",webCheckIntervalMs:"Probe interval (ms)",webMaxRestart:"Max restart",watchdogAutoSpawn:"Watchdog process",autoMcpSetup:"Auto-mount MCP",saveConfig:"Save config",saveFail:"Save failed",savedOk:"Saved",recallTool:"recall tool",costControl:"Cost control",costHint:"save tokens, control LLM usage",distillEnabled:"Distill cards (on=LLM compress, off=raw cards zero LLM)",dedupByLLM:"Dedup feeds LLM (off=pure lexical, cheaper)",captureMaxTokens:"Distill output cap (tokens)",recallMinScore:"Recall min score (higher = cheaper)",configNeedsDsh:"Edit config inside DSH (this page may be read-only or partially missing)",installMcp:"Install MCP",uninstallMcp:"Uninstall MCP",uninstallConfirm:"Confirm uninstall MCP for this agent? Claude Code/Codex will lose access to the memory vault.",presetConfig:"One-click preset config",presetHint:"Click to fill a plan, then hit Save",planA:"A Light",planB:"B Budget",planC:"C Premium",pluginInfo:"Plugin info",organizeTitle:"Organize",scanAndOrganize:"Scan & organize",scanHint:'Click "\u{1F50D} Scan & organize" to find similar/stale cards, then "\u26A1 One-click optimize" to run.',mergeNow:"Merge",delete:"Delete",captureAlert:"Auto-capture failed",captureAlertHint:'Open "Usage / Today" for the capture log; if the cause is an API/version mismatch, update the memory-eternal plugin.',captureLog:"Auto-capture log",captureLogHint:"Runs after every turn: listen \u2192 judge \u2192 write. Last 100 entries, so you can see why a card was not written.",captureLogEmpty:"No entries yet. Chat one turn (> min capture chars) and come back.",captureLogUnavailable:"Log is available only inside the DSH host (the standalone web page has no host runtime).",captureAgentCards:"Cards auto-captured by the agent",noCards:"none",loadMore:"Load more",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed",mcpInstalled:"\u2705 {agent} MCP installed",mcpUninstalled:"\u2705 {agent} MCP uninstalled",mcpActionFail:"\u274C {agent} MCP action failed: {error}",dshHostLabel:"DeepSeek Harness (current host)",restartHint:"Saved. autoWebMode/watchdogAutoSpawn take effect after restarting DSH",conflictRefresh:"Config changed elsewhere \u2014 refresh and retry",untitled:"Untitled",tplBlank:"\u{1F4C4} Blank",tagsHint:"Tags (comma-separated)",connCount:"{n} connections",tplDecisionTags:"decision, plan",tplBugTags:"pitfall, lesson",tplMeetingTags:"meeting, minutes",tplWeeklyTags:"weekly report",tplDecisionBody:`# Tech decision: [title]
56
+ - `},Rt={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",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]
57
57
 
58
58
  ## Background
59
59
  - Problem
@@ -98,7 +98,7 @@ Option A, because:
98
98
  -
99
99
 
100
100
  ## Risks/blockers
101
- - `},ht=["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}"},De={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},ot="deepseek-harness",tt=t=>{let l=String(t||""),s=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||s.startsWith("claude-code")?s.startsWith("claude-code")?"claude":ot:s==="deepseek harness"?ot:l.split(":")[0]||ot},Qt=[ot,"claude","codex","cursor","codex-desktop"],Rt=(t=[])=>[...new Set([...Qt,...(t||[]).map(tt)])],ea={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},ze=`
101
+ - `},vt=["all","project","knowledge","content","prompt","business","tool","mistake"],He={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}"},$e={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},lt="deepseek-harness",at=t=>{let l=String(t||""),c=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||c.startsWith("claude-code")?c.startsWith("claude-code")?"claude":lt:c==="deepseek harness"?lt:l.split(":")[0]||lt},ea=[lt,"claude","codex","cursor","codex-desktop"],Pt=(t=[])=>[...new Set([...ea,...(t||[]).map(at)])],ta={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Be=`
102
102
  .memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
103
103
  .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; }
104
104
  .mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
@@ -154,10 +154,15 @@ Option A, because:
154
154
  .mc-flag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l2, #d1d5db); margin-left: 6px; }
155
155
 
156
156
  /* ---- sidebar footer button ---- */
157
- /* \u8BA9\u300C\u8BB0\u5FC6\u300D\u6309\u94AE\u72EC\u5360\u4E00\u884C\uFF1A\u8BA9\u5BB9\u5668\u53EF\u6362\u884C\uFF0C\u672C\u6309\u94AE flex-basis:100% \u5360\u6EE1\u6574\u884C\u3002
158
- \u540C\u65F6\u547D\u4E2D\u300CfooterActions \u76F4\u63A5\u5305\u542B\u300D\u4E0E\u300C\u4E2D\u95F4\u9694\u4E00\u5C42 wrapper\u300D\u4E24\u79CD\u60C5\u51B5\uFF08:has \u5728 WebView2/Chromium \u5747\u652F\u6301\uFF09\u3002 */
159
- [class*="footerActions"]:has(.me-footer), :has(> .me-footer) { flex-wrap: wrap; width: 100%; }
160
- .me-footer { width: 100%; flex: 1 1 100%; }
157
+ /* \u8BA9\u300C\u8BB0\u5FC6\u300D\u6309\u94AE\u72EC\u5360\u4E00\u884C\u3002\u6CE8\u610F\uFF1A\u69FD\u4F4D\u5BBF\u4E3B\u6709\u4E24\u79CD\u5F62\u6001 \u2014\u2014
158
+ \u2460 \u58F3\u81EA\u5DF1\u7684\u6A2A\u5411\u884C\u5BB9\u5668\uFF08.footerActions\uFF09\uFF0C\u8FD9\u91CC\u8981 flex-wrap + width:100% \u624D\u80FD\u8BA9\u5165\u53E3\u72EC\u5360\u4E00\u884C\uFF1B
159
+ \u2461 \u88AB\u522B\u7684\u63D2\u4EF6\uFF08dsh-diff-approval / dsh-footer-order \u7B49\uFF09\u6539\u6210 flex-direction:column \u7684
160
+ div[data-slot="sidebar.footer.action"]\u3002\u7EB5\u5411\u5BB9\u5668\u91CC wrap \u7684\u8BED\u4E49\u662F\u300C\u6362\u5217\u300D\uFF0C
161
+ \u800C flex-basis:100% \u6307\u7684\u662F\u300C\u9AD8\u5EA6 100%\u300D\u2014\u2014\u4E24\u8005\u53E0\u52A0\u4F1A\u628A\u6309\u94AE\u6324\u8FDB\u53F3\u4FA7\u6EA2\u51FA\u5217\uFF0C
162
+ \u6700\u7EC8\u88C1\u5207\u5230\u53EA\u5269\u53F3\u8FB9\u7F18\u4E00\u6761\u7F1D\uFF08issue #2\uFF09\u3002\u6240\u4EE5\u8FD9\u4E24\u6761\u53EA\u7528\u5728 \u2460\uFF0C\u2461 \u53EA\u7ED9\u5BBD\u5EA6\u3002 */
163
+ [class*="footerActions"]:has(.me-footer), :has(> .me-footer) { width: 100%; }
164
+ [class*="footerActions"]:has(.me-footer) { flex-wrap: wrap; }
165
+ .me-footer { width: 100%; flex: 0 0 auto; min-width: 0; }
161
166
  .me-footer-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,0.14)); background: var(--dsw-alias-bg-layer-1, rgba(255,255,255,0.04)); color: var(--dsw-alias-label-secondary, #6b7280); font: inherit; font-size: 13.5px; line-height: 18px; border-radius: 8px; cursor: pointer; text-align: left; }
162
167
  .me-footer-btn:hover { background: var(--dsw-alias-bg-layer-1, rgba(255,255,255,0.06)); color: var(--dsw-alias-label-primary, #111); }
163
168
  .me-footer-btn:active { transform: translateY(0.5px); }
@@ -285,12 +290,12 @@ Option A, because:
285
290
  height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
286
291
  max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
287
292
  }
288
- `;function ta(t){t.effect(()=>t.locale.register(Je,{zh:At,en:Dt}),"memory-eternal: locale");let l=t.locale.bind(Je);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Je,order:25,label:()=>l("nav"),locale:Je,inject:()=>({})},()=>n.default.createElement(na,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Je}:footer`,order:100,label:()=>l("nav"),locale:Je,inject:()=>({})},s=>n.default.createElement(oa,{t:l,locale:t.locale,wide:!(s&&s.wide===!1)}))),"memory-eternal: sidebar footer action")}function aa(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(s=>s.json()).then(s=>{s&&s.ok&&s.url&&l(s.url.endsWith("/")?s.url:s.url+"/")}).catch(()=>{})},[]),t}function na({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:ze}),(0,e.jsx)(jt,{t,onReload:()=>{},version:0})]})}function oa({t,locale:l,wide:s}){let[f,c]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:ze}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>c(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Ft,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),f&&(0,e.jsx)(ia,{t,locale:l,onClose:()=>c(!1)})]})}function ia({t,locale:l,onClose:s,tab:f}){let[c,i]=(0,n.useState)(!1),k=(0,n.useRef)(null),x=aa(),N=(0,n.useCallback)(z=>l&&typeof l.subscribe=="function"?l.subscribe(z):()=>{},[l]),L=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),C=(0,n.useSyncExternalStore)(N,L),b=C&&(C.active==="zh"||C.active==="en")?C.active:null,y=(0,n.useRef)(null);y.current===null&&b&&(y.current=b);let B=(0,n.useMemo)(()=>{let z=y.current?`lang=${y.current}`:"";return f==="config"?`${_}/ui/config?tab=config${z?`&${z}`:""}`:f?`${x.replace(/\/$/,"")}/?tab=${f}${z?`&${z}`:""}`:z?`${x}${x.endsWith("/")?"":"/"}?${z}`:x},[x,f]);return(0,n.useEffect)(()=>{let z=k.current&&k.current.contentWindow;z&&b&&z.postMessage({source:"memory-eternal",type:"locale",lang:b},"*")},[b]),(0,n.useEffect)(()=>{let z=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:ze}),(0,e.jsx)("div",{className:"me-modal"+(c?" me-modal-full":""),onClick:z=>z.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:()=>i(z=>!z),"aria-label":t(c?"exitFullscreen":"enterFullscreen"),title:t(c?"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:c?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:s,"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:k,src:B,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Ft(){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 la({t,inModal:l,onClose:s,onFull:f,full:c}){let[i,k]=(0,n.useState)(null),[x,N]=(0,n.useState)([]),[L,C]=(0,n.useState)(!0),[b,y]=(0,n.useState)(null),[B,z]=(0,n.useState)(""),[v,I]=(0,n.useState)("all"),[S,P]=(0,n.useState)(""),[re,te]=(0,n.useState)("all"),[W,Ie]=(0,n.useState)("all"),[j,he]=(0,n.useState)(()=>{try{let u=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),E={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(u&&E[u])return E[u]}catch{}return"cards"}),[w,oe]=(0,n.useState)(()=>new Set([j])),g=(0,n.useCallback)(u=>{oe(E=>E.has(u)?E:new Set(E).add(u)),he(u)},[]),[D,U]=(0,n.useState)("recent"),[V,O]=(0,n.useState)(null),H=(0,n.useRef)(null),Z=(0,n.useRef)(null),[J,xe]=(0,n.useState)(!1),[Re,He]=(0,n.useState)(null),[Ce,se]=(0,n.useState)(!1),[Q,p]=(0,n.useState)(!0),[q,X]=(0,n.useState)(null),[ne,Se]=(0,n.useState)(0),Ae=(0,n.useCallback)(()=>Se(u=>u+1),[]),Ne=(0,n.useRef)(null),[_e,Ue]=(0,n.useState)(0),[Fe,ie]=(0,n.useState)(!1),Ke=(0,n.useRef)(null),ke=(0,n.useRef)(null),r=(0,n.useCallback)(async(u=v,E=S,K=W,fe={})=>{let me=fe.append===!0;try{me?ie(!0):(C(!0),z(""));let ue=new URLSearchParams;u&&u!=="all"&&ue.set("kind",u),E.trim()&&ue.set("q",E.trim()),ue.set("status",K||"all"),ue.set("limit",String(Jt)),ue.set("offset",String(fe.offset||0)),D==="title"&&ue.set("sort","title");let Pe=await(await fetch(`${_}/cards?${ue.toString()}`)).json();if(Pe.ok){let je=Pe.cards||[];N(we=>me?[...we,...je.filter(Ye=>!we.some(qe=>qe.path===Ye.path))]:je),Ue(Number(Pe.total)||je.length)}}catch(ue){z(String(ue&&ue.message?ue.message:ue))}finally{me?ie(!1):C(!1)}},[v,S,W,D]),o=(0,n.useCallback)(async()=>{try{let[u,E]=await Promise.all([fetch(`${_}/overview`).then(K=>K.json()),fetch(`${_}/capture-log`).then(K=>K.json()).catch(()=>null)]);u.ok&&k(u),y(E&&E.ok&&E.available&&E.health||null)}catch(u){z(String(u&&u.message?u.message:u))}finally{C(!1)}},[]),A=async u=>{try{let K=await(await fetch(`${_}/delete?path=${encodeURIComponent(u)}`)).json();K.ok?(O({ok:!0,msg:t("deleted")}),await o(),Ae()):O({ok:!1,msg:K.error||t("deleteFail")})}catch{O({ok:!1,msg:t("deleteFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)};(0,n.useEffect)(()=>(o(),()=>{Ne.current&&clearTimeout(Ne.current)}),[o]);let ae=u=>{P(u),Ne.current&&clearTimeout(Ne.current),Ne.current=setTimeout(()=>r(v,u,W),280)},ce=u=>{I(u),r(u,S,W)};(0,n.useEffect)(()=>{j==="cards"&&r(v,S,W)},[W,j,ne,D]),(0,n.useEffect)(()=>{if(j!=="cards"||L||Fe||x.length>=_e)return;let u=Ke.current,E=ke.current;if(!u)return;let K=new IntersectionObserver(fe=>{fe[0]&&fe[0].isIntersecting&&r(v,S,W,{append:!0,offset:x.length})},{root:E||null,rootMargin:"400px"});return K.observe(u),()=>K.disconnect()},[j,x,_e,L,Fe,v,S,W,r]);let ve=async u=>{try{let K=await(await fetch(`${_}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();K.ok&&He({path:K.path,title:u.title,text:K.text})}catch(E){z(String(E&&E.message?E.message:E))}},a=async(u,E)=>{xe(!0);try{let K=await fetch(`${_}/export`);if(!K.ok)throw new Error("HTTP "+K.status);let fe=await K.json();if(!fe.ok)throw new Error(fe.error||"export failed");let me,ue,be;u==="json"?(ue="memory-vault.json",be="application/json",me=JSON.stringify(fe.cards.map(we=>({path:we.path,title:we.title,kind:we.kind,text:we.text})),null,2)):(ue="memory-vault.md",be="text/markdown;charset=utf-8",me=fe.cards.map(we=>we.text.trim()).filter(Boolean).join(`
293
+ `;function aa(t){t.effect(()=>t.locale.register(Ze,{zh:Dt,en:Rt}),"memory-eternal: locale");let l=t.locale.bind(Ze);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Ze,order:25,label:()=>l("nav"),locale:Ze,inject:()=>({})},()=>n.default.createElement(oa,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ze}:footer`,order:100,label:()=>l("nav"),locale:Ze,inject:()=>({})},c=>n.default.createElement(ia,{t:l,locale:t.locale,wide:!(c&&c.wide===!1)}))),"memory-eternal: sidebar footer action")}function na(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(c=>c.json()).then(c=>{c&&c.ok&&c.url&&l(c.url.endsWith("/")?c.url:c.url+"/")}).catch(()=>{})},[]),t}function oa({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Be}),(0,e.jsx)(jt,{t,onReload:()=>{},version:0})]})}function ia({t,locale:l,wide:c}){let[y,u]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${c?"":" rail"}`,children:[(0,e.jsx)("style",{children:Be}),(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)(Et,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),y&&(0,e.jsx)(la,{t,locale:l,onClose:()=>u(!1)})]})}function la({t,locale:l,onClose:c,tab:y}){let[u,i]=(0,n.useState)(!1),S=(0,n.useRef)(null),w=na(),z=(0,n.useCallback)(N=>l&&typeof l.subscribe=="function"?l.subscribe(N):()=>{},[l]),B=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),v=(0,n.useSyncExternalStore)(z,B),b=v&&(v.active==="zh"||v.active==="en")?v.active:null,f=(0,n.useRef)(null);f.current===null&&b&&(f.current=b);let T=(0,n.useMemo)(()=>{let N=f.current?`lang=${f.current}`:"";return y==="config"?`${U}/ui/config?tab=config${N?`&${N}`:""}`:y?`${w.replace(/\/$/,"")}/?tab=${y}${N?`&${N}`:""}`:N?`${w}${w.endsWith("/")?"":"/"}?${N}`:w},[w,y]);return(0,n.useEffect)(()=>{let N=S.current&&S.current.contentWindow;N&&b&&N.postMessage({source:"memory-eternal",type:"locale",lang:b},"*")},[b]),(0,n.useEffect)(()=>{let N=k=>{k.key==="Escape"&&c()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[c]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:c,children:[(0,e.jsx)("style",{children:Be}),(0,e.jsx)("div",{className:"me-modal"+(u?" me-modal-full":""),onClick:N=>N.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:()=>i(N=>!N),"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:c,"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:S,src:T,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Et(){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 ra({t,inModal:l,onClose:c,onFull:y,full:u}){let[i,S]=(0,n.useState)(null),[w,z]=(0,n.useState)([]),[B,v]=(0,n.useState)(!0),[b,f]=(0,n.useState)(null),[T,N]=(0,n.useState)(""),[k,L]=(0,n.useState)("all"),[M,$]=(0,n.useState)(""),[ie,te]=(0,n.useState)("all"),[W,Te]=(0,n.useState)("all"),[P,ye]=(0,n.useState)(()=>{try{let m=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),j={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(m&&j[m])return j[m]}catch{}return"cards"}),[C,ne]=(0,n.useState)(()=>new Set([P])),g=(0,n.useCallback)(m=>{ne(j=>j.has(m)?j:new Set(j).add(m)),ye(m)},[]),[D,K]=(0,n.useState)("recent"),[J,O]=(0,n.useState)(null),H=(0,n.useRef)(null),ee=(0,n.useRef)(null),[Q,he]=(0,n.useState)(!1),[_e,Ae]=(0,n.useState)(null),[Ne,De]=(0,n.useState)(!1),[de,ke]=(0,n.useState)(!0),[Ue,ze]=(0,n.useState)(null),[Ie,pe]=(0,n.useState)(0),Ce=(0,n.useCallback)(()=>pe(m=>m+1),[]),s=(0,n.useRef)(null),[E,_]=(0,n.useState)(0),[Y,q]=(0,n.useState)(!1),xe=(0,n.useRef)(null),ue=(0,n.useRef)(null),r=(0,n.useCallback)(async(m=k,j=M,X=W,fe={})=>{let ve=fe.append===!0;try{ve?q(!0):(v(!0),N(""));let ge=new URLSearchParams;m&&m!=="all"&&ge.set("kind",m),j.trim()&&ge.set("q",j.trim()),ge.set("status",X||"all"),ge.set("limit",String(Zt)),ge.set("offset",String(fe.offset||0)),D==="title"&&ge.set("sort","title");let Ke=await(await fetch(`${U}/cards?${ge.toString()}`)).json();if(Ke.ok){let me=Ke.cards||[];z(Le=>ve?[...Le,...me.filter(dt=>!Le.some(qe=>qe.path===dt.path))]:me),_(Number(Ke.total)||me.length)}}catch(ge){N(String(ge&&ge.message?ge.message:ge))}finally{ve?q(!1):v(!1)}},[k,M,W,D]),o=(0,n.useCallback)(async()=>{try{let[m,j]=await Promise.all([fetch(`${U}/overview`).then(X=>X.json()),fetch(`${U}/capture-log`).then(X=>X.json()).catch(()=>null)]);m.ok&&S(m),f(j&&j.ok&&j.available&&j.health||null)}catch(m){N(String(m&&m.message?m.message:m))}finally{v(!1)}},[]),A=async m=>{try{let X=await(await fetch(`${U}/delete?path=${encodeURIComponent(m)}`)).json();X.ok?(O({ok:!0,msg:t("deleted")}),await o(),Ce()):O({ok:!1,msg:X.error||t("deleteFail")})}catch{O({ok:!1,msg:t("deleteFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)};(0,n.useEffect)(()=>(o(),()=>{s.current&&clearTimeout(s.current)}),[o]);let ae=m=>{$(m),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r(k,m,W),280)},ce=m=>{L(m),r(m,M,W)};(0,n.useEffect)(()=>{P==="cards"&&r(k,M,W)},[W,P,Ie,D]),(0,n.useEffect)(()=>{if(P!=="cards"||B||Y||w.length>=E)return;let m=xe.current,j=ue.current;if(!m)return;let X=new IntersectionObserver(fe=>{fe[0]&&fe[0].isIntersecting&&r(k,M,W,{append:!0,offset:w.length})},{root:j||null,rootMargin:"400px"});return X.observe(m),()=>X.disconnect()},[P,w,E,B,Y,k,M,W,r]);let Se=async m=>{try{let X=await(await fetch(`${U}/card?path=${encodeURIComponent(m.path||m.id)}`)).json();X.ok&&Ae({path:X.path,title:m.title,text:X.text})}catch(j){N(String(j&&j.message?j.message:j))}},a=async(m,j)=>{he(!0);try{let X=await fetch(`${U}/export`);if(!X.ok)throw new Error("HTTP "+X.status);let fe=await X.json();if(!fe.ok)throw new Error(fe.error||"export failed");let ve,ge,Ee;m==="json"?(ge="memory-vault.json",Ee="application/json",ve=JSON.stringify(fe.cards.map(Le=>({path:Le.path,title:Le.title,kind:Le.kind,text:Le.text})),null,2)):(ge="memory-vault.md",Ee="text/markdown;charset=utf-8",ve=fe.cards.map(Le=>Le.text.trim()).filter(Boolean).join(`
289
294
 
290
295
  ---
291
296
 
292
- `));let Pe=new Blob([me],{type:be}),je=await ha(Pe,ue,!1);if(!je.ok){O({ok:!1,msg:t("exportFail")}),xe(!1);return}O({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+je.name})}catch(K){O({ok:!1,msg:t("exportFail")+" \xB7 "+(K.message||"")})}finally{xe(!1)}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2600)},at=async u=>{let E=u.target.files&&u.target.files[0];if(u.target.value="",!!E){try{let K=await E.text(),me=await(await fetch(`${_}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:K})).json();me.ok?(await o(),O({ok:!0,msg:t("importedVault")+"\uFF1A"+(me.imported||0)+(me.skipped?t("importedSkipped")+me.skipped:"")})):O({ok:!1,msg:me.error||t("importFail")})}catch{O({ok:!1,msg:t("importFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2400)}},it=(0,n.useMemo)(()=>{let u=x.slice();return re!=="all"&&(u=u.filter(E=>tt(E.submittedBy)===re)),W!=="all"&&(u=u.filter(E=>(E.status||"approved")===W)),D==="title"?u.sort((E,K)=>String(E.title||"").localeCompare(String(K.title||""))):D==="hot"?u.sort((E,K)=>(K.weight||K.links||0)-(E.weight||E.links||0)):u.sort((E,K)=>new Date(K.updated||0).getTime()-new Date(E.updated||0).getTime()),u},[x,D,re,W]),lt=(0,n.useMemo)(()=>[...new Set(x.map(u=>tt(u.submittedBy)))],[x]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:ze}),V&&(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 "+(V.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:V.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:V.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:V.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)(Ft,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),f&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:f,"aria-label":t(c?"exitFull":"fullscreen"),children:c?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:s,"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?et(new Date(b.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${Q?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>p(u=>!u),"aria-label":t(Q?"collapse":"expand"),title:t(Q?"collapse":"expand"),children:Q?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${j==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),Q&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:ke,children:[j==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ze,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Ze,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Ze,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Ze,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Ze,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Ze,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),j==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:S,onChange:u=>ae(u.target.value)}),(0,e.jsx)("input",{ref:Z,type:"file",accept:".json,application/json",style:{display:"none"},onChange:at}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>Z.current&&Z.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>X({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:J,onClick:()=>a("md"),children:t(J?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:J,onClick:()=>a("json"),children:t(J?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),j==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ht.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${v===u?" active":""}`,onClick:()=>ce(u),children:t(u==="all"?"all":De[u])},u)),(0,e.jsxs)("select",{value:re,onChange:u=>te(u.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")]}),Rt(lt).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsxs)("select",{value:W,onChange:u=>Ie(u.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(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${D===u.key?" active":""}`,onClick:()=>U(u.key),children:u.label},u.key))]}),B&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",B]}),(0,e.jsx)("div",{style:{display:j==="cards"?"contents":"none"},children:L?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):B?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",B," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("retry")})]}):x.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(u=>(0,e.jsx)(da,{card:u,t,query:S.trim(),onOpen:ve,onDelete:A},u.path))}),x.length<_e&&(0,e.jsx)("div",{ref:Ke,style:{height:1}}),Fe&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",x.length," / ",_e,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:j==="graph"?"flex":"none",flex:1,minHeight:0},children:w.has("graph")&&(0,e.jsx)(ua,{t,onOpen:ve,all:Ce,onAllChange:se,onMutate:Ae,active:j==="graph",visible:j==="graph"})}),(0,e.jsx)("div",{style:{display:j==="config"?"contents":"none"},children:w.has("config")&&(0,e.jsx)(jt,{t,onReload:()=>o(),version:ne})}),(0,e.jsx)("div",{style:{display:j==="stats"?"contents":"none"},children:w.has("stats")&&(0,e.jsx)(ca,{t,tab:"stats",onReload:()=>o(),version:ne})}),(0,e.jsx)("div",{style:{display:j==="audit"?"contents":"none"},children:w.has("audit")&&(0,e.jsx)(ra,{t,onReload:()=>o(),version:ne})}),(0,e.jsx)("div",{style:{display:j==="optimize"?"contents":"none"},children:w.has("optimize")&&(0,e.jsx)(sa,{t,onReload:()=>o(),version:ne})}),Re&&(0,e.jsx)(ma,{t,card:Re,query:S.trim(),onClose:()=>He(null),onDelete:u=>{He(null),A(u)},onFeedback:u=>{let E=Re.path;fetch(`${_}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:S.trim(),path:E,useful:u})}).then(()=>O({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)}}),(0,e.jsx)(pa,{t,newCard:q,setNewCard:X,onCreated:()=>{o(),Ae(),O({ok:!0,msg:t("created")}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)}})]})]})]})}var Ze=({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 jt({t,onReload:l,version:s,compact:f}){let[c,i]=(0,n.useState)(null),[k,x]=(0,n.useState)(0),[N,L]=(0,n.useState)(null),[C,b]=(0,n.useState)(null),[y,B]=(0,n.useState)(!1),[z,v]=(0,n.useState)(null),[I,S]=(0,n.useState)(null),[P,re]=(0,n.useState)(""),[te,W]=(0,n.useState)(""),[Ie,j]=(0,n.useState)(""),[he,w]=(0,n.useState)(""),[oe,g]=(0,n.useState)(null),D=(0,n.useRef)(null),U=(p,q=!0)=>{D.current&&clearTimeout(D.current),g({msg:p,ok:q}),D.current=setTimeout(()=>g(null),1900)},V=(p,q)=>Object.keys(q).reduce((X,ne)=>X.split("{"+ne+"}").join(q[ne]),t(p)),O=(0,n.useCallback)(async()=>{try{let[p,q,X]=await Promise.all([fetch(`${_}/config`).then(ne=>ne.json()).catch(()=>null),fetch(`${_}/setup-status`).then(ne=>ne.json()).catch(()=>null),fetch(`${_}/budget`).then(ne=>ne.json()).catch(()=>null)]);p&&p.ok?(i(p),x(p.revision??0),L(p.schema??null),b({...p.config??{}}),v(p.dsh??null),B(p.writable===!1),re("")):X&&X.ok?(b({...X}),B(!0),re(t("configNeedsDsh"))):re(t("adminLoadFail")),q&&q.ok&&S(q),j("")}catch{re(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{O()},[s,O]);let H=(p,q)=>b(X=>({...X??{},[p]:q})),Z=p=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[p]||p,J=async()=>{if(C){if(y){U(t("editInSetting"),!1);return}W("save");try{let p=await fetch(`${_}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:C,expectedRevision:k})}),q=await p.json();if(q&&q.ok)j(t("savedOk")+(q.note?` \xB7 ${t("restartHint")}`:"")),U(t("savedOk")),await O();else{let X=p.status===409?t("conflictRefresh"):q?.error||t("saveFail");re(X),U(X,!1)}}catch{re(t("saveFail")),U(t("saveFail"),!1)}finally{W("")}}},xe=()=>{b({...c?.config??{}}),j("")},Re={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}},He=async p=>{let q=Re[p];q&&b(X=>({...X??{},...q}))},Ce=async(p,q)=>{W(p+q);try{let ne=await(await fetch(`${_}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:p,action:q})})).json();ne&&ne.ok?U(V(q==="install"?"mcpInstalled":"mcpUninstalled",{agent:p})):U(V("mcpActionFail",{agent:p,error:ne?.error||""}),!1);try{let Se=await fetch(`${_}/setup-status`).then(Ae=>Ae.json());Se&&Se.ok&&S(Se)}catch{}}catch{U(t("mergeFail"),!1)}finally{W("")}},se=({k:p,label:q,type:X="text",step:ne,min:Se,max:Ae})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:q||p}),(0,e.jsx)("input",{type:X,step:ne,min:Se,max:Ae,value:C?C[p]??"":"",onChange:Ne=>H(p,X==="number"?Number(Ne.target.value):Ne.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12}})]}),Q=({k:p,label:q})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(C&&C[p]),onChange:X=>H(p,X.target.checked)}),(0,e.jsx)("span",{children:q||p})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:f?"0 0 auto":1,minHeight:0,maxHeight:f?"52vh":void 0},children:[(0,e.jsx)("style",{children:ze}),oe&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(oe.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:oe.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:oe.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:oe.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[P&&(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 ",P]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:O,children:["\u21BB ",t("retry")]})]}),y&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #f59e0b",background:"rgba(245,158,11,0.08)",padding:"10px 14px",marginBottom:10,fontSize:12,color:"#b45309"},children:["\u2139\uFE0F ",t("configNeedsDsh")," \u2014\u2014 ",t("editInSetting")]}),Ie&&(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 ",Ie]}),c&&(c.version||c.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")}),c.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",c.version]}),c.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",c.dsh.vaultDir]})]}),I&&I.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:I.agents.map(p=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1},children:[(0,e.jsx)("b",{children:p.isDsh?t("dshHostLabel"):p.name}),p.isDsh&&p.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",p.version]}),!p.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),p.installed&&p.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),p.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),p.mcpConfigured===!0&&p.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),p.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",p.recallTool?t("enabled"):t("disabled"),")"]})]}),p.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",p.hook]}),!p.isDsh&&p.installed&&p.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!te,onClick:()=>Ce(p.name,"install"),children:t("installMcp")}),!p.isDsh&&p.installed&&p.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!te,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Ce(p.name,"uninstall")},children:t("uninstallMcp")})]},p.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),he&&(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:he})})]}),C?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",t("presetConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("presetHint")})]}),(0,e.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(p=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>He(p),disabled:!!te,children:[p==="A"?"\u{1F7E2} ":p==="B"?"\u{1F4B0} ":"\u2B50 ",Re[p].label]},p))})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",t("dshMemoryConfig")]})}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,e.jsx)(Q,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Q,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(se,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(se,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(se,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(se,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(se,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Q,{k:"recallIncludeBody",label:t("recallBody")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",t("costControl")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("costHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,e.jsx)(Q,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Q,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(se,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(se,{k:"recallMinScore",label:t("recallMinScore"),type:"number"})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",t("auditConfig")]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("auditHint")})]}),(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("auditMode")}),(0,e.jsxs)("select",{value:C.auditMode??"all",onChange:p=>H("auditMode",p.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"all",children:t("auditAll")}),(0,e.jsx)("option",{value:"none",children:t("auditNone")})]})]}),(0,e.jsx)(Bt,{label:t("auditExemptAgents"),value:C.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(I?.agents||[]).filter(p=>!p.isDsh).map(p=>({value:p.name,label:p.name}))],onChange:p=>H("auditExemptAgents",p)}),(0,e.jsx)(Bt,{label:t("auditExemptKinds"),value:C.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...ht.filter(p=>p!=="all").map(p=>({value:p,label:t(De[p])}))],onChange:p=>H("auditExemptKinds",p)}),(0,e.jsx)(se,{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)(Q,{k:"autoWeb",label:t("autoWeb")}),(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:t("autoWebMode")}),(0,e.jsxs)("select",{value:C.autoWebMode??"init",onChange:p=>H("autoWebMode",p.target.value),style:{padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12},children:[(0,e.jsx)("option",{value:"init",children:t("modeInit")}),(0,e.jsx)("option",{value:"interval",children:t("modeInterval")}),(0,e.jsx)("option",{value:"manual",children:t("modeManual")})]})]}),(0,e.jsx)(se,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(se,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(se,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Q,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Q,{k:"autoMcpSetup",label:t("autoMcpSetup")})]})]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:xe,disabled:!!te,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:J,disabled:!!te||te==="save"||y,children:te==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function ra({t,onReload:l,version:s}){let[f,c]=(0,n.useState)([]),[i,k]=(0,n.useState)([]),[x,N]=(0,n.useState)("all"),[L,C]=(0,n.useState)("all"),[b,y]=(0,n.useState)(""),[B,z]=(0,n.useState)(new Set),[v,I]=(0,n.useState)(""),[S,P]=(0,n.useState)("pending"),re=[...new Set([...f,...i].map(w=>w.submittedBy).filter(Boolean))],te=(0,n.useCallback)(async()=>{try{let w=await fetch(`${_}/audit/list`).then(oe=>oe.json());w.ok&&(c(w.pending||[]),k(w.rejected||[]),z(new Set))}catch{}},[]);(0,n.useEffect)(()=>{te()},[s,te]);let W=(S==="pending"?f:i).filter(w=>{if(x!=="all"&&w.kind!==x||L!=="all"&&tt(w.submittedBy)!==L)return!1;if(b){let oe=(w.created||"").slice(0,10);if(oe&&oe!==b)return!1}return!0}),Ie=w=>z(oe=>{let g=new Set(oe);return g.has(w)?g.delete(w):g.add(w),g}),j=async(w,oe)=>{I("apply");try{for(let g of oe||[...B])await fetch(`${_}/${w==="approved"?"audit/approve":w==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${w==="delete"?"&permanent=0":""}`);await te(),l&&l()}catch{}finally{I("")}},he=[...B];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:ze}),(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:x,onChange:w=>N(w.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")}),ht.filter(w=>w!=="all").map(w=>(0,e.jsx)("option",{value:w,children:t(De[w])},w))]}),(0,e.jsxs)("select",{value:L,onChange:w=>C(w.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")}),Rt(re).map(w=>(0,e.jsx)("option",{value:w,children:w},w))]}),(0,e.jsx)("input",{type:"date",value:b,onChange:w=>y(w.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${S==="pending"?" me-on":""}`,onClick:()=>P("pending"),children:[t("pending"),"\uFF08",f.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${S==="rejected"?" me-on":""}`,onClick:()=>P("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:W.length>0&&he.length===W.length,onChange:w=>{w.target.checked?z(new Set(W.map(oe=>oe.path))):z(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!he.length||!!v,onClick:()=>j("approved"),children:["\u2713 ",t(S==="rejected"?"restore":"approve")]}),S==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!v,onClick:()=>j("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!he.length||!!v,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&j("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),W.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:W.map(w=>(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:B.has(w.path),onChange:()=>Ie(w.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:$e[w.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:tt(w.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:w.created?w.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:w.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:w.severity==="high"?"#f87171":"#9ca3af"},children:w.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.reason||"-"}),S==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>j("approved",[w.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>j("rejected",[w.path]),children:"\u2715"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:t("restore"),onClick:()=>j("approved",[w.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:t("restoreDelete"),onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&j("delete",[w.path])},children:"\u{1F5D1}"})]})]},w.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function sa({t,onReload:l,version:s}){let[f,c]=(0,n.useState)([]),[i,k]=(0,n.useState)(""),x=(0,n.useCallback)(async()=>{try{let L=await fetch(`${_}/recycle/list`).then(C=>C.json());L.ok&&c(L.items||[])}catch{}},[]);(0,n.useEffect)(()=>{x()},[s,x]);let N=async(L,C)=>{k(L+C);try{L==="restore"?await fetch(`${_}/recycle/restore?path=${encodeURIComponent(C)}`):L==="purge"&&await fetch(`${_}/recycle/purge?path=${encodeURIComponent(C)}`),await x(),l&&l()}catch{}finally{k("")}};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:ze}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i,onClick:async()=>{k("purgeAll");try{await fetch(`${_}/recycle/purge-expired?days=0`),await x()}catch{}finally{k("")}},children:t("emptyRecycle")})]}),f.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:f.map(L=>(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[L.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(L.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>N("restore",L.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&N("purge",L.path)},children:t("purge")})]},L.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var da=({card:t,t:l,onOpen:s,query:f,onDelete:c})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>s(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}"}),f?Tt(t.title,f):t.title,ya(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:f?Tt(t.summary||"",f):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[mt[t.kind]||"\u{1F4CE}"," ",l(De[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",tt(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",et(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&c&&c(t.path)},children:"\u{1F5D1}"})]})]});function ca({t,tab:l,onReload:s,version:f}){let[c,i]=(0,n.useState)(null),[k,x]=(0,n.useState)(""),[N,L]=(0,n.useState)(null),[C,b]=(0,n.useState)(null),[y,B]=(0,n.useState)(null),[z,v]=(0,n.useState)([]),[I,S]=(0,n.useState)(""),[P,re]=(0,n.useState)(!1),te=(0,n.useCallback)(async()=>{if(!(!N||!N.merge||!N.merge.length)&&window.confirm(t("mergeAllConfirm"))){S("merge");try{let g={},D=Z=>g[Z]===void 0?Z:g[Z]=D(g[Z]),U=(Z,J)=>{g[D(Z)]=D(J)},V=new Set;for(let Z of N.merge)V.add(Z.a.path),V.add(Z.b.path),U(Z.a.path,Z.b.path);let O={};for(let Z of V){let J=D(Z);(O[J]=O[J]||[]).push(Z)}let H=0;for(let Z of Object.values(O)){if(Z.length<2)continue;(await fetch(`${_}/merge?paths=${encodeURIComponent(Z.join(","))}`).then(xe=>xe.json())).ok&&H++}await W(),s&&s()}catch{}S("")}},[N,W,s,t]);async function W(){try{let g=await Promise.all([fetch(`${_}/stats`),fetch(`${_}/budget`),fetch(`${_}/capture-log`),fetch(`${_}/cards?status=all&limit=30&agent=${ot}`)]),[D,U,V,O]=await Promise.all(g.map(H=>H.json()));D&&D.ok&&i(D),U&&U.ok&&b(U),V&&V.ok&&B(V),O&&O.ok&&v(O.cards||[]),x(!D||!D.ok?t("adminLoadFail"):"")}catch{x(t("adminLoadFail"))}}let Ie=(0,n.useCallback)(async()=>{S("scan");try{let g=await fetch(`${_}/optimize`).then(D=>D.json());g.ok&&L(g)}catch{x(t("adminLoadFail"))}finally{S("")}},[t]);(0,n.useEffect)(()=>{W()},[f]);let j=async(g,D)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${_}/merge?paths=${encodeURIComponent(g+","+D)}`).then(V=>V.json())).ok&&(await W(),s&&s())}catch{}},he=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${_}/delete?path=${encodeURIComponent(g)}`).then(U=>U.json())).ok&&(await W(),s&&s())}catch{}},w=["project","knowledge","content","prompt","business","tool","mistake"],oe=({title:g,kind:D,updated:U,path:V})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Qe.colors[D]||"#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:et(U)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>he(V),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:ze}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[k&&(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 ",k]}),(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")]})]}),y?y.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(y.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:(y.entries||[]).map((g,D)=>{let U=ea[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:et(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:U[1],fontWeight:600},children:[U[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||""})]},D)})})})}):(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",z.length,"\uFF09"]}),z.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.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:et(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),c&&(0,e.jsxs)(e.Fragment,{children:[c.trend&&c.trend.length>0&&(()=>{let g=c.trend,D=Math.max(...g.map(H=>H.count),1),U=260,V=50,O=U/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:U,height:V,style:{display:"block",width:"100%",height:50},children:g.map((H,Z)=>{let J=Math.round(H.count/D*(V-4));return(0,e.jsx)("rect",{x:Z*O+1,y:V-J,width:Math.max(O-2,2),height:J,rx:1.5,fill:H.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:H.count>0?.85:.35},H.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:c.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:w.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Qe.colors[g]||"#666"}}),t(De[g]),": ",c.byKind?.[g]||0]},g))})]}),C&&(C.budgetChars||C.recallLimit||C.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:C.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:C.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",C.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",c.todayCards?.length||0,"\uFF09"]}),c.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:c.todayCards.map(g=>(0,e.jsx)(oe,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!I,onClick:Ie,children:I==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),N&&N.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!I,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){S("oneclick");try{let g=JSON.stringify({cleanupStale:P}),U=await(await fetch(`${_}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();U&&U.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${U.plan.merged} ${t("optimizedMerged")}${P?` \xB7 ${U.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await W(),s&&s(),L(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{S("")}}},children:I==="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:P,onChange:g=>re(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:!!I,onClick:te,children:t(I==="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,D)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[g.a.title," \u21C4 ",g.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(g.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>j(g.a.path,g.b.path),children:t("mergeNow")})]},D))}):(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:!!I,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;S("clean");let g=0;for(let D of N.stale)try{await fetch(`${_}/delete?path=${encodeURIComponent(D.path)}`),g++}catch{}S(""),notify(`${g} ${t("deletedStale")}`),await W(),s&&s()},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)(oe,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var 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 pa({t,newCard:l,setNewCard:s,onCreated:f}){if(!l)return null;let c=yt.find(b=>b.key===l.template),i=l.body||(c?t(c.bodyKey):""),k=l.kind||(c?c.kind:"knowledge"),x=l.tags||(c?t(c.tagKey):""),N=l._creating,L=b=>{let y=yt.find(B=>B.key===b);s(B=>({...B,template:b,kind:y?y.kind:B.kind,body:y?t(y.bodyKey):B.body,tags:y?t(y.tagKey):B.tags}))},C=async()=>{if(!(!l.title&&!i)){s(b=>({...b,_creating:!0}));try{(await fetch(`${_}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:k,tags:x.split(",").map(y=>y.trim()).filter(Boolean),body:i,source:"manual"})}).then(y=>y.json())).ok?(s(null),f&&f()):s(y=>({...y,_creating:!1}))}catch{s(y=>({...y,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>s(null),children:[(0,e.jsx)("style",{children:ze}),(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:()=>s(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(b=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===b.key?" me-on":""}`,onClick:()=>L(b.key),children:t(b.label)},b.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>s(b=>({...b,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:k,onChange:b=>s(y=>({...y,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=>s(y=>({...y,title:b.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:x,onChange:b=>s(y=>({...y,tags:b.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:b=>s(y=>({...y,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:C,children:t(N?"exporting":"createCard")})})]})]})]})}function ma({t,card:l,query:s,onClose:f,onDelete:c,onFeedback:i}){(0,n.useEffect)(()=>{let I=S=>{S.key==="Escape"&&f()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[f]);let{meta:k,body:x}=(0,n.useMemo)(()=>bt(l.text||""),[l.text]),N=I=>{let S=k.find(([P])=>String(P).toLowerCase()===I);return S?S[1]:""},L=It(N("tags")),C=N("kind")||"knowledge",b=(N("status")||"approved").toLowerCase(),y=$e[C]||"#6B7280",B=(x||"").length>460,[z,v]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:f,children:[(0,e.jsx)("style",{children:ze}),(0,e.jsxs)("div",{className:"me-dialog",onClick:I=>I.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[C]||"\u{1F4CE}"}),l.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[s&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),B&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":z,onClick:()=>v(I=>!I),children:t(z?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&c&&c(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:f,children:t("close")})]})]}),(0,e.jsxs)("div",{className:"md-meta",children:[(0,e.jsxs)("span",{className:"md-chip md-chip-kind",style:{color:y,borderColor:y+"59",background:y+"1a"},children:[mt[C]||"\u{1F4CE}"," ",t(De[C]||"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")]}),L.slice(0,8).map(I=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",I]},I)),!!N("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",et(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:z?{}:{maxHeight:300,overflow:"hidden"},onClick:z?void 0:I=>{I.stopPropagation(),v(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:Lt(x)}})}),!z&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:I=>{I.stopPropagation(),v(!0)},children:[t("expand")," \u2304"]})]})]})}function ua({t,onOpen:l,all:s,onAllChange:f,onMutate:c,active:i,visible:k}){let[x,N]=(0,n.useState)(null),[L,C]=(0,n.useState)(""),b=(0,n.useRef)(!1),y=(0,n.useRef)(0),B=(0,n.useRef)(t);B.current=t;let z=(0,n.useCallback)(async()=>{try{b.current=!1;let P=await(await fetch(`${_}/graph${s?"?all=1":""}`)).json();P.ok?(N(P),C(""),b.current=!0):(N(null),C(P.error||t("error")))}catch(S){C(String(S&&S.message?S.message:S))}},[s,t]);(0,n.useEffect)(()=>{if(!i||b.current)return;let S=!0;return fetch(`${_}/graph${s?"?all=1":""}`).then(P=>P.json()).then(P=>{S&&(P.ok?(N(P),C(""),b.current=!0):(N(null),C(P.error||t("error"))))}).catch(P=>{S&&C(String(P&&P.message?P.message:P))}),()=>{S=!1}},[s,t,i]),(0,n.useEffect)(()=>{k&&x&&y.current++},[k,x]);let v=(0,n.useCallback)(async S=>{try{let re=await(await fetch(`${_}/delete?path=${encodeURIComponent(S)}`)).json();return re&&re.ok?(await z(),c&&c(),!0):!1}catch{return!1}},[z]),I=(0,n.useCallback)(async S=>{if(!S||S.length<2)return!1;try{let P=await fetch(`${_}/merge?paths=${encodeURIComponent(S.join(","))}`).then(re=>re.json());return P&&P.ok?(await z(),c&&c(),!0):!1}catch{return!1}},[z,c]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:ze}),L&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",L]}),!x&&!L&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),x&&x.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),x&&x.nodes.length>0&&(0,e.jsx)(fa,{nodes:x.nodes,edges:x.edges,onOpen:l,onDelete:v,onMerge:I,t,all:s,onAllChange:f,countLabel:`${x.nodes.length} ${t("nodes")} \xB7 ${ga(x.edges)} ${t("edges")}`,fitTrigger:y.current})]})}function ga(t){let l=new Set;for(let s of t||[])l.add([s.source,s.target].sort().join("|"));return l.size}var Qe={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function fa({nodes:t,edges:l,onOpen:s,onDelete:f,onMerge:c,t:i,countLabel:k,all:x,onAllChange:N,fitTrigger:L}){let C=(0,n.useRef)(null),b=(0,n.useRef)(null),y=(0,n.useRef)(null),B=(0,n.useRef)(null),z=(0,n.useRef)(null),v=(0,n.useRef)(s);(0,n.useEffect)(()=>{v.current=s},[s]);let I=(0,n.useRef)(f);(0,n.useEffect)(()=>{I.current=f},[f]);let S=(0,n.useRef)(c);(0,n.useEffect)(()=>{S.current=c},[c]);let[P,re]=(0,n.useState)(""),[te,W]=(0,n.useState)(null),Ie=(0,n.useRef)("");(0,n.useEffect)(()=>{Ie.current=P.trim().toLowerCase()},[P]),(0,n.useEffect)(()=>{let r=y.current;if(!r)return;let o=P.trim().toLowerCase();if(!o)return;let A=r.nodes.find(ae=>(ae.name||"").toLowerCase().includes(o));A&&(y.current.selectedId=A.id,W(A.id),r.panX=r.w/2-A.x*r.zoom,r.panY=r.h/2-A.y*r.zoom,r.render&&r.render())},[P]);let[j,he]=(0,n.useState)("all"),[w,oe]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[D,U]=(0,n.useState)(""),V=(0,n.useRef)(""),[O,H]=(0,n.useState)(!1),Z=(0,n.useRef)(!1),[J,xe]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=j},[j]),(0,n.useEffect)(()=>{V.current=D},[D]),(0,n.useEffect)(()=>{Z.current=O},[O]);let Re=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let A of o.tags||[]){let ae=String(A).trim();ae&&r.set(ae,(r.get(ae)||0)+1)}return[...r.entries()].sort((o,A)=>A[1]-o[1]).slice(0,24).map(([o,A])=>({tag:o,n:A}))},[t]),He=(()=>{let r=P.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(De[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=y.current;r&&r.wake&&r.wake()},[P]),(0,n.useEffect)(()=>{let r=y.current;r&&r.render&&r.render()},[j,D,O]);let Ce=(0,n.useRef)(null),[se,Q]=(0,n.useState)([]),[p,q]=(0,n.useState)(null),[X,ne]=(0,n.useState)(!1),[Se,Ae]=(0,n.useState)(null),[Ne,_e]=(0,n.useState)(""),Ue=(0,n.useRef)(null),Fe=(0,n.useRef)(null),ie=(r,o=!0)=>{Ue.current&&clearTimeout(Ue.current),Ae({msg:r,ok:o}),Ue.current=setTimeout(()=>Ae(null),1900)},Ke=r=>{_e(r),Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout(()=>_e(""),1600)};(0,n.useEffect)(()=>()=>{Ue.current&&clearTimeout(Ue.current),Fe.current&&clearTimeout(Fe.current)},[]);let ke=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=C.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let A=Math.max(1,window.devicePixelRatio||1),ae=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(d=>{ce[d.source]=(ce[d.source]||0)+1,ce[d.target]=(ce[d.target]||0)+1});let ve=Math.max(1,...Object.values(ce)),a={nodes:t.map(d=>({id:d.id,name:d.title||"",type:d.kind||"other",r:9+Math.min(10,(ce[d.id]||0)/ve*8),x:0,y:0,vx:0,vy:0})),edges:l.map(d=>({sourceNodeId:d.source,targetNodeId:d.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:A,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((d,M)=>(d[M.id]=M,d),{}),a.nodes.forEach((d,M)=>{let h=M/a.nodes.length*Math.PI*2-Math.PI/2;d.x=Math.cos(h)*60,d.y=Math.sin(h)*60});let at=[...new Set(a.nodes.map(d=>d.type))];a.clustered=at.length>1,a.typeCenters={},at.forEach((d,M)=>{let h=M/at.length*Math.PI*2-Math.PI/2;a.typeCenters[d]={x:Math.cos(h)*160,y:Math.sin(h)*160}}),y.current=a;let it=0,lt=0,u=()=>{let d=r.clientWidth,M=r.clientHeight;a.w=d,a.h=M,r.width=d*A,r.height=M*A,o.setTransform(A,0,0,A,0,0),(it===0||lt===0)&&d>0&&M>0&&a.tickCount>0&&requestAnimationFrame(()=>me()),it=d,lt=M};u();let E=new ResizeObserver(u);E.observe(r.parentElement);let K=(d,M)=>d&&d.length>M?d.slice(0,M)+"\u2026":d,fe=(d,M,h,T)=>{if(o.beginPath(),T==="rect")o.rect(d-h,M-h*.75,h*2,h*1.5);else if(T==="diamond")o.moveTo(d,M-h),o.lineTo(d+h,M),o.lineTo(d,M+h),o.lineTo(d-h,M),o.closePath();else if(T==="hexagon"){for(let R=0;R<6;R++){let ee=Math.PI/3*R-Math.PI/2,Y=d+h*Math.cos(ee),ge=M+h*Math.sin(ee);R===0?o.moveTo(Y,ge):o.lineTo(Y,ge)}o.closePath()}else o.arc(d,M,h,0,Math.PI*2)},me=()=>{if(!a.nodes.length)return;let d=1/0,M=-1/0,h=1/0,T=-1/0;a.nodes.forEach(Me=>{d=Math.min(d,Me.x),M=Math.max(M,Me.x),h=Math.min(h,Me.y),T=Math.max(T,Me.y)});let R=20,ee=M-d+R*2,Y=T-h+R*2,ge=Math.min(a.w/ee,a.h/Y);a.zoom=Math.max(.35,Math.min(1.8,ge)),a.panX=a.w/2-(d+M)/2*a.zoom,a.panY=a.h/2-(h+T)/2*a.zoom};B.current=me;let ue=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Ie.current,a.kindFilter=g.current,a.timeMode=Z.current,a.tagFilter=V.current;let d=a.tagFilter,M=a.kindFilter,h=m=>String(m||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=ae()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let m=0;m<a.w;m+=24)o.beginPath(),o.moveTo(m,0),o.lineTo(m,a.h),o.stroke();for(let m=0;m<a.h;m+=24)o.beginPath(),o.moveTo(0,m),o.lineTo(a.w,m),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let T={};a.nodes.forEach(m=>T[m.id]=m);let R=a.nodes.length>40,ee=R?1.5:.55,Y=a.selectedId||a.hoverId;a.edges.forEach(m=>{let F=T[m.sourceNodeId],$=T[m.targetNodeId];if(!F||!$)return;if(M!=="all"){let dt=a.domainById[m.sourceNodeId]&&a.domainById[m.sourceNodeId].kind,Te=a.domainById[m.targetNodeId]&&a.domainById[m.targetNodeId].kind;if(dt!==M&&Te!==M)return}if(d){let dt=a.domainById[m.sourceNodeId]&&(a.domainById[m.sourceNodeId].tags||[]).includes(d),Te=a.domainById[m.targetNodeId]&&(a.domainById[m.targetNodeId].tags||[]).includes(d);if(!dt&&!Te)return}let G=$.x-F.x,le=$.y-F.y,de=Math.sqrt(G*G+le*le)||1,ye=R?12:18,pe=-le/de*ye,Le=G/de*ye,Be=(F.x+$.x)/2+pe,Ee=(F.y+$.y)/2+Le,Oe=Qe.colors[a.domainById[F.id]&&a.domainById[F.id].kind||"other"],rt=Y&&(m.sourceNodeId===Y||m.targetNodeId===Y),ut=Y?rt?.6:.08:R?.14:.24,gt=parseInt(Oe.slice(1,3),16),nt=parseInt(Oe.slice(3,5),16),st=parseInt(Oe.slice(5,7),16);o.strokeStyle="rgba("+gt+","+nt+","+st+","+ut+")",o.lineWidth=rt?1.6+(m.weight||1):.8+(m.weight||1)*.5,o.beginPath(),o.moveTo(F.x,F.y),o.quadraticCurveTo(Be,Ee,$.x,$.y),o.stroke()});let ge=null;Y&&(ge=new Set,a.edges.forEach(m=>{m.sourceNodeId===Y?ge.add(m.targetNodeId):m.targetNodeId===Y&&ge.add(m.sourceNodeId)}));let Me=[];if(a.nodes.forEach(m=>{let F=a.domainById[m.id]||{},$=F.kind||"other",G=a.timeMode?ba(F.updated):Qe.colors[$],le=Qe.shapes[$],de=a.selectedId===m.id,ye=a.hoverId===m.id,pe=a.searchTerm||"",Le=!pe||(m.name||"").toLowerCase().includes(pe)||String(De[$]||"").toLowerCase().includes(pe)||String($).toLowerCase().includes(pe),Be=M==="all"||$===M,Ee=!d||(F.tags||[]).includes(d),Oe=Y&&m.id!==Y&&!(ge&&ge.has(m.id))||pe&&!Le||!Be||!Ee;o.save(),o.globalAlpha=Oe?.08:1,(de||ye)&&(o.shadowColor=G,o.shadowBlur=de?20:14),fe(m.x,m.y,m.r,le);let rt=parseInt(G.slice(1,3),16),ut=parseInt(G.slice(3,5),16),gt=parseInt(G.slice(5,7),16),nt=o.createRadialGradient(m.x-m.r*.3,m.y-m.r*.3,0,m.x,m.y,m.r*1.2);nt.addColorStop(0,"rgba("+Math.min(255,rt+70)+","+Math.min(255,ut+70)+","+Math.min(255,gt+70)+",0.95)"),nt.addColorStop(1,G),o.fillStyle=nt,o.fill(),o.restore(),de?(o.save(),fe(m.x,m.y,m.r+3,le),o.strokeStyle=G,o.lineWidth=3,o.shadowColor=G,o.shadowBlur=12,o.stroke(),o.restore()):ye?(o.save(),fe(m.x,m.y,m.r+2,le),o.strokeStyle=G,o.lineWidth=2,o.stroke(),o.restore()):pe&&Le?(o.save(),fe(m.x,m.y,m.r+2,le),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(m.id)>=0&&(o.save(),fe(m.x,m.y,m.r+2,le),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let st=K(m.name,16);if((de||ye||a.zoom>ee||!R&&a.zoom>.6)&&Be&&Ee){let Te=1/a.zoom;o.font="500 "+(12*Te).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let We=o.measureText(st).width+16*Te,ct=18*Te,Xe=m.y+m.r+8*Te,Nt=!0;for(let Ve of Me)if(m.x-We/2<Ve.x+Ve.w&&m.x+We/2>Ve.x&&Xe<Ve.y+Ve.h&&Xe+ct>Ve.y){Nt=!1;break}if(!Nt&&!de&&!ye)return;Me.push({x:m.x-We/2,y:Xe,w:We,h:ct}),o.fillStyle=ae()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(m.x-We/2,Xe,We,ct,4*Te):o.rect(m.x-We/2,Xe,We,ct),o.fill(),o.strokeStyle=ae()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*Te,o.stroke(),o.fillStyle=ae()?de||ye?"#eee":"#bbb":de||ye?"#111":"#444",o.textAlign="center",o.fillText(st,m.x,Xe+13*Te)}}),o.restore(),a.marquee){let m=a.marquee,F=Math.min(m.sx,m.ex),$=Math.min(m.sy,m.ey),G=Math.abs(m.ex-m.sx),le=Math.abs(m.ey-m.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(F,$,G,le),o.strokeRect(F,$,G,le),o.restore()}if(a.hoverId&&Ce.current){let m=a.domainById[a.hoverId],F=a.nodes.find(function($){return $.id===a.hoverId});if(m&&F){let $=a.edges.filter(function(de){return de.sourceNodeId===m.id||de.targetNodeId===m.id}).length,G=F.x*a.zoom+a.panX,le=F.y*a.zoom+a.panY;Ce.current.style.display="block",Ce.current.style.left=G+14+"px",Ce.current.style.top=le-6+"px",Ce.current.innerHTML="<b>"+h(m.title||m.name||"")+'</b><br/><span style="opacity:.8">'+h(m.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",$)+"</span>"}}else Ce.current&&(Ce.current.style.display="none")},be=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(je))};a.wake=be,a.render=ue;let Pe=()=>{let d=a.nodes.length;a.tickCount++;let h=.9-Math.min(.4,a.tickCount/1500),T=d>1e3?3e3:d>100?2e3:d>50?1200:800,R=d>100?.002:.005,ee=d>1e3?.012:d>100?.005:.01,Y=d>1e3?6:d>200?12:24,ge={};a.nodes.forEach(F=>ge[F.id]=F);for(let F=0;F<d;F++){if(a.dragNode===a.nodes[F])continue;let $=a.nodes[F],G=0,le=0;for(let pe=0;pe<d;pe++){if(F===pe)continue;let Le=$.x-a.nodes[pe].x,Be=$.y-a.nodes[pe].y,Ee=Math.sqrt(Le*Le+Be*Be)||1,Oe=T/(Ee*Ee);G+=Le/Ee*Oe,le+=Be/Ee*Oe}if(a.clustered&&a.typeCenters[$.type]){let pe=a.typeCenters[$.type];G+=(pe.x-$.x)*.006,le+=(pe.y-$.y)*.006}else G-=$.x*ee,le-=$.y*ee;let de=($.vx+G)*h,ye=($.vy+le)*h;de=Math.max(-Y,Math.min(Y,de)),ye=Math.max(-Y,Math.min(Y,ye)),$.vx=de,$.vy=ye}a.edges.forEach(F=>{let $=ge[F.sourceNodeId],G=ge[F.targetNodeId];if(!$||!G)return;let le=G.x-$.x,de=G.y-$.y,ye=Math.sqrt(le*le+de*de)||1,pe=(ye-100)*R,Le=le/ye*pe,Be=de/ye*pe;a.dragNode!==$&&($.vx+=Le,$.vy+=Be),a.dragNode!==G&&(G.vx-=Le,G.vy-=Be)});let Me=0;a.nodes.forEach(F=>{a.dragNode!==F&&(F.x+=F.vx,F.y+=F.vy,Me+=F.vx*F.vx+F.vy*F.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,me()),(d?Math.sqrt(Me/d):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},je=()=>{if(a.running){try{Pe(),ue()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(je)}},we=(d,M)=>{let h=r.getBoundingClientRect();return{x:(d-h.left-a.panX)/a.zoom,y:(M-h.top-a.panY)/a.zoom}},Ye=d=>{let M=a.domainById[d];return!(!M||g.current!=="all"&&M.kind!==g.current||V.current&&!(M.tags||[]).includes(V.current))},qe=(d,M,h)=>Math.max(M,Math.min(h,d)),xt=d=>{a.mouseX=d.clientX,a.mouseY=d.clientY;let M=we(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let ee=R.x-M.x,Y=R.y-M.y;if(ee*ee+Y*Y<R.r*R.r+36){h=R.id;break}}h!==a.hoverId&&(a.hoverId=h,be())},vt=d=>{if(d.button!==0)return;let M=we(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let ee=R.x-M.x,Y=R.y-M.y;if(ee*ee+Y*Y<R.r*R.r+25){h=R;break}}if(d.shiftKey){if(h){a.shiftClick=h.id;return}a.marquee={sx:d.clientX,sy:d.clientY,ex:d.clientX,ey:d.clientY};return}a.dragStart={x:d.clientX,y:d.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=h||null,h&&(a.dragOffset={dx:h.x-M.x,dy:h.y-M.y})},wt=d=>{if(a.marquee){a.marquee.ex=d.clientX,a.marquee.ey=d.clientY,be();return}if(!a.dragStart)return;let M=d.clientX-a.dragStart.x,h=d.clientY-a.dragStart.y;if(Math.abs(M)+Math.abs(h)>3&&(a.dragging=!0),a.dragNode){let T=we(d.clientX,d.clientY);a.dragNode.x=T.x+a.dragOffset.dx,a.dragNode.y=T.y+a.dragOffset.dy,be()}else a.dragging&&(a.panX=qe(a.dragStart.px+M,-1e5,1e5),a.panY=qe(a.dragStart.py+h,-1e5,1e5),be())},kt=d=>{if(a.marquee){let h=a.marquee;a.marquee=null;let T=r.getBoundingClientRect(),R=Math.min(h.sx,h.ex)-T.left,ee=Math.max(h.sx,h.ex)-T.left,Y=Math.min(h.sy,h.ey)-T.top,ge=Math.max(h.sy,h.ey)-T.top,Me=a.nodes.filter(m=>{let F=m.x*a.zoom+a.panX,$=m.y*a.zoom+a.panY;return F>=R&&F<=ee&&$>=Y&&$<=ge}).map(m=>m.id);a.multi=Me,Q(Me),be();return}let M=a.dragStart&&!a.dragging;if(a.shiftClick){let h=a.shiftClick;a.shiftClick=null;let T=Array.isArray(a.multi)?a.multi.slice():[];T.includes(h)||T.push(h),a.multi=T,Q(T),be();return}if(M){let h=we(d.clientX,d.clientY),T=null;for(let R=a.nodes.length-1;R>=0;R--){let ee=a.nodes[R];if(!Ye(ee.id))continue;let Y=ee.x-h.x,ge=ee.y-h.y;if(Y*Y+ge*ge<ee.r*ee.r+20){T=ee;break}}T?(a.selectedId=T.id,W(T.id),be()):(a.selectedId=null,a.hoverId=null,d.shiftKey||(a.multi=[],Q([])),W(null),be())}a.dragStart=null,a.dragging=!1,a.dragNode=null},Ct=d=>{d.preventDefault();let M=we(d.clientX,d.clientY),h=null;for(let T=a.nodes.length-1;T>=0;T--){let R=a.nodes[T];if(!Ye(R.id))continue;let ee=R.x-M.x,Y=R.y-M.y;if(ee*ee+Y*Y<R.r*R.r+25){h=R;break}}if(h){let T=a.domainById[h.id];T&&xe({x:d.clientX,y:d.clientY,id:h.id,path:T.id,title:T.title})}else xe(null)},St=d=>{d.preventDefault();let M=r.getBoundingClientRect(),h=(d.clientX-M.left-a.panX)/a.zoom,T=(d.clientY-M.top-a.panY)/a.zoom,R=Math.max(.3,Math.min(3,a.zoom*(d.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+h*(a.zoom-R),-1e5,1e5),a.panY=qe(a.panY+T*(a.zoom-R),-1e5,1e5),a.zoom=R,be()};r.addEventListener("mousemove",xt),r.addEventListener("mousedown",vt),window.addEventListener("mousemove",wt),window.addEventListener("mouseup",kt),r.addEventListener("wheel",St,{passive:!1}),r.addEventListener("contextmenu",Ct),z.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Q([]),me(),be()};for(let d=0;d<200;d++)Pe();me(),be();let Mt=()=>oe(!1);return window.addEventListener("mousedown",Mt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),E.disconnect(),r.removeEventListener("mousemove",xt),r.removeEventListener("mousedown",vt),window.removeEventListener("mousemove",wt),window.removeEventListener("mouseup",kt),r.removeEventListener("wheel",St),r.removeEventListener("contextmenu",Ct),window.removeEventListener("mousedown",Mt)}},[t,l]),(0,n.useEffect)(()=>{L!==void 0&&B.current&&requestAnimationFrame(()=>B.current())},[L]),(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," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:P,onChange:r=>re(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>oe(r=>!r),"aria-expanded":w,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",j!=="all"||O||D?"\u25CF":"\u25BE"]}),w&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:r=>r.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${j==="all"&&!O?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{he("all"),H(!1)},children:i("all")}),Object.keys($e).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${j===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>he(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Qe.colors[r]||$e[r]}}),i(De[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${O?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>H(r=>!r),children:["\u23F1 ",i("timeDim")]}),Re.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:Re.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${D===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>U(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(j!=="all"||O||D)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{he("all"),H(!1),U("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!x,onChange:r=>N&&N(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${O?" me-on":""}`,onClick:()=>H(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=C.current;if(r)try{r.toBlob(o=>{o&&q({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>B.current&&B.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{W(null),he("all"),z.current&&z.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:C,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Ce,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)"}}),He&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),J&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>xe(null)}),J&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:J.x,top:J.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{v.current({path:J.path,title:J.title}),xe(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{J.id&&(y.current.selectedId=J.id,W(J.id)),xe(null);let r=y.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(J.title||"")}catch{}xe(null),ie(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=y.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],A=J.id;if(A&&!o.includes(A)&&o.push(A),xe(null),o.length<2){ie(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let ae=S.current&&S.current(o);ae&&ae.then?ae.then(ce=>ce?ie(i("merged")):ie(i("mergeFail"),!1)).catch(()=>ie(i("mergeFail"),!1)):ae&&ie(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=J.path;xe(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(I.current?await I.current(r):!1)?ie(i("deleted")):ie(i("deleteFail"),!1)}catch{ie(i("deleteFail"),!1)}})()},children:i("delete")})]}),se.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[se.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=se.map(ve=>ke[ve]).filter(Boolean).map(ve=>ve.title||ve.name).join(`
293
- `),A=new Blob([o],{type:"text/plain;charset=utf-8"}),ae=URL.createObjectURL(A),ce=document.createElement("a");ce.href=ae,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(ae),1e3),ie(se.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(se.length<2){ie(i("mergeNeed"),!1);return}let r=se.map(A=>ke[A]?ke[A].id:A);if(!window.confirm(i("mergeConfirm")))return;Q([]);let o=y.current;o&&(o.multi=[]),fetch(`${_}/merge?paths=${encodeURIComponent(r.join(","))}`).then(A=>A.json()).then(A=>{A&&A.ok?ie(i("merged")):ie(i("mergeFail"),!1)}).catch(()=>ie(i("mergeFail"),!1))},children:i("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(i("deleteConfirm")))return;let r=se.map(A=>ke[A]?ke[A].id:A);Q([]);let o=y.current;o&&(o.multi=[]),(async()=>{let A=0;for(let ae of r)try{(I.current?await I.current(ae):!1)&&A++}catch{}ie(A+i("deletedSelected"),A>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=y.current;r&&(r.multi=[]),Q([]);let o=y.current;o&&o.render&&o.render()},children:i("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:ke[te]?ke[te].title||ke[te].name:te}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:ke[te]?i(De[ke[te].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===te||r.target===te)||[]).slice(0,8).map((r,o)=>{let A=r.source===te?r.target:r.source,ae=ke[A];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let ve=y.current;ve&&(ve.selectedId=A,ve.hoverId=A,ve.wake&&ve.wake()),W(A)},children:ae?(ae.title||ae.name).slice(0,28):A},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),Se&&(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 "+(Se.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:Se.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:Se.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:Se.msg})]}),p&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{p.url&&URL.revokeObjectURL(p.url),q(null),ne(!1)},children:[(0,e.jsx)("style",{children:ze}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:X?"100vw":900,width:X?"100vw":"92vw",maxHeight:X?"100%":"90vh",height:X?"100%":void 0,borderRadius:X?0:14},onClick:r=>r.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:p.url,download:"memory-graph.png",onClick:()=>{Ke("download"),ie(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(Ne==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ke("full"),ne(r=>!r),ie(i("fullscreen"))},children:i(Ne==="full"?"done":X?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=p.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{Ke("copy"),ie(i("copied"))}).catch(()=>{ie(i("copyFail"),!1)}):ie(i("copyFail"),!1)},children:i(Ne==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{p.url&&URL.revokeObjectURL(p.url),q(null),ne(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:X?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:p.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:X?"calc(100% - 64px)":"70vh",borderRadius:X?0:8,cursor:"zoom-in"},onClick:()=>ne(r=>!r)})})]})]})]})}function ba(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let s=(Date.now()-l)/864e5;return s<3?"#10b981":s<14?"#f59e0b":s<30?"#f97316":"#94a3b8"}function Bt({label:t,value:l=[],options:s,onChange:f,placeholder:c,z:i=20}){let[k,x]=(0,n.useState)(!1),N=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!k)return;let v=I=>{N.current&&!N.current.contains(I.target)&&x(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[k]);let L=Array.isArray(l)?l:[],C=L.includes("__all__"),b=C?s.find(v=>v.value==="__all__")?.label||"":L.length?L.map(v=>s.find(I=>I.value===v)?.label||v).join("\u3001"):"",y=(v,I)=>{if(v.value==="__all__"){f(I?["__all__"]:[]);return}let S=new Set(L);S.has("__all__")&&S.delete("__all__"),I?S.add(v.value):S.delete(v.value),f([...S])},B=s.find(v=>v.value==="__all__"),z=s.filter(v=>v.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:()=>x(v=>!v),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||c||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),k&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[B&&(0,e.jsxs)("label",{onClick:v=>v.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:C,onChange:v=>y(B,v.target.checked)}),(0,e.jsx)("span",{children:B.label})]}),z.map(v=>(0,e.jsxs)("label",{onClick:I=>I.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:L.includes(v.value),onChange:I=>y(v,I.target.checked)}),(0,e.jsx)("span",{children:v.label})]},v.value))]})]})]})}function ya(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function ha(t,l,s){if(s&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),k=await i.createWritable();return await k.write(t),await k.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let f=URL.createObjectURL(t),c=document.createElement("a");return c.href=f,c.download=l,document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(f),1e3),{ok:!0,picked:!1,name:l}}function Tt(t,l){if(!l||!t)return t;let s=t.toLowerCase(),f=l.toLowerCase(),c=[],i=0;for(;i<t.length;){let k=s.indexOf(f,i);if(k<0){c.push(t.slice(i));break}k>i&&c.push(t.slice(i,k)),c.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(k,k+f.length)},k)),i=k+f.length}return c}function et(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let s=new Date,f=l.toDateString()===s.toDateString(),c=k=>String(k).padStart(2,"0"),i=`${c(l.getHours())}:${c(l.getMinutes())}`;return f?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
297
+ `));let Ke=new Blob([ve],{type:Ee}),me=await xa(Ke,ge,!1);if(!me.ok){O({ok:!1,msg:t("exportFail")}),he(!1);return}O({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+me.name})}catch(X){O({ok:!1,msg:t("exportFail")+" \xB7 "+(X.message||"")})}finally{he(!1)}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2600)},nt=async m=>{let j=m.target.files&&m.target.files[0];if(m.target.value="",!!j){try{let X=await j.text(),ve=await(await fetch(`${U}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:X})).json();ve.ok?(await o(),O({ok:!0,msg:t("importedVault")+"\uFF1A"+(ve.imported||0)+(ve.skipped?t("importedSkipped")+ve.skipped:"")})):O({ok:!1,msg:ve.error||t("importFail")})}catch{O({ok:!1,msg:t("importFail")})}H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2400)}},rt=(0,n.useMemo)(()=>{let m=w.slice();return ie!=="all"&&(m=m.filter(j=>at(j.submittedBy)===ie)),W!=="all"&&(m=m.filter(j=>(j.status||"approved")===W)),D==="title"?m.sort((j,X)=>String(j.title||"").localeCompare(String(X.title||""))):D==="hot"?m.sort((j,X)=>(X.weight||X.links||0)-(j.weight||j.links||0)):m.sort((j,X)=>new Date(X.updated||0).getTime()-new Date(j.updated||0).getTime()),m},[w,D,ie,W]),st=(0,n.useMemo)(()=>[...new Set(w.map(m=>at(m.submittedBy)))],[w]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Be}),J&&(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 "+(J.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:J.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:J.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:J.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)(Et,{})}),(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:c,"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?tt(new Date(b.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${de?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>ke(m=>!m),"aria-label":t(de?"collapse":"expand"),title:t(de?"collapse":"expand"),children:de?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${P==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),de&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:ue,children:[P==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Qe,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Qe,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Qe,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Qe,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Qe,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Qe,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:M,onChange:m=>ae(m.target.value)}),(0,e.jsx)("input",{ref:ee,type:"file",accept:".json,application/json",style:{display:"none"},onChange:nt}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ee.current&&ee.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>ze({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Q,onClick:()=>a("md"),children:t(Q?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Q,onClick:()=>a("json"),children:t(Q?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),P==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[vt.map(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${k===m?" active":""}`,onClick:()=>ce(m),children:t(m==="all"?"all":$e[m])},m)),(0,e.jsxs)("select",{value:ie,onChange:m=>te(m.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsxs)("option",{value:"all",children:["\u{1F916} ",t("allAgents")]}),Pt(st).map(m=>(0,e.jsx)("option",{value:m,children:m},m))]}),(0,e.jsxs)("select",{value:W,onChange:m=>Te(m.target.value),style:{fontSize:12,padding:"4px 8px",borderRadius:8,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",border:"1px solid var(--dsw-alias-border-l2, #d1d5db)"},children:[(0,e.jsx)("option",{value:"all",children:t("allStatus")}),(0,e.jsx)("option",{value:"approved",children:t("statusApproved")}),(0,e.jsx)("option",{value:"pending",children:t("statusPending")}),(0,e.jsx)("option",{value:"rejected",children:t("statusRejected")})]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(m=>(0,e.jsx)("button",{type:"button",className:`mc-chip${D===m.key?" active":""}`,onClick:()=>K(m.key),children:m.label},m.key))]}),T&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T]}),(0,e.jsx)("div",{style:{display:P==="cards"?"contents":"none"},children:B?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):T?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),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:rt.map(m=>(0,e.jsx)(ca,{card:m,t,query:M.trim(),onOpen:Se,onDelete:A},m.path))}),w.length<E&&(0,e.jsx)("div",{ref:xe,style:{height:1}}),Y&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",w.length," / ",E,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:P==="graph"?"flex":"none",flex:1,minHeight:0},children:C.has("graph")&&(0,e.jsx)(ga,{t,onOpen:Se,all:Ne,onAllChange:De,onMutate:Ce,active:P==="graph",visible:P==="graph"})}),(0,e.jsx)("div",{style:{display:P==="config"?"contents":"none"},children:C.has("config")&&(0,e.jsx)(jt,{t,onReload:()=>o(),version:Ie})}),(0,e.jsx)("div",{style:{display:P==="stats"?"contents":"none"},children:C.has("stats")&&(0,e.jsx)(pa,{t,tab:"stats",onReload:()=>o(),version:Ie})}),(0,e.jsx)("div",{style:{display:P==="audit"?"contents":"none"},children:C.has("audit")&&(0,e.jsx)(sa,{t,onReload:()=>o(),version:Ie})}),(0,e.jsx)("div",{style:{display:P==="optimize"?"contents":"none"},children:C.has("optimize")&&(0,e.jsx)(da,{t,onReload:()=>o(),version:Ie})}),_e&&(0,e.jsx)(ma,{t,card:_e,query:M.trim(),onClose:()=>Ae(null),onDelete:m=>{Ae(null),A(m)},onFeedback:m=>{let j=_e.path;fetch(`${U}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:M.trim(),path:j,useful:m})}).then(()=>O({ok:!0,msg:t(m?"fbUseful":"fbIrr")})).catch(()=>{}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)}}),(0,e.jsx)(ua,{t,newCard:Ue,setNewCard:ze,onCreated:()=>{o(),Ce(),O({ok:!0,msg:t("created")}),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>O(null),2e3)}})]})]})]})}var Qe=({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 jt({t,onReload:l,version:c,compact:y}){let[u,i]=(0,n.useState)(null),[S,w]=(0,n.useState)(0),[z,B]=(0,n.useState)(null),[v,b]=(0,n.useState)(null),[f,T]=(0,n.useState)(!1),[N,k]=(0,n.useState)(null),[L,M]=(0,n.useState)(null),[$,ie]=(0,n.useState)(""),[te,W]=(0,n.useState)(""),[Te,P]=(0,n.useState)(""),[ye,C]=(0,n.useState)(""),[ne,g]=(0,n.useState)(null),D=(0,n.useRef)(null),K=(s,E=!0)=>{D.current&&clearTimeout(D.current),g({msg:s,ok:E}),D.current=setTimeout(()=>g(null),1900)},J=(s,E)=>Object.keys(E).reduce((_,Y)=>_.split("{"+Y+"}").join(E[Y]),t(s)),O=(0,n.useCallback)(async()=>{try{let[s,E,_]=await Promise.all([fetch(`${U}/config`).then(Y=>Y.json()).catch(()=>null),fetch(`${U}/setup-status`).then(Y=>Y.json()).catch(()=>null),fetch(`${U}/budget`).then(Y=>Y.json()).catch(()=>null)]);s&&s.ok?(i(s),w(s.revision??0),B(s.schema??null),b({...s.config??{}}),k(s.dsh??null),T(s.writable===!1),ie("")):_&&_.ok?(b({..._}),T(!0),ie(t("configNeedsDsh"))):ie(t("adminLoadFail")),E&&E.ok&&M(E),P("")}catch{ie(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{O()},[c,O]);let H=(s,E)=>b(_=>({..._??{},[s]:E})),ee=s=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[s]||s,Q=async()=>{if(v){if(f){K(t("editInSetting"),!1);return}W("save");try{let s={...v};Array.isArray(s.vaultProfiles)&&(s.vaultProfiles=s.vaultProfiles.filter(Y=>Y&&(String(Y.name||"").trim()||String(Y.path||"").trim())));let E=await fetch(`${U}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:s,expectedRevision:S})}),_=await E.json();if(_&&_.ok)P(t("savedOk")+(_.note?` \xB7 ${t("restartHint")}`:"")),K(t("savedOk")),await O();else{let Y=E.status===409?t("conflictRefresh"):_?.error||t("saveFail");ie(Y),K(Y,!1)}}catch{ie(t("saveFail")),K(t("saveFail"),!1)}finally{W("")}}},he=()=>{b({...u?.config??{}}),P("")},_e={env:"vaultSrcEnv",profile:"vaultSrcProfile",workspace:"vaultSrcWorkspace",vaultDir:"vaultSrcVaultDir",default:"vaultSrcDefault"},Ae=s=>Array.isArray(s?.vaultProfiles)?s.vaultProfiles:[],Ne=(s,E,_)=>b(Y=>{let q=Ae(Y).map(ue=>({...ue||{}})),xe={...q[s]||{}};return E==="match"?String(_).trim()?xe.match={...xe.match||{},workspace:_}:delete xe.match:xe[E]=_,q[s]=xe,{...Y??{},vaultProfiles:q}}),De=()=>b(s=>({...s??{},vaultProfiles:[...Ae(s),{name:"",path:""}]})),de=s=>b(E=>({...E??{},vaultProfiles:Ae(E).filter((_,Y)=>Y!==s)})),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},Ue={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}},ze=async s=>{let E=Ue[s];E&&b(_=>({..._??{},...E}))},Ie=async(s,E)=>{W(s+E);try{let Y=await(await fetch(`${U}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:s,action:E})})).json();Y&&Y.ok?K(J(E==="install"?"mcpInstalled":"mcpUninstalled",{agent:s})):K(J("mcpActionFail",{agent:s,error:Y?.error||""}),!1);try{let q=await fetch(`${U}/setup-status`).then(xe=>xe.json());q&&q.ok&&M(q)}catch{}}catch{K(t("mergeFail"),!1)}finally{W("")}},pe=({k:s,label:E,type:_="text",step:Y,min:q,max:xe})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:E||s}),(0,e.jsx)("input",{type:_,step:Y,min:q,max:xe,value:v?v[s]??"":"",onChange:ue=>H(s,_==="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}})]}),Ce=({k:s,label:E})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(v&&v[s]),onChange:_=>H(s,_.target.checked)}),(0,e.jsx)("span",{children:E||s})]});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:Be}),ne&&(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 "+(ne.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ne.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ne.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ne.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[$&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",$]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:O,children:["\u21BB ",t("retry")]})]}),f&&(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")]}),Te&&(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 ",Te]}),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]})]}),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(s=>(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:s.isDsh?t("dshHostLabel"):s.name}),s.isDsh&&s.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",s.version]}),!s.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),s.installed&&s.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),s.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),s.mcpConfigured===!0&&s.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),s.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",s.recallTool?t("enabled"):t("disabled"),")"]})]}),s.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",s.hook]}),!s.isDsh&&s.installed&&s.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!te,onClick:()=>Ie(s.name,"install"),children:t("installMcp")}),!s.isDsh&&s.installed&&s.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!te,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Ie(s.name,"uninstall")},children:t("uninstallMcp")})]},s.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),ye&&(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:ye})})]}),v?(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(s=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ze(s),disabled:!!te,children:[s==="A"?"\u{1F7E2} ":s==="B"?"\u{1F4B0} ":"\u2B50 ",Ue[s].label]},s))})]}),(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)(Ce,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Ce,{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)(Ce,{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:N?.vaultDir||"\u2014"}),N?.vaultName?`\uFF08${N.vaultName}\uFF09`:""," \xB7 ",t("vaultSource"),"\uFF1A",t(_e[N?.vaultSource]||"vaultSrcDefault"),N?.workspace?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("br",{}),t("vaultWorkspace"),"\uFF1A",(0,e.jsx)("code",{children:N.workspace})]}):null]}),Ae(v).map((s,E)=>(0,e.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1.6fr 1.5fr auto",gap:6,marginBottom:6},children:[(0,e.jsx)("input",{value:s.name||"",placeholder:t("vaultNamePh"),onChange:_=>Ne(E,"name",_.target.value),style:ke,disabled:f}),(0,e.jsx)("input",{value:s.path||"",placeholder:t("vaultPathPh"),onChange:_=>Ne(E,"path",_.target.value),style:ke,disabled:f}),(0,e.jsx)("input",{value:s.match&&s.match.workspace||"",placeholder:t("vaultMatchPh"),onChange:_=>Ne(E,"match",_.target.value),style:ke,disabled:f}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>de(E),disabled:f,title:t("delete"),children:"\u2715"})]},E)),(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:De,disabled:f,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:v.activeVault||"",onChange:s=>H("activeVault",s.target.value),disabled:f,style:ke,children:[(0,e.jsx)("option",{value:"",children:t("vaultActiveNone")}),Ae(v).filter(s=>s&&s.name).map(s=>(0,e.jsx)("option",{value:s.name,children:s.name},s.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)(Ce,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Ce,{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:v.auditMode??"all",onChange:s=>H("auditMode",s.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)(Tt,{label:t("auditExemptAgents"),value:v.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(L?.agents||[]).filter(s=>!s.isDsh).map(s=>({value:s.name,label:s.name}))],onChange:s=>H("auditExemptAgents",s)}),(0,e.jsx)(Tt,{label:t("auditExemptKinds"),value:v.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...vt.filter(s=>s!=="all").map(s=>({value:s,label:t($e[s])}))],onChange:s=>H("auditExemptKinds",s)}),(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)(Ce,{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:v.autoWebMode??"init",onChange:s=>H("autoWebMode",s.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)(Ce,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Ce,{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:he,disabled:!!te,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:Q,disabled:!!te||te==="save"||f,children:te==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function sa({t,onReload:l,version:c}){let[y,u]=(0,n.useState)([]),[i,S]=(0,n.useState)([]),[w,z]=(0,n.useState)("all"),[B,v]=(0,n.useState)("all"),[b,f]=(0,n.useState)(""),[T,N]=(0,n.useState)(new Set),[k,L]=(0,n.useState)(""),[M,$]=(0,n.useState)("pending"),ie=[...new Set([...y,...i].map(C=>C.submittedBy).filter(Boolean))],te=(0,n.useCallback)(async()=>{try{let C=await fetch(`${U}/audit/list`).then(ne=>ne.json());C.ok&&(u(C.pending||[]),S(C.rejected||[]),N(new Set))}catch{}},[]);(0,n.useEffect)(()=>{te()},[c,te]);let W=(M==="pending"?y:i).filter(C=>{if(w!=="all"&&C.kind!==w||B!=="all"&&at(C.submittedBy)!==B)return!1;if(b){let ne=(C.created||"").slice(0,10);if(ne&&ne!==b)return!1}return!0}),Te=C=>N(ne=>{let g=new Set(ne);return g.has(C)?g.delete(C):g.add(C),g}),P=async(C,ne)=>{L("apply");try{for(let g of ne||[...T])await fetch(`${U}/${C==="approved"?"audit/approve":C==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${C==="delete"?"&permanent=0":""}`);await te(),l&&l()}catch{}finally{L("")}},ye=[...T];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:Be}),(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:w,onChange:C=>z(C.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(C=>C!=="all").map(C=>(0,e.jsx)("option",{value:C,children:t($e[C])},C))]}),(0,e.jsxs)("select",{value:B,onChange:C=>v(C.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")}),Pt(ie).map(C=>(0,e.jsx)("option",{value:C,children:C},C))]}),(0,e.jsx)("input",{type:"date",value:b,onChange:C=>f(C.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:()=>$("pending"),children:[t("pending"),"\uFF08",y.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${M==="rejected"?" me-on":""}`,onClick:()=>$("rejected"),children:[t("rejected"),"\uFF08",i.length,"\uFF09"]}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsxs)("label",{style:{fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:W.length>0&&ye.length===W.length,onChange:C=>{C.target.checked?N(new Set(W.map(ne=>ne.path))):N(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!ye.length||!!k,onClick:()=>P("approved"),children:["\u2713 ",t(M==="rejected"?"restore":"approve")]}),M==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!ye.length||!!k,onClick:()=>P("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!ye.length||!!k,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&P("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),W.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:W.map(C=>(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:T.has(C.path),onChange:()=>Te(C.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:He[C.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:at(C.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:C.created?C.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:C.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:C.severity==="high"?"#f87171":"#9ca3af"},children:C.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.reason||"-"}),M==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>P("approved",[C.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>P("rejected",[C.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:()=>P("approved",[C.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"))&&P("delete",[C.path])},children:"\u{1F5D1}"})]})]},C.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function da({t,onReload:l,version:c}){let[y,u]=(0,n.useState)([]),[i,S]=(0,n.useState)(""),w=(0,n.useCallback)(async()=>{try{let B=await fetch(`${U}/recycle/list`).then(v=>v.json());B.ok&&u(B.items||[])}catch{}},[]);(0,n.useEffect)(()=>{w()},[c,w]);let z=async(B,v)=>{S(B+v);try{B==="restore"?await fetch(`${U}/recycle/restore?path=${encodeURIComponent(v)}`):B==="purge"&&await fetch(`${U}/recycle/purge?path=${encodeURIComponent(v)}`),await w(),l&&l()}catch{}finally{S("")}};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:Be}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",t("tabRecycle")]}),(0,e.jsx)("span",{style:{fontSize:11,opacity:.6},children:t("recycleHint")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!i,onClick:async()=>{S("purgeAll");try{await fetch(`${U}/recycle/purge-expired?days=0`),await w()}catch{}finally{S("")}},children:t("emptyRecycle")})]}),y.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:y.map(B=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:He[B.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(B.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>z("restore",B.path),children:t("restore")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!i,onClick:()=>{window.confirm(t("purgeConfirm"))&&z("purge",B.path)},children:t("purge")})]},B.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var ca=({card:t,t:l,onOpen:c,query:y,onDelete:u})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>c(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:He[t.kind]||He.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:mt[t.kind]||"\u{1F4CE}"}),y?At(t.title,y):t.title,ha(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?At(t.summary||"",y):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(i=>(0,e.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",i]},i))}),(0,e.jsxs)("footer",{children:[(0,e.jsxs)("span",{children:[mt[t.kind]||"\u{1F4CE}"," ",l($e[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",at(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",tt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&u&&u(t.path)},children:"\u{1F5D1}"})]})]});function pa({t,tab:l,onReload:c,version:y}){let[u,i]=(0,n.useState)(null),[S,w]=(0,n.useState)(""),[z,B]=(0,n.useState)(null),[v,b]=(0,n.useState)(null),[f,T]=(0,n.useState)(null),[N,k]=(0,n.useState)([]),[L,M]=(0,n.useState)(""),[$,ie]=(0,n.useState)(!1),te=(0,n.useCallback)(async()=>{if(!(!z||!z.merge||!z.merge.length)&&window.confirm(t("mergeAllConfirm"))){M("merge");try{let g={},D=ee=>g[ee]===void 0?ee:g[ee]=D(g[ee]),K=(ee,Q)=>{g[D(ee)]=D(Q)},J=new Set;for(let ee of z.merge)J.add(ee.a.path),J.add(ee.b.path),K(ee.a.path,ee.b.path);let O={};for(let ee of J){let Q=D(ee);(O[Q]=O[Q]||[]).push(ee)}let H=0;for(let ee of Object.values(O)){if(ee.length<2)continue;(await fetch(`${U}/merge?paths=${encodeURIComponent(ee.join(","))}`).then(he=>he.json())).ok&&H++}await W(),c&&c()}catch{}M("")}},[z,W,c,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=${lt}`)]),[D,K,J,O]=await Promise.all(g.map(H=>H.json()));D&&D.ok&&i(D),K&&K.ok&&b(K),J&&J.ok&&T(J),O&&O.ok&&k(O.cards||[]),w(!D||!D.ok?t("adminLoadFail"):"")}catch{w(t("adminLoadFail"))}}let Te=(0,n.useCallback)(async()=>{M("scan");try{let g=await fetch(`${U}/optimize`).then(D=>D.json());g.ok&&B(g)}catch{w(t("adminLoadFail"))}finally{M("")}},[t]);(0,n.useEffect)(()=>{W()},[y]);let P=async(g,D)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${U}/merge?paths=${encodeURIComponent(g+","+D)}`).then(J=>J.json())).ok&&(await W(),c&&c())}catch{}},ye=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${U}/delete?path=${encodeURIComponent(g)}`).then(K=>K.json())).ok&&(await W(),c&&c())}catch{}},C=["project","knowledge","content","prompt","business","tool","mistake"],ne=({title:g,kind:D,updated:K,path:J})=>(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:et.colors[D]||"#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:tt(K)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ye(J),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:Be}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[S&&(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 ",S]}),(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")]})]}),f?f.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(f.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:(f.entries||[]).map((g,D)=>{let K=ta[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:tt(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:K[1],fontWeight:600},children:[K[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||""})]},D)})})})}):(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",N.length,"\uFF09"]}),N.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:N.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:He[g.kind]||He.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:tt(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,D=Math.max(...g.map(H=>H.count),1),K=260,J=50,O=K/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:K,height:J,style:{display:"block",width:"100%",height:50},children:g.map((H,ee)=>{let Q=Math.round(H.count/D*(J-4));return(0,e.jsx)("rect",{x:ee*O+1,y:J-Q,width:Math.max(O-2,2),height:Q,rx:1.5,fill:H.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:H.count>0?.85:.35},H.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:C.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:et.colors[g]||"#666"}}),t($e[g]),": ",u.byKind?.[g]||0]},g))})]}),v&&(v.budgetChars||v.recallLimit||v.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:v.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:v.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",v.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)(ne,{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:!!L,onClick:Te,children:L==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),z&&z.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!L,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){M("oneclick");try{let g=JSON.stringify({cleanupStale:$}),K=await(await fetch(`${U}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();K&&K.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${K.plan.merged} ${t("optimizedMerged")}${$?` \xB7 ${K.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await W(),c&&c(),B(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{M("")}}},children:L==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),z&&z.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:$,onChange:g=>ie(g.target.checked)}),t("oneClickAlsoStale")]})]}),!z&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),z&&(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}}),z.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!L,onClick:te,children:t(L==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),z.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:z.merge.map((g,D)=>(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:()=>P(g.a.path,g.b.path),children:t("mergeNow")})]},D))}):(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",z.stale?.length||0,"\uFF09"]}),z.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;M("clean");let g=0;for(let D of z.stale)try{await fetch(`${U}/delete?path=${encodeURIComponent(D.path)}`),g++}catch{}M(""),notify(`${g} ${t("deletedStale")}`),await W(),c&&c()},children:t("cleanStale")})}),z.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.stale.map(g=>(0,e.jsx)(ne,{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 xt=[{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 ua({t,newCard:l,setNewCard:c,onCreated:y}){if(!l)return null;let u=xt.find(b=>b.key===l.template),i=l.body||(u?t(u.bodyKey):""),S=l.kind||(u?u.kind:"knowledge"),w=l.tags||(u?t(u.tagKey):""),z=l._creating,B=b=>{let f=xt.find(T=>T.key===b);c(T=>({...T,template:b,kind:f?f.kind:T.kind,body:f?t(f.bodyKey):T.body,tags:f?t(f.tagKey):T.tags}))},v=async()=>{if(!(!l.title&&!i)){c(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:S,tags:w.split(",").map(f=>f.trim()).filter(Boolean),body:i,source:"manual"})}).then(f=>f.json())).ok?(c(null),y&&y()):c(f=>({...f,_creating:!1}))}catch{c(f=>({...f,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>c(null),children:[(0,e.jsx)("style",{children:Be}),(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:()=>c(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[xt.map(b=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===b.key?" me-on":""}`,onClick:()=>B(b.key),children:t(b.label)},b.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>c(b=>({...b,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:S,onChange:b=>c(f=>({...f,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=>c(f=>({...f,title:b.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:w,onChange:b=>c(f=>({...f,tags:b.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:b=>c(f=>({...f,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:z,onClick:v,children:t(z?"exporting":"createCard")})})]})]})]})}function ma({t,card:l,query:c,onClose:y,onDelete:u,onFeedback:i}){(0,n.useEffect)(()=>{let L=M=>{M.key==="Escape"&&y()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[y]);let{meta:S,body:w}=(0,n.useMemo)(()=>ht(l.text||""),[l.text]),z=L=>{let M=S.find(([$])=>String($).toLowerCase()===L);return M?M[1]:""},B=Lt(z("tags")),v=z("kind")||"knowledge",b=(z("status")||"approved").toLowerCase(),f=He[v]||"#6B7280",T=(w||"").length>460,[N,k]=(0,n.useState)(!0);return(0,e.jsxs)("div",{className:"me-overlay",onClick:y,children:[(0,e.jsx)("style",{children:Be}),(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:mt[v]||"\u{1F4CE}"}),l.title]}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[c&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>i&&i(!1),children:["\u{1F44E} ",t("fbNotUseful")]})]}),T&&(0,e.jsx)("button",{type:"button",className:"mc-btn","aria-expanded":N,onClick:()=>k(L=>!L),children:t(N?"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:f,borderColor:f+"59",background:f+"1a"},children:[mt[v]||"\u{1F4CE}"," ",t($e[v]||"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")]}),B.slice(0,8).map(L=>(0,e.jsxs)("span",{className:"md-chip md-chip-tag",children:["\u{1F3F7} ",L]},L)),!!z("updated")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F552} ",t("updated")," ",tt(z("updated"))]}),!!z("source")&&(0,e.jsxs)("span",{className:"md-chip md-date",children:["\u{1F4E5} ",z("source")]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:N?{}:{maxHeight:300,overflow:"hidden"},onClick:N?void 0:L=>{L.stopPropagation(),k(!0)},children:(0,e.jsx)("div",{className:"md-doc",dangerouslySetInnerHTML:{__html:Bt(w)}})}),!N&&(0,e.jsxs)("div",{className:"md-collapsed-hint",onClick:L=>{L.stopPropagation(),k(!0)},children:[t("expand")," \u2304"]})]})]})}function ga({t,onOpen:l,all:c,onAllChange:y,onMutate:u,active:i,visible:S}){let[w,z]=(0,n.useState)(null),[B,v]=(0,n.useState)(""),b=(0,n.useRef)(!1),f=(0,n.useRef)(0),T=(0,n.useRef)(t);T.current=t;let N=(0,n.useCallback)(async()=>{try{b.current=!1;let $=await(await fetch(`${U}/graph${c?"?all=1":""}`)).json();$.ok?(z($),v(""),b.current=!0):(z(null),v($.error||t("error")))}catch(M){v(String(M&&M.message?M.message:M))}},[c,t]);(0,n.useEffect)(()=>{if(!i||b.current)return;let M=!0;return fetch(`${U}/graph${c?"?all=1":""}`).then($=>$.json()).then($=>{M&&($.ok?(z($),v(""),b.current=!0):(z(null),v($.error||t("error"))))}).catch($=>{M&&v(String($&&$.message?$.message:$))}),()=>{M=!1}},[c,t,i]),(0,n.useEffect)(()=>{S&&w&&f.current++},[S,w]);let k=(0,n.useCallback)(async M=>{try{let ie=await(await fetch(`${U}/delete?path=${encodeURIComponent(M)}`)).json();return ie&&ie.ok?(await N(),u&&u(),!0):!1}catch{return!1}},[N]),L=(0,n.useCallback)(async M=>{if(!M||M.length<2)return!1;try{let $=await fetch(`${U}/merge?paths=${encodeURIComponent(M.join(","))}`).then(ie=>ie.json());return $&&$.ok?(await N(),u&&u(),!0):!1}catch{return!1}},[N,u]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Be}),B&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",B]}),!w&&!B&&(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)(ba,{nodes:w.nodes,edges:w.edges,onOpen:l,onDelete:k,onMerge:L,t,all:c,onAllChange:y,countLabel:`${w.nodes.length} ${t("nodes")} \xB7 ${fa(w.edges)} ${t("edges")}`,fitTrigger:f.current})]})}function fa(t){let l=new Set;for(let c of t||[])l.add([c.source,c.target].sort().join("|"));return l.size}var et={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 ba({nodes:t,edges:l,onOpen:c,onDelete:y,onMerge:u,t:i,countLabel:S,all:w,onAllChange:z,fitTrigger:B}){let v=(0,n.useRef)(null),b=(0,n.useRef)(null),f=(0,n.useRef)(null),T=(0,n.useRef)(null),N=(0,n.useRef)(null),k=(0,n.useRef)(c);(0,n.useEffect)(()=>{k.current=c},[c]);let L=(0,n.useRef)(y);(0,n.useEffect)(()=>{L.current=y},[y]);let M=(0,n.useRef)(u);(0,n.useEffect)(()=>{M.current=u},[u]);let[$,ie]=(0,n.useState)(""),[te,W]=(0,n.useState)(null),Te=(0,n.useRef)("");(0,n.useEffect)(()=>{Te.current=$.trim().toLowerCase()},[$]),(0,n.useEffect)(()=>{let r=f.current;if(!r)return;let o=$.trim().toLowerCase();if(!o)return;let A=r.nodes.find(ae=>(ae.name||"").toLowerCase().includes(o));A&&(f.current.selectedId=A.id,W(A.id),r.panX=r.w/2-A.x*r.zoom,r.panY=r.h/2-A.y*r.zoom,r.render&&r.render())},[$]);let[P,ye]=(0,n.useState)("all"),[C,ne]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[D,K]=(0,n.useState)(""),J=(0,n.useRef)(""),[O,H]=(0,n.useState)(!1),ee=(0,n.useRef)(!1),[Q,he]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=P},[P]),(0,n.useEffect)(()=>{J.current=D},[D]),(0,n.useEffect)(()=>{ee.current=O},[O]);let _e=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let A of o.tags||[]){let ae=String(A).trim();ae&&r.set(ae,(r.get(ae)||0)+1)}return[...r.entries()].sort((o,A)=>A[1]-o[1]).slice(0,24).map(([o,A])=>({tag:o,n:A}))},[t]),Ae=(()=>{let r=$.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String($e[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=f.current;r&&r.wake&&r.wake()},[$]),(0,n.useEffect)(()=>{let r=f.current;r&&r.render&&r.render()},[P,D,O]);let Ne=(0,n.useRef)(null),[De,de]=(0,n.useState)([]),[ke,Ue]=(0,n.useState)(null),[ze,Ie]=(0,n.useState)(!1),[pe,Ce]=(0,n.useState)(null),[s,E]=(0,n.useState)(""),_=(0,n.useRef)(null),Y=(0,n.useRef)(null),q=(r,o=!0)=>{_.current&&clearTimeout(_.current),Ce({msg:r,ok:o}),_.current=setTimeout(()=>Ce(null),1900)},xe=r=>{E(r),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(""),1600)};(0,n.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),Y.current&&clearTimeout(Y.current)},[]);let ue=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=v.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let A=Math.max(1,window.devicePixelRatio||1),ae=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(d=>{ce[d.source]=(ce[d.source]||0)+1,ce[d.target]=(ce[d.target]||0)+1});let Se=Math.max(1,...Object.values(ce)),a={nodes:t.map(d=>({id:d.id,name:d.title||"",type:d.kind||"other",r:9+Math.min(10,(ce[d.id]||0)/Se*8),x:0,y:0,vx:0,vy:0})),edges:l.map(d=>({sourceNodeId:d.source,targetNodeId:d.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:A,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((d,x)=>(d[x.id]=x,d),{}),a.nodes.forEach((d,x)=>{let h=x/a.nodes.length*Math.PI*2-Math.PI/2;d.x=Math.cos(h)*60,d.y=Math.sin(h)*60});let nt=[...new Set(a.nodes.map(d=>d.type))];a.clustered=nt.length>1,a.typeCenters={},nt.forEach((d,x)=>{let h=x/nt.length*Math.PI*2-Math.PI/2;a.typeCenters[d]={x:Math.cos(h)*160,y:Math.sin(h)*160}}),f.current=a;let rt=0,st=0,m=()=>{let d=r.clientWidth,x=r.clientHeight;a.w=d,a.h=x,r.width=d*A,r.height=x*A,o.setTransform(A,0,0,A,0,0),(rt===0||st===0)&&d>0&&x>0&&a.tickCount>0&&requestAnimationFrame(()=>Ee()),rt=d,st=x};m();let j=new ResizeObserver(m);j.observe(r.parentElement);let X=(d,x)=>d&&d.length>x?d.slice(0,x)+"\u2026":d,fe=(d,x,h,I)=>{if(o.beginPath(),I==="rect")o.rect(d-h,x-h*.75,h*2,h*1.5);else if(I==="diamond")o.moveTo(d,x-h),o.lineTo(d+h,x),o.lineTo(d,x+h),o.lineTo(d-h,x),o.closePath();else if(I==="hexagon"){for(let R=0;R<6;R++){let Z=Math.PI/3*R-Math.PI/2,V=d+h*Math.cos(Z),be=x+h*Math.sin(Z);R===0?o.moveTo(V,be):o.lineTo(V,be)}o.closePath()}else o.arc(d,x,h,0,Math.PI*2)},ve=new Map,ge=(d,x)=>{let h=d+"|"+Math.round(x),I=ve.get(h);if(!I){let R=parseInt(d.slice(1,3),16),Z=parseInt(d.slice(3,5),16),V=parseInt(d.slice(5,7),16);I=o.createRadialGradient(-x*.3,-x*.3,0,0,0,x*1.2),I.addColorStop(0,"rgba("+Math.min(255,R+70)+","+Math.min(255,Z+70)+","+Math.min(255,V+70)+",0.95)"),I.addColorStop(1,d),ve.set(h,I)}return I},Ee=()=>{if(!a.nodes.length)return;let d=1/0,x=-1/0,h=1/0,I=-1/0;a.nodes.forEach(we=>{d=Math.min(d,we.x),x=Math.max(x,we.x),h=Math.min(h,we.y),I=Math.max(I,we.y)});let R=20,Z=x-d+R*2,V=I-h+R*2,be=Math.min(a.w/Z,a.h/V);a.zoom=Math.max(.35,Math.min(1.8,be)),a.panX=a.w/2-(d+x)/2*a.zoom,a.panY=a.h/2-(h+I)/2*a.zoom};T.current=Ee;let Ke=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Te.current,a.kindFilter=g.current,a.timeMode=ee.current,a.tagFilter=J.current;let d=a.tagFilter,x=a.kindFilter,h=p=>String(p||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=ae()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let p=0;p<a.w;p+=24)o.beginPath(),o.moveTo(p,0),o.lineTo(p,a.h),o.stroke();for(let p=0;p<a.h;p+=24)o.beginPath(),o.moveTo(0,p),o.lineTo(a.w,p),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let I={};a.nodes.forEach(p=>I[p.id]=p);let R=a.nodes.length>40,Z=R?1.5:.55,V=a.selectedId||a.hoverId,be=new Map;a.edges.forEach(p=>{let F=I[p.sourceNodeId],G=I[p.targetNodeId];if(!F||!G)return;if(x!=="all"){let Fe=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,bt=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(Fe!==x&&bt!==x)return}if(d){let Fe=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(d),bt=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(d);if(!Fe&&!bt)return}let oe=G.x-F.x,le=G.y-F.y,re=Math.sqrt(oe*oe+le*le)||1,se=R?12:18,Me=-le/re*se,Re=oe/re*se,Oe=(F.x+G.x)/2+Me,Xe=(F.y+G.y)/2+Re,ot=et.colors[a.domainById[F.id]&&a.domainById[F.id].kind||"other"],it=V&&(p.sourceNodeId===V||p.targetNodeId===V),gt=V?it?.6:.08:R?.14:.24,je=parseInt(ot.slice(1,3),16),ft=parseInt(ot.slice(3,5),16),Pe=parseInt(ot.slice(5,7),16),Ge=it?1.6+(p.weight||1):.8+(p.weight||1)*.5,We=je+","+ft+","+Pe+","+gt+","+Ge,Ve=be.get(We);Ve||(Ve={path:new Path2D,stroke:"rgba("+je+","+ft+","+Pe+","+gt+")",width:Ge},be.set(We,Ve)),Ve.path.moveTo(F.x,F.y),Ve.path.quadraticCurveTo(Oe,Xe,G.x,G.y)}),be.forEach(p=>{o.strokeStyle=p.stroke,o.lineWidth=p.width,o.stroke(p.path)});let we=null;V&&(we=new Set,a.edges.forEach(p=>{p.sourceNodeId===V?we.add(p.targetNodeId):p.targetNodeId===V&&we.add(p.sourceNodeId)}));let Ye=[];if(a.nodes.forEach(p=>{let F=a.domainById[p.id]||{},G=F.kind||"other",oe=a.timeMode?ya(F.updated):et.colors[G],le=et.shapes[G],re=a.selectedId===p.id,se=a.hoverId===p.id,Me=a.searchTerm||"",Re=!Me||(p.name||"").toLowerCase().includes(Me)||String($e[G]||"").toLowerCase().includes(Me)||String(G).toLowerCase().includes(Me),Oe=x==="all"||G===x,Xe=!d||(F.tags||[]).includes(d),ot=V&&p.id!==V&&!(we&&we.has(p.id))||Me&&!Re||!Oe||!Xe;o.save(),o.globalAlpha=ot?.08:1,(re||se)&&(o.shadowColor=oe,o.shadowBlur=re?20:14),o.translate(p.x,p.y),fe(0,0,p.r,le),o.fillStyle=ge(oe,p.r),o.fill(),o.restore(),re?(o.save(),fe(p.x,p.y,p.r+3,le),o.strokeStyle=oe,o.lineWidth=3,o.shadowColor=oe,o.shadowBlur=12,o.stroke(),o.restore()):se?(o.save(),fe(p.x,p.y,p.r+2,le),o.strokeStyle=oe,o.lineWidth=2,o.stroke(),o.restore()):Me&&Re?(o.save(),fe(p.x,p.y,p.r+2,le),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(p.id)>=0&&(o.save(),fe(p.x,p.y,p.r+2,le),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let it=X(p.name,16);if((re||se||a.zoom>Z||!R&&a.zoom>.6)&&Oe&&Xe){let je=1/a.zoom;o.font="500 "+(12*je).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Pe=o.measureText(it).width+16*je,Ge=18*je,We=p.y+p.r+8*je,Ve=!0;for(let Fe of Ye)if(p.x-Pe/2<Fe.x+Fe.w&&p.x+Pe/2>Fe.x&&We<Fe.y+Fe.h&&We+Ge>Fe.y){Ve=!1;break}if(!Ve&&!re&&!se)return;Ye.push({x:p.x-Pe/2,y:We,w:Pe,h:Ge}),o.fillStyle=ae()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(p.x-Pe/2,We,Pe,Ge,4*je):o.rect(p.x-Pe/2,We,Pe,Ge),o.fill(),o.strokeStyle=ae()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*je,o.stroke(),o.fillStyle=ae()?re||se?"#eee":"#bbb":re||se?"#111":"#444",o.textAlign="center",o.fillText(it,p.x,We+13*je)}}),o.restore(),a.marquee){let p=a.marquee,F=Math.min(p.sx,p.ex),G=Math.min(p.sy,p.ey),oe=Math.abs(p.ex-p.sx),le=Math.abs(p.ey-p.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(F,G,oe,le),o.strokeRect(F,G,oe,le),o.restore()}if(a.hoverId&&Ne.current){let p=a.domainById[a.hoverId],F=a.nodes.find(function(G){return G.id===a.hoverId});if(p&&F){let G=a.edges.filter(function(re){return re.sourceNodeId===p.id||re.targetNodeId===p.id}).length,oe=F.x*a.zoom+a.panX,le=F.y*a.zoom+a.panY;Ne.current.style.display="block",Ne.current.style.left=oe+14+"px",Ne.current.style.top=le-6+"px",Ne.current.innerHTML="<b>"+h(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+h(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",G)+"</span>"}}else Ne.current&&(Ne.current.style.display="none")},me=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(dt))};a.wake=me,a.render=Ke;let Le=()=>{let d=a.nodes.length;a.tickCount++;let h=.9-Math.min(.4,a.tickCount/1500),I=d>1e3?3e3:d>100?2e3:d>50?1200:800,R=d>100?.002:.005,Z=d>1e3?.012:d>100?.005:.01,V=d>1e3?6:d>200?12:24,be={};a.nodes.forEach(p=>be[p.id]=p);for(let p=0;p<d;p++){if(a.dragNode===a.nodes[p])continue;let F=a.nodes[p],G=0,oe=0;for(let se=0;se<d;se++){if(p===se)continue;let Me=F.x-a.nodes[se].x,Re=F.y-a.nodes[se].y,Oe=Math.sqrt(Me*Me+Re*Re)||1,Xe=I/(Oe*Oe);G+=Me/Oe*Xe,oe+=Re/Oe*Xe}if(a.clustered&&a.typeCenters[F.type]){let se=a.typeCenters[F.type];G+=(se.x-F.x)*.006,oe+=(se.y-F.y)*.006}else G-=F.x*Z,oe-=F.y*Z;let le=(F.vx+G)*h,re=(F.vy+oe)*h;le=Math.max(-V,Math.min(V,le)),re=Math.max(-V,Math.min(V,re)),F.vx=le,F.vy=re}a.edges.forEach(p=>{let F=be[p.sourceNodeId],G=be[p.targetNodeId];if(!F||!G)return;let oe=G.x-F.x,le=G.y-F.y,re=Math.sqrt(oe*oe+le*le)||1,se=(re-100)*R,Me=oe/re*se,Re=le/re*se;a.dragNode!==F&&(F.vx+=Me,F.vy+=Re),a.dragNode!==G&&(G.vx-=Me,G.vy-=Re)});let we=0;a.nodes.forEach(p=>{a.dragNode!==p&&(p.x+=p.vx,p.y+=p.vy,we+=p.vx*p.vx+p.vy*p.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ee()),(d?Math.sqrt(we/d):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},dt=()=>{if(a.running){try{Le(),Ke()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(dt)}},qe=(d,x)=>{let h=r.getBoundingClientRect();return{x:(d-h.left-a.panX)/a.zoom,y:(x-h.top-a.panY)/a.zoom}},ct=d=>{let x=a.domainById[d];return!(!x||g.current!=="all"&&x.kind!==g.current||J.current&&!(x.tags||[]).includes(J.current))},pt=(d,x,h)=>Math.max(x,Math.min(h,d)),wt=d=>{a.mouseX=d.clientX,a.mouseY=d.clientY;let x=qe(d.clientX,d.clientY),h=null;for(let I=a.nodes.length-1;I>=0;I--){let R=a.nodes[I];if(!ct(R.id))continue;let Z=R.x-x.x,V=R.y-x.y;if(Z*Z+V*V<R.r*R.r+36){h=R.id;break}}h!==a.hoverId&&(a.hoverId=h,me())},kt=d=>{if(d.button!==0)return;let x=qe(d.clientX,d.clientY),h=null;for(let I=a.nodes.length-1;I>=0;I--){let R=a.nodes[I];if(!ct(R.id))continue;let Z=R.x-x.x,V=R.y-x.y;if(Z*Z+V*V<R.r*R.r+25){h=R;break}}if(d.shiftKey){if(h){a.shiftClick=h.id;return}a.marquee={sx:d.clientX,sy:d.clientY,ex:d.clientX,ey:d.clientY};return}a.dragStart={x:d.clientX,y:d.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=h||null,h&&(a.dragOffset={dx:h.x-x.x,dy:h.y-x.y})},Ct=d=>{if(a.marquee){a.marquee.ex=d.clientX,a.marquee.ey=d.clientY,me();return}if(!a.dragStart)return;let x=d.clientX-a.dragStart.x,h=d.clientY-a.dragStart.y;if(Math.abs(x)+Math.abs(h)>3&&(a.dragging=!0),a.dragNode){let I=qe(d.clientX,d.clientY);a.dragNode.x=I.x+a.dragOffset.dx,a.dragNode.y=I.y+a.dragOffset.dy,me()}else a.dragging&&(a.panX=pt(a.dragStart.px+x,-1e5,1e5),a.panY=pt(a.dragStart.py+h,-1e5,1e5),me())},St=d=>{if(a.marquee){let h=a.marquee;a.marquee=null;let I=r.getBoundingClientRect(),R=Math.min(h.sx,h.ex)-I.left,Z=Math.max(h.sx,h.ex)-I.left,V=Math.min(h.sy,h.ey)-I.top,be=Math.max(h.sy,h.ey)-I.top,we=a.nodes.filter(Ye=>{let p=Ye.x*a.zoom+a.panX,F=Ye.y*a.zoom+a.panY;return p>=R&&p<=Z&&F>=V&&F<=be}).map(Ye=>Ye.id);a.multi=we,de(we),me();return}let x=a.dragStart&&!a.dragging;if(a.shiftClick){let h=a.shiftClick;a.shiftClick=null;let I=Array.isArray(a.multi)?a.multi.slice():[];I.includes(h)||I.push(h),a.multi=I,de(I),me();return}if(x){let h=qe(d.clientX,d.clientY),I=null;for(let R=a.nodes.length-1;R>=0;R--){let Z=a.nodes[R];if(!ct(Z.id))continue;let V=Z.x-h.x,be=Z.y-h.y;if(V*V+be*be<Z.r*Z.r+20){I=Z;break}}I?(a.selectedId=I.id,W(I.id),me()):(a.selectedId=null,a.hoverId=null,d.shiftKey||(a.multi=[],de([])),W(null),me())}a.dragStart=null,a.dragging=!1,a.dragNode=null},Mt=d=>{d.preventDefault();let x=qe(d.clientX,d.clientY),h=null;for(let I=a.nodes.length-1;I>=0;I--){let R=a.nodes[I];if(!ct(R.id))continue;let Z=R.x-x.x,V=R.y-x.y;if(Z*Z+V*V<R.r*R.r+25){h=R;break}}if(h){let I=a.domainById[h.id];I&&he({x:d.clientX,y:d.clientY,id:h.id,path:I.id,title:I.title})}else he(null)},Nt=d=>{d.preventDefault();let x=r.getBoundingClientRect(),h=(d.clientX-x.left-a.panX)/a.zoom,I=(d.clientY-x.top-a.panY)/a.zoom,R=Math.max(.3,Math.min(3,a.zoom*(d.deltaY<0?1.1:1/1.1)));a.panX=pt(a.panX+h*(a.zoom-R),-1e5,1e5),a.panY=pt(a.panY+I*(a.zoom-R),-1e5,1e5),a.zoom=R,me()};r.addEventListener("mousemove",wt),r.addEventListener("mousedown",kt),window.addEventListener("mousemove",Ct),window.addEventListener("mouseup",St),r.addEventListener("wheel",Nt,{passive:!1}),r.addEventListener("contextmenu",Mt),N.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],de([]),Ee(),me()};for(let d=0;d<200;d++)Le();Ee(),me();let zt=()=>ne(!1);return window.addEventListener("mousedown",zt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),j.disconnect(),r.removeEventListener("mousemove",wt),r.removeEventListener("mousedown",kt),window.removeEventListener("mousemove",Ct),window.removeEventListener("mouseup",St),r.removeEventListener("wheel",Nt),r.removeEventListener("contextmenu",Mt),window.removeEventListener("mousedown",zt)}},[t,l]),(0,n.useEffect)(()=>{B!==void 0&&T.current&&requestAnimationFrame(()=>T.current())},[B]),(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," ",i("nodes")," \xB7 ",l.length," ",i("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:i("search"),value:$,onChange:r=>ie(r.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>ne(r=>!r),"aria-expanded":C,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",P!=="all"||O||D?"\u25CF":"\u25BE"]}),C&&(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${P==="all"&&!O?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{ye("all"),H(!1)},children:i("all")}),Object.keys(He).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${P===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ye(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:et.colors[r]||He[r]}}),i($e[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${O?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>H(r=>!r),children:["\u23F1 ",i("timeDim")]}),_e.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:_e.map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${D===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>K(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(P!=="all"||O||D)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{ye("all"),H(!1),K("")},children:[i("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:i("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!w,onChange:r=>z&&z(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${O?" me-on":""}`,onClick:()=>H(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=v.current;if(r)try{r.toBlob(o=>{o&&Ue({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>T.current&&T.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{W(null),ye("all"),N.current&&N.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:v,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Ne,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Ae&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),Q&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>he(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}),he(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{Q.id&&(f.current.selectedId=Q.id,W(Q.id)),he(null);let r=f.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(Q.title||"")}catch{}he(null),q(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=f.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],A=Q.id;if(A&&!o.includes(A)&&o.push(A),he(null),o.length<2){q(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let ae=M.current&&M.current(o);ae&&ae.then?ae.then(ce=>ce?q(i("merged")):q(i("mergeFail"),!1)).catch(()=>q(i("mergeFail"),!1)):ae&&q(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=Q.path;he(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(L.current?await L.current(r):!1)?q(i("deleted")):q(i("deleteFail"),!1)}catch{q(i("deleteFail"),!1)}})()},children:i("delete")})]}),De.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[De.length," ",i("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=De.map(Se=>ue[Se]).filter(Boolean).map(Se=>Se.title||Se.name).join(`
298
+ `),A=new Blob([o],{type:"text/plain;charset=utf-8"}),ae=URL.createObjectURL(A),ce=document.createElement("a");ce.href=ae,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(ae),1e3),q(De.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(De.length<2){q(i("mergeNeed"),!1);return}let r=De.map(A=>ue[A]?ue[A].id:A);if(!window.confirm(i("mergeConfirm")))return;de([]);let o=f.current;o&&(o.multi=[]),fetch(`${U}/merge?paths=${encodeURIComponent(r.join(","))}`).then(A=>A.json()).then(A=>{A&&A.ok?q(i("merged")):q(i("mergeFail"),!1)}).catch(()=>q(i("mergeFail"),!1))},children:i("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(i("deleteConfirm")))return;let r=De.map(A=>ue[A]?ue[A].id:A);de([]);let o=f.current;o&&(o.multi=[]),(async()=>{let A=0;for(let ae of r)try{(L.current?await L.current(ae):!1)&&A++}catch{}q(A+i("deletedSelected"),A>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=f.current;r&&(r.multi=[]),de([]);let o=f.current;o&&o.render&&o.render()},children:i("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]?i($e[ue[te].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===te||r.target===te)||[]).slice(0,8).map((r,o)=>{let A=r.source===te?r.target:r.source,ae=ue[A];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let Se=f.current;Se&&(Se.selectedId=A,Se.hoverId=A,Se.wake&&Se.wake()),W(A)},children:ae?(ae.title||ae.name).slice(0,28):A},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("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),Ue(null),Ie(!1)},children:[(0,e.jsx)("style",{children:Be}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:ze?"100vw":900,width:ze?"100vw":"92vw",maxHeight:ze?"100%":"90vh",height:ze?"100%":void 0,borderRadius:ze?0:14},onClick:r=>r.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:i("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:ke.url,download:"memory-graph.png",onClick:()=>{xe("download"),q(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(s==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{xe("full"),Ie(r=>!r),q(i("fullscreen"))},children:i(s==="full"?"done":ze?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=ke.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{xe("copy"),q(i("copied"))}).catch(()=>{q(i("copyFail"),!1)}):q(i("copyFail"),!1)},children:i(s==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ke.url&&URL.revokeObjectURL(ke.url),Ue(null),Ie(!1)},children:i("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:ze?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:ke.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:ze?"calc(100% - 64px)":"70vh",borderRadius:ze?0:8,cursor:"zoom-in"},onClick:()=>Ie(r=>!r)})})]})]})]})}function ya(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let c=(Date.now()-l)/864e5;return c<3?"#10b981":c<14?"#f59e0b":c<30?"#f97316":"#94a3b8"}function Tt({label:t,value:l=[],options:c,onChange:y,placeholder:u,z:i=20}){let[S,w]=(0,n.useState)(!1),z=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!S)return;let k=L=>{z.current&&!z.current.contains(L.target)&&w(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[S]);let B=Array.isArray(l)?l:[],v=B.includes("__all__"),b=v?c.find(k=>k.value==="__all__")?.label||"":B.length?B.map(k=>c.find(L=>L.value===k)?.label||k).join("\u3001"):"",f=(k,L)=>{if(k.value==="__all__"){y(L?["__all__"]:[]);return}let M=new Set(B);M.has("__all__")&&M.delete("__all__"),L?M.add(k.value):M.delete(k.value),y([...M])},T=c.find(k=>k.value==="__all__"),N=c.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:z,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:b||u||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),S&&(0,e.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:i,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[T&&(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:v,onChange:k=>f(T,k.target.checked)}),(0,e.jsx)("span",{children:T.label})]}),N.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:B.includes(k.value),onChange:L=>f(k,L.target.checked)}),(0,e.jsx)("span",{children:k.label})]},k.value))]})]})]})}function ha(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function xa(t,l,c){if(c&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),S=await i.createWritable();return await S.write(t),await S.close(),{ok:!0,picked:!0,name:i.name}}catch(i){return i&&i.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(i.message||i)}}let 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 At(t,l){if(!l||!t)return t;let c=t.toLowerCase(),y=l.toLowerCase(),u=[],i=0;for(;i<t.length;){let S=c.indexOf(y,i);if(S<0){u.push(t.slice(i));break}S>i&&u.push(t.slice(i,S)),u.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(S,S+y.length)},S)),i=S+y.length}return u}function tt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let c=new Date,y=l.toDateString()===c.toDateString(),u=S=>String(S).padStart(2,"0"),i=`${u(l.getHours())}:${u(l.getMinutes())}`;return y?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
294
299
 
295
300
  return module.exports;
296
301
  },