memory-eternal 0.9.5 → 0.9.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://anthropic.com/claude-code/plugin.schema.json",
3
3
  "name": "memory-eternal",
4
- "version": "0.9.5",
4
+ "version": "0.9.6",
5
5
  "description": "璁板繂鏍稿績锛圡emory Eternal锛夛細鐭ヨ瘑鍗¤嚜鍔ㄦ矇娣€/鍙洖锛岀粺涓€ ~/.dsh/memory-vault锛屼細璇濈粨鏉熻嚜鍔ㄥ叆搴撹繘寰呭鏍搞€?,
6
6
  "author": {
7
7
  "name": "EternalNight996",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-eternal",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "璁板繂鏍稿績锛圡emory Eternal锛夛細鐭ヨ瘑鍗¤嚜鍔ㄦ矇娣€/鍙洖锛岀粺涓€ ~/.dsh/memory-vault锛屼細璇濈粨鏉熻嚜鍔ㄥ叆搴撹繘寰呭鏍搞€?,
5
5
  "author": {
6
6
  "name": "EternalNight996",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-eternal",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "璁板繂鏍稿績锛圡emory Eternal锛夛細鐭ヨ瘑鍗¤嚜鍔ㄦ矇娣€/鍙洖锛岀粺涓€ ~/.dsh/memory-vault锛屼細璇濈粨鏉熻嚜鍔ㄥ叆搴撹繘寰呭鏍搞€?,
5
5
  "author": {
6
6
  "name": "EternalNight996",
package/README.en.md CHANGED
@@ -244,12 +244,13 @@ npm run build # builds lib/client.js (DSH embed) + web/app.js (standalone web
244
244
 
245
245
  ## 📋 Changelog
246
246
 
247
- > **Withdrawn versions**: **v0.9.0 / v0.9.1 / v0.9.2 / v0.9.3 are all deprecated on npm, and the release tags for v0.9.1 / v0.9.2 / v0.9.3 have been removed from git** — v0.9.1/v0.9.2 ship the blank-memory-page defect, v0.9.0 false-alarms its capture warnings, and **v0.9.3 does not support DSH v0.1.7-rc.2** (the plugin stops mounting entirely: the settings service changed and the client-side `settingsScope` is gone). Use **v0.9.4+** (`npm i memory-eternal@latest`).
247
+ > **Withdrawn versions**: **v0.9.0 – v0.9.4 are all deprecated on npm, and the release tags for v0.9.1 / v0.9.2 / v0.9.3 / v0.9.4 have been removed from git** — v0.9.1/v0.9.2 ship the blank-memory-page defect, v0.9.0 false-alarms its capture warnings, v0.9.3 does not support DSH v0.1.7-rc.2 (the plugin stops mounting entirely: the settings service changed and the client-side `settingsScope` is gone), and **v0.9.4 crashes under the official desktop build** (schemastery 3.18.4 volatile live references) with `cfg.vaultDir.trim is not a function`. Use **v0.9.5+** (`npm i memory-eternal@latest`).
248
248
 
249
- > **DSH compatibility**: `>=0.1.5-alpha.2 <0.2.0`. **v0.9.4 adds support for DSH v0.1.7-rc.2**, which replaced the settings service with a forms-only API and removed `@deepseek-ai/dsh-client-runtime` / `settingsScope`; **v0.9.5 adds support for schemastery ≥3.18.4 volatile live references** (the shape the official desktop profile uses, while the web profile still ships 3.18.1 — both work). The 0.1.5 line still uses the legacy `settings.register` path; both paths are kept.
249
+ > **DSH compatibility**: `>=0.1.5-alpha.2 <0.2.0`. **v0.9.4 adds support for DSH v0.1.7-rc.2**, which replaced the settings service with a forms-only API and removed `@deepseek-ai/dsh-client-runtime` / `settingsScope`; **v0.9.5 adds support for schemastery ≥3.18.4 volatile live references** (the shape the official desktop profile uses, while the web profile still ships 3.18.1 — both work); **v0.9.6 keeps full-screen overlays clear of the desktop shell's window controls**. The 0.1.5 line still uses the legacy `settings.register` path; both paths are kept.
250
250
 
251
251
  | Version | Date | Highlights |
252
252
  |---|---|---|
253
+ | **v0.9.6** | 2026-09-28 | **Fixed the full-screen overlay covering the desktop shell's window controls (clicking Close quit the whole shell)**: the desktop shell draws minimize / maximize / close at the top of the page and, per the DSH convention, marks `<html>` with `data-windows-titlebar` and publishes `--dsh-windows-titlebar-height` (both confirmed present inside the official desktop build's `app.asar`); the memory overlay used `inset:0` plus an inline `100vh`, covering that whole strip, and our own top-right "×" landed exactly on the shell's window Close — one click quit the entire desktop shell. The full-screen state now uses the `.me-modal-full` class (no inline `100vh`, which CSS cannot override), and under `[data-windows-titlebar]` the `.me-overlay-top` / `.me-overlay` / `.me-modal-full` surfaces are pushed down by `--dsh-windows-titlebar-height` with height `calc(100vh - that)`. Browsers without the attribute get a 0px offset, so behaviour is unchanged there. The export-graph full-screen preview also moved from `100vh` to `100%` so it cannot overflow the shortened overlay. Adds 1 render regression asserting all three avoidance rules ship in the bundle |
253
254
  | **v0.9.5** | 2026-09-28 | **Fixed the plugin failing to mount under the official desktop build (schemastery 3.18.4)**: the desktop profile resolves **schemastery 3.18.4**, which turns every `volatile` Config field into a cosmokit **live reference** (`{ get(): snapshot }` branded with `Symbol.for('cosmokit.volatile.write')`), while 0.9.4 treated those fields as plain values — `cfg.vaultDir.trim()` threw `TypeError: cfg.vaultDir.trim is not a function` and the plugin died inside `apply` (the exact desktop error). The plugin now **deep-unwraps** references per the cosmokit protocol (snapshot each reference, recurse through arrays/objects), so `settings.get()` only ever exposes plain values; each read unwraps afresh, so in-place volatile hot updates stay immediately visible, and `JSON.stringify` no longer writes `{}` into the shared config file. Adds 2 regressions (the real 3.18.4 reference shape + nested arrays/objects) and verifies `apply` under the **desktop build's real module-resolution layout** (schemastery 3.18.4 + real cosmokit) |
254
255
  | **v0.9.4** | 2026-09-28 | **DSH v0.1.7-rc.2 support (fixes "the plugin goes dark after the upgrade")**: (1) **The settings service was replaced** — in 0.1.7 `ctx.settings` is a forms-only API (`describe/update/replace/mutate/configure`) with no `register()`; the old `ctx.settings.register(...)` call throws a `TypeError`, so the plugin never mounts (memory page gone, auto-capture dead). A cross-version shim keeps `register` for older hosts while new hosts read the **live config reference** the loader passes in, subscribe to `loader/volatile-update` for hot updates, and write back through `settings.update(entry id, patch, revision)` (revision conflicts map to HTTP 409); it also registers `configure({ auto:false })` so the host does not generate a duplicate form page. (2) **Volatile field marking moved after construction**: no more chained `.volatile()` — that method only exists in schemastery ≥3.18.4, while the plugin actually resolves **3.18.1** at the profile level, so the chain threw `volatile is not a function` at import time and killed the plugin. (3) **Dead client references removed**: `inject` no longer lists `settingsScope`, which disappeared together with `@deepseek-ai/dsh-client-runtime` (0.1.7 has no such service, so the client plugin waited forever and never activated — taking the memory page and the sidebar button with it); `dsh.client.inject` dropped its non-existent package names. (4) New **`tests/settings-compat.test.mjs`** (8 cases: 0.1.7-shaped mount / live-reference reads / volatile hot update / write-back and revision conflict / legacy `register` path / field volatile markers) wired into `npm test`. Verified by booting a **real DSH v0.1.7-rc.2**: the host plugin mounts (config written to `memory-eternal-config.json`) and the client bundle composes into the boot graph (`plugins/??memory-eternal/client.js`) |
255
256
  | **v0.9.3** | 2026-09-12 | **Fixed the blank memory page ("no UI")**: v0.9.1 placed the infinite-scroll `useEffect` **before** the `loadCards` definition — React evaluates the dependency array during render, hitting a TDZ error (`Cannot access 'loadCards' before initialization`) that **crashed the whole memory page on first render**. It now comes after the definition. Added a **render smoke test** (`tests/ssr.test.mjs`: renders the built bundle through all four entry points — cards / settings / usage / graph — wired into `npm test`) so "green build, blank page" bugs cannot ship again |
package/README.md CHANGED
@@ -257,12 +257,13 @@ npm run build # 构建 lib/client.js(DSH 内嵌)+ web/app.js(独立 web
257
257
 
258
258
  ## 📋 更新日志
259
259
 
260
- > **版本撤回说明**:**v0.9.0 / v0.9.1 / v0.9.2 / v0.9.3 均已在 npm 标记 deprecated;v0.9.1 / v0.9.2 / v0.9.3 的 release tag 已从 git 移除** —— v0.9.1/v0.9.2 带记忆页白屏缺陷,v0.9.0 沉淀告警误报刷屏,**v0.9.3 不支持 DSH v0.1.7-rc.2**(升级后插件整体挂不上:设置服务换血 + 客户端 `settingsScope` 消失)。请使用 **v0.9.4+**(`npm i memory-eternal@latest`)。
260
+ > **版本撤回说明**:**v0.9.0 – v0.9.4 均已在 npm 标记 deprecated;v0.9.1 / v0.9.2 / v0.9.3 / v0.9.4 的 release tag 已从 git 移除** —— v0.9.1/v0.9.2 带记忆页白屏缺陷,v0.9.0 沉淀告警误报刷屏,v0.9.3 不支持 DSH v0.1.7-rc.2(升级后插件整体挂不上:设置服务换血 + 客户端 `settingsScope` 消失),**v0.9.4 在官方桌面版(schemastery 3.18.4 的 volatile 活引用)下抛 `cfg.vaultDir.trim is not a function`、插件整体挂不上**。请使用 **v0.9.5+**(`npm i memory-eternal@latest`)。
261
261
 
262
- > **DSH 兼容性**:`>=0.1.5-alpha.2 <0.2.0`。**v0.9.4 起适配 DSH v0.1.7-rc.2**(该版本把设置服务换成纯表单 API,并移除了 `@deepseek-ai/dsh-client-runtime` 与 `settingsScope`);**v0.9.5 起兼容 schemastery ≥3.18.4 的 volatile 活引用**(官方桌面版 profile 即此形态,web profile 仍是 3.18.1,两者都支持)。0.1.5 系列仍走旧的 `settings.register` 路径,两条路径都保留。
262
+ > **DSH 兼容性**:`>=0.1.5-alpha.2 <0.2.0`。**v0.9.4 起适配 DSH v0.1.7-rc.2**(该版本把设置服务换成纯表单 API,并移除了 `@deepseek-ai/dsh-client-runtime` 与 `settingsScope`);**v0.9.5 起兼容 schemastery ≥3.18.4 的 volatile 活引用**(官方桌面版 profile 即此形态,web profile 仍是 3.18.1,两者都支持);**v0.9.6 起全屏浮层自动让开桌面壳的窗口标题栏**(不再压住最小化/最大化/关闭)。0.1.5 系列仍走旧的 `settings.register` 路径,两条路径都保留。
263
263
 
264
264
  | 版本 | 日期 | 关键改动 |
265
265
  |---|---|---|
266
+ | **v0.9.6** | 2026-09-28 | **修复官方桌面版全屏浮层挡住窗口控制面板(点「关闭」会退出整个桌面壳)**:桌面壳把「最小化 / 最大化 / 关闭」画在页面顶部,并按 DSH 约定在 `<html>` 上打 `data-windows-titlebar` + 给出 `--dsh-windows-titlebar-height`(已在官方桌面版 `app.asar` 里确认这两个标记确实存在);记忆库全屏浮层原本是 `inset:0` + 内联 `100vh`,整条盖住标题栏,而我们右上角的「×」恰好压在窗口「关闭」上 —— 用户一点就直接退出整个桌面壳。现全屏态改用 `.me-modal-full` 类(不再写死内联 `100vh`:内联样式无法被 CSS 覆盖),并在 `[data-windows-titlebar]` 下把 `.me-overlay-top` / `.me-overlay` / `.me-modal-full` 一律下移 `--dsh-windows-titlebar-height`、高度改为 `calc(100vh - 该高度)`;浏览器里没有该属性时偏移 0px,行为与之前完全一致。导出图谱的全屏预览同步从 `100vh` 改为 `100%`,避免在缩短后的浮层里溢出。新增 1 项渲染回归断言(三处让位规则必须出现在打包产物中) |
266
267
  | **v0.9.5** | 2026-09-28 | **修复官方桌面版(schemastery 3.18.4)下插件整体挂不上**:桌面版 profile 解析到的是 **schemastery 3.18.4**,它会把标了 `volatile` 的 Config 字段解析成 cosmokit 的**活引用**(`{ get(): snapshot }`,品牌 `Symbol.for('cosmokit.volatile.write')`),而 0.9.4 的业务代码把字段当普通值用 —— `cfg.vaultDir.trim()` 当场抛 `TypeError: cfg.vaultDir.trim is not a function`,插件在 `apply` 里就崩(桌面版实测报错原文)。现按 cosmokit 协议统一**深解引用**(引用取快照、数组/对象递归展开),`settings.get()` 对外只给普通值;每次读取都重新解,loader 原地提交的 volatile 热更新照样立刻可见,`JSON.stringify` 写共享配置也不再变成 `{}`。新增 2 项回归(3.18.4 真实引用形态 + 嵌套数组/对象),并用**桌面版真实模块解析布局**(schemastery 3.18.4 + 真 cosmokit)跑通 `apply` 验证 |
267
268
  | **v0.9.4** | 2026-09-28 | **适配 DSH v0.1.7-rc.2(修复「升级后插件整体失联」)**:① **设置服务换血** —— 0.1.7 的 `ctx.settings` 只剩表单 API(`describe/update/replace/mutate/configure`),不再有 `register()`;旧代码 `ctx.settings.register(...)` 直接抛 `TypeError`,插件根本挂不上(记忆页消失、自动沉淀停摆)。现改为跨版本兼容层:旧版仍走 `register`,新版读 loader 传进来的**活配置引用**、订阅 `loader/volatile-update` 做热更新、写回走 `settings.update(条目 id, patch, revision)`(revision 冲突映射 HTTP 409),并注册 `configure({ auto:false })` 免得宿主再生成一张重复的表单页。② **字段 volatile 标记改为构造后统一打**:不再链式写 `.volatile()` —— 该方法 schemastery ≥3.18.4 才有,而插件在 profile 层实际解析到的是 **3.18.1**,链式调用会在 `import` 期抛 `volatile is not a function`,把插件整个打挂。③ **客户端去死引用**:`inject` 移除已随 `@deepseek-ai/dsh-client-runtime` 一起消失的 `settingsScope`(0.1.7 客户端服务表里已无此服务,插件会永远等待服务而永不激活 → 记忆页与侧边栏按钮全部不见);`dsh.client.inject` 同步去掉不存在的包名。④ 新增 **`tests/settings-compat.test.mjs`**(8 项:0.1.7 形状挂载 / 活引用读值 / volatile 热更新 / 写回与 revision 冲突 / 老版本 `register` 路径 / 字段 volatile 标记),已并入 `npm test`。已在**真实 DSH v0.1.7-rc.2** 上启动验证:宿主插件正常挂载(配置落盘 `memory-eternal-config.json`)、客户端 bundle 正常进入 boot graph(`plugins/??memory-eternal/client.js`) |
268
269
  | **v0.9.3** | 2026-09-12 | **修复记忆页白屏("没画面")**:v0.9.1 把「滚动续拉」的 `useEffect` 写在了 `loadCards` 定义**之前**——React 在渲染期求值依赖数组,触发 TDZ(`Cannot access 'loadCards' before initialization`),**整个记忆页一渲染就崩**;现已移到定义之后。**新增渲染冒烟测试**(`tests/ssr.test.mjs`:真跑打包产物、把卡片/设置/用量/图谱四个入口各渲染一遍,已并入 `npm test`)——「构建全绿、页面白屏」这类 bug 以后发不出去 |
package/lib/client.js CHANGED
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
3
3
  factory: (require) => {
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
- var Bt=Object.create;var dt=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ft=(t,l)=>{for(var d in l)dt(t,d,{get:l[d],enumerable:!0})},kt=(t,l,d,v)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of Dt(l))!jt.call(t,m)&&m!==d&&dt(t,m,{get:()=>l[m],enumerable:!(v=At(l,m))||v.enumerable});return t};var Pt=(t,l,d)=>(d=t!=null?Bt(Rt(t)):{},kt(l||!t||!t.__esModule?dt(d,"default",{value:t,enumerable:!0}):d,t)),Et=t=>kt(dt({},"__esModule",{value:!0}),t);var sa={};Ft(sa,{EN:()=>zt,MemoryLibrary:()=>Xt,ZH:()=>Nt,apply:()=>_t,inject:()=>Ot});module.exports=Et(sa);var n=Pt(require("react"),1),e=require("react/jsx-runtime"),Ge="memory-eternal",W="/memory-eternal/api",$t=100,Ot=["slots","locale"],Nt={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 Bt=Object.create;var dt=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Rt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var Ft=(t,l)=>{for(var d in l)dt(t,d,{get:l[d],enumerable:!0})},kt=(t,l,d,v)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of At(l))!jt.call(t,m)&&m!==d&&dt(t,m,{get:()=>l[m],enumerable:!(v=Dt(l,m))||v.enumerable});return t};var Et=(t,l,d)=>(d=t!=null?Bt(Rt(t)):{},kt(l||!t||!t.__esModule?dt(d,"default",{value:t,enumerable:!0}):d,t)),Pt=t=>kt(dt({},"__esModule",{value:!0}),t);var sa={};Ft(sa,{EN:()=>zt,MemoryLibrary:()=>Xt,ZH:()=>Nt,apply:()=>_t,inject:()=>Ot});module.exports=Pt(sa);var n=Et(require("react"),1),e=require("react/jsx-runtime"),Ge="memory-eternal",W="/memory-eternal/api",$t=100,Ot=["slots","locale"],Nt={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]
7
7
 
8
8
  ## \u80CC\u666F
9
9
  - \u95EE\u9898\u63CF\u8FF0
@@ -93,7 +93,7 @@ Option A, because:
93
93
  -
94
94
 
95
95
  ## Risks/blockers
96
- - `},ut=["all","project","knowledge","content","prompt","business","tool","mistake"],Oe={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Ct={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},Pe={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},at="deepseek-harness",Qe=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":at:d==="deepseek harness"?at:l.split(":")[0]||at},Wt=[at,"claude","codex","cursor","codex-desktop"],It=(t=[])=>[...new Set([...Wt,...(t||[]).map(Qe)])],Ht={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Ie=`
96
+ - `},ut=["all","project","knowledge","content","prompt","business","tool","mistake"],Oe={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Ct={project:"\u{1F4C1}",knowledge:"\u{1F4DA}",content:"\u{1F4DD}",prompt:"\u{1F4AC}",business:"\u{1F4BC}",tool:"\u{1F527}",mistake:"\u26A0\uFE0F",other:"\u{1F4CE}"},Ee={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},at="deepseek-harness",Qe=t=>{let l=String(t||""),d=l.toLowerCase();return!l||l==="agent"||l==="unknown"||l.startsWith("session:")||d.startsWith("claude-code")?d.startsWith("claude-code")?"claude":at:d==="deepseek harness"?at:l.split(":")[0]||at},Wt=[at,"claude","codex","cursor","codex-desktop"],It=(t=[])=>[...new Set([...Wt,...(t||[]).map(Qe)])],Ht={boot:["\u{1F680}","#8b5cf6"],listen:["\u{1F442}","inherit"],created:["\u2705","#10b981"],appended:["\u2795","#3b82f6"],skip:["\u23ED","#f59e0b"],fail:["\u274C","#ef4444"]},Ie=`
97
97
  .memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
98
98
  .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; }
99
99
  .mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
@@ -219,12 +219,37 @@ Option A, because:
219
219
  .me-graph-ctxmenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
220
220
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
221
221
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
222
- `;function _t(t){t.effect(()=>t.locale.register(Ge,{zh:Nt,en:zt}),"memory-eternal: locale");let l=t.locale.bind(Ge);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Ge,order:25,label:()=>l("nav"),locale:Ge,inject:()=>({})},()=>n.default.createElement(Kt,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ge}:footer`,order:100,label:()=>l("nav"),locale:Ge,inject:()=>({})},d=>n.default.createElement(Yt,{t:l,locale:t.locale,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function Ut(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&l(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function Kt({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)(Tt,{t,onReload:()=>{},version:0})]})}function Yt({t,locale:l,wide:d}){let[v,m]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${d?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>m(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Lt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),v&&(0,e.jsx)(qt,{t,locale:l,onClose:()=>m(!1)})]})}function qt({t,locale:l,onClose:d,tab:v}){let[m,i]=(0,n.useState)(!1),A=(0,n.useRef)(null),C=Ut(),L=(0,n.useCallback)(D=>l&&typeof l.subscribe=="function"?l.subscribe(D):()=>{},[l]),S=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),k=(0,n.useSyncExternalStore)(L,S),y=k&&(k.active==="zh"||k.active==="en")?k.active:null,x=(0,n.useRef)(null);x.current===null&&y&&(x.current=y);let U=(0,n.useMemo)(()=>{let D=x.current?`lang=${x.current}`:"";return v==="config"?`${W}/ui/config?tab=config${D?`&${D}`:""}`:v?`${C.replace(/\/$/,"")}/?tab=${v}${D?`&${D}`:""}`:D?`${C}${C.endsWith("/")?"":"/"}?${D}`:C},[C,v]);return(0,n.useEffect)(()=>{let D=A.current&&A.current.contentWindow;D&&y&&D.postMessage({source:"memory-eternal",type:"locale",lang:y},"*")},[y]),(0,n.useEffect)(()=>{let D=N=>{N.key==="Escape"&&d()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[d]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:d,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)("div",{className:"me-modal",onClick:D=>D.stopPropagation(),style:m?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},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(D=>!D),"aria-label":t(m?"exitFullscreen":"enterFullscreen"),title:t(m?"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:m?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:d,"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:A,src:U,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Lt(){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 Xt({t,inModal:l,onClose:d,onFull:v,full:m}){let[i,A]=(0,n.useState)(null),[C,L]=(0,n.useState)([]),[S,k]=(0,n.useState)(!0),[y,x]=(0,n.useState)(null),[U,D]=(0,n.useState)(""),[N,H]=(0,n.useState)("all"),[w,P]=(0,n.useState)(""),[re,ee]=(0,n.useState)("all"),[E,Le]=(0,n.useState)("all"),[R,be]=(0,n.useState)(()=>{try{let u=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(u&&j[u])return j[u]}catch{}return"cards"}),[b,ie]=(0,n.useState)(()=>new Set([R])),g=(0,n.useCallback)(u=>{ie(j=>j.has(u)?j:new Set(j).add(u)),be(u)},[]),[I,_]=(0,n.useState)("recent"),[V,F]=(0,n.useState)(null),O=(0,n.useRef)(null),J=(0,n.useRef)(null),[G,ye]=(0,n.useState)(!1),[Re,We]=(0,n.useState)(null),[Me,de]=(0,n.useState)(!1),[Z,c]=(0,n.useState)(!0),[Y,X]=(0,n.useState)(null),[oe,Ne]=(0,n.useState)(0),Ae=(0,n.useCallback)(()=>Ne(u=>u+1),[]),ze=(0,n.useRef)(null),[He,_e]=(0,n.useState)(0),[je,le]=(0,n.useState)(!1),Ke=(0,n.useRef)(null),Se=(0,n.useRef)(null),r=(0,n.useCallback)(async(u=N,j=w,K=E,ue={})=>{let pe=ue.append===!0;try{pe?le(!0):(k(!0),D(""));let me=new URLSearchParams;u&&u!=="all"&&me.set("kind",u),j.trim()&&me.set("q",j.trim()),me.set("status",K||"all"),me.set("limit",String($t)),me.set("offset",String(ue.offset||0)),I==="title"&&me.set("sort","title");let Ee=await(await fetch(`${W}/cards?${me.toString()}`)).json();if(Ee.ok){let Fe=Ee.cards||[];L(Ce=>pe?[...Ce,...Fe.filter(Ye=>!Ce.some(qe=>qe.path===Ye.path))]:Fe),_e(Number(Ee.total)||Fe.length)}}catch(me){D(String(me&&me.message?me.message:me))}finally{pe?le(!1):k(!1)}},[N,w,E,I]),o=(0,n.useCallback)(async()=>{try{let[u,j]=await Promise.all([fetch(`${W}/overview`).then(K=>K.json()),fetch(`${W}/capture-log`).then(K=>K.json()).catch(()=>null)]);u.ok&&A(u),x(j&&j.ok&&j.available&&j.health||null)}catch(u){D(String(u&&u.message?u.message:u))}finally{k(!1)}},[]),z=async u=>{try{let K=await(await fetch(`${W}/delete?path=${encodeURIComponent(u)}`)).json();K.ok?(F({ok:!0,msg:t("deleted")}),await o(),Ae()):F({ok:!1,msg:K.error||t("deleteFail")})}catch{F({ok:!1,msg:t("deleteFail")})}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)};(0,n.useEffect)(()=>(o(),()=>{ze.current&&clearTimeout(ze.current)}),[o]);let te=u=>{P(u),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>r(N,u,E),280)},ce=u=>{H(u),r(u,w,E)};(0,n.useEffect)(()=>{R==="cards"&&r(N,w,E)},[E,R,oe,I]),(0,n.useEffect)(()=>{if(R!=="cards"||S||je||C.length>=He)return;let u=Ke.current,j=Se.current;if(!u)return;let K=new IntersectionObserver(ue=>{ue[0]&&ue[0].isIntersecting&&r(N,w,E,{append:!0,offset:C.length})},{root:j||null,rootMargin:"400px"});return K.observe(u),()=>K.disconnect()},[R,C,He,S,je,N,w,E,r]);let ke=async u=>{try{let K=await(await fetch(`${W}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();K.ok&&We({path:K.path,title:u.title,text:K.text})}catch(j){D(String(j&&j.message?j.message:j))}},a=async(u,j)=>{ye(!0);try{let K=await fetch(`${W}/export`);if(!K.ok)throw new Error("HTTP "+K.status);let ue=await K.json();if(!ue.ok)throw new Error(ue.error||"export failed");let pe,me,ge;u==="json"?(me="memory-vault.json",ge="application/json",pe=JSON.stringify(ue.cards.map(Ce=>({path:Ce.path,title:Ce.title,kind:Ce.kind,text:Ce.text})),null,2)):(me="memory-vault.md",ge="text/markdown;charset=utf-8",pe=ue.cards.map(Ce=>Ce.text.trim()).filter(Boolean).join(`
222
+ /* ---- \u5B98\u65B9\u684C\u9762\u7248\uFF1A\u8BA9\u5F00\u7A97\u53E3\u6807\u9898\u680F ----------------------------------------------
223
+ \u684C\u9762\u58F3\uFF08Electron\uFF09\u628A\u300C\u6700\u5C0F\u5316 / \u6700\u5927\u5316 / \u5173\u95ED\u300D\u753B\u5728\u9875\u9762\u9876\u90E8\uFF0C\u5E76\u6309 DSH \u7684\u7EA6\u5B9A\u5728
224
+ <html> \u4E0A\u6253 data-windows-titlebar\u3001\u7ED9\u51FA --dsh-windows-titlebar-height
225
+ \uFF08DSH \u81EA\u5DF1\u7684\u5168\u5C4F\u6D6E\u5C42\u4E5F\u662F\u8FD9\u4E48\u8BA9\u4F4D\u7684\uFF1B\u5DF2\u5728\u5B98\u65B9\u684C\u9762\u7248\u7684 app.asar \u91CC\u786E\u8BA4\u8FD9\u4E24\u4E2A\u6807\u8BB0\u5B58\u5728\uFF09\u3002
226
+ \u8BB0\u5FC6\u5E93\u6D6E\u5C42\u5FC5\u987B\u6574\u6761\u8BA9\u5F00\uFF1A\u4E00\u6765\u76D6\u4F4F\u7A97\u53E3\u63A7\u5236\u9762\u677F\u5F88\u96BE\u770B\uFF0C\u4E8C\u6765\u6211\u4EEC\u81EA\u5DF1\u53F3\u4E0A\u89D2\u7684\u300C\xD7\u300D
227
+ \u6070\u597D\u538B\u5728\u7A97\u53E3\u300C\u5173\u95ED\u300D\u4E0A \u2014\u2014 \u70B9\u4E0B\u53BB\u4F1A\u76F4\u63A5\u9000\u51FA\u6574\u4E2A\u684C\u9762\u58F3\uFF08\u5B9E\u6D4B\u8E29\u5751\uFF09\u3002
228
+ \u6D4F\u89C8\u5668\u91CC\u6CA1\u6709\u8BE5\u5C5E\u6027 \u2192 \u504F\u79FB 0px\uFF0C\u884C\u4E3A\u4E0E\u4E4B\u524D\u5B8C\u5168\u4E00\u81F4\u3002 */
229
+ [data-windows-titlebar] .me-overlay-top,
230
+ [data-windows-titlebar] .me-overlay {
231
+ top: var(--dsh-windows-titlebar-height, 0px);
232
+ }
233
+ .me-modal-full {
234
+ position: fixed;
235
+ inset: 0;
236
+ width: 100vw;
237
+ height: 100vh;
238
+ max-width: 100vw;
239
+ max-height: 100vh;
240
+ border-radius: 0;
241
+ }
242
+ [data-windows-titlebar] .me-modal-full {
243
+ top: var(--dsh-windows-titlebar-height, 0px);
244
+ height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
245
+ max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
246
+ }
247
+ `;function _t(t){t.effect(()=>t.locale.register(Ge,{zh:Nt,en:zt}),"memory-eternal: locale");let l=t.locale.bind(Ge);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Ge,order:25,label:()=>l("nav"),locale:Ge,inject:()=>({})},()=>n.default.createElement(Kt,{t:l}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Ge}:footer`,order:100,label:()=>l("nav"),locale:Ge,inject:()=>({})},d=>n.default.createElement(Yt,{t:l,locale:t.locale,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function Ut(){let[t,l]=(0,n.useState)("http://127.0.0.1:7999/");return(0,n.useEffect)(()=>{fetch("/memory-eternal/api/web-info").then(d=>d.json()).then(d=>{d&&d.ok&&d.url&&l(d.url.endsWith("/")?d.url:d.url+"/")}).catch(()=>{})},[]),t}function Kt({t}){return(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)(Tt,{t,onReload:()=>{},version:0})]})}function Yt({t,locale:l,wide:d}){let[v,m]=(0,n.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${d?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>m(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(Lt,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),v&&(0,e.jsx)(qt,{t,locale:l,onClose:()=>m(!1)})]})}function qt({t,locale:l,onClose:d,tab:v}){let[m,i]=(0,n.useState)(!1),D=(0,n.useRef)(null),C=Ut(),L=(0,n.useCallback)(A=>l&&typeof l.subscribe=="function"?l.subscribe(A):()=>{},[l]),S=(0,n.useCallback)(()=>l&&typeof l.getSnapshot=="function"?l.getSnapshot():null,[l]),k=(0,n.useSyncExternalStore)(L,S),y=k&&(k.active==="zh"||k.active==="en")?k.active:null,x=(0,n.useRef)(null);x.current===null&&y&&(x.current=y);let U=(0,n.useMemo)(()=>{let A=x.current?`lang=${x.current}`:"";return v==="config"?`${W}/ui/config?tab=config${A?`&${A}`:""}`:v?`${C.replace(/\/$/,"")}/?tab=${v}${A?`&${A}`:""}`:A?`${C}${C.endsWith("/")?"":"/"}?${A}`:C},[C,v]);return(0,n.useEffect)(()=>{let A=D.current&&D.current.contentWindow;A&&y&&A.postMessage({source:"memory-eternal",type:"locale",lang:y},"*")},[y]),(0,n.useEffect)(()=>{let A=N=>{N.key==="Escape"&&d()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[d]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:d,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsx)("div",{className:"me-modal"+(m?" me-modal-full":""),onClick:A=>A.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(A=>!A),"aria-label":t(m?"exitFullscreen":"enterFullscreen"),title:t(m?"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:m?"\u2921":"\u2922"}),(0,e.jsx)("button",{type:"button",onClick:d,"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:D,src:U,title:"memory-eternal",style:{width:"100%",flex:1,border:0,borderRadius:"inherit",background:"var(--dsw-alias-bg-base, #fff)"}})]})})]})}function Lt(){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 Xt({t,inModal:l,onClose:d,onFull:v,full:m}){let[i,D]=(0,n.useState)(null),[C,L]=(0,n.useState)([]),[S,k]=(0,n.useState)(!0),[y,x]=(0,n.useState)(null),[U,A]=(0,n.useState)(""),[N,H]=(0,n.useState)("all"),[w,E]=(0,n.useState)(""),[re,ee]=(0,n.useState)("all"),[P,Le]=(0,n.useState)("all"),[R,be]=(0,n.useState)(()=>{try{let u=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(u&&j[u])return j[u]}catch{}return"cards"}),[b,ie]=(0,n.useState)(()=>new Set([R])),g=(0,n.useCallback)(u=>{ie(j=>j.has(u)?j:new Set(j).add(u)),be(u)},[]),[I,_]=(0,n.useState)("recent"),[V,F]=(0,n.useState)(null),O=(0,n.useRef)(null),J=(0,n.useRef)(null),[G,ye]=(0,n.useState)(!1),[Re,We]=(0,n.useState)(null),[Me,de]=(0,n.useState)(!1),[Z,c]=(0,n.useState)(!0),[Y,X]=(0,n.useState)(null),[oe,Ne]=(0,n.useState)(0),De=(0,n.useCallback)(()=>Ne(u=>u+1),[]),ze=(0,n.useRef)(null),[He,_e]=(0,n.useState)(0),[je,le]=(0,n.useState)(!1),Ke=(0,n.useRef)(null),Se=(0,n.useRef)(null),r=(0,n.useCallback)(async(u=N,j=w,K=P,ue={})=>{let pe=ue.append===!0;try{pe?le(!0):(k(!0),A(""));let me=new URLSearchParams;u&&u!=="all"&&me.set("kind",u),j.trim()&&me.set("q",j.trim()),me.set("status",K||"all"),me.set("limit",String($t)),me.set("offset",String(ue.offset||0)),I==="title"&&me.set("sort","title");let Pe=await(await fetch(`${W}/cards?${me.toString()}`)).json();if(Pe.ok){let Fe=Pe.cards||[];L(Ce=>pe?[...Ce,...Fe.filter(Ye=>!Ce.some(qe=>qe.path===Ye.path))]:Fe),_e(Number(Pe.total)||Fe.length)}}catch(me){A(String(me&&me.message?me.message:me))}finally{pe?le(!1):k(!1)}},[N,w,P,I]),o=(0,n.useCallback)(async()=>{try{let[u,j]=await Promise.all([fetch(`${W}/overview`).then(K=>K.json()),fetch(`${W}/capture-log`).then(K=>K.json()).catch(()=>null)]);u.ok&&D(u),x(j&&j.ok&&j.available&&j.health||null)}catch(u){A(String(u&&u.message?u.message:u))}finally{k(!1)}},[]),z=async u=>{try{let K=await(await fetch(`${W}/delete?path=${encodeURIComponent(u)}`)).json();K.ok?(F({ok:!0,msg:t("deleted")}),await o(),De()):F({ok:!1,msg:K.error||t("deleteFail")})}catch{F({ok:!1,msg:t("deleteFail")})}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)};(0,n.useEffect)(()=>(o(),()=>{ze.current&&clearTimeout(ze.current)}),[o]);let te=u=>{E(u),ze.current&&clearTimeout(ze.current),ze.current=setTimeout(()=>r(N,u,P),280)},ce=u=>{H(u),r(u,w,P)};(0,n.useEffect)(()=>{R==="cards"&&r(N,w,P)},[P,R,oe,I]),(0,n.useEffect)(()=>{if(R!=="cards"||S||je||C.length>=He)return;let u=Ke.current,j=Se.current;if(!u)return;let K=new IntersectionObserver(ue=>{ue[0]&&ue[0].isIntersecting&&r(N,w,P,{append:!0,offset:C.length})},{root:j||null,rootMargin:"400px"});return K.observe(u),()=>K.disconnect()},[R,C,He,S,je,N,w,P,r]);let ke=async u=>{try{let K=await(await fetch(`${W}/card?path=${encodeURIComponent(u.path||u.id)}`)).json();K.ok&&We({path:K.path,title:u.title,text:K.text})}catch(j){A(String(j&&j.message?j.message:j))}},a=async(u,j)=>{ye(!0);try{let K=await fetch(`${W}/export`);if(!K.ok)throw new Error("HTTP "+K.status);let ue=await K.json();if(!ue.ok)throw new Error(ue.error||"export failed");let pe,me,ge;u==="json"?(me="memory-vault.json",ge="application/json",pe=JSON.stringify(ue.cards.map(Ce=>({path:Ce.path,title:Ce.title,kind:Ce.kind,text:Ce.text})),null,2)):(me="memory-vault.md",ge="text/markdown;charset=utf-8",pe=ue.cards.map(Ce=>Ce.text.trim()).filter(Boolean).join(`
223
248
 
224
249
  ---
225
250
 
226
- `));let Ee=new Blob([pe],{type:ge}),Fe=await la(Ee,me,!1);if(!Fe.ok){F({ok:!1,msg:t("exportFail")}),ye(!1);return}F({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(K){F({ok:!1,msg:t("exportFail")+" \xB7 "+(K.message||"")})}finally{ye(!1)}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2600)},et=async u=>{let j=u.target.files&&u.target.files[0];if(u.target.value="",!!j){try{let K=await j.text(),pe=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:K})).json();pe.ok?(await o(),F({ok:!0,msg:t("importedVault")+"\uFF1A"+(pe.imported||0)+(pe.skipped?t("importedSkipped")+pe.skipped:"")})):F({ok:!1,msg:pe.error||t("importFail")})}catch{F({ok:!1,msg:t("importFail")})}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2400)}},ot=(0,n.useMemo)(()=>{let u=C.slice();return re!=="all"&&(u=u.filter(j=>Qe(j.submittedBy)===re)),E!=="all"&&(u=u.filter(j=>(j.status||"approved")===E)),I==="title"?u.sort((j,K)=>String(j.title||"").localeCompare(String(K.title||""))):I==="hot"?u.sort((j,K)=>(K.weight||K.links||0)-(j.weight||j.links||0)):u.sort((j,K)=>new Date(K.updated||0).getTime()-new Date(j.updated||0).getTime()),u},[C,I,re,E]),it=(0,n.useMemo)(()=>[...new Set(C.map(u=>Qe(u.submittedBy)))],[C]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ie}),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)(Lt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),v&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:v,"aria-label":t(m?"exitFull":"fullscreen"),children:m?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),y&&y.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[y.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:y.since?nt(new Date(y.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${Z?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>c(u=>!u),"aria-label":t(Z?"collapse":"expand"),title:t(Z?"collapse":"expand"),children:Z?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Se,children:[R==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Je,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Je,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Je,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Je,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Je,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Je,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:w,onChange:u=>te(u.target.value)}),(0,e.jsx)("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:et}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>J.current&&J.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:G,onClick:()=>a("md"),children:t(G?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("json"),children:t(G?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ut.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${N===u?" active":""}`,onClick:()=>ce(u),children:t(u==="all"?"all":Pe[u])},u)),(0,e.jsxs)("select",{value:re,onChange:u=>ee(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")]}),It(it).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsxs)("select",{value:E,onChange:u=>Le(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${I===u.key?" active":""}`,onClick:()=>_(u.key),children:u.label},u.key))]}),U&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U]}),(0,e.jsx)("div",{style:{display:R==="cards"?"contents":"none"},children:S?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):U?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("retry")})]}):C.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:ot.map(u=>(0,e.jsx)(Jt,{card:u,t,query:w.trim(),onOpen:ke,onDelete:z},u.path))}),C.length<He&&(0,e.jsx)("div",{ref:Ke,style:{height:1}}),je&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",C.length," / ",He,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:R==="graph"?"flex":"none",flex:1,minHeight:0},children:b.has("graph")&&(0,e.jsx)(ta,{t,onOpen:ke,all:Me,onAllChange:de,onMutate:Ae,active:R==="graph",visible:R==="graph"})}),(0,e.jsx)("div",{style:{display:R==="config"?"contents":"none"},children:b.has("config")&&(0,e.jsx)(Tt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="stats"?"contents":"none"},children:b.has("stats")&&(0,e.jsx)(Zt,{t,tab:"stats",onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="audit"?"contents":"none"},children:b.has("audit")&&(0,e.jsx)(Vt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="optimize"?"contents":"none"},children:b.has("optimize")&&(0,e.jsx)(Gt,{t,onReload:()=>o(),version:oe})}),Re&&(0,e.jsx)(ea,{t,card:Re,query:w.trim(),onClose:()=>We(null),onDelete:u=>{We(null),z(u)},onFeedback:u=>{let j=Re.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:w.trim(),path:j,useful:u})}).then(()=>F({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}}),(0,e.jsx)(Qt,{t,newCard:Y,setNewCard:X,onCreated:()=>{o(),Ae(),F({ok:!0,msg:t("created")}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}})]})]})]})}var Je=({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 Tt({t,onReload:l,version:d,compact:v}){let[m,i]=(0,n.useState)(null),[A,C]=(0,n.useState)(0),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(!1),[D,N]=(0,n.useState)(null),[H,w]=(0,n.useState)(null),[P,re]=(0,n.useState)(""),[ee,E]=(0,n.useState)(""),[Le,R]=(0,n.useState)(""),[be,b]=(0,n.useState)(""),[ie,g]=(0,n.useState)(null),I=(0,n.useRef)(null),_=(c,Y=!0)=>{I.current&&clearTimeout(I.current),g({msg:c,ok:Y}),I.current=setTimeout(()=>g(null),1900)},V=(c,Y)=>Object.keys(Y).reduce((X,oe)=>X.split("{"+oe+"}").join(Y[oe]),t(c)),F=(0,n.useCallback)(async()=>{try{let[c,Y,X]=await Promise.all([fetch(`${W}/config`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/setup-status`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/budget`).then(oe=>oe.json()).catch(()=>null)]);c&&c.ok?(i(c),C(c.revision??0),S(c.schema??null),y({...c.config??{}}),N(c.dsh??null),U(c.writable===!1),re("")):X&&X.ok?(y({...X}),U(!0),re(t("configNeedsDsh"))):re(t("adminLoadFail")),Y&&Y.ok&&w(Y),R("")}catch{re(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{F()},[d,F]);let O=(c,Y)=>y(X=>({...X??{},[c]:Y})),J=c=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[c]||c,G=async()=>{if(k){if(x){_(t("editInSetting"),!1);return}E("save");try{let c=await fetch(`${W}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:k,expectedRevision:A})}),Y=await c.json();if(Y&&Y.ok)R(t("savedOk")+(Y.note?` \xB7 ${t("restartHint")}`:"")),_(t("savedOk")),await F();else{let X=c.status===409?t("conflictRefresh"):Y?.error||t("saveFail");re(X),_(X,!1)}}catch{re(t("saveFail")),_(t("saveFail"),!1)}finally{E("")}}},ye=()=>{y({...m?.config??{}}),R("")},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}},We=async c=>{let Y=Re[c];Y&&y(X=>({...X??{},...Y}))},Me=async(c,Y)=>{E(c+Y);try{let oe=await(await fetch(`${W}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:c,action:Y})})).json();oe&&oe.ok?_(V(Y==="install"?"mcpInstalled":"mcpUninstalled",{agent:c})):_(V("mcpActionFail",{agent:c,error:oe?.error||""}),!1);try{let Ne=await fetch(`${W}/setup-status`).then(Ae=>Ae.json());Ne&&Ne.ok&&w(Ne)}catch{}}catch{_(t("mergeFail"),!1)}finally{E("")}},de=({k:c,label:Y,type:X="text",step:oe,min:Ne,max:Ae})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:Y||c}),(0,e.jsx)("input",{type:X,step:oe,min:Ne,max:Ae,value:k?k[c]??"":"",onChange:ze=>O(c,X==="number"?Number(ze.target.value):ze.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}})]}),Z=({k:c,label:Y})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(k&&k[c]),onChange:X=>O(c,X.target.checked)}),(0,e.jsx)("span",{children:Y||c})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:v?"0 0 auto":1,minHeight:0,maxHeight:v?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ie}),ie&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ie.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ie.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ie.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ie.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[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:F,children:["\u21BB ",t("retry")]})]}),x&&(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")]}),Le&&(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 ",Le]}),m&&(m.version||m.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")}),m.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",m.version]}),m.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",m.dsh.vaultDir]})]}),H&&H.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:H.agents.map(c=>(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:c.isDsh?t("dshHostLabel"):c.name}),c.isDsh&&c.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",c.version]}),!c.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),c.installed&&c.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),c.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),c.mcpConfigured===!0&&c.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),c.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",c.recallTool?t("enabled"):t("disabled"),")"]})]}),c.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",c.hook]}),!c.isDsh&&c.installed&&c.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ee,onClick:()=>Me(c.name,"install"),children:t("installMcp")}),!c.isDsh&&c.installed&&c.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ee,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Me(c.name,"uninstall")},children:t("uninstallMcp")})]},c.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),be&&(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:be})})]}),k?(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(c=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>We(c),disabled:!!ee,children:[c==="A"?"\u{1F7E2} ":c==="B"?"\u{1F4B0} ":"\u2B50 ",Re[c].label]},c))})]}),(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)(Z,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Z,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(de,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(de,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(de,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(de,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(de,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Z,{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)(Z,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Z,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(de,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(de,{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:k.auditMode??"all",onChange:c=>O("auditMode",c.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)(St,{label:t("auditExemptAgents"),value:k.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(H?.agents||[]).filter(c=>!c.isDsh).map(c=>({value:c.name,label:c.name}))],onChange:c=>O("auditExemptAgents",c)}),(0,e.jsx)(St,{label:t("auditExemptKinds"),value:k.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...ut.filter(c=>c!=="all").map(c=>({value:c,label:t(Pe[c])}))],onChange:c=>O("auditExemptKinds",c)}),(0,e.jsx)(de,{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)(Z,{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:k.autoWebMode??"init",onChange:c=>O("autoWebMode",c.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)(de,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(de,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(de,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Z,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Z,{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:ye,disabled:!!ee,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:G,disabled:!!ee||ee==="save"||x,children:ee==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Vt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,A]=(0,n.useState)([]),[C,L]=(0,n.useState)("all"),[S,k]=(0,n.useState)("all"),[y,x]=(0,n.useState)(""),[U,D]=(0,n.useState)(new Set),[N,H]=(0,n.useState)(""),[w,P]=(0,n.useState)("pending"),re=[...new Set([...v,...i].map(b=>b.submittedBy).filter(Boolean))],ee=(0,n.useCallback)(async()=>{try{let b=await fetch(`${W}/audit/list`).then(ie=>ie.json());b.ok&&(m(b.pending||[]),A(b.rejected||[]),D(new Set))}catch{}},[]);(0,n.useEffect)(()=>{ee()},[d,ee]);let E=(w==="pending"?v:i).filter(b=>{if(C!=="all"&&b.kind!==C||S!=="all"&&Qe(b.submittedBy)!==S)return!1;if(y){let ie=(b.created||"").slice(0,10);if(ie&&ie!==y)return!1}return!0}),Le=b=>D(ie=>{let g=new Set(ie);return g.has(b)?g.delete(b):g.add(b),g}),R=async(b,ie)=>{H("apply");try{for(let g of ie||[...U])await fetch(`${W}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${b==="delete"?"&permanent=0":""}`);await ee(),l&&l()}catch{}finally{H("")}},be=[...U];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:Ie}),(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:C,onChange:b=>L(b.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")}),ut.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(Pe[b])},b))]}),(0,e.jsxs)("select",{value:S,onChange:b=>k(b.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")}),It(re).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>x(b.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${w==="pending"?" me-on":""}`,onClick:()=>P("pending"),children:[t("pending"),"\uFF08",v.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${w==="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:E.length>0&&be.length===E.length,onChange:b=>{b.target.checked?D(new Set(E.map(ie=>ie.path))):D(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!be.length||!!N,onClick:()=>R("approved"),children:["\u2713 ",t(w==="rejected"?"restore":"approve")]}),w==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>R("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&R("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),E.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:E.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)("input",{type:"checkbox",checked:U.has(b.path),onChange:()=>Le(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Qe(b.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.created?b.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:b.severity==="high"?"#f87171":"#9ca3af"},children:b.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.reason||"-"}),w==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>R("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>R("rejected",[b.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:()=>R("approved",[b.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"))&&R("delete",[b.path])},children:"\u{1F5D1}"})]})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Gt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,A]=(0,n.useState)(""),C=(0,n.useCallback)(async()=>{try{let S=await fetch(`${W}/recycle/list`).then(k=>k.json());S.ok&&m(S.items||[])}catch{}},[]);(0,n.useEffect)(()=>{C()},[d,C]);let L=async(S,k)=>{A(S+k);try{S==="restore"?await fetch(`${W}/recycle/restore?path=${encodeURIComponent(k)}`):S==="purge"&&await fetch(`${W}/recycle/purge?path=${encodeURIComponent(k)}`),await C(),l&&l()}catch{}finally{A("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ie}),(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()=>{A("purgeAll");try{await fetch(`${W}/recycle/purge-expired?days=0`),await C()}catch{}finally{A("")}},children:t("emptyRecycle")})]}),v.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:v.map(S=>(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:Oe[S.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(S.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>L("restore",S.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"))&&L("purge",S.path)},children:t("purge")})]},S.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Jt=({card:t,t:l,onOpen:d,query:v,onDelete:m})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[t.kind]||Oe.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:Ct[t.kind]||"\u{1F4CE}"}),v?Mt(t.title,v):t.title,ia(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:v?Mt(t.summary||"",v):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:[Ct[t.kind]||"\u{1F4CE}"," ",l(Pe[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Qe(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",nt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&m&&m(t.path)},children:"\u{1F5D1}"})]})]});function Zt({t,tab:l,onReload:d,version:v}){let[m,i]=(0,n.useState)(null),[A,C]=(0,n.useState)(""),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(null),[D,N]=(0,n.useState)([]),[H,w]=(0,n.useState)(""),[P,re]=(0,n.useState)(!1),ee=(0,n.useCallback)(async()=>{if(!(!L||!L.merge||!L.merge.length)&&window.confirm(t("mergeAllConfirm"))){w("merge");try{let g={},I=J=>g[J]===void 0?J:g[J]=I(g[J]),_=(J,G)=>{g[I(J)]=I(G)},V=new Set;for(let J of L.merge)V.add(J.a.path),V.add(J.b.path),_(J.a.path,J.b.path);let F={};for(let J of V){let G=I(J);(F[G]=F[G]||[]).push(J)}let O=0;for(let J of Object.values(F)){if(J.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(J.join(","))}`).then(ye=>ye.json())).ok&&O++}await E(),d&&d()}catch{}w("")}},[L,E,d,t]);async function E(){try{let g=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/budget`),fetch(`${W}/capture-log`),fetch(`${W}/cards?status=all&limit=30&agent=${at}`)]),[I,_,V,F]=await Promise.all(g.map(O=>O.json()));I&&I.ok&&i(I),_&&_.ok&&y(_),V&&V.ok&&U(V),F&&F.ok&&N(F.cards||[]),C(!I||!I.ok?t("adminLoadFail"):"")}catch{C(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{w("scan");try{let g=await fetch(`${W}/optimize`).then(I=>I.json());g.ok&&S(g)}catch{C(t("adminLoadFail"))}finally{w("")}},[t]);(0,n.useEffect)(()=>{E()},[v]);let R=async(g,I)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(g+","+I)}`).then(V=>V.json())).ok&&(await E(),d&&d())}catch{}},be=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(g)}`).then(_=>_.json())).ok&&(await E(),d&&d())}catch{}},b=["project","knowledge","content","prompt","business","tool","mistake"],ie=({title:g,kind:I,updated:_,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:Ze.colors[I]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(_)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>be(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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[A&&(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 ",A]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:E,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:()=>E(),children:["\u21BB ",t("refresh")]})]}),x?x.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(x.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:(x.entries||[]).map((g,I)=>{let _=Ht[g.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:nt(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:_[1],fontWeight:600},children:[_[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||""})]},I)})})})}):(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",D.length,"\uFF09"]}),D.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:D.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:Oe[g.kind]||Oe.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),m&&(0,e.jsxs)(e.Fragment,{children:[m.trend&&m.trend.length>0&&(()=>{let g=m.trend,I=Math.max(...g.map(O=>O.count),1),_=260,V=50,F=_/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:_,height:V,style:{display:"block",width:"100%",height:50},children:g.map((O,J)=>{let G=Math.round(O.count/I*(V-4));return(0,e.jsx)("rect",{x:J*F+1,y:V-G,width:Math.max(F-2,2),height:G,rx:1.5,fill:O.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:O.count>0?.85:.35},O.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.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:b.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[g]||"#666"}}),t(Pe[g]),": ",m.byKind?.[g]||0]},g))})]}),k&&(k.budgetChars||k.recallLimit||k.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:k.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:k.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",k.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",m.todayCards?.length||0,"\uFF09"]}),m.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:m.todayCards.map(g=>(0,e.jsx)(ie,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!H,onClick:Le,children:H==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),L&&L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){w("oneclick");try{let g=JSON.stringify({cleanupStale:P}),_=await(await fetch(`${W}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();_&&_.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${_.plan.merged} ${t("optimizedMerged")}${P?` \xB7 ${_.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await E(),d&&d(),S(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{w("")}}},children:H==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),L&&L.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")]})]}),!L&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),L&&(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}}),L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:ee,children:t(H==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),L.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:L.merge.map((g,I)=>(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:()=>R(g.a.path,g.b.path),children:t("mergeNow")})]},I))}):(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",L.stale?.length||0,"\uFF09"]}),L.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!H,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;w("clean");let g=0;for(let I of L.stale)try{await fetch(`${W}/delete?path=${encodeURIComponent(I.path)}`),g++}catch{}w(""),notify(`${g} ${t("deletedStale")}`),await E(),d&&d()},children:t("cleanStale")})}),L.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:L.stale.map(g=>(0,e.jsx)(ie,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var mt=[{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 Qt({t,newCard:l,setNewCard:d,onCreated:v}){if(!l)return null;let m=mt.find(y=>y.key===l.template),i=l.body||(m?t(m.bodyKey):""),A=l.kind||(m?m.kind:"knowledge"),C=l.tags||(m?t(m.tagKey):""),L=l._creating,S=y=>{let x=mt.find(U=>U.key===y);d(U=>({...U,template:y,kind:x?x.kind:U.kind,body:x?t(x.bodyKey):U.body,tags:x?t(x.tagKey):U.tags}))},k=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${W}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:A,tags:C.split(",").map(x=>x.trim()).filter(Boolean),body:i,source:"manual"})}).then(x=>x.json())).ok?(d(null),v&&v()):d(x=>({...x,_creating:!1}))}catch{d(x=>({...x,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[mt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>S(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:A,onChange:y=>d(x=>({...x,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(x=>({...x,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:C,onChange:y=>d(x=>({...x,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(x=>({...x,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:L,onClick:k,children:t(L?"exporting":"createCard")})})]})]})]})}function ea({t,card:l,query:d,onClose:v,onDelete:m,onFeedback:i}){(0,n.useEffect)(()=>{let S=k=>{k.key==="Escape"&&v()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[v]);let[A,C]=(0,n.useState)(!1),L=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:v,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",onClick:S=>S.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(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("fbIrr")]})]}),L&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>C(S=>!S),children:t(A?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&m&&m(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:v,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:A?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ra(l.text)}})]})]})}function ta({t,onOpen:l,all:d,onAllChange:v,onMutate:m,active:i,visible:A}){let[C,L]=(0,n.useState)(null),[S,k]=(0,n.useState)(""),y=(0,n.useRef)(!1),x=(0,n.useRef)(0),U=(0,n.useRef)(t);U.current=t;let D=(0,n.useCallback)(async()=>{try{y.current=!1;let P=await(await fetch(`${W}/graph${d?"?all=1":""}`)).json();P.ok?(L(P),k(""),y.current=!0):(L(null),k(P.error||t("error")))}catch(w){k(String(w&&w.message?w.message:w))}},[d,t]);(0,n.useEffect)(()=>{if(!i||y.current)return;let w=!0;return fetch(`${W}/graph${d?"?all=1":""}`).then(P=>P.json()).then(P=>{w&&(P.ok?(L(P),k(""),y.current=!0):(L(null),k(P.error||t("error"))))}).catch(P=>{w&&k(String(P&&P.message?P.message:P))}),()=>{w=!1}},[d,t,i]),(0,n.useEffect)(()=>{A&&C&&x.current++},[A,C]);let N=(0,n.useCallback)(async w=>{try{let re=await(await fetch(`${W}/delete?path=${encodeURIComponent(w)}`)).json();return re&&re.ok?(await D(),m&&m(),!0):!1}catch{return!1}},[D]),H=(0,n.useCallback)(async w=>{if(!w||w.length<2)return!1;try{let P=await fetch(`${W}/merge?paths=${encodeURIComponent(w.join(","))}`).then(re=>re.json());return P&&P.ok?(await D(),m&&m(),!0):!1}catch{return!1}},[D,m]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ie}),S&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",S]}),!C&&!S&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),C&&C.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),C&&C.nodes.length>0&&(0,e.jsx)(na,{nodes:C.nodes,edges:C.edges,onOpen:l,onDelete:N,onMerge:H,t,all:d,onAllChange:v,countLabel:`${C.nodes.length} ${t("nodes")} \xB7 ${aa(C.edges)} ${t("edges")}`,fitTrigger:x.current})]})}function aa(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var Ze={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 na({nodes:t,edges:l,onOpen:d,onDelete:v,onMerge:m,t:i,countLabel:A,all:C,onAllChange:L,fitTrigger:S}){let k=(0,n.useRef)(null),y=(0,n.useRef)(null),x=(0,n.useRef)(null),U=(0,n.useRef)(null),D=(0,n.useRef)(null),N=(0,n.useRef)(d);(0,n.useEffect)(()=>{N.current=d},[d]);let H=(0,n.useRef)(v);(0,n.useEffect)(()=>{H.current=v},[v]);let w=(0,n.useRef)(m);(0,n.useEffect)(()=>{w.current=m},[m]);let[P,re]=(0,n.useState)(""),[ee,E]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=P.trim().toLowerCase()},[P]),(0,n.useEffect)(()=>{let r=x.current;if(!r)return;let o=P.trim().toLowerCase();if(!o)return;let z=r.nodes.find(te=>(te.name||"").toLowerCase().includes(o));z&&(x.current.selectedId=z.id,E(z.id),r.panX=r.w/2-z.x*r.zoom,r.panY=r.h/2-z.y*r.zoom,r.render&&r.render())},[P]);let[R,be]=(0,n.useState)("all"),[b,ie]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[I,_]=(0,n.useState)(""),V=(0,n.useRef)(""),[F,O]=(0,n.useState)(!1),J=(0,n.useRef)(!1),[G,ye]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=R},[R]),(0,n.useEffect)(()=>{V.current=I},[I]),(0,n.useEffect)(()=>{J.current=F},[F]);let Re=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let z of o.tags||[]){let te=String(z).trim();te&&r.set(te,(r.get(te)||0)+1)}return[...r.entries()].sort((o,z)=>z[1]-o[1]).slice(0,24).map(([o,z])=>({tag:o,n:z}))},[t]),We=(()=>{let r=P.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(Pe[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=x.current;r&&r.wake&&r.wake()},[P]),(0,n.useEffect)(()=>{let r=x.current;r&&r.render&&r.render()},[R,I,F]);let Me=(0,n.useRef)(null),[de,Z]=(0,n.useState)([]),[c,Y]=(0,n.useState)(null),[X,oe]=(0,n.useState)(!1),[Ne,Ae]=(0,n.useState)(null),[ze,He]=(0,n.useState)(""),_e=(0,n.useRef)(null),je=(0,n.useRef)(null),le=(r,o=!0)=>{_e.current&&clearTimeout(_e.current),Ae({msg:r,ok:o}),_e.current=setTimeout(()=>Ae(null),1900)},Ke=r=>{He(r),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>He(""),1600)};(0,n.useEffect)(()=>()=>{_e.current&&clearTimeout(_e.current),je.current&&clearTimeout(je.current)},[]);let Se=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let z=Math.max(1,window.devicePixelRatio||1),te=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(s=>{ce[s.source]=(ce[s.source]||0)+1,ce[s.target]=(ce[s.target]||0)+1});let ke=Math.max(1,...Object.values(ce)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(ce[s.id]||0)/ke*8),x:0,y:0,vx:0,vy:0})),edges:l.map(s=>({sourceNodeId:s.source,targetNodeId:s.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:z,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,h)=>(s[h.id]=h,s),{}),a.nodes.forEach((s,h)=>{let f=h/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let et=[...new Set(a.nodes.map(s=>s.type))];a.clustered=et.length>1,a.typeCenters={},et.forEach((s,h)=>{let f=h/et.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),x.current=a;let ot=0,it=0,u=()=>{let s=r.clientWidth,h=r.clientHeight;a.w=s,a.h=h,r.width=s*z,r.height=h*z,o.setTransform(z,0,0,z,0,0),(ot===0||it===0)&&s>0&&h>0&&a.tickCount>0&&requestAnimationFrame(()=>pe()),ot=s,it=h};u();let j=new ResizeObserver(u);j.observe(r.parentElement);let K=(s,h)=>s&&s.length>h?s.slice(0,h)+"\u2026":s,ue=(s,h,f,M)=>{if(o.beginPath(),M==="rect")o.rect(s-f,h-f*.75,f*2,f*1.5);else if(M==="diamond")o.moveTo(s,h-f),o.lineTo(s+f,h),o.lineTo(s,h+f),o.lineTo(s-f,h),o.closePath();else if(M==="hexagon"){for(let T=0;T<6;T++){let Q=Math.PI/3*T-Math.PI/2,q=s+f*Math.cos(Q),he=h+f*Math.sin(Q);T===0?o.moveTo(q,he):o.lineTo(q,he)}o.closePath()}else o.arc(s,h,f,0,Math.PI*2)},pe=()=>{if(!a.nodes.length)return;let s=1/0,h=-1/0,f=1/0,M=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),h=Math.max(h,p.x),f=Math.min(f,p.y),M=Math.max(M,p.y)});let T=20,Q=h-s+T*2,q=M-f+T*2,he=Math.min(a.w/Q,a.h/q);a.zoom=Math.max(.35,Math.min(1.8,he)),a.panX=a.w/2-(s+h)/2*a.zoom,a.panY=a.h/2-(f+M)/2*a.zoom};U.current=pe;let me=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=g.current,a.timeMode=J.current,a.tagFilter=V.current;let s=a.tagFilter,h=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=te()?"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 M={};a.nodes.forEach(p=>M[p.id]=p);let T=a.nodes.length>40,Q=T?1.5:.55,q=a.selectedId||a.hoverId;a.edges.forEach(p=>{let ae=M[p.sourceNodeId],B=M[p.targetNodeId];if(!ae||!B)return;if(h!=="all"){let rt=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,we=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(rt!==h&&we!==h)return}if(s){let rt=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),we=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!rt&&!we)return}let $=B.x-ae.x,ne=B.y-ae.y,se=Math.sqrt($*$+ne*ne)||1,fe=T?12:18,xe=-ne/se*fe,ve=$/se*fe,Te=(ae.x+B.x)/2+xe,Be=(ae.y+B.y)/2+ve,De=Ze.colors[a.domainById[ae.id]&&a.domainById[ae.id].kind||"other"],Ue=q&&(p.sourceNodeId===q||p.targetNodeId===q),ct=q?Ue?.6:.08:T?.14:.24,pt=parseInt(De.slice(1,3),16),tt=parseInt(De.slice(3,5),16),lt=parseInt(De.slice(5,7),16);o.strokeStyle="rgba("+pt+","+tt+","+lt+","+ct+")",o.lineWidth=Ue?1.6+(p.weight||1):.8+(p.weight||1)*.5,o.beginPath(),o.moveTo(ae.x,ae.y),o.quadraticCurveTo(Te,Be,B.x,B.y),o.stroke()});let he=[];if(a.nodes.forEach(p=>{let ae=a.domainById[p.id]||{},B=ae.kind||"other",$=a.timeMode?oa(ae.updated):Ze.colors[B],ne=Ze.shapes[B],se=a.selectedId===p.id,fe=a.hoverId===p.id,xe=a.searchTerm||"",ve=!xe||(p.name||"").toLowerCase().includes(xe)||String(Pe[B]||"").toLowerCase().includes(xe)||String(B).toLowerCase().includes(xe),Te=h==="all"||B===h,Be=!s||(ae.tags||[]).includes(s),De=q&&p.id!==q&&!a.edges.some(we=>we.sourceNodeId===q&&we.targetNodeId===p.id||we.targetNodeId===q&&we.sourceNodeId===p.id)||xe&&!ve||!Te||!Be;o.save(),o.globalAlpha=De?.08:1,(se||fe)&&(o.shadowColor=$,o.shadowBlur=se?20:14),ue(p.x,p.y,p.r,ne);let Ue=parseInt($.slice(1,3),16),ct=parseInt($.slice(3,5),16),pt=parseInt($.slice(5,7),16),tt=o.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);tt.addColorStop(0,"rgba("+Math.min(255,Ue+70)+","+Math.min(255,ct+70)+","+Math.min(255,pt+70)+",0.95)"),tt.addColorStop(1,$),o.fillStyle=tt,o.fill(),o.restore(),se?(o.save(),ue(p.x,p.y,p.r+3,ne),o.strokeStyle=$,o.lineWidth=3,o.shadowColor=$,o.shadowBlur=12,o.stroke(),o.restore()):fe?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle=$,o.lineWidth=2,o.stroke(),o.restore()):xe&&ve?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(p.id)>=0&&(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let lt=K(p.name,16);if((se||fe||a.zoom>Q||!T&&a.zoom>.6)&&Te&&Be){let we=1/a.zoom;o.font="500 "+(12*we).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let $e=o.measureText(lt).width+16*we,st=18*we,Xe=p.y+p.r+8*we,wt=!0;for(let Ve of he)if(p.x-$e/2<Ve.x+Ve.w&&p.x+$e/2>Ve.x&&Xe<Ve.y+Ve.h&&Xe+st>Ve.y){wt=!1;break}if(!wt&&!se&&!fe)return;he.push({x:p.x-$e/2,y:Xe,w:$e,h:st}),o.fillStyle=te()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(p.x-$e/2,Xe,$e,st,4*we):o.rect(p.x-$e/2,Xe,$e,st),o.fill(),o.strokeStyle=te()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*we,o.stroke(),o.fillStyle=te()?se||fe?"#eee":"#bbb":se||fe?"#111":"#444",o.textAlign="center",o.fillText(lt,p.x,Xe+13*we)}}),o.restore(),a.marquee){let p=a.marquee,ae=Math.min(p.sx,p.ex),B=Math.min(p.sy,p.ey),$=Math.abs(p.ex-p.sx),ne=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(ae,B,$,ne),o.strokeRect(ae,B,$,ne),o.restore()}if(a.hoverId&&Me.current){let p=a.domainById[a.hoverId],ae=a.nodes.find(function(B){return B.id===a.hoverId});if(p&&ae){let B=a.edges.filter(function(se){return se.sourceNodeId===p.id||se.targetNodeId===p.id}).length,$=ae.x*a.zoom+a.panX,ne=ae.y*a.zoom+a.panY;Me.current.style.display="block",Me.current.style.left=$+14+"px",Me.current.style.top=ne-6+"px",Me.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",B)+"</span>"}}else Me.current&&(Me.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Fe))};a.wake=ge,a.render=me;let Ee=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),M=s>1e3?3e3:s>100?2e3:s>50?1200:800,T=s>100?.002:.005,Q=s>1e3?.012:s>100?.005:.01,q=s>1e3?6:s>200?12:24,he={};a.nodes.forEach(B=>he[B.id]=B);for(let B=0;B<s;B++){if(a.dragNode===a.nodes[B])continue;let $=a.nodes[B],ne=0,se=0;for(let ve=0;ve<s;ve++){if(B===ve)continue;let Te=$.x-a.nodes[ve].x,Be=$.y-a.nodes[ve].y,De=Math.sqrt(Te*Te+Be*Be)||1,Ue=M/(De*De);ne+=Te/De*Ue,se+=Be/De*Ue}if(a.clustered&&a.typeCenters[$.type]){let ve=a.typeCenters[$.type];ne+=(ve.x-$.x)*.006,se+=(ve.y-$.y)*.006}else ne-=$.x*Q,se-=$.y*Q;let fe=($.vx+ne)*f,xe=($.vy+se)*f;fe=Math.max(-q,Math.min(q,fe)),xe=Math.max(-q,Math.min(q,xe)),$.vx=fe,$.vy=xe}a.edges.forEach(B=>{let $=he[B.sourceNodeId],ne=he[B.targetNodeId];if(!$||!ne)return;let se=ne.x-$.x,fe=ne.y-$.y,xe=Math.sqrt(se*se+fe*fe)||1,ve=(xe-100)*T,Te=se/xe*ve,Be=fe/xe*ve;a.dragNode!==$&&($.vx+=Te,$.vy+=Be),a.dragNode!==ne&&(ne.vx-=Te,ne.vy-=Be)});let p=0;a.nodes.forEach(B=>{a.dragNode!==B&&(B.x+=B.vx,B.y+=B.vy,p+=B.vx*B.vx+B.vy*B.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,pe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Fe=()=>{if(a.running){try{Ee(),me()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Fe)}},Ce=(s,h)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(h-f.top-a.panY)/a.zoom}},Ye=s=>{let h=a.domainById[s];return!(!h||g.current!=="all"&&h.kind!==g.current||V.current&&!(h.tags||[]).includes(V.current))},qe=(s,h,f)=>Math.max(h,Math.min(f,s)),gt=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+36){f=T.id;break}}f!==a.hoverId&&(a.hoverId=f,ge())},ft=s=>{if(s.button!==0)return;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(s.shiftKey){if(f){a.shiftClick=f.id;return}a.marquee={sx:s.clientX,sy:s.clientY,ex:s.clientX,ey:s.clientY};return}a.dragStart={x:s.clientX,y:s.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=f||null,f&&(a.dragOffset={dx:f.x-h.x,dy:f.y-h.y})},bt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ge();return}if(!a.dragStart)return;let h=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let M=Ce(s.clientX,s.clientY);a.dragNode.x=M.x+a.dragOffset.dx,a.dragNode.y=M.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=qe(a.dragStart.px+h,-1e5,1e5),a.panY=qe(a.dragStart.py+f,-1e5,1e5),ge())},yt=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let M=r.getBoundingClientRect(),T=Math.min(f.sx,f.ex)-M.left,Q=Math.max(f.sx,f.ex)-M.left,q=Math.min(f.sy,f.ey)-M.top,he=Math.max(f.sy,f.ey)-M.top,p=a.nodes.filter(ae=>{let B=ae.x*a.zoom+a.panX,$=ae.y*a.zoom+a.panY;return B>=T&&B<=Q&&$>=q&&$<=he}).map(ae=>ae.id);a.multi=p,Z(p),ge();return}let h=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let M=Array.isArray(a.multi)?a.multi.slice():[];M.includes(f)||M.push(f),a.multi=M,Z(M),ge();return}if(h){let f=Ce(s.clientX,s.clientY),M=null;for(let T=a.nodes.length-1;T>=0;T--){let Q=a.nodes[T];if(!Ye(Q.id))continue;let q=Q.x-f.x,he=Q.y-f.y;if(q*q+he*he<Q.r*Q.r+20){M=Q;break}}M?(a.selectedId=M.id,E(M.id),ge()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],Z([])),E(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ht=s=>{s.preventDefault();let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(f){let M=a.domainById[f.id];M&&ye({x:s.clientX,y:s.clientY,id:f.id,path:M.id,title:M.title})}else ye(null)},xt=s=>{s.preventDefault();let h=r.getBoundingClientRect(),f=(s.clientX-h.left-a.panX)/a.zoom,M=(s.clientY-h.top-a.panY)/a.zoom,T=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+f*(a.zoom-T),-1e5,1e5),a.panY=qe(a.panY+M*(a.zoom-T),-1e5,1e5),a.zoom=T,ge()};r.addEventListener("mousemove",gt),r.addEventListener("mousedown",ft),window.addEventListener("mousemove",bt),window.addEventListener("mouseup",yt),r.addEventListener("wheel",xt,{passive:!1}),r.addEventListener("contextmenu",ht),D.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Z([]),pe(),ge()};for(let s=0;s<200;s++)Ee();pe(),ge();let vt=()=>ie(!1);return window.addEventListener("mousedown",vt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),j.disconnect(),r.removeEventListener("mousemove",gt),r.removeEventListener("mousedown",ft),window.removeEventListener("mousemove",bt),window.removeEventListener("mouseup",yt),r.removeEventListener("wheel",xt),r.removeEventListener("contextmenu",ht),window.removeEventListener("mousedown",vt)}},[t,l]),(0,n.useEffect)(()=>{S!==void 0&&U.current&&requestAnimationFrame(()=>U.current())},[S]),(0,e.jsxs)("div",{className:"me-graph",ref:y,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",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:()=>ie(r=>!r),"aria-expanded":b,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",R!=="all"||F||I?"\u25CF":"\u25BE"]}),b&&(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${R==="all"&&!F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{be("all"),O(!1)},children:i("all")}),Object.keys(Oe).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${R===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>be(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[r]||Oe[r]}}),i(Pe[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${F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>O(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${I===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>_(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(R!=="all"||F||I)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{be("all"),O(!1),_("")},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:!!C,onChange:r=>L&&L(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${F?" me-on":""}`,onClick:()=>O(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(o=>{o&&Y({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>U.current&&U.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{E(null),be("all"),D.current&&D.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Me,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),We&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),G&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ye(null)}),G&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:G.x,top:G.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{N.current({path:G.path,title:G.title}),ye(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.id&&(x.current.selectedId=G.id,E(G.id)),ye(null);let r=x.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(G.title||"")}catch{}ye(null),le(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=x.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],z=G.id;if(z&&!o.includes(z)&&o.push(z),ye(null),o.length<2){le(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let te=w.current&&w.current(o);te&&te.then?te.then(ce=>ce?le(i("merged")):le(i("mergeFail"),!1)).catch(()=>le(i("mergeFail"),!1)):te&&le(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=G.path;ye(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(H.current?await H.current(r):!1)?le(i("deleted")):le(i("deleteFail"),!1)}catch{le(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(ke=>Se[ke]).filter(Boolean).map(ke=>ke.title||ke.name).join(`
227
- `),z=new Blob([o],{type:"text/plain;charset=utf-8"}),te=URL.createObjectURL(z),ce=document.createElement("a");ce.href=te,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(te),1e3),le(de.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(de.length<2){le(i("mergeNeed"),!1);return}let r=de.map(z=>Se[z]?Se[z].id:z);if(!window.confirm(i("mergeConfirm")))return;Z([]);let o=x.current;o&&(o.multi=[]),fetch(`${W}/merge?paths=${encodeURIComponent(r.join(","))}`).then(z=>z.json()).then(z=>{z&&z.ok?le(i("merged")):le(i("mergeFail"),!1)}).catch(()=>le(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(z=>Se[z]?Se[z].id:z);Z([]);let o=x.current;o&&(o.multi=[]),(async()=>{let z=0;for(let te of r)try{(H.current?await H.current(te):!1)&&z++}catch{}le(z+i("deletedSelected"),z>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=x.current;r&&(r.multi=[]),Z([]);let o=x.current;o&&o.render&&o.render()},children:i("clearSelection")})]}),ee&&(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:Se[ee]?Se[ee].title||Se[ee].name:ee}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:Se[ee]?i(Pe[Se[ee].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===ee||r.target===ee)||[]).slice(0,8).map((r,o)=>{let z=r.source===ee?r.target:r.source,te=Se[z];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let ke=x.current;ke&&(ke.selectedId=z,ke.hoverId=z,ke.wake&&ke.wake()),E(z)},children:te?(te.title||te.name).slice(0,28):z},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),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})]}),c&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),Y(null),oe(!1)},children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:X?"100vw":900,width:X?"100vw":"92vw",maxHeight:X?"100vh":"90vh",height:X?"100vh":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:c.url,download:"memory-graph.png",onClick:()=>{Ke("download"),le(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(ze==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ke("full"),oe(r=>!r),le(i("fullscreen"))},children:i(ze==="full"?"done":X?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=c.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{Ke("copy"),le(i("copied"))}).catch(()=>{le(i("copyFail"),!1)}):le(i("copyFail"),!1)},children:i(ze==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),Y(null),oe(!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:c.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:X?"calc(100vh - 64px)":"70vh",borderRadius:X?0:8,cursor:"zoom-in"},onClick:()=>oe(r=>!r)})})]})]})]})}function oa(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let d=(Date.now()-l)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function St({label:t,value:l=[],options:d,onChange:v,placeholder:m,z:i=20}){let[A,C]=(0,n.useState)(!1),L=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!A)return;let N=H=>{L.current&&!L.current.contains(H.target)&&C(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[A]);let S=Array.isArray(l)?l:[],k=S.includes("__all__"),y=k?d.find(N=>N.value==="__all__")?.label||"":S.length?S.map(N=>d.find(H=>H.value===N)?.label||N).join("\u3001"):"",x=(N,H)=>{if(N.value==="__all__"){v(H?["__all__"]:[]);return}let w=new Set(S);w.has("__all__")&&w.delete("__all__"),H?w.add(N.value):w.delete(N.value),v([...w])},U=d.find(N=>N.value==="__all__"),D=d.filter(N=>N.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:L,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>C(N=>!N),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||m||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),A&&(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:[U&&(0,e.jsxs)("label",{onClick:N=>N.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:k,onChange:N=>x(U,N.target.checked)}),(0,e.jsx)("span",{children:U.label})]}),D.map(N=>(0,e.jsxs)("label",{onClick:H=>H.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:S.includes(N.value),onChange:H=>x(N,H.target.checked)}),(0,e.jsx)("span",{children:N.label})]},N.value))]})]})]})}function ia(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function la(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),A=await i.createWritable();return await A.write(t),await A.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 v=URL.createObjectURL(t),m=document.createElement("a");return m.href=v,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>URL.revokeObjectURL(v),1e3),{ok:!0,picked:!1,name:l}}function Mt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),v=l.toLowerCase(),m=[],i=0;for(;i<t.length;){let A=d.indexOf(v,i);if(A<0){m.push(t.slice(i));break}A>i&&m.push(t.slice(i,A)),m.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(A,A+v.length)},A)),i=A+v.length}return m}function ra(t){if(!t)return"";let l=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),d=[];return l=l.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(v,m,i){return d.push("<pre><code>"+i+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(v,m,i){return"<h"+m.length+">"+i+"</h"+m.length+">"}),l=l.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),l=l.replace(/`([^`\n]+)`/g,"<code>$1</code>"),l=l.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),l=l.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(v,m,i){return/^(https?:|\/)/.test(i)?'<a href="'+i+'" target="_blank" rel="noopener noreferrer">'+m+"</a>":m}),l=l.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),l=l.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),l=l.replace(/\n/g,"<br/>"),l=l.replace(/\u0000(\d+)\u0000/g,function(v,m){return d[m]}),l}function nt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,v=l.toDateString()===d.toDateString(),m=A=>String(A).padStart(2,"0"),i=`${m(l.getHours())}:${m(l.getMinutes())}`;return v?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
251
+ `));let Pe=new Blob([pe],{type:ge}),Fe=await la(Pe,me,!1);if(!Fe.ok){F({ok:!1,msg:t("exportFail")}),ye(!1);return}F({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+Fe.name})}catch(K){F({ok:!1,msg:t("exportFail")+" \xB7 "+(K.message||"")})}finally{ye(!1)}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2600)},et=async u=>{let j=u.target.files&&u.target.files[0];if(u.target.value="",!!j){try{let K=await j.text(),pe=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:K})).json();pe.ok?(await o(),F({ok:!0,msg:t("importedVault")+"\uFF1A"+(pe.imported||0)+(pe.skipped?t("importedSkipped")+pe.skipped:"")})):F({ok:!1,msg:pe.error||t("importFail")})}catch{F({ok:!1,msg:t("importFail")})}O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2400)}},ot=(0,n.useMemo)(()=>{let u=C.slice();return re!=="all"&&(u=u.filter(j=>Qe(j.submittedBy)===re)),P!=="all"&&(u=u.filter(j=>(j.status||"approved")===P)),I==="title"?u.sort((j,K)=>String(j.title||"").localeCompare(String(K.title||""))):I==="hot"?u.sort((j,K)=>(K.weight||K.links||0)-(j.weight||j.links||0)):u.sort((j,K)=>new Date(K.updated||0).getTime()-new Date(j.updated||0).getTime()),u},[C,I,re,P]),it=(0,n.useMemo)(()=>[...new Set(C.map(u=>Qe(u.submittedBy)))],[C]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ie}),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)(Lt,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),v&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:v,"aria-label":t(m?"exitFull":"fullscreen"),children:m?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),y&&y.ok===!1&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8,margin:"0 0 8px",padding:"9px 14px",borderRadius:10,background:"rgba(239,68,68,0.10)",border:"1px solid rgba(239,68,68,0.45)",borderLeft:"4px solid #ef4444",color:"var(--dsw-alias-label-primary, #e5e7eb)",fontSize:12.5,lineHeight:1.6},children:[(0,e.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",t("captureAlert")]}),(0,e.jsxs)("span",{style:{flex:1},children:[y.reason,(0,e.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:t("captureAlertHint")})]}),(0,e.jsx)("span",{style:{opacity:.7},children:y.since?nt(new Date(y.since).toISOString()):""})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${Z?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>c(u=>!u),"aria-label":t(Z?"collapse":"expand"),title:t(Z?"collapse":"expand"),children:Z?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="cards"?" active":""}`,onClick:()=>g("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="graph"?" active":""}`,onClick:()=>g("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="stats"?" active":""}`,onClick:()=>g("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="audit"?" active":""}`,onClick:()=>g("audit"),title:t("tabAudit"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabAudit")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="optimize"?" active":""}`,onClick:()=>g("optimize"),title:t("tabRecycle"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabRecycle")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${R==="config"?" active":""}`,onClick:()=>g("config"),title:t("tabConfig"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),Z&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabConfig")})]})]}),(0,e.jsxs)("div",{className:"mc-main",ref:Se,children:[R==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Je,{label:t("total"),value:i?i.total:"\u2014"}),(0,e.jsx)(Je,{label:t("recent"),value:i?i.recent:"\u2014"}),(0,e.jsx)(Je,{label:t("tags"),value:i?i.tags:"\u2014"}),(0,e.jsx)(Je,{label:t("pending"),value:i?.status?.pending??0}),(0,e.jsx)(Je,{label:t("rejected"),value:i?.status?.rejected??0}),(0,e.jsx)(Je,{label:t("cardCount"),value:i?i.byKind?.knowledge??0:"\u2014"})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:w,onChange:u=>te(u.target.value)}),(0,e.jsx)("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:et}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>J.current&&J.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:G,onClick:()=>a("md"),children:t(G?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:G,onClick:()=>a("json"),children:t(G?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("refresh")})]}),R==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[ut.map(u=>(0,e.jsx)("button",{type:"button",className:`mc-chip${N===u?" active":""}`,onClick:()=>ce(u),children:t(u==="all"?"all":Ee[u])},u)),(0,e.jsxs)("select",{value:re,onChange:u=>ee(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")]}),It(it).map(u=>(0,e.jsx)("option",{value:u,children:u},u))]}),(0,e.jsxs)("select",{value:P,onChange:u=>Le(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${I===u.key?" active":""}`,onClick:()=>_(u.key),children:u.label},u.key))]}),U&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U]}),(0,e.jsx)("div",{style:{display:R==="cards"?"contents":"none"},children:S?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):U?(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",U," ",(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>o(),children:t("retry")})]}):C.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:ot.map(u=>(0,e.jsx)(Jt,{card:u,t,query:w.trim(),onOpen:ke,onDelete:z},u.path))}),C.length<He&&(0,e.jsx)("div",{ref:Ke,style:{height:1}}),je&&(0,e.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[t("loading"),"\uFF08",C.length," / ",He,"\uFF09"]})]})}),(0,e.jsx)("div",{style:{display:R==="graph"?"flex":"none",flex:1,minHeight:0},children:b.has("graph")&&(0,e.jsx)(ta,{t,onOpen:ke,all:Me,onAllChange:de,onMutate:De,active:R==="graph",visible:R==="graph"})}),(0,e.jsx)("div",{style:{display:R==="config"?"contents":"none"},children:b.has("config")&&(0,e.jsx)(Tt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="stats"?"contents":"none"},children:b.has("stats")&&(0,e.jsx)(Zt,{t,tab:"stats",onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="audit"?"contents":"none"},children:b.has("audit")&&(0,e.jsx)(Vt,{t,onReload:()=>o(),version:oe})}),(0,e.jsx)("div",{style:{display:R==="optimize"?"contents":"none"},children:b.has("optimize")&&(0,e.jsx)(Gt,{t,onReload:()=>o(),version:oe})}),Re&&(0,e.jsx)(ea,{t,card:Re,query:w.trim(),onClose:()=>We(null),onDelete:u=>{We(null),z(u)},onFeedback:u=>{let j=Re.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:w.trim(),path:j,useful:u})}).then(()=>F({ok:!0,msg:t(u?"fbUseful":"fbIrr")})).catch(()=>{}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}}),(0,e.jsx)(Qt,{t,newCard:Y,setNewCard:X,onCreated:()=>{o(),De(),F({ok:!0,msg:t("created")}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>F(null),2e3)}})]})]})]})}var Je=({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 Tt({t,onReload:l,version:d,compact:v}){let[m,i]=(0,n.useState)(null),[D,C]=(0,n.useState)(0),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(!1),[A,N]=(0,n.useState)(null),[H,w]=(0,n.useState)(null),[E,re]=(0,n.useState)(""),[ee,P]=(0,n.useState)(""),[Le,R]=(0,n.useState)(""),[be,b]=(0,n.useState)(""),[ie,g]=(0,n.useState)(null),I=(0,n.useRef)(null),_=(c,Y=!0)=>{I.current&&clearTimeout(I.current),g({msg:c,ok:Y}),I.current=setTimeout(()=>g(null),1900)},V=(c,Y)=>Object.keys(Y).reduce((X,oe)=>X.split("{"+oe+"}").join(Y[oe]),t(c)),F=(0,n.useCallback)(async()=>{try{let[c,Y,X]=await Promise.all([fetch(`${W}/config`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/setup-status`).then(oe=>oe.json()).catch(()=>null),fetch(`${W}/budget`).then(oe=>oe.json()).catch(()=>null)]);c&&c.ok?(i(c),C(c.revision??0),S(c.schema??null),y({...c.config??{}}),N(c.dsh??null),U(c.writable===!1),re("")):X&&X.ok?(y({...X}),U(!0),re(t("configNeedsDsh"))):re(t("adminLoadFail")),Y&&Y.ok&&w(Y),R("")}catch{re(t("adminLoadFail"))}},[t]);(0,n.useEffect)(()=>{F()},[d,F]);let O=(c,Y)=>y(X=>({...X??{},[c]:Y})),J=c=>({init:t("modeInit"),interval:t("modeInterval"),manual:t("modeManual")})[c]||c,G=async()=>{if(k){if(x){_(t("editInSetting"),!1);return}P("save");try{let c=await fetch(`${W}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:k,expectedRevision:D})}),Y=await c.json();if(Y&&Y.ok)R(t("savedOk")+(Y.note?` \xB7 ${t("restartHint")}`:"")),_(t("savedOk")),await F();else{let X=c.status===409?t("conflictRefresh"):Y?.error||t("saveFail");re(X),_(X,!1)}}catch{re(t("saveFail")),_(t("saveFail"),!1)}finally{P("")}}},ye=()=>{y({...m?.config??{}}),R("")},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}},We=async c=>{let Y=Re[c];Y&&y(X=>({...X??{},...Y}))},Me=async(c,Y)=>{P(c+Y);try{let oe=await(await fetch(`${W}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:c,action:Y})})).json();oe&&oe.ok?_(V(Y==="install"?"mcpInstalled":"mcpUninstalled",{agent:c})):_(V("mcpActionFail",{agent:c,error:oe?.error||""}),!1);try{let Ne=await fetch(`${W}/setup-status`).then(De=>De.json());Ne&&Ne.ok&&w(Ne)}catch{}}catch{_(t("mergeFail"),!1)}finally{P("")}},de=({k:c,label:Y,type:X="text",step:oe,min:Ne,max:De})=>(0,e.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,e.jsx)("span",{style:{opacity:.6},children:Y||c}),(0,e.jsx)("input",{type:X,step:oe,min:Ne,max:De,value:k?k[c]??"":"",onChange:ze=>O(c,X==="number"?Number(ze.target.value):ze.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}})]}),Z=({k:c,label:Y})=>(0,e.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,e.jsx)("input",{type:"checkbox",checked:!!(k&&k[c]),onChange:X=>O(c,X.target.checked)}),(0,e.jsx)("span",{children:Y||c})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:v?"0 0 auto":1,minHeight:0,maxHeight:v?"52vh":void 0},children:[(0,e.jsx)("style",{children:Ie}),ie&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ie.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ie.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ie.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ie.msg})]}),(0,e.jsxs)("div",{style:{overflow:"auto",padding:4},children:[E&&(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 ",E]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:F,children:["\u21BB ",t("retry")]})]}),x&&(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")]}),Le&&(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 ",Le]}),m&&(m.version||m.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")}),m.version&&(0,e.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",m.version]}),m.dsh?.vaultDir&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",m.dsh.vaultDir]})]}),H&&H.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:H.agents.map(c=>(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:c.isDsh?t("dshHostLabel"):c.name}),c.isDsh&&c.version&&(0,e.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",c.version]}),!c.installed&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",t("notInstalled"),")"]}),c.installed&&c.mcpConfigured===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",t("noMcpEntry"),")"]}),c.mcpConfigured===!0&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",t("healthy")]}),c.mcpConfigured===!0&&c.mcpMatchesCurrentNode===!1&&(0,e.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",t("nodePathNote"),")"]}),c.isDsh&&(0,e.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",t("recallTool"),": ",c.recallTool?t("enabled"):t("disabled"),")"]})]}),c.hook&&(0,e.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",c.hook]}),!c.isDsh&&c.installed&&c.mcpConfigured===!1&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!ee,onClick:()=>Me(c.name,"install"),children:t("installMcp")}),!c.isDsh&&c.installed&&c.mcpConfigured===!0&&(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!ee,onClick:()=>{window.confirm(t("uninstallConfirm"))&&Me(c.name,"uninstall")},children:t("uninstallMcp")})]},c.name))}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:t("mcpSetupHint")}),be&&(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:be})})]}),k?(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(c=>(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>We(c),disabled:!!ee,children:[c==="A"?"\u{1F7E2} ":c==="B"?"\u{1F4B0} ":"\u2B50 ",Re[c].label]},c))})]}),(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)(Z,{k:"autoCapture",label:t("autoCapture")}),(0,e.jsx)(Z,{k:"autoRecall",label:t("autoRecall")}),(0,e.jsx)(de,{k:"captureMinChars",label:t("captureMinChars"),type:"number"}),(0,e.jsx)(de,{k:"maxCardsPerDay",label:t("maxCardsPerDay"),type:"number"}),(0,e.jsx)(de,{k:"dedupThreshold",label:t("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,e.jsx)(de,{k:"recallLimit",label:t("recallLimit"),type:"number"}),(0,e.jsx)(de,{k:"recallSummaryLen",label:t("recallSummaryLen"),type:"number"}),(0,e.jsx)(Z,{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)(Z,{k:"distillEnabled",label:t("distillEnabled")}),(0,e.jsx)(Z,{k:"dedupByLLM",label:t("dedupByLLM")}),(0,e.jsx)(de,{k:"captureMaxTokens",label:t("captureMaxTokens"),type:"number"}),(0,e.jsx)(de,{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:k.auditMode??"all",onChange:c=>O("auditMode",c.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)(St,{label:t("auditExemptAgents"),value:k.auditExemptAgents||[],options:[{value:"__all__",label:t("allExempt")},...(H?.agents||[]).filter(c=>!c.isDsh).map(c=>({value:c.name,label:c.name}))],onChange:c=>O("auditExemptAgents",c)}),(0,e.jsx)(St,{label:t("auditExemptKinds"),value:k.auditExemptKinds||[],options:[{value:"__all__",label:t("allExempt")},...ut.filter(c=>c!=="all").map(c=>({value:c,label:t(Ee[c])}))],onChange:c=>O("auditExemptKinds",c)}),(0,e.jsx)(de,{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)(Z,{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:k.autoWebMode??"init",onChange:c=>O("autoWebMode",c.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)(de,{k:"webPort",label:t("webPort"),type:"number"}),(0,e.jsx)(de,{k:"webCheckIntervalMs",label:t("webCheckIntervalMs"),type:"number"}),(0,e.jsx)(de,{k:"webMaxRestart",label:t("webMaxRestart"),type:"number"}),(0,e.jsx)(Z,{k:"watchdogAutoSpawn",label:t("watchdogAutoSpawn")}),(0,e.jsx)(Z,{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:ye,disabled:!!ee,children:t("reset")}),(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:G,disabled:!!ee||ee==="save"||x,children:ee==="save"?t("exporting"):"\u{1F4BE} "+t("saveConfig")})]})]}):(0,e.jsx)("div",{style:{fontSize:12,opacity:.6},children:t("loading")})]})]})}function Vt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,D]=(0,n.useState)([]),[C,L]=(0,n.useState)("all"),[S,k]=(0,n.useState)("all"),[y,x]=(0,n.useState)(""),[U,A]=(0,n.useState)(new Set),[N,H]=(0,n.useState)(""),[w,E]=(0,n.useState)("pending"),re=[...new Set([...v,...i].map(b=>b.submittedBy).filter(Boolean))],ee=(0,n.useCallback)(async()=>{try{let b=await fetch(`${W}/audit/list`).then(ie=>ie.json());b.ok&&(m(b.pending||[]),D(b.rejected||[]),A(new Set))}catch{}},[]);(0,n.useEffect)(()=>{ee()},[d,ee]);let P=(w==="pending"?v:i).filter(b=>{if(C!=="all"&&b.kind!==C||S!=="all"&&Qe(b.submittedBy)!==S)return!1;if(y){let ie=(b.created||"").slice(0,10);if(ie&&ie!==y)return!1}return!0}),Le=b=>A(ie=>{let g=new Set(ie);return g.has(b)?g.delete(b):g.add(b),g}),R=async(b,ie)=>{H("apply");try{for(let g of ie||[...U])await fetch(`${W}/${b==="approved"?"audit/approve":b==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(g)}${b==="delete"?"&permanent=0":""}`);await ee(),l&&l()}catch{}finally{H("")}},be=[...U];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:Ie}),(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:C,onChange:b=>L(b.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")}),ut.filter(b=>b!=="all").map(b=>(0,e.jsx)("option",{value:b,children:t(Ee[b])},b))]}),(0,e.jsxs)("select",{value:S,onChange:b=>k(b.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")}),It(re).map(b=>(0,e.jsx)("option",{value:b,children:b},b))]}),(0,e.jsx)("input",{type:"date",value:y,onChange:b=>x(b.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${w==="pending"?" me-on":""}`,onClick:()=>E("pending"),children:[t("pending"),"\uFF08",v.length,"\uFF09"]}),(0,e.jsxs)("button",{type:"button",className:`mc-btn${w==="rejected"?" me-on":""}`,onClick:()=>E("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:P.length>0&&be.length===P.length,onChange:b=>{b.target.checked?A(new Set(P.map(ie=>ie.path))):A(new Set)}})," ",t("selectAll")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!be.length||!!N,onClick:()=>R("approved"),children:["\u2713 ",t(w==="rejected"?"restore":"approve")]}),w==="pending"?(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>R("rejected"),children:["\u2715 ",t("reject")]}):(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!be.length||!!N,onClick:()=>{window.confirm(t("recycleDeleteConfirm"))&&R("delete")},children:["\u{1F5D1} ",t("restoreDelete")]})]}),P.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:P.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)("input",{type:"checkbox",checked:U.has(b.path),onChange:()=>Le(b.path)}),(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[b.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.title}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:Qe(b.submittedBy)}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.created?b.created.slice(0,16).replace("T"," "):"-"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6},children:b.kind}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,color:b.severity==="high"?"#f87171":"#9ca3af"},children:b.severity}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.reason||"-"}),w==="pending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>R("approved",[b.path]),children:"\u2713"}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>R("rejected",[b.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:()=>R("approved",[b.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"))&&R("delete",[b.path])},children:"\u{1F5D1}"})]})]},b.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("noAuditItems")})]})]})}function Gt({t,onReload:l,version:d}){let[v,m]=(0,n.useState)([]),[i,D]=(0,n.useState)(""),C=(0,n.useCallback)(async()=>{try{let S=await fetch(`${W}/recycle/list`).then(k=>k.json());S.ok&&m(S.items||[])}catch{}},[]);(0,n.useEffect)(()=>{C()},[d,C]);let L=async(S,k)=>{D(S+k);try{S==="restore"?await fetch(`${W}/recycle/restore?path=${encodeURIComponent(k)}`):S==="purge"&&await fetch(`${W}/recycle/purge?path=${encodeURIComponent(k)}`),await C(),l&&l()}catch{}finally{D("")}};return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ie}),(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()=>{D("purgeAll");try{await fetch(`${W}/recycle/purge-expired?days=0`),await C()}catch{}finally{D("")}},children:t("emptyRecycle")})]}),v.length?(0,e.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:v.map(S=>(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:Oe[S.kind]||"#999"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[t("deletedAt")," ",(S.deletedAt||"").slice(0,10)]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!i,onClick:()=>L("restore",S.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"))&&L("purge",S.path)},children:t("purge")})]},S.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:t("emptyRecycle")})]})]})}var Jt=({card:t,t:l,onOpen:d,query:v,onDelete:m})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Oe[t.kind]||Oe.other}}),(0,e.jsx)("span",{style:{marginRight:4},children:Ct[t.kind]||"\u{1F4CE}"}),v?Mt(t.title,v):t.title,ia(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:v?Mt(t.summary||"",v):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:[Ct[t.kind]||"\u{1F4CE}"," ",l(Ee[t.kind])]}),(0,e.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Qe(t.submittedBy)]}),(0,e.jsxs)("span",{children:["\u{1F4C5} ",nt(t.updated)]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:i=>{i.stopPropagation(),window.confirm(l("deleteConfirm"))&&m&&m(t.path)},children:"\u{1F5D1}"})]})]});function Zt({t,tab:l,onReload:d,version:v}){let[m,i]=(0,n.useState)(null),[D,C]=(0,n.useState)(""),[L,S]=(0,n.useState)(null),[k,y]=(0,n.useState)(null),[x,U]=(0,n.useState)(null),[A,N]=(0,n.useState)([]),[H,w]=(0,n.useState)(""),[E,re]=(0,n.useState)(!1),ee=(0,n.useCallback)(async()=>{if(!(!L||!L.merge||!L.merge.length)&&window.confirm(t("mergeAllConfirm"))){w("merge");try{let g={},I=J=>g[J]===void 0?J:g[J]=I(g[J]),_=(J,G)=>{g[I(J)]=I(G)},V=new Set;for(let J of L.merge)V.add(J.a.path),V.add(J.b.path),_(J.a.path,J.b.path);let F={};for(let J of V){let G=I(J);(F[G]=F[G]||[]).push(J)}let O=0;for(let J of Object.values(F)){if(J.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(J.join(","))}`).then(ye=>ye.json())).ok&&O++}await P(),d&&d()}catch{}w("")}},[L,P,d,t]);async function P(){try{let g=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/budget`),fetch(`${W}/capture-log`),fetch(`${W}/cards?status=all&limit=30&agent=${at}`)]),[I,_,V,F]=await Promise.all(g.map(O=>O.json()));I&&I.ok&&i(I),_&&_.ok&&y(_),V&&V.ok&&U(V),F&&F.ok&&N(F.cards||[]),C(!I||!I.ok?t("adminLoadFail"):"")}catch{C(t("adminLoadFail"))}}let Le=(0,n.useCallback)(async()=>{w("scan");try{let g=await fetch(`${W}/optimize`).then(I=>I.json());g.ok&&S(g)}catch{C(t("adminLoadFail"))}finally{w("")}},[t]);(0,n.useEffect)(()=>{P()},[v]);let R=async(g,I)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(g+","+I)}`).then(V=>V.json())).ok&&(await P(),d&&d())}catch{}},be=async g=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(g)}`).then(_=>_.json())).ok&&(await P(),d&&d())}catch{}},b=["project","knowledge","content","prompt","business","tool","mistake"],ie=({title:g,kind:I,updated:_,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:Ze.colors[I]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(_)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>be(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:Ie}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[D&&(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 ",D]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:P,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:()=>P(),children:["\u21BB ",t("refresh")]})]}),x?x.available===!1?(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:t("captureLogUnavailable")}):(x.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:(x.entries||[]).map((g,I)=>{let _=Ht[g.action]||["\u2022","inherit"];return(0,e.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:nt(g.time?new Date(g.time).toISOString():"")}),(0,e.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:_[1],fontWeight:600},children:[_[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||""})]},I)})})})}):(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",A.length,"\uFF09"]}),A.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:A.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:Oe[g.kind]||Oe.other}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.title}),g.status==="pending"&&(0,e.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:nt(g.updated)})]},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noCards")})]}),m&&(0,e.jsxs)(e.Fragment,{children:[m.trend&&m.trend.length>0&&(()=>{let g=m.trend,I=Math.max(...g.map(O=>O.count),1),_=260,V=50,F=_/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:_,height:V,style:{display:"block",width:"100%",height:50},children:g.map((O,J)=>{let G=Math.round(O.count/I*(V-4));return(0,e.jsx)("rect",{x:J*F+1,y:V-G,width:Math.max(F-2,2),height:G,rx:1.5,fill:O.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:O.count>0?.85:.35},O.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:m.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:b.map(g=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[g]||"#666"}}),t(Ee[g]),": ",m.byKind?.[g]||0]},g))})]}),k&&(k.budgetChars||k.recallLimit||k.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:k.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:k.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",k.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",m.todayCards?.length||0,"\uFF09"]}),m.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:m.todayCards.map(g=>(0,e.jsx)(ie,{title:g.title,kind:g.kind,updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("organizeTitle")}),(0,e.jsx)("div",{style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:!!H,onClick:Le,children:H==="scan"?t("exporting"):"\u{1F50D} "+t("scanAndOrganize")}),L&&L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:async()=>{if(window.confirm(t("oneClickOptimizeConfirm"))){w("oneclick");try{let g=JSON.stringify({cleanupStale:E}),_=await(await fetch(`${W}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:g})).json();_&&_.ok?(notify(`${t("oneClickOptimizeDone")}\uFF1A${_.plan.merged} ${t("optimizedMerged")}${E?` \xB7 ${_.plan.staleDeleted} ${t("optimizedStaleDeleted")}`:""}`),await P(),d&&d(),S(null)):notify(t("mergeFail"),!1)}catch{notify(t("mergeFail"),!1)}finally{w("")}}},children:H==="oneclick"?t("exporting"):"\u26A1 "+t("oneClickOptimize")}),L&&L.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:E,onChange:g=>re(g.target.checked)}),t("oneClickAlsoStale")]})]}),!L&&(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:t("scanHint")}),L&&(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}}),L.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!H,onClick:ee,children:t(H==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),L.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:L.merge.map((g,I)=>(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:()=>R(g.a.path,g.b.path),children:t("mergeNow")})]},I))}):(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",L.stale?.length||0,"\uFF09"]}),L.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!H,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;w("clean");let g=0;for(let I of L.stale)try{await fetch(`${W}/delete?path=${encodeURIComponent(I.path)}`),g++}catch{}w(""),notify(`${g} ${t("deletedStale")}`),await P(),d&&d()},children:t("cleanStale")})}),L.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:L.stale.map(g=>(0,e.jsx)(ie,{title:g.title,kind:"other",updated:g.updated,path:g.path},g.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})]})}var mt=[{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 Qt({t,newCard:l,setNewCard:d,onCreated:v}){if(!l)return null;let m=mt.find(y=>y.key===l.template),i=l.body||(m?t(m.bodyKey):""),D=l.kind||(m?m.kind:"knowledge"),C=l.tags||(m?t(m.tagKey):""),L=l._creating,S=y=>{let x=mt.find(U=>U.key===y);d(U=>({...U,template:y,kind:x?x.kind:U.kind,body:x?t(x.bodyKey):U.body,tags:x?t(x.tagKey):U.tags}))},k=async()=>{if(!(!l.title&&!i)){d(y=>({...y,_creating:!0}));try{(await fetch(`${W}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title||t("untitled"),kind:D,tags:C.split(",").map(x=>x.trim()).filter(Boolean),body:i,source:"manual"})}).then(x=>x.json())).ok?(d(null),v&&v()):d(x=>({...x,_creating:!1}))}catch{d(x=>({...x,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[mt.map(y=>(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===y.key?" me-on":""}`,onClick:()=>S(y.key),children:t(y.label)},y.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${l.template===""?" me-on":""}`,onClick:()=>d(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:t("tplBlank")})]}),(0,e.jsx)("select",{className:"mc-btn",value:D,onChange:y=>d(x=>({...x,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,e.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:l.title||"",onChange:y=>d(x=>({...x,title:y.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tagsHint"),value:C,onChange:y=>d(x=>({...x,tags:y.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:i,onChange:y=>d(x=>({...x,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:L,onClick:k,children:t(L?"exporting":"createCard")})})]})]})]})}function ea({t,card:l,query:d,onClose:v,onDelete:m,onFeedback:i}){(0,n.useEffect)(()=>{let S=k=>{k.key==="Escape"&&v()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[v]);let[D,C]=(0,n.useState)(!1),L=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:v,children:[(0,e.jsx)("style",{children:Ie}),(0,e.jsxs)("div",{className:"me-dialog",onClick:S=>S.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(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("fbIrr")]})]}),L&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>C(S=>!S),children:t(D?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&m&&m(l.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:v,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:D?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:ra(l.text)}})]})]})}function ta({t,onOpen:l,all:d,onAllChange:v,onMutate:m,active:i,visible:D}){let[C,L]=(0,n.useState)(null),[S,k]=(0,n.useState)(""),y=(0,n.useRef)(!1),x=(0,n.useRef)(0),U=(0,n.useRef)(t);U.current=t;let A=(0,n.useCallback)(async()=>{try{y.current=!1;let E=await(await fetch(`${W}/graph${d?"?all=1":""}`)).json();E.ok?(L(E),k(""),y.current=!0):(L(null),k(E.error||t("error")))}catch(w){k(String(w&&w.message?w.message:w))}},[d,t]);(0,n.useEffect)(()=>{if(!i||y.current)return;let w=!0;return fetch(`${W}/graph${d?"?all=1":""}`).then(E=>E.json()).then(E=>{w&&(E.ok?(L(E),k(""),y.current=!0):(L(null),k(E.error||t("error"))))}).catch(E=>{w&&k(String(E&&E.message?E.message:E))}),()=>{w=!1}},[d,t,i]),(0,n.useEffect)(()=>{D&&C&&x.current++},[D,C]);let N=(0,n.useCallback)(async w=>{try{let re=await(await fetch(`${W}/delete?path=${encodeURIComponent(w)}`)).json();return re&&re.ok?(await A(),m&&m(),!0):!1}catch{return!1}},[A]),H=(0,n.useCallback)(async w=>{if(!w||w.length<2)return!1;try{let E=await fetch(`${W}/merge?paths=${encodeURIComponent(w.join(","))}`).then(re=>re.json());return E&&E.ok?(await A(),m&&m(),!0):!1}catch{return!1}},[A,m]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ie}),S&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",S]}),!C&&!S&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),C&&C.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),C&&C.nodes.length>0&&(0,e.jsx)(na,{nodes:C.nodes,edges:C.edges,onOpen:l,onDelete:N,onMerge:H,t,all:d,onAllChange:v,countLabel:`${C.nodes.length} ${t("nodes")} \xB7 ${aa(C.edges)} ${t("edges")}`,fitTrigger:x.current})]})}function aa(t){let l=new Set;for(let d of t||[])l.add([d.source,d.target].sort().join("|"));return l.size}var Ze={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 na({nodes:t,edges:l,onOpen:d,onDelete:v,onMerge:m,t:i,countLabel:D,all:C,onAllChange:L,fitTrigger:S}){let k=(0,n.useRef)(null),y=(0,n.useRef)(null),x=(0,n.useRef)(null),U=(0,n.useRef)(null),A=(0,n.useRef)(null),N=(0,n.useRef)(d);(0,n.useEffect)(()=>{N.current=d},[d]);let H=(0,n.useRef)(v);(0,n.useEffect)(()=>{H.current=v},[v]);let w=(0,n.useRef)(m);(0,n.useEffect)(()=>{w.current=m},[m]);let[E,re]=(0,n.useState)(""),[ee,P]=(0,n.useState)(null),Le=(0,n.useRef)("");(0,n.useEffect)(()=>{Le.current=E.trim().toLowerCase()},[E]),(0,n.useEffect)(()=>{let r=x.current;if(!r)return;let o=E.trim().toLowerCase();if(!o)return;let z=r.nodes.find(te=>(te.name||"").toLowerCase().includes(o));z&&(x.current.selectedId=z.id,P(z.id),r.panX=r.w/2-z.x*r.zoom,r.panY=r.h/2-z.y*r.zoom,r.render&&r.render())},[E]);let[R,be]=(0,n.useState)("all"),[b,ie]=(0,n.useState)(!1),g=(0,n.useRef)("all"),[I,_]=(0,n.useState)(""),V=(0,n.useRef)(""),[F,O]=(0,n.useState)(!1),J=(0,n.useRef)(!1),[G,ye]=(0,n.useState)(null);(0,n.useEffect)(()=>{g.current=R},[R]),(0,n.useEffect)(()=>{V.current=I},[I]),(0,n.useEffect)(()=>{J.current=F},[F]);let Re=(0,n.useMemo)(()=>{let r=new Map;for(let o of t)for(let z of o.tags||[]){let te=String(z).trim();te&&r.set(te,(r.get(te)||0)+1)}return[...r.entries()].sort((o,z)=>z[1]-o[1]).slice(0,24).map(([o,z])=>({tag:o,n:z}))},[t]),We=(()=>{let r=E.trim().toLowerCase();return!!r&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(r)||String(o.kind||"").toLowerCase().includes(r)||String(Ee[o.kind]||"").toLowerCase().includes(r))})();(0,n.useEffect)(()=>{let r=x.current;r&&r.wake&&r.wake()},[E]),(0,n.useEffect)(()=>{let r=x.current;r&&r.render&&r.render()},[R,I,F]);let Me=(0,n.useRef)(null),[de,Z]=(0,n.useState)([]),[c,Y]=(0,n.useState)(null),[X,oe]=(0,n.useState)(!1),[Ne,De]=(0,n.useState)(null),[ze,He]=(0,n.useState)(""),_e=(0,n.useRef)(null),je=(0,n.useRef)(null),le=(r,o=!0)=>{_e.current&&clearTimeout(_e.current),De({msg:r,ok:o}),_e.current=setTimeout(()=>De(null),1900)},Ke=r=>{He(r),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>He(""),1600)};(0,n.useEffect)(()=>()=>{_e.current&&clearTimeout(_e.current),je.current&&clearTimeout(je.current)},[]);let Se=(0,n.useMemo)(()=>t.reduce((r,o)=>(r[o.id]=o,r),{}),[t]);return(0,n.useEffect)(()=>{let r=k.current;if(!r||t.length===0)return;let o=r.getContext("2d");if(!o)return;let z=Math.max(1,window.devicePixelRatio||1),te=()=>document.documentElement.getAttribute("data-theme")==="dark",ce={};l.forEach(s=>{ce[s.source]=(ce[s.source]||0)+1,ce[s.target]=(ce[s.target]||0)+1});let ke=Math.max(1,...Object.values(ce)),a={nodes:t.map(s=>({id:s.id,name:s.title||"",type:s.kind||"other",r:9+Math.min(10,(ce[s.id]||0)/ke*8),x:0,y:0,vx:0,vy:0})),edges:l.map(s=>({sourceNodeId:s.source,targetNodeId:s.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:z,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((s,h)=>(s[h.id]=h,s),{}),a.nodes.forEach((s,h)=>{let f=h/a.nodes.length*Math.PI*2-Math.PI/2;s.x=Math.cos(f)*60,s.y=Math.sin(f)*60});let et=[...new Set(a.nodes.map(s=>s.type))];a.clustered=et.length>1,a.typeCenters={},et.forEach((s,h)=>{let f=h/et.length*Math.PI*2-Math.PI/2;a.typeCenters[s]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),x.current=a;let ot=0,it=0,u=()=>{let s=r.clientWidth,h=r.clientHeight;a.w=s,a.h=h,r.width=s*z,r.height=h*z,o.setTransform(z,0,0,z,0,0),(ot===0||it===0)&&s>0&&h>0&&a.tickCount>0&&requestAnimationFrame(()=>pe()),ot=s,it=h};u();let j=new ResizeObserver(u);j.observe(r.parentElement);let K=(s,h)=>s&&s.length>h?s.slice(0,h)+"\u2026":s,ue=(s,h,f,M)=>{if(o.beginPath(),M==="rect")o.rect(s-f,h-f*.75,f*2,f*1.5);else if(M==="diamond")o.moveTo(s,h-f),o.lineTo(s+f,h),o.lineTo(s,h+f),o.lineTo(s-f,h),o.closePath();else if(M==="hexagon"){for(let T=0;T<6;T++){let Q=Math.PI/3*T-Math.PI/2,q=s+f*Math.cos(Q),he=h+f*Math.sin(Q);T===0?o.moveTo(q,he):o.lineTo(q,he)}o.closePath()}else o.arc(s,h,f,0,Math.PI*2)},pe=()=>{if(!a.nodes.length)return;let s=1/0,h=-1/0,f=1/0,M=-1/0;a.nodes.forEach(p=>{s=Math.min(s,p.x),h=Math.max(h,p.x),f=Math.min(f,p.y),M=Math.max(M,p.y)});let T=20,Q=h-s+T*2,q=M-f+T*2,he=Math.min(a.w/Q,a.h/q);a.zoom=Math.max(.35,Math.min(1.8,he)),a.panX=a.w/2-(s+h)/2*a.zoom,a.panY=a.h/2-(f+M)/2*a.zoom};U.current=pe;let me=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=Le.current,a.kindFilter=g.current,a.timeMode=J.current,a.tagFilter=V.current;let s=a.tagFilter,h=a.kindFilter,f=p=>String(p||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.save(),o.strokeStyle=te()?"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 M={};a.nodes.forEach(p=>M[p.id]=p);let T=a.nodes.length>40,Q=T?1.5:.55,q=a.selectedId||a.hoverId;a.edges.forEach(p=>{let ae=M[p.sourceNodeId],B=M[p.targetNodeId];if(!ae||!B)return;if(h!=="all"){let rt=a.domainById[p.sourceNodeId]&&a.domainById[p.sourceNodeId].kind,we=a.domainById[p.targetNodeId]&&a.domainById[p.targetNodeId].kind;if(rt!==h&&we!==h)return}if(s){let rt=a.domainById[p.sourceNodeId]&&(a.domainById[p.sourceNodeId].tags||[]).includes(s),we=a.domainById[p.targetNodeId]&&(a.domainById[p.targetNodeId].tags||[]).includes(s);if(!rt&&!we)return}let $=B.x-ae.x,ne=B.y-ae.y,se=Math.sqrt($*$+ne*ne)||1,fe=T?12:18,xe=-ne/se*fe,ve=$/se*fe,Te=(ae.x+B.x)/2+xe,Be=(ae.y+B.y)/2+ve,Ae=Ze.colors[a.domainById[ae.id]&&a.domainById[ae.id].kind||"other"],Ue=q&&(p.sourceNodeId===q||p.targetNodeId===q),ct=q?Ue?.6:.08:T?.14:.24,pt=parseInt(Ae.slice(1,3),16),tt=parseInt(Ae.slice(3,5),16),lt=parseInt(Ae.slice(5,7),16);o.strokeStyle="rgba("+pt+","+tt+","+lt+","+ct+")",o.lineWidth=Ue?1.6+(p.weight||1):.8+(p.weight||1)*.5,o.beginPath(),o.moveTo(ae.x,ae.y),o.quadraticCurveTo(Te,Be,B.x,B.y),o.stroke()});let he=[];if(a.nodes.forEach(p=>{let ae=a.domainById[p.id]||{},B=ae.kind||"other",$=a.timeMode?oa(ae.updated):Ze.colors[B],ne=Ze.shapes[B],se=a.selectedId===p.id,fe=a.hoverId===p.id,xe=a.searchTerm||"",ve=!xe||(p.name||"").toLowerCase().includes(xe)||String(Ee[B]||"").toLowerCase().includes(xe)||String(B).toLowerCase().includes(xe),Te=h==="all"||B===h,Be=!s||(ae.tags||[]).includes(s),Ae=q&&p.id!==q&&!a.edges.some(we=>we.sourceNodeId===q&&we.targetNodeId===p.id||we.targetNodeId===q&&we.sourceNodeId===p.id)||xe&&!ve||!Te||!Be;o.save(),o.globalAlpha=Ae?.08:1,(se||fe)&&(o.shadowColor=$,o.shadowBlur=se?20:14),ue(p.x,p.y,p.r,ne);let Ue=parseInt($.slice(1,3),16),ct=parseInt($.slice(3,5),16),pt=parseInt($.slice(5,7),16),tt=o.createRadialGradient(p.x-p.r*.3,p.y-p.r*.3,0,p.x,p.y,p.r*1.2);tt.addColorStop(0,"rgba("+Math.min(255,Ue+70)+","+Math.min(255,ct+70)+","+Math.min(255,pt+70)+",0.95)"),tt.addColorStop(1,$),o.fillStyle=tt,o.fill(),o.restore(),se?(o.save(),ue(p.x,p.y,p.r+3,ne),o.strokeStyle=$,o.lineWidth=3,o.shadowColor=$,o.shadowBlur=12,o.stroke(),o.restore()):fe?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle=$,o.lineWidth=2,o.stroke(),o.restore()):xe&&ve?(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(p.id)>=0&&(o.save(),ue(p.x,p.y,p.r+2,ne),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let lt=K(p.name,16);if((se||fe||a.zoom>Q||!T&&a.zoom>.6)&&Te&&Be){let we=1/a.zoom;o.font="500 "+(12*we).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let $e=o.measureText(lt).width+16*we,st=18*we,Xe=p.y+p.r+8*we,wt=!0;for(let Ve of he)if(p.x-$e/2<Ve.x+Ve.w&&p.x+$e/2>Ve.x&&Xe<Ve.y+Ve.h&&Xe+st>Ve.y){wt=!1;break}if(!wt&&!se&&!fe)return;he.push({x:p.x-$e/2,y:Xe,w:$e,h:st}),o.fillStyle=te()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(p.x-$e/2,Xe,$e,st,4*we):o.rect(p.x-$e/2,Xe,$e,st),o.fill(),o.strokeStyle=te()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*we,o.stroke(),o.fillStyle=te()?se||fe?"#eee":"#bbb":se||fe?"#111":"#444",o.textAlign="center",o.fillText(lt,p.x,Xe+13*we)}}),o.restore(),a.marquee){let p=a.marquee,ae=Math.min(p.sx,p.ex),B=Math.min(p.sy,p.ey),$=Math.abs(p.ex-p.sx),ne=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(ae,B,$,ne),o.strokeRect(ae,B,$,ne),o.restore()}if(a.hoverId&&Me.current){let p=a.domainById[a.hoverId],ae=a.nodes.find(function(B){return B.id===a.hoverId});if(p&&ae){let B=a.edges.filter(function(se){return se.sourceNodeId===p.id||se.targetNodeId===p.id}).length,$=ae.x*a.zoom+a.panX,ne=ae.y*a.zoom+a.panY;Me.current.style.display="block",Me.current.style.left=$+14+"px",Me.current.style.top=ne-6+"px",Me.current.innerHTML="<b>"+f(p.title||p.name||"")+'</b><br/><span style="opacity:.8">'+f(p.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",B)+"</span>"}}else Me.current&&(Me.current.style.display="none")},ge=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(Fe))};a.wake=ge,a.render=me;let Pe=()=>{let s=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),M=s>1e3?3e3:s>100?2e3:s>50?1200:800,T=s>100?.002:.005,Q=s>1e3?.012:s>100?.005:.01,q=s>1e3?6:s>200?12:24,he={};a.nodes.forEach(B=>he[B.id]=B);for(let B=0;B<s;B++){if(a.dragNode===a.nodes[B])continue;let $=a.nodes[B],ne=0,se=0;for(let ve=0;ve<s;ve++){if(B===ve)continue;let Te=$.x-a.nodes[ve].x,Be=$.y-a.nodes[ve].y,Ae=Math.sqrt(Te*Te+Be*Be)||1,Ue=M/(Ae*Ae);ne+=Te/Ae*Ue,se+=Be/Ae*Ue}if(a.clustered&&a.typeCenters[$.type]){let ve=a.typeCenters[$.type];ne+=(ve.x-$.x)*.006,se+=(ve.y-$.y)*.006}else ne-=$.x*Q,se-=$.y*Q;let fe=($.vx+ne)*f,xe=($.vy+se)*f;fe=Math.max(-q,Math.min(q,fe)),xe=Math.max(-q,Math.min(q,xe)),$.vx=fe,$.vy=xe}a.edges.forEach(B=>{let $=he[B.sourceNodeId],ne=he[B.targetNodeId];if(!$||!ne)return;let se=ne.x-$.x,fe=ne.y-$.y,xe=Math.sqrt(se*se+fe*fe)||1,ve=(xe-100)*T,Te=se/xe*ve,Be=fe/xe*ve;a.dragNode!==$&&($.vx+=Te,$.vy+=Be),a.dragNode!==ne&&(ne.vx-=Te,ne.vy-=Be)});let p=0;a.nodes.forEach(B=>{a.dragNode!==B&&(B.x+=B.vx,B.y+=B.vy,p+=B.vx*B.vx+B.vy*B.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,pe()),(s?Math.sqrt(p/s):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},Fe=()=>{if(a.running){try{Pe(),me()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(Fe)}},Ce=(s,h)=>{let f=r.getBoundingClientRect();return{x:(s-f.left-a.panX)/a.zoom,y:(h-f.top-a.panY)/a.zoom}},Ye=s=>{let h=a.domainById[s];return!(!h||g.current!=="all"&&h.kind!==g.current||V.current&&!(h.tags||[]).includes(V.current))},qe=(s,h,f)=>Math.max(h,Math.min(f,s)),gt=s=>{a.mouseX=s.clientX,a.mouseY=s.clientY;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+36){f=T.id;break}}f!==a.hoverId&&(a.hoverId=f,ge())},ft=s=>{if(s.button!==0)return;let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(s.shiftKey){if(f){a.shiftClick=f.id;return}a.marquee={sx:s.clientX,sy:s.clientY,ex:s.clientX,ey:s.clientY};return}a.dragStart={x:s.clientX,y:s.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=f||null,f&&(a.dragOffset={dx:f.x-h.x,dy:f.y-h.y})},bt=s=>{if(a.marquee){a.marquee.ex=s.clientX,a.marquee.ey=s.clientY,ge();return}if(!a.dragStart)return;let h=s.clientX-a.dragStart.x,f=s.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let M=Ce(s.clientX,s.clientY);a.dragNode.x=M.x+a.dragOffset.dx,a.dragNode.y=M.y+a.dragOffset.dy,ge()}else a.dragging&&(a.panX=qe(a.dragStart.px+h,-1e5,1e5),a.panY=qe(a.dragStart.py+f,-1e5,1e5),ge())},yt=s=>{if(a.marquee){let f=a.marquee;a.marquee=null;let M=r.getBoundingClientRect(),T=Math.min(f.sx,f.ex)-M.left,Q=Math.max(f.sx,f.ex)-M.left,q=Math.min(f.sy,f.ey)-M.top,he=Math.max(f.sy,f.ey)-M.top,p=a.nodes.filter(ae=>{let B=ae.x*a.zoom+a.panX,$=ae.y*a.zoom+a.panY;return B>=T&&B<=Q&&$>=q&&$<=he}).map(ae=>ae.id);a.multi=p,Z(p),ge();return}let h=a.dragStart&&!a.dragging;if(a.shiftClick){let f=a.shiftClick;a.shiftClick=null;let M=Array.isArray(a.multi)?a.multi.slice():[];M.includes(f)||M.push(f),a.multi=M,Z(M),ge();return}if(h){let f=Ce(s.clientX,s.clientY),M=null;for(let T=a.nodes.length-1;T>=0;T--){let Q=a.nodes[T];if(!Ye(Q.id))continue;let q=Q.x-f.x,he=Q.y-f.y;if(q*q+he*he<Q.r*Q.r+20){M=Q;break}}M?(a.selectedId=M.id,P(M.id),ge()):(a.selectedId=null,a.hoverId=null,s.shiftKey||(a.multi=[],Z([])),P(null),ge())}a.dragStart=null,a.dragging=!1,a.dragNode=null},ht=s=>{s.preventDefault();let h=Ce(s.clientX,s.clientY),f=null;for(let M=a.nodes.length-1;M>=0;M--){let T=a.nodes[M];if(!Ye(T.id))continue;let Q=T.x-h.x,q=T.y-h.y;if(Q*Q+q*q<T.r*T.r+25){f=T;break}}if(f){let M=a.domainById[f.id];M&&ye({x:s.clientX,y:s.clientY,id:f.id,path:M.id,title:M.title})}else ye(null)},xt=s=>{s.preventDefault();let h=r.getBoundingClientRect(),f=(s.clientX-h.left-a.panX)/a.zoom,M=(s.clientY-h.top-a.panY)/a.zoom,T=Math.max(.3,Math.min(3,a.zoom*(s.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+f*(a.zoom-T),-1e5,1e5),a.panY=qe(a.panY+M*(a.zoom-T),-1e5,1e5),a.zoom=T,ge()};r.addEventListener("mousemove",gt),r.addEventListener("mousedown",ft),window.addEventListener("mousemove",bt),window.addEventListener("mouseup",yt),r.addEventListener("wheel",xt,{passive:!1}),r.addEventListener("contextmenu",ht),A.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],Z([]),pe(),ge()};for(let s=0;s<200;s++)Pe();pe(),ge();let vt=()=>ie(!1);return window.addEventListener("mousedown",vt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),j.disconnect(),r.removeEventListener("mousemove",gt),r.removeEventListener("mousedown",ft),window.removeEventListener("mousemove",bt),window.removeEventListener("mouseup",yt),r.removeEventListener("wheel",xt),r.removeEventListener("contextmenu",ht),window.removeEventListener("mousedown",vt)}},[t,l]),(0,n.useEffect)(()=>{S!==void 0&&U.current&&requestAnimationFrame(()=>U.current())},[S]),(0,e.jsxs)("div",{className:"me-graph",ref:y,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",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:E,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:()=>ie(r=>!r),"aria-expanded":b,title:i("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",i("filterLabel")," ",R!=="all"||F||I?"\u25CF":"\u25BE"]}),b&&(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${R==="all"&&!F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{be("all"),O(!1)},children:i("all")}),Object.keys(Oe).map(r=>(0,e.jsxs)("button",{type:"button",className:`lg${R===r?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>be(o=>o===r?"all":r),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:Ze.colors[r]||Oe[r]}}),i(Ee[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${F?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>O(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${I===r.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>_(o=>o===r.tag?"":r.tag),title:r.tag,children:["#",r.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:r.n})]},r.tag))})]}),(R!=="all"||F||I)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{be("all"),O(!1),_("")},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:!!C,onChange:r=>L&&L(r.target.checked)}),i("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${F?" me-on":""}`,onClick:()=>O(r=>!r),children:i("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=k.current;if(r)try{r.toBlob(o=>{o&&Y({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:i("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>U.current&&U.current(),children:i("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{P(null),be("all"),A.current&&A.current()},children:i("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:k,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:Me,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),We&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:i("noMatch")}),G&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>ye(null)}),G&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:G.x,top:G.y,zIndex:31},onMouseDown:r=>r.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{N.current({path:G.path,title:G.title}),ye(null)},children:i("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{G.id&&(x.current.selectedId=G.id,P(G.id)),ye(null);let r=x.current;r&&r.wake&&r.wake()},children:i("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(G.title||"")}catch{}ye(null),le(i("copied"))},children:i("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let r=x.current,o=r&&Array.isArray(r.multi)?r.multi.slice():[],z=G.id;if(z&&!o.includes(z)&&o.push(z),ye(null),o.length<2){le(i("mergeNeed"),!1);return}if(!window.confirm(i("mergeConfirm")))return;let te=w.current&&w.current(o);te&&te.then?te.then(ce=>ce?le(i("merged")):le(i("mergeFail"),!1)).catch(()=>le(i("mergeFail"),!1)):te&&le(i("merged"))},children:i("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let r=G.path;ye(null),window.confirm(i("deleteConfirm"))&&(async()=>{try{(H.current?await H.current(r):!1)?le(i("deleted")):le(i("deleteFail"),!1)}catch{le(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(ke=>Se[ke]).filter(Boolean).map(ke=>ke.title||ke.name).join(`
252
+ `),z=new Blob([o],{type:"text/plain;charset=utf-8"}),te=URL.createObjectURL(z),ce=document.createElement("a");ce.href=te,ce.download="memory-selected.txt",document.body.appendChild(ce),ce.click(),document.body.removeChild(ce),setTimeout(()=>URL.revokeObjectURL(te),1e3),le(de.length+i("exportedSel"))},children:i("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(de.length<2){le(i("mergeNeed"),!1);return}let r=de.map(z=>Se[z]?Se[z].id:z);if(!window.confirm(i("mergeConfirm")))return;Z([]);let o=x.current;o&&(o.multi=[]),fetch(`${W}/merge?paths=${encodeURIComponent(r.join(","))}`).then(z=>z.json()).then(z=>{z&&z.ok?le(i("merged")):le(i("mergeFail"),!1)}).catch(()=>le(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(z=>Se[z]?Se[z].id:z);Z([]);let o=x.current;o&&(o.multi=[]),(async()=>{let z=0;for(let te of r)try{(H.current?await H.current(te):!1)&&z++}catch{}le(z+i("deletedSelected"),z>0)})()},children:i("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=x.current;r&&(r.multi=[]),Z([]);let o=x.current;o&&o.render&&o.render()},children:i("clearSelection")})]}),ee&&(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:Se[ee]?Se[ee].title||Se[ee].name:ee}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:Se[ee]?i(Ee[Se[ee].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:i("graphHint")}),(l.filter(r=>r.source===ee||r.target===ee)||[]).slice(0,8).map((r,o)=>{let z=r.source===ee?r.target:r.source,te=Se[z];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ce=>{ce.preventDefault();let ke=x.current;ke&&(ke.selectedId=z,ke.hoverId=z,ke.wake&&ke.wake()),P(z)},children:te?(te.title||te.name).slice(0,28):z},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:i("graphTip")}),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})]}),c&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),Y(null),oe(!1)},children:[(0,e.jsx)("style",{children:Ie}),(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:c.url,download:"memory-graph.png",onClick:()=>{Ke("download"),le(i("downloaded")+" \xB7 "+i("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i(ze==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Ke("full"),oe(r=>!r),le(i("fullscreen"))},children:i(ze==="full"?"done":X?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let r=c.blob;r&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":r})]).then(()=>{Ke("copy"),le(i("copied"))}).catch(()=>{le(i("copyFail"),!1)}):le(i("copyFail"),!1)},children:i(ze==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{c.url&&URL.revokeObjectURL(c.url),Y(null),oe(!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:c.url,alt:i("exportGraph"),style:{maxWidth:"100%",maxHeight:X?"calc(100% - 64px)":"70vh",borderRadius:X?0:8,cursor:"zoom-in"},onClick:()=>oe(r=>!r)})})]})]})]})}function oa(t){let l=new Date(t||0).getTime();if(!l)return"#94a3b8";let d=(Date.now()-l)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function St({label:t,value:l=[],options:d,onChange:v,placeholder:m,z:i=20}){let[D,C]=(0,n.useState)(!1),L=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!D)return;let N=H=>{L.current&&!L.current.contains(H.target)&&C(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[D]);let S=Array.isArray(l)?l:[],k=S.includes("__all__"),y=k?d.find(N=>N.value==="__all__")?.label||"":S.length?S.map(N=>d.find(H=>H.value===N)?.label||N).join("\u3001"):"",x=(N,H)=>{if(N.value==="__all__"){v(H?["__all__"]:[]);return}let w=new Set(S);w.has("__all__")&&w.delete("__all__"),H?w.add(N.value):w.delete(N.value),v([...w])},U=d.find(N=>N.value==="__all__"),A=d.filter(N=>N.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:L,style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button",onClick:()=>C(N=>!N),style:{width:"100%",textAlign:"left",padding:"6px 8px",borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[(0,e.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||m||"\u2014"}),(0,e.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),D&&(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:[U&&(0,e.jsxs)("label",{onClick:N=>N.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:k,onChange:N=>x(U,N.target.checked)}),(0,e.jsx)("span",{children:U.label})]}),A.map(N=>(0,e.jsxs)("label",{onClick:H=>H.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,e.jsx)("input",{type:"checkbox",checked:S.includes(N.value),onChange:H=>x(N,H.target.checked)}),(0,e.jsx)("span",{children:N.label})]},N.value))]})]})]})}function ia(t){let l=new Date(t||0).getTime();return!!l&&(Date.now()-l)/864e5<3}async function la(t,l,d){if(d&&typeof window.showSaveFilePicker=="function")try{let i=await window.showSaveFilePicker({suggestedName:l}),D=await i.createWritable();return await D.write(t),await D.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 v=URL.createObjectURL(t),m=document.createElement("a");return m.href=v,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>URL.revokeObjectURL(v),1e3),{ok:!0,picked:!1,name:l}}function Mt(t,l){if(!l||!t)return t;let d=t.toLowerCase(),v=l.toLowerCase(),m=[],i=0;for(;i<t.length;){let D=d.indexOf(v,i);if(D<0){m.push(t.slice(i));break}D>i&&m.push(t.slice(i,D)),m.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(D,D+v.length)},D)),i=D+v.length}return m}function ra(t){if(!t)return"";let l=String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),d=[];return l=l.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(v,m,i){return d.push("<pre><code>"+i+"</code></pre>"),"\0"+(d.length-1)+"\0"}),l=l.replace(/^(#{1,3})\s+(.+)$/gm,function(v,m,i){return"<h"+m.length+">"+i+"</h"+m.length+">"}),l=l.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),l=l.replace(/`([^`\n]+)`/g,"<code>$1</code>"),l=l.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),l=l.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(v,m,i){return/^(https?:|\/)/.test(i)?'<a href="'+i+'" target="_blank" rel="noopener noreferrer">'+m+"</a>":m}),l=l.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),l=l.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),l=l.replace(/\n/g,"<br/>"),l=l.replace(/\u0000(\d+)\u0000/g,function(v,m){return d[m]}),l}function nt(t){if(!t)return"";let l=new Date(t);if(Number.isNaN(l.getTime()))return"";let d=new Date,v=l.toDateString()===d.toDateString(),m=D=>String(D).padStart(2,"0"),i=`${m(l.getHours())}:${m(l.getMinutes())}`;return v?i:`${l.getMonth()+1}-${l.getDate()} ${i}`}
228
253
 
229
254
  return module.exports;
230
255
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-eternal",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
5
5
  "license": "MIT",
6
6
  "repository": {
package/web/app.js CHANGED
@@ -221,12 +221,37 @@ Option A, because:
221
221
  .me-graph-ctxmenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
222
222
  .me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
223
223
  .me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
224
+ /* ---- \u5B98\u65B9\u684C\u9762\u7248\uFF1A\u8BA9\u5F00\u7A97\u53E3\u6807\u9898\u680F ----------------------------------------------
225
+ \u684C\u9762\u58F3\uFF08Electron\uFF09\u628A\u300C\u6700\u5C0F\u5316 / \u6700\u5927\u5316 / \u5173\u95ED\u300D\u753B\u5728\u9875\u9762\u9876\u90E8\uFF0C\u5E76\u6309 DSH \u7684\u7EA6\u5B9A\u5728
226
+ <html> \u4E0A\u6253 data-windows-titlebar\u3001\u7ED9\u51FA --dsh-windows-titlebar-height
227
+ \uFF08DSH \u81EA\u5DF1\u7684\u5168\u5C4F\u6D6E\u5C42\u4E5F\u662F\u8FD9\u4E48\u8BA9\u4F4D\u7684\uFF1B\u5DF2\u5728\u5B98\u65B9\u684C\u9762\u7248\u7684 app.asar \u91CC\u786E\u8BA4\u8FD9\u4E24\u4E2A\u6807\u8BB0\u5B58\u5728\uFF09\u3002
228
+ \u8BB0\u5FC6\u5E93\u6D6E\u5C42\u5FC5\u987B\u6574\u6761\u8BA9\u5F00\uFF1A\u4E00\u6765\u76D6\u4F4F\u7A97\u53E3\u63A7\u5236\u9762\u677F\u5F88\u96BE\u770B\uFF0C\u4E8C\u6765\u6211\u4EEC\u81EA\u5DF1\u53F3\u4E0A\u89D2\u7684\u300C\xD7\u300D
229
+ \u6070\u597D\u538B\u5728\u7A97\u53E3\u300C\u5173\u95ED\u300D\u4E0A \u2014\u2014 \u70B9\u4E0B\u53BB\u4F1A\u76F4\u63A5\u9000\u51FA\u6574\u4E2A\u684C\u9762\u58F3\uFF08\u5B9E\u6D4B\u8E29\u5751\uFF09\u3002
230
+ \u6D4F\u89C8\u5668\u91CC\u6CA1\u6709\u8BE5\u5C5E\u6027 \u2192 \u504F\u79FB 0px\uFF0C\u884C\u4E3A\u4E0E\u4E4B\u524D\u5B8C\u5168\u4E00\u81F4\u3002 */
231
+ [data-windows-titlebar] .me-overlay-top,
232
+ [data-windows-titlebar] .me-overlay {
233
+ top: var(--dsh-windows-titlebar-height, 0px);
234
+ }
235
+ .me-modal-full {
236
+ position: fixed;
237
+ inset: 0;
238
+ width: 100vw;
239
+ height: 100vh;
240
+ max-width: 100vw;
241
+ max-height: 100vh;
242
+ border-radius: 0;
243
+ }
244
+ [data-windows-titlebar] .me-modal-full {
245
+ top: var(--dsh-windows-titlebar-height, 0px);
246
+ height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
247
+ max-height: calc(100vh - var(--dsh-windows-titlebar-height, 0px));
248
+ }
224
249
  `;function dg(){return(0,i.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,i.jsx)("defs",{children:(0,i.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,i.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,i.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,i.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,i.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,i.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,i.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,i.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}function Tp({t:e,inModal:t,onClose:n,onFull:r,full:l}){let[o,a]=(0,x.useState)(null),[s,u]=(0,x.useState)([]),[p,v]=(0,x.useState)(!0),[y,g]=(0,x.useState)(null),[C,_]=(0,x.useState)(""),[S,B]=(0,x.useState)("all"),[d,c]=(0,x.useState)(""),[m,k]=(0,x.useState)("all"),[N,O]=(0,x.useState)("all"),[E,F]=(0,x.useState)(()=>{try{let P=new URLSearchParams(typeof location<"u"?location.search:"").get("tab"),K={cards:"cards",graph:"graph",usage:"stats",stats:"stats",audit:"audit",recycle:"optimize",optimize:"optimize",config:"config"};if(P&&K[P])return K[P]}catch{}return"cards"}),[I,A]=(0,x.useState)(()=>new Set([E])),L=(0,x.useCallback)(P=>{A(K=>K.has(P)?K:new Set(K).add(P)),F(P)},[]),[W,q]=(0,x.useState)("recent"),[le,Q]=(0,x.useState)(null),X=(0,x.useRef)(null),ae=(0,x.useRef)(null),[ie,$e]=(0,x.useState)(!1),[Ut,Tn]=(0,x.useState)(null),[ut,Ne]=(0,x.useState)(!1),[se,z]=(0,x.useState)(!0),[te,re]=(0,x.useState)(null),[ge,ct]=(0,x.useState)(0),Dt=(0,x.useCallback)(()=>ct(P=>P+1),[]),ht=(0,x.useRef)(null),[_n,Pn]=(0,x.useState)(0),[Ht,xe]=(0,x.useState)(!1),Gn=(0,x.useRef)(null),rt=(0,x.useRef)(null),w=(0,x.useCallback)(async(P=S,K=d,J=N,De={})=>{let Le=De.append===!0;try{Le?xe(!0):(v(!0),_(""));let Te=new URLSearchParams;P&&P!=="all"&&Te.set("kind",P),K.trim()&&Te.set("q",K.trim()),Te.set("status",J||"all"),Te.set("limit",String(sg)),Te.set("offset",String(De.offset||0)),W==="title"&&Te.set("sort","title");let on=await(await fetch(`${Z}/cards?${Te.toString()}`)).json();if(on.ok){let Vt=on.cards||[];u(Ze=>Le?[...Ze,...Vt.filter(qn=>!Ze.some(Zn=>Zn.path===qn.path))]:Vt),Pn(Number(on.total)||Vt.length)}}catch(Te){_(String(Te&&Te.message?Te.message:Te))}finally{Le?xe(!1):v(!1)}},[S,d,N,W]),h=(0,x.useCallback)(async()=>{try{let[P,K]=await Promise.all([fetch(`${Z}/overview`).then(J=>J.json()),fetch(`${Z}/capture-log`).then(J=>J.json()).catch(()=>null)]);P.ok&&a(P),g(K&&K.ok&&K.available&&K.health||null)}catch(P){_(String(P&&P.message?P.message:P))}finally{v(!1)}},[]),U=async P=>{try{let J=await(await fetch(`${Z}/delete?path=${encodeURIComponent(P)}`)).json();J.ok?(Q({ok:!0,msg:e("deleted")}),await h(),Dt()):Q({ok:!1,msg:J.error||e("deleteFail")})}catch{Q({ok:!1,msg:e("deleteFail")})}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Q(null),2e3)};(0,x.useEffect)(()=>(h(),()=>{ht.current&&clearTimeout(ht.current)}),[h]);let ce=P=>{c(P),ht.current&&clearTimeout(ht.current),ht.current=setTimeout(()=>w(S,P,N),280)},ze=P=>{B(P),w(P,d,N)};(0,x.useEffect)(()=>{E==="cards"&&w(S,d,N)},[N,E,ge,W]),(0,x.useEffect)(()=>{if(E!=="cards"||p||Ht||s.length>=_n)return;let P=Gn.current,K=rt.current;if(!P)return;let J=new IntersectionObserver(De=>{De[0]&&De[0].isIntersecting&&w(S,d,N,{append:!0,offset:s.length})},{root:K||null,rootMargin:"400px"});return J.observe(P),()=>J.disconnect()},[E,s,_n,p,Ht,S,d,N,w]);let qe=async P=>{try{let J=await(await fetch(`${Z}/card?path=${encodeURIComponent(P.path||P.id)}`)).json();J.ok&&Tn({path:J.path,title:P.title,text:J.text})}catch(K){_(String(K&&K.message?K.message:K))}},f=async(P,K)=>{$e(!0);try{let J=await fetch(`${Z}/export`);if(!J.ok)throw new Error("HTTP "+J.status);let De=await J.json();if(!De.ok)throw new Error(De.error||"export failed");let Le,Te,Oe;P==="json"?(Te="memory-vault.json",Oe="application/json",Le=JSON.stringify(De.cards.map(Ze=>({path:Ze.path,title:Ze.title,kind:Ze.kind,text:Ze.text})),null,2)):(Te="memory-vault.md",Oe="text/markdown;charset=utf-8",Le=De.cards.map(Ze=>Ze.text.trim()).filter(Boolean).join(`
225
250
 
226
251
  ---
227
252
 
228
253
  `));let on=new Blob([Le],{type:Oe}),Vt=await Cg(on,Te,!1);if(!Vt.ok){Q({ok:!1,msg:e("exportFail")}),$e(!1);return}Q({ok:!0,msg:e("exportedTo")+"\uFF1A"+e("defaultDownloads")+" \xB7 "+Vt.name})}catch(J){Q({ok:!1,msg:e("exportFail")+" \xB7 "+(J.message||"")})}finally{$e(!1)}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Q(null),2600)},Dr=async P=>{let K=P.target.files&&P.target.files[0];if(P.target.value="",!!K){try{let J=await K.text(),Le=await(await fetch(`${Z}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:J})).json();Le.ok?(await h(),Q({ok:!0,msg:e("importedVault")+"\uFF1A"+(Le.imported||0)+(Le.skipped?e("importedSkipped")+Le.skipped:"")})):Q({ok:!1,msg:Le.error||e("importFail")})}catch{Q({ok:!1,msg:e("importFail")})}X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Q(null),2400)}},Il=(0,x.useMemo)(()=>{let P=s.slice();return m!=="all"&&(P=P.filter(K=>Ir(K.submittedBy)===m)),N!=="all"&&(P=P.filter(K=>(K.status||"approved")===N)),W==="title"?P.sort((K,J)=>String(K.title||"").localeCompare(String(J.title||""))):W==="hot"?P.sort((K,J)=>(J.weight||J.links||0)-(K.weight||K.links||0)):P.sort((K,J)=>new Date(J.updated||0).getTime()-new Date(K.updated||0).getTime()),P},[s,W,m,N]),Rl=(0,x.useMemo)(()=>[...new Set(s.map(P=>Ir(P.submittedBy)))],[s]);return(0,i.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,i.jsx)("style",{children:ln}),le&&(0,i.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 "+(le.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,i.jsx)("span",{style:{color:le.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:le.ok?"\u2713":"\u2715"}),(0,i.jsx)("span",{children:le.msg})]}),t&&(0,i.jsxs)("div",{className:"me-modal-head",children:[(0,i.jsxs)("div",{className:"me-modal-title",children:[(0,i.jsx)("span",{className:"me-wicon",children:(0,i.jsx)(dg,{})}),(0,i.jsx)("h2",{children:e("memoryTitle")}),(0,i.jsx)("span",{children:e("memoryHint")})]}),(0,i.jsx)("div",{className:"spacer"}),r&&(0,i.jsx)("button",{type:"button",className:"me-modal-close",onClick:r,"aria-label":e(l?"exitFull":"fullscreen"),children:l?"\u2750":"\u26F6"}),(0,i.jsx)("button",{type:"button",className:"me-modal-close",onClick:n,"aria-label":e("close"),children:"\u2715"})]}),y&&y.ok===!1&&(0,i.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,i.jsxs)("span",{style:{fontWeight:800},children:["\u26A0 ",e("captureAlert")]}),(0,i.jsxs)("span",{style:{flex:1},children:[y.reason,(0,i.jsx)("div",{style:{opacity:.68,fontSize:11.5,marginTop:2},children:e("captureAlertHint")})]}),(0,i.jsx)("span",{style:{opacity:.7},children:y.since?Pl(new Date(y.since).toISOString()):""})]}),(0,i.jsxs)("div",{className:"me-modal-body",children:[(0,i.jsxs)("div",{className:`mc-rail${se?" open":""}`,children:[(0,i.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>z(P=>!P),"aria-label":e(se?"collapse":"expand"),title:e(se?"collapse":"expand"),children:se?"\xAB":"\xBB"}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="cards"?" active":""}`,onClick:()=>L("cards"),title:e("cardsTab"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9E0}"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("cardsTab")})]}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="graph"?" active":""}`,onClick:()=>L("graph"),title:e("graphTab"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u{1F52E}"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("graphTab")})]}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="stats"?" active":""}`,onClick:()=>L("stats"),title:e("tabUsage"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C8}"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("tabUsage")})]}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="audit"?" active":""}`,onClick:()=>L("audit"),title:e("tabAudit"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u{1F50D}"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("tabAudit")})]}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="optimize"?" active":""}`,onClick:()=>L("optimize"),title:e("tabRecycle"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u267B\uFE0F"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("tabRecycle")})]}),(0,i.jsxs)("button",{type:"button",className:`mc-railbtn${E==="config"?" active":""}`,onClick:()=>L("config"),title:e("tabConfig"),children:[(0,i.jsx)("span",{className:"mc-rail-ico",children:"\u2699\uFE0F"}),se&&(0,i.jsx)("span",{className:"mc-rail-label",children:e("tabConfig")})]})]}),(0,i.jsxs)("div",{className:"mc-main",ref:rt,children:[E==="cards"&&(0,i.jsxs)("div",{className:"mc-stats",children:[(0,i.jsx)(_r,{label:e("total"),value:o?o.total:"\u2014"}),(0,i.jsx)(_r,{label:e("recent"),value:o?o.recent:"\u2014"}),(0,i.jsx)(_r,{label:e("tags"),value:o?o.tags:"\u2014"}),(0,i.jsx)(_r,{label:e("pending"),value:o?.status?.pending??0}),(0,i.jsx)(_r,{label:e("rejected"),value:o?.status?.rejected??0}),(0,i.jsx)(_r,{label:e("cardCount"),value:o?o.byKind?.knowledge??0:"\u2014"})]}),E==="cards"&&(0,i.jsxs)("div",{className:"mc-toolbar",children:[(0,i.jsx)("input",{type:"text",placeholder:e("searchPlaceholder"),value:d,onChange:P=>ce(P.target.value)}),(0,i.jsx)("input",{ref:ae,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Dr}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>ae.current&&ae.current.click(),children:e("importVault")}),(0,i.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>re({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",e("newCard")]}),(0,i.jsx)("button",{type:"button",className:"mc-btn",disabled:ie,onClick:()=>f("md"),children:e(ie?"exporting":"exportVault")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",disabled:ie,onClick:()=>f("json"),children:e(ie?"exporting":"exportJson")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h(),children:e("refresh")})]}),E==="cards"&&(0,i.jsxs)("div",{className:"mc-chips",children:[_s.map(P=>(0,i.jsx)("button",{type:"button",className:`mc-chip${S===P?" active":""}`,onClick:()=>ze(P),children:e(P==="all"?"all":rn[P])},P)),(0,i.jsxs)("select",{value:m,onChange:P=>k(P.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,i.jsxs)("option",{value:"all",children:["\u{1F916} ",e("allAgents")]}),Lp(Rl).map(P=>(0,i.jsx)("option",{value:P,children:P},P))]}),(0,i.jsxs)("select",{value:N,onChange:P=>O(P.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,i.jsx)("option",{value:"all",children:e("allStatus")}),(0,i.jsx)("option",{value:"approved",children:e("statusApproved")}),(0,i.jsx)("option",{value:"pending",children:e("statusPending")}),(0,i.jsx)("option",{value:"rejected",children:e("statusRejected")})]}),(0,i.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:e("sortRecent")},{key:"title",label:e("sortTitle")},{key:"hot",label:e("sortHot")}].map(P=>(0,i.jsx)("button",{type:"button",className:`mc-chip${W===P.key?" active":""}`,onClick:()=>q(P.key),children:P.label},P.key))]}),C&&(0,i.jsxs)("div",{className:"mc-empty",children:[e("error"),"\uFF1A",C]}),(0,i.jsx)("div",{style:{display:E==="cards"?"contents":"none"},children:p?(0,i.jsx)("div",{className:"mc-empty",children:e("loading")}):C?(0,i.jsxs)("div",{className:"mc-empty",children:[e("error"),"\uFF1A",C," ",(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>h(),children:e("retry")})]}):s.length===0?(0,i.jsx)("div",{className:"mc-empty",children:e("empty")}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"mc-grid",children:Il.map(P=>(0,i.jsx)(gg,{card:P,t:e,query:d.trim(),onOpen:qe,onDelete:U},P.path))}),s.length<_n&&(0,i.jsx)("div",{ref:Gn,style:{height:1}}),Ht&&(0,i.jsxs)("div",{className:"mc-empty",style:{padding:"10px 0"},children:[e("loading"),"\uFF08",s.length," / ",_n,"\uFF09"]})]})}),(0,i.jsx)("div",{style:{display:E==="graph"?"flex":"none",flex:1,minHeight:0},children:I.has("graph")&&(0,i.jsx)(xg,{t:e,onOpen:qe,all:ut,onAllChange:Ne,onMutate:Dt,active:E==="graph",visible:E==="graph"})}),(0,i.jsx)("div",{style:{display:E==="config"?"contents":"none"},children:I.has("config")&&(0,i.jsx)(pg,{t:e,onReload:()=>h(),version:ge})}),(0,i.jsx)("div",{style:{display:E==="stats"?"contents":"none"},children:I.has("stats")&&(0,i.jsx)(yg,{t:e,tab:"stats",onReload:()=>h(),version:ge})}),(0,i.jsx)("div",{style:{display:E==="audit"?"contents":"none"},children:I.has("audit")&&(0,i.jsx)(fg,{t:e,onReload:()=>h(),version:ge})}),(0,i.jsx)("div",{style:{display:E==="optimize"?"contents":"none"},children:I.has("optimize")&&(0,i.jsx)(mg,{t:e,onReload:()=>h(),version:ge})}),Ut&&(0,i.jsx)(vg,{t:e,card:Ut,query:d.trim(),onClose:()=>Tn(null),onDelete:P=>{Tn(null),U(P)},onFeedback:P=>{let K=Ut.path;fetch(`${Z}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:d.trim(),path:K,useful:P})}).then(()=>Q({ok:!0,msg:e(P?"fbUseful":"fbIrr")})).catch(()=>{}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Q(null),2e3)}}),(0,i.jsx)(hg,{t:e,newCard:te,setNewCard:re,onCreated:()=>{h(),Dt(),Q({ok:!0,msg:e("created")}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>Q(null),2e3)}})]})]})]})}var _r=({label:e,value:t})=>(0,i.jsxs)("div",{className:"mc-stat mc-card",children:[(0,i.jsx)("b",{children:t}),(0,i.jsx)("span",{children:e})]});function pg({t:e,onReload:t,version:n,compact:r}){let[l,o]=(0,x.useState)(null),[a,s]=(0,x.useState)(0),[u,p]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),[g,C]=(0,x.useState)(!1),[_,S]=(0,x.useState)(null),[B,d]=(0,x.useState)(null),[c,m]=(0,x.useState)(""),[k,N]=(0,x.useState)(""),[O,E]=(0,x.useState)(""),[F,I]=(0,x.useState)(""),[A,L]=(0,x.useState)(null),W=(0,x.useRef)(null),q=(z,te=!0)=>{W.current&&clearTimeout(W.current),L({msg:z,ok:te}),W.current=setTimeout(()=>L(null),1900)},le=(z,te)=>Object.keys(te).reduce((re,ge)=>re.split("{"+ge+"}").join(te[ge]),e(z)),Q=(0,x.useCallback)(async()=>{try{let[z,te,re]=await Promise.all([fetch(`${Z}/config`).then(ge=>ge.json()).catch(()=>null),fetch(`${Z}/setup-status`).then(ge=>ge.json()).catch(()=>null),fetch(`${Z}/budget`).then(ge=>ge.json()).catch(()=>null)]);z&&z.ok?(o(z),s(z.revision??0),p(z.schema??null),y({...z.config??{}}),S(z.dsh??null),C(z.writable===!1),m("")):re&&re.ok?(y({...re}),C(!0),m(e("configNeedsDsh"))):m(e("adminLoadFail")),te&&te.ok&&d(te),E("")}catch{m(e("adminLoadFail"))}},[e]);(0,x.useEffect)(()=>{Q()},[n,Q]);let X=(z,te)=>y(re=>({...re??{},[z]:te})),ae=z=>({init:e("modeInit"),interval:e("modeInterval"),manual:e("modeManual")})[z]||z,ie=async()=>{if(v){if(g){q(e("editInSetting"),!1);return}N("save");try{let z=await fetch(`${Z}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({patch:v,expectedRevision:a})}),te=await z.json();if(te&&te.ok)E(e("savedOk")+(te.note?` \xB7 ${e("restartHint")}`:"")),q(e("savedOk")),await Q();else{let re=z.status===409?e("conflictRefresh"):te?.error||e("saveFail");m(re),q(re,!1)}}catch{m(e("saveFail")),q(e("saveFail"),!1)}finally{N("")}}},$e=()=>{y({...l?.config??{}}),E("")},Ut={A:{label:e("planA"),autoWebMode:"init",watchdogAutoSpawn:!1,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:900,recallMinScore:2,recallLimit:5,recallSummaryLen:130,recallIncludeBody:!1,captureCooldownMs:3e5},B:{label:e("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:e("planC"),autoWebMode:"interval",watchdogAutoSpawn:!0,distillEnabled:!0,dedupByLLM:!0,captureMaxTokens:1200,recallMinScore:1,recallLimit:8,recallSummaryLen:200,recallIncludeBody:!0,captureCooldownMs:12e4}},Tn=async z=>{let te=Ut[z];te&&y(re=>({...re??{},...te}))},ut=async(z,te)=>{N(z+te);try{let ge=await(await fetch(`${Z}/mcp/action`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:z,action:te})})).json();ge&&ge.ok?q(le(te==="install"?"mcpInstalled":"mcpUninstalled",{agent:z})):q(le("mcpActionFail",{agent:z,error:ge?.error||""}),!1);try{let ct=await fetch(`${Z}/setup-status`).then(Dt=>Dt.json());ct&&ct.ok&&d(ct)}catch{}}catch{q(e("mergeFail"),!1)}finally{N("")}},Ne=({k:z,label:te,type:re="text",step:ge,min:ct,max:Dt})=>(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,i.jsx)("span",{style:{opacity:.6},children:te||z}),(0,i.jsx)("input",{type:re,step:ge,min:ct,max:Dt,value:v?v[z]??"":"",onChange:ht=>X(z,re==="number"?Number(ht.target.value):ht.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}})]}),se=({k:z,label:te})=>(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12},children:[(0,i.jsx)("input",{type:"checkbox",checked:!!(v&&v[z]),onChange:re=>X(z,re.target.checked)}),(0,i.jsx)("span",{children:te||z})]});return(0,i.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:r?"0 0 auto":1,minHeight:0,maxHeight:r?"52vh":void 0},children:[(0,i.jsx)("style",{children:ln}),A&&(0,i.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 "+(A.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,i.jsx)("span",{style:{color:A.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:A.ok?"\u2713":"\u2715"}),(0,i.jsx)("span",{style:{wordBreak:"break-all"},children:A.msg})]}),(0,i.jsxs)("div",{style:{overflow:"auto",padding:4},children:[c&&(0,i.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,i.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",c]}),(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:Q,children:["\u21BB ",e("retry")]})]}),g&&(0,i.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 ",e("configNeedsDsh")," \u2014\u2014 ",e("editInSetting")]}),O&&(0,i.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 ",O]}),l&&(l.version||l.dsh?.vaultDir)&&(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px",display:"flex",gap:14,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F4E6} ",e("pluginInfo")]}),(0,i.jsx)("span",{style:{fontSize:12,opacity:.7},children:e("dshHostLabel")}),l.version&&(0,i.jsxs)("code",{style:{fontSize:11,padding:"2px 8px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:6},children:["v",l.version]}),l.dsh?.vaultDir&&(0,i.jsxs)("span",{style:{fontSize:11,opacity:.6},children:["\u{1F4C1} ",l.dsh.vaultDir]})]}),B&&B.agents&&(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F50C} ",e("mcpSetupStatus")]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("mcpManageHint")})]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:B.agents.map(z=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12},children:[(0,i.jsxs)("span",{style:{flex:1},children:[(0,i.jsx)("b",{children:z.isDsh?e("dshHostLabel"):z.name}),z.isDsh&&z.version&&(0,i.jsxs)("span",{style:{marginLeft:6,fontSize:11,opacity:.5},children:["v",z.version]}),!z.installed&&(0,i.jsxs)("span",{style:{marginLeft:6,opacity:.6},children:["(",e("notInstalled"),")"]}),z.installed&&z.mcpConfigured===!1&&(0,i.jsxs)("span",{style:{marginLeft:6,color:"#f59e0b"},children:["(",e("noMcpEntry"),")"]}),z.mcpConfigured===!0&&(0,i.jsxs)("span",{style:{marginLeft:6,color:"#10b981"},children:["\u2713 ",e("healthy")]}),z.mcpConfigured===!0&&z.mcpMatchesCurrentNode===!1&&(0,i.jsxs)("span",{style:{marginLeft:6,color:"#9ca3af",fontSize:10},children:["(",e("nodePathNote"),")"]}),z.isDsh&&(0,i.jsxs)("span",{style:{marginLeft:6,opacity:.6,fontSize:11},children:["(",e("recallTool"),": ",z.recallTool?e("enabled"):e("disabled"),")"]})]}),z.hook&&(0,i.jsxs)("span",{style:{fontSize:11,opacity:.7},children:["hook: ",z.hook]}),!z.isDsh&&z.installed&&z.mcpConfigured===!1&&(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!k,onClick:()=>ut(z.name,"install"),children:e("installMcp")}),!z.isDsh&&z.installed&&z.mcpConfigured===!0&&(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!k,onClick:()=>{window.confirm(e("uninstallConfirm"))&&ut(z.name,"uninstall")},children:e("uninstallMcp")})]},z.name))}),(0,i.jsx)("div",{style:{fontSize:11,opacity:.55,marginTop:6},children:e("mcpSetupHint")}),F&&(0,i.jsx)("div",{style:{fontSize:11,marginTop:6},children:(0,i.jsx)("code",{style:{padding:"2px 6px",background:"var(--dsw-alias-bg-layer-2, #f3f4f6)",borderRadius:4},children:F})})]}),v?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #3b82f6"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8,flexWrap:"wrap"},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F3AF} ",e("presetConfig")]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("presetHint")})]}),(0,i.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["A","B","C"].map(z=>(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Tn(z),disabled:!!k,children:[z==="A"?"\u{1F7E2} ":z==="B"?"\u{1F4B0} ":"\u2B50 ",Ut[z].label]},z))})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F9E0} ",e("dshMemoryConfig")]})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,i.jsx)(se,{k:"autoCapture",label:e("autoCapture")}),(0,i.jsx)(se,{k:"autoRecall",label:e("autoRecall")}),(0,i.jsx)(Ne,{k:"captureMinChars",label:e("captureMinChars"),type:"number"}),(0,i.jsx)(Ne,{k:"maxCardsPerDay",label:e("maxCardsPerDay"),type:"number"}),(0,i.jsx)(Ne,{k:"dedupThreshold",label:e("dedupThreshold"),type:"number",step:"0.01",min:"0",max:"1"}),(0,i.jsx)(Ne,{k:"recallLimit",label:e("recallLimit"),type:"number"}),(0,i.jsx)(Ne,{k:"recallSummaryLen",label:e("recallSummaryLen"),type:"number"}),(0,i.jsx)(se,{k:"recallIncludeBody",label:e("recallBody")})]})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #f59e0b"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:4},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F4B0} ",e("costControl")]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("costHint")})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8,marginTop:6},children:[(0,i.jsx)(se,{k:"distillEnabled",label:e("distillEnabled")}),(0,i.jsx)(se,{k:"dedupByLLM",label:e("dedupByLLM")}),(0,i.jsx)(Ne,{k:"captureMaxTokens",label:e("captureMaxTokens"),type:"number"}),(0,i.jsx)(Ne,{k:"recallMinScore",label:e("recallMinScore"),type:"number"})]})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px",borderLeft:"3px solid #8b5cf6"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",e("auditConfig")]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("auditHint")})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:8},children:[(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,i.jsx)("span",{style:{opacity:.6},children:e("auditMode")}),(0,i.jsxs)("select",{value:v.auditMode??"all",onChange:z=>X("auditMode",z.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,i.jsx)("option",{value:"all",children:e("auditAll")}),(0,i.jsx)("option",{value:"none",children:e("auditNone")})]})]}),(0,i.jsx)(Ep,{label:e("auditExemptAgents"),value:v.auditExemptAgents||[],options:[{value:"__all__",label:e("allExempt")},...(B?.agents||[]).filter(z=>!z.isDsh).map(z=>({value:z.name,label:z.name}))],onChange:z=>X("auditExemptAgents",z)}),(0,i.jsx)(Ep,{label:e("auditExemptKinds"),value:v.auditExemptKinds||[],options:[{value:"__all__",label:e("allExempt")},..._s.filter(z=>z!=="all").map(z=>({value:z,label:e(rn[z])}))],onChange:z=>X("auditExemptKinds",z)}),(0,i.jsx)(Ne,{k:"recycleRetentionDays",label:e("recycleDays"),type:"number"})]})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"12px 14px"},children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E0} ",e("serviceConfig")]})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(150px, 1fr))",gap:8},children:[(0,i.jsx)(se,{k:"autoWeb",label:e("autoWeb")}),(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,i.jsx)("span",{style:{opacity:.6},children:e("autoWebMode")}),(0,i.jsxs)("select",{value:v.autoWebMode??"init",onChange:z=>X("autoWebMode",z.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,i.jsx)("option",{value:"init",children:e("modeInit")}),(0,i.jsx)("option",{value:"interval",children:e("modeInterval")}),(0,i.jsx)("option",{value:"manual",children:e("modeManual")})]})]}),(0,i.jsx)(Ne,{k:"webPort",label:e("webPort"),type:"number"}),(0,i.jsx)(Ne,{k:"webCheckIntervalMs",label:e("webCheckIntervalMs"),type:"number"}),(0,i.jsx)(Ne,{k:"webMaxRestart",label:e("webMaxRestart"),type:"number"}),(0,i.jsx)(se,{k:"watchdogAutoSpawn",label:e("watchdogAutoSpawn")}),(0,i.jsx)(se,{k:"autoMcpSetup",label:e("autoMcpSetup")})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginBottom:10},children:[(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:$e,disabled:!!k,children:e("reset")}),(0,i.jsx)("button",{type:"button",className:"mc-btn me-on",onClick:ie,disabled:!!k||k==="save"||g,children:k==="save"?e("exporting"):"\u{1F4BE} "+e("saveConfig")})]})]}):(0,i.jsx)("div",{style:{fontSize:12,opacity:.6},children:e("loading")})]})]})}function fg({t:e,onReload:t,version:n}){let[r,l]=(0,x.useState)([]),[o,a]=(0,x.useState)([]),[s,u]=(0,x.useState)("all"),[p,v]=(0,x.useState)("all"),[y,g]=(0,x.useState)(""),[C,_]=(0,x.useState)(new Set),[S,B]=(0,x.useState)(""),[d,c]=(0,x.useState)("pending"),m=[...new Set([...r,...o].map(I=>I.submittedBy).filter(Boolean))],k=(0,x.useCallback)(async()=>{try{let I=await fetch(`${Z}/audit/list`).then(A=>A.json());I.ok&&(l(I.pending||[]),a(I.rejected||[]),_(new Set))}catch{}},[]);(0,x.useEffect)(()=>{k()},[n,k]);let N=(d==="pending"?r:o).filter(I=>{if(s!=="all"&&I.kind!==s||p!=="all"&&Ir(I.submittedBy)!==p)return!1;if(y){let A=(I.created||"").slice(0,10);if(A&&A!==y)return!1}return!0}),O=I=>_(A=>{let L=new Set(A);return L.has(I)?L.delete(I):L.add(I),L}),E=async(I,A)=>{B("apply");try{for(let L of A||[...C])await fetch(`${Z}/${I==="approved"?"audit/approve":I==="rejected"?"audit/reject":"delete"}?path=${encodeURIComponent(L)}${I==="delete"?"&permanent=0":""}`);await k(),t&&t()}catch{}finally{B("")}},F=[...C];return(0,i.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F6E1}\uFE0F ",e("tabAudit")]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsxs)("select",{value:s,onChange:I=>u(I.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,i.jsx)("option",{value:"all",children:e("all")}),_s.filter(I=>I!=="all").map(I=>(0,i.jsx)("option",{value:I,children:e(rn[I])},I))]}),(0,i.jsxs)("select",{value:p,onChange:I=>v(I.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,i.jsx)("option",{value:"all",children:e("allAgents")}),Lp(m).map(I=>(0,i.jsx)("option",{value:I,children:I},I))]}),(0,i.jsx)("input",{type:"date",value:y,onChange:I=>g(I.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,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("button",{type:"button",className:`mc-btn${d==="pending"?" me-on":""}`,onClick:()=>c("pending"),children:[e("pending"),"\uFF08",r.length,"\uFF09"]}),(0,i.jsxs)("button",{type:"button",className:`mc-btn${d==="rejected"?" me-on":""}`,onClick:()=>c("rejected"),children:[e("rejected"),"\uFF08",o.length,"\uFF09"]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsxs)("label",{style:{fontSize:12},children:[(0,i.jsx)("input",{type:"checkbox",checked:N.length>0&&F.length===N.length,onChange:I=>{I.target.checked?_(new Set(N.map(A=>A.path))):_(new Set)}})," ",e("selectAll")]}),(0,i.jsxs)("button",{type:"button",className:"mc-btn me-on",disabled:!F.length||!!S,onClick:()=>E("approved"),children:["\u2713 ",e(d==="rejected"?"restore":"approve")]}),d==="pending"?(0,i.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!F.length||!!S,onClick:()=>E("rejected"),children:["\u2715 ",e("reject")]}):(0,i.jsxs)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!F.length||!!S,onClick:()=>{window.confirm(e("recycleDeleteConfirm"))&&E("delete")},children:["\u{1F5D1} ",e("restoreDelete")]})]}),N.length?(0,i.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:N.map(I=>(0,i.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,i.jsx)("input",{type:"checkbox",checked:C.has(I.path),onChange:()=>O(I.path)}),(0,i.jsx)("span",{className:"mc-kind",style:{background:Ln[I.kind]||"#999"}}),(0,i.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.title}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.6},children:Ir(I.submittedBy)}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.6},children:I.created?I.created.slice(0,16).replace("T"," "):"-"}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.6},children:I.kind}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.6,color:I.severity==="high"?"#f87171":"#9ca3af"},children:I.severity}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.6,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.reason||"-"}),d==="pending"?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>E("approved",[I.path]),children:"\u2713"}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},onClick:()=>E("rejected",[I.path]),children:"\u2715"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},title:e("restore"),onClick:()=>E("approved",[I.path]),children:"\u2713"}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},title:e("restoreDelete"),onClick:()=>{window.confirm(e("recycleDeleteConfirm"))&&E("delete",[I.path])},children:"\u{1F5D1}"})]})]},I.path))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:e("noAuditItems")})]})]})}function mg({t:e,onReload:t,version:n}){let[r,l]=(0,x.useState)([]),[o,a]=(0,x.useState)(""),s=(0,x.useCallback)(async()=>{try{let p=await fetch(`${Z}/recycle/list`).then(v=>v.json());p.ok&&l(p.items||[])}catch{}},[]);(0,x.useEffect)(()=>{s()},[n,s]);let u=async(p,v)=>{a(p+v);try{p==="restore"?await fetch(`${Z}/recycle/restore?path=${encodeURIComponent(v)}`):p==="purge"&&await fetch(`${Z}/recycle/purge?path=${encodeURIComponent(v)}`),await s(),t&&t()}catch{}finally{a("")}};return(0,i.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{style:{overflow:"auto",padding:4},children:[(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1F5D1}\uFE0F ",e("tabRecycle")]}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("recycleHint")}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("button",{type:"button",className:"mc-btn",disabled:!!o,onClick:async()=>{a("purgeAll");try{await fetch(`${Z}/recycle/purge-expired?days=0`),await s()}catch{}finally{a("")}},children:e("emptyRecycle")})]}),r.length?(0,i.jsx)("div",{className:"mc-card",style:{display:"flex",flexDirection:"column"},children:r.map(p=>(0,i.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,i.jsx)("span",{className:"mc-kind",style:{background:Ln[p.kind]||"#999"}}),(0,i.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.title}),(0,i.jsxs)("span",{style:{fontSize:10,opacity:.6},children:[e("deletedAt")," ",(p.deletedAt||"").slice(0,10)]}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},disabled:!!o,onClick:()=>u("restore",p.path),children:e("restore")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px",color:"#f87171"},disabled:!!o,onClick:()=>{window.confirm(e("purgeConfirm"))&&u("purge",p.path)},children:e("purge")})]},p.path))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,padding:20,textAlign:"center"},children:e("emptyRecycle")})]})]})}var gg=({card:e,t,onOpen:n,query:r,onDelete:l})=>(0,i.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>n(e),children:[(0,i.jsxs)("h4",{children:[(0,i.jsx)("span",{className:"mc-kind",style:{background:Ln[e.kind]||Ln.other}}),(0,i.jsx)("span",{style:{marginRight:4},children:Np[e.kind]||"\u{1F4CE}"}),r?zp(e.title,r):e.title,Sg(e.updated)&&(0,i.jsx)("span",{className:"mc-new",children:t("newBadge")}),e.status==="pending"&&(0,i.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",t("statusPending")]}),e.status==="rejected"&&(0,i.jsxs)("span",{className:"mc-status",style:{background:"#ef4444"},children:["\u274C ",t("statusRejected")]}),(!e.status||e.status==="approved")&&(0,i.jsxs)("span",{className:"mc-status",style:{background:"#10b981"},children:["\u2705 ",t("statusApproved")]})]}),(0,i.jsx)("p",{children:r?zp(e.summary||"",r):e.summary||""}),e.tags.length>0&&(0,i.jsx)("div",{className:"mc-tags",children:e.tags.slice(0,4).map(o=>(0,i.jsxs)("span",{className:"mc-tag",children:["\u{1F3F7} ",o]},o))}),(0,i.jsxs)("footer",{children:[(0,i.jsxs)("span",{children:[Np[e.kind]||"\u{1F4CE}"," ",t(rn[e.kind])]}),(0,i.jsxs)("span",{style:{fontSize:10,opacity:.6},children:["\u{1F916} ",Ir(e.submittedBy)]}),(0,i.jsxs)("span",{children:["\u{1F4C5} ",Pl(e.updated)]}),(0,i.jsx)("span",{className:"spacer",style:{flex:1}}),(0,i.jsx)("button",{type:"button",className:"mc-card-del",title:t("delete"),onClick:o=>{o.stopPropagation(),window.confirm(t("deleteConfirm"))&&l&&l(e.path)},children:"\u{1F5D1}"})]})]});function yg({t:e,tab:t,onReload:n,version:r}){let[l,o]=(0,x.useState)(null),[a,s]=(0,x.useState)(""),[u,p]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),[g,C]=(0,x.useState)(null),[_,S]=(0,x.useState)([]),[B,d]=(0,x.useState)(""),[c,m]=(0,x.useState)(!1),k=(0,x.useCallback)(async()=>{if(!(!u||!u.merge||!u.merge.length)&&window.confirm(e("mergeAllConfirm"))){d("merge");try{let L={},W=ae=>L[ae]===void 0?ae:L[ae]=W(L[ae]),q=(ae,ie)=>{L[W(ae)]=W(ie)},le=new Set;for(let ae of u.merge)le.add(ae.a.path),le.add(ae.b.path),q(ae.a.path,ae.b.path);let Q={};for(let ae of le){let ie=W(ae);(Q[ie]=Q[ie]||[]).push(ae)}let X=0;for(let ae of Object.values(Q)){if(ae.length<2)continue;(await fetch(`${Z}/merge?paths=${encodeURIComponent(ae.join(","))}`).then($e=>$e.json())).ok&&X++}await N(),n&&n()}catch{}d("")}},[u,N,n,e]);async function N(){try{let L=await Promise.all([fetch(`${Z}/stats`),fetch(`${Z}/budget`),fetch(`${Z}/capture-log`),fetch(`${Z}/cards?status=all&limit=30&agent=${_l}`)]),[W,q,le,Q]=await Promise.all(L.map(X=>X.json()));W&&W.ok&&o(W),q&&q.ok&&y(q),le&&le.ok&&C(le),Q&&Q.ok&&S(Q.cards||[]),s(!W||!W.ok?e("adminLoadFail"):"")}catch{s(e("adminLoadFail"))}}let O=(0,x.useCallback)(async()=>{d("scan");try{let L=await fetch(`${Z}/optimize`).then(W=>W.json());L.ok&&p(L)}catch{s(e("adminLoadFail"))}finally{d("")}},[e]);(0,x.useEffect)(()=>{N()},[r]);let E=async(L,W)=>{if(window.confirm(e("mergeConfirm")))try{(await fetch(`${Z}/merge?paths=${encodeURIComponent(L+","+W)}`).then(le=>le.json())).ok&&(await N(),n&&n())}catch{}},F=async L=>{if(window.confirm(e("deleteConfirm")))try{(await fetch(`${Z}/delete?path=${encodeURIComponent(L)}`).then(q=>q.json())).ok&&(await N(),n&&n())}catch{}},I=["project","knowledge","content","prompt","business","tool","mistake"],A=({title:L,kind:W,updated:q,path:le})=>(0,i.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,i.jsx)("span",{className:"mc-kind",style:{background:Pr.colors[W]||"#666"}}),(0,i.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L}),(0,i.jsx)("span",{style:{opacity:.55,fontSize:11},children:Pl(q)}),(0,i.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>F(le),children:[e("delete")," \u2715"]})]});return(0,i.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{style:{overflow:"auto"},children:[a&&(0,i.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,i.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",a]}),(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:N,children:["\u21BB ",e("retry")]})]}),t==="stats"&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("b",{style:{fontSize:12},children:["\u{1FAB5} ",e("captureLog")]}),(0,i.jsx)("span",{style:{fontSize:11,opacity:.6},children:e("captureLogHint")}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>N(),children:["\u21BB ",e("refresh")]})]}),g?g.available===!1?(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:e("captureLogUnavailable")}):(g.entries||[]).length===0?(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:e("captureLogEmpty")}):(0,i.jsx)("div",{style:{maxHeight:260,overflow:"auto",marginTop:8},children:(0,i.jsx)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:(0,i.jsx)("tbody",{children:(g.entries||[]).map((L,W)=>{let q=cg[L.action]||["\u2022","inherit"];return(0,i.jsxs)("tr",{style:{borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,i.jsx)("td",{style:{padding:"4px 6px",opacity:.55,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:Pl(L.time?new Date(L.time).toISOString():"")}),(0,i.jsxs)("td",{style:{padding:"4px 6px",whiteSpace:"nowrap",color:q[1],fontWeight:600},children:[q[0]," ",L.action]}),(0,i.jsx)("td",{style:{padding:"4px 6px"},children:L.reason||""}),(0,i.jsx)("td",{style:{padding:"4px 6px",opacity:.55,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:L.preview||"",children:L.preview||""})]},W)})})})}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,padding:"8px 0"},children:e("loading")})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,i.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:["\u{1F916} ",e("captureAgentCards"),"\uFF08",_.length,"\uFF09"]}),_.length?(0,i.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:_.map(L=>(0,i.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,i.jsx)("span",{className:"mc-kind",style:{background:Ln[L.kind]||Ln.other}}),(0,i.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.title}),L.status==="pending"&&(0,i.jsxs)("span",{className:"mc-status",style:{background:"#f59e0b"},children:["\u23F3 ",e("statusPending")]}),(0,i.jsx)("span",{style:{opacity:.55,fontSize:11},children:Pl(L.updated)})]},L.path))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12},children:e("noCards")})]}),l&&(0,i.jsxs)(i.Fragment,{children:[l.trend&&l.trend.length>0&&(()=>{let L=l.trend,W=Math.max(...L.map(X=>X.count),1),q=260,le=50,Q=q/L.length;return(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,i.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",e("trendLabel")]}),(0,i.jsx)("svg",{width:q,height:le,style:{display:"block",width:"100%",height:50},children:L.map((X,ae)=>{let ie=Math.round(X.count/W*(le-4));return(0,i.jsx)("rect",{x:ae*Q+1,y:le-ie,width:Math.max(Q-2,2),height:ie,rx:1.5,fill:X.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:X.count>0?.85:.35},X.date)})})]})})(),(0,i.jsxs)("div",{className:"mc-stats",children:[(0,i.jsxs)("div",{className:"mc-stat mc-card",children:[(0,i.jsx)("b",{children:l.total}),(0,i.jsx)("span",{children:e("total")})]}),(0,i.jsxs)("div",{className:"mc-stat mc-card",children:[(0,i.jsx)("b",{children:l.today}),(0,i.jsx)("span",{children:e("todayAdd")})]}),(0,i.jsxs)("div",{className:"mc-stat mc-card",children:[(0,i.jsx)("b",{children:l.week}),(0,i.jsx)("span",{children:e("weekAdd")})]}),(0,i.jsxs)("div",{className:"mc-stat mc-card",children:[(0,i.jsx)("b",{children:l.tags}),(0,i.jsx)("span",{children:e("tags")})]})]}),(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:e("byKind")}),(0,i.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:I.map(L=>(0,i.jsxs)("span",{style:{fontSize:12},children:[(0,i.jsx)("span",{className:"mc-kind",style:{background:Pr.colors[L]||"#666"}}),e(rn[L]),": ",l.byKind?.[L]||0]},L))})]}),v&&(v.budgetChars||v.recallLimit||v.embedding)&&(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,i.jsx)("b",{children:e("budgetLabel")}),"\uFF1A",e("budgetChars")," ",(0,i.jsx)("b",{children:v.budgetChars||8e4})," \xB7 ",e("recallLimitLabel")," ",(0,i.jsx)("b",{children:v.recallLimit||5})," \xB7 ",e("embeddingLabel")," ",v.embedding?"ON":"OFF"]}),(0,i.jsxs)("div",{className:"mc-card",children:[(0,i.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[e("todayList"),"\uFF08",l.todayCards?.length||0,"\uFF09"]}),l.todayCards?.length?(0,i.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:l.todayCards.map(L=>(0,i.jsx)(A,{title:L.title,kind:L.kind,updated:L.updated,path:L.path},L.path))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12},children:e("noOptimize")})]})]})]}),t==="optimize"&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsx)("b",{style:{fontSize:12},children:e("organizeTitle")}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("button",{type:"button",className:"mc-btn",disabled:!!B,onClick:O,children:B==="scan"?e("exporting"):"\u{1F50D} "+e("scanAndOrganize")}),u&&u.merge?.length>0&&(0,i.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!B,onClick:async()=>{if(window.confirm(e("oneClickOptimizeConfirm"))){d("oneclick");try{let L=JSON.stringify({cleanupStale:c}),q=await(await fetch(`${Z}/optimize-execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:L})).json();q&&q.ok?(notify(`${e("oneClickOptimizeDone")}\uFF1A${q.plan.merged} ${e("optimizedMerged")}${c?` \xB7 ${q.plan.staleDeleted} ${e("optimizedStaleDeleted")}`:""}`),await N(),n&&n(),p(null)):notify(e("mergeFail"),!1)}catch{notify(e("mergeFail"),!1)}finally{d("")}}},children:B==="oneclick"?e("exporting"):"\u26A1 "+e("oneClickOptimize")}),u&&u.merge?.length>0&&(0,i.jsxs)("label",{style:{fontSize:11,opacity:.7,display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)("input",{type:"checkbox",checked:c,onChange:L=>m(L.target.checked)}),e("oneClickAlsoStale")]})]}),!u&&(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:10},children:e("scanHint")}),u&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",flexDirection:"column",gap:8},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[(0,i.jsx)("b",{style:{fontSize:12},children:e("mergePairs")}),(0,i.jsx)("div",{className:"spacer",style:{flex:1}}),u.merge?.length>0&&(0,i.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!B,onClick:k,children:e(B==="merge"?"exporting":"batchMerge")})]}),(0,i.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:e("mergePairs")}),u.merge?.length?(0,i.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:u.merge.map((L,W)=>(0,i.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,i.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[L.a.title," \u21C4 ",L.b.title]}),(0,i.jsxs)("span",{style:{opacity:.6},children:[Math.round(L.sim*100),"%"]}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>E(L.a.path,L.b.path),children:e("mergeNow")})]},W))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:e("noOptimize")}),(0,i.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[e("staleCards"),"\uFF08",u.stale?.length||0,"\uFF09"]}),u.stale?.length>0&&(0,i.jsx)("div",{style:{marginBottom:6},children:(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!B,onClick:async()=>{if(!window.confirm(e("deleteConfirm")))return;d("clean");let L=0;for(let W of u.stale)try{await fetch(`${Z}/delete?path=${encodeURIComponent(W.path)}`),L++}catch{}d(""),notify(`${L} ${e("deletedStale")}`),await N(),n&&n()},children:e("cleanStale")})}),u.stale?.length?(0,i.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:u.stale.map(L=>(0,i.jsx)(A,{title:L.title,kind:"other",updated:L.updated,path:L.path},L.path))}):(0,i.jsx)("div",{style:{opacity:.6,fontSize:12},children:e("noOptimize")})]})})]})]})]})}var Ls=[{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 hg({t:e,newCard:t,setNewCard:n,onCreated:r}){if(!t)return null;let l=Ls.find(y=>y.key===t.template),o=t.body||(l?e(l.bodyKey):""),a=t.kind||(l?l.kind:"knowledge"),s=t.tags||(l?e(l.tagKey):""),u=t._creating,p=y=>{let g=Ls.find(C=>C.key===y);n(C=>({...C,template:y,kind:g?g.kind:C.kind,body:g?e(g.bodyKey):C.body,tags:g?e(g.tagKey):C.tags}))},v=async()=>{if(!(!t.title&&!o)){n(y=>({...y,_creating:!0}));try{(await fetch(`${Z}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title||e("untitled"),kind:a,tags:s.split(",").map(g=>g.trim()).filter(Boolean),body:o,source:"manual"})}).then(g=>g.json())).ok?(n(null),r&&r()):n(g=>({...g,_creating:!1}))}catch{n(g=>({...g,_creating:!1}))}}};return(0,i.jsxs)("div",{className:"me-overlay",onClick:()=>n(null),children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:y=>y.stopPropagation(),children:[(0,i.jsxs)("div",{className:"me-dialog-head",children:[(0,i.jsx)("h3",{children:e("newCard")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>n(null),children:e("close")})]}),(0,i.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[Ls.map(y=>(0,i.jsx)("button",{type:"button",className:`mc-btn${t.template===y.key?" me-on":""}`,onClick:()=>p(y.key),children:e(y.label)},y.key)),(0,i.jsx)("button",{type:"button",className:`mc-btn${t.template===""?" me-on":""}`,onClick:()=>n(y=>({...y,template:"",body:"",tags:"",kind:"knowledge"})),children:e("tplBlank")})]}),(0,i.jsx)("select",{className:"mc-btn",value:a,onChange:y=>n(g=>({...g,kind:y.target.value})),style:{maxWidth:180,background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:["project","knowledge","content","prompt","business","tool","mistake"].map(y=>(0,i.jsx)("option",{value:y,style:{background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)"},children:y},y))}),(0,i.jsx)("input",{type:"text",className:"mc-btn",placeholder:e("cardTitle"),value:t.title||"",onChange:y=>n(g=>({...g,title:y.target.value}))}),(0,i.jsx)("input",{type:"text",className:"mc-btn",placeholder:e("tagsHint"),value:s,onChange:y=>n(g=>({...g,tags:y.target.value}))}),(0,i.jsx)("textarea",{className:"mc-btn",placeholder:e("cardBody"),value:o,onChange:y=>n(g=>({...g,body:y.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,i.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:u,onClick:v,children:e(u?"exporting":"createCard")})})]})]})]})}function vg({t:e,card:t,query:n,onClose:r,onDelete:l,onFeedback:o}){(0,x.useEffect)(()=>{let p=v=>{v.key==="Escape"&&r()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r]);let[a,s]=(0,x.useState)(!1),u=(t.text||"").length>460;return(0,i.jsxs)("div",{className:"me-overlay",onClick:r,children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{className:"me-dialog",onClick:p=>p.stopPropagation(),children:[(0,i.jsxs)("div",{className:"me-dialog-head",children:[(0,i.jsx)("h3",{children:t.title}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[n&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>o&&o(!0),children:["\u{1F44D} ",e("fbUseful")]}),(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>o&&o(!1),children:["\u{1F44E} ",e("fbIrr")]})]}),u&&(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>s(p=>!p),children:e(a?"collapse":"expand")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(e("deleteConfirm"))&&l&&l(t.path)},children:e("delete")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:r,children:e("close")})]})]}),(0,i.jsx)("div",{className:"me-dialog-body",style:a?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Ng(t.text)}})]})]})}function xg({t:e,onOpen:t,all:n,onAllChange:r,onMutate:l,active:o,visible:a}){let[s,u]=(0,x.useState)(null),[p,v]=(0,x.useState)(""),y=(0,x.useRef)(!1),g=(0,x.useRef)(0),C=(0,x.useRef)(e);C.current=e;let _=(0,x.useCallback)(async()=>{try{y.current=!1;let c=await(await fetch(`${Z}/graph${n?"?all=1":""}`)).json();c.ok?(u(c),v(""),y.current=!0):(u(null),v(c.error||e("error")))}catch(d){v(String(d&&d.message?d.message:d))}},[n,e]);(0,x.useEffect)(()=>{if(!o||y.current)return;let d=!0;return fetch(`${Z}/graph${n?"?all=1":""}`).then(c=>c.json()).then(c=>{d&&(c.ok?(u(c),v(""),y.current=!0):(u(null),v(c.error||e("error"))))}).catch(c=>{d&&v(String(c&&c.message?c.message:c))}),()=>{d=!1}},[n,e,o]),(0,x.useEffect)(()=>{a&&s&&g.current++},[a,s]);let S=(0,x.useCallback)(async d=>{try{let m=await(await fetch(`${Z}/delete?path=${encodeURIComponent(d)}`)).json();return m&&m.ok?(await _(),l&&l(),!0):!1}catch{return!1}},[_]),B=(0,x.useCallback)(async d=>{if(!d||d.length<2)return!1;try{let c=await fetch(`${Z}/merge?paths=${encodeURIComponent(d.join(","))}`).then(m=>m.json());return c&&c.ok?(await _(),l&&l(),!0):!1}catch{return!1}},[_,l]);return(0,i.jsxs)("div",{className:"me-graph",children:[(0,i.jsx)("style",{children:ln}),p&&(0,i.jsxs)("div",{className:"mc-empty",children:[e("error"),"\uFF1A",p]}),!s&&!p&&(0,i.jsx)("div",{className:"mc-empty",children:e("loading")}),s&&s.nodes.length===0&&(0,i.jsx)("div",{className:"mc-empty",children:e("emptyGraph")}),s&&s.nodes.length>0&&(0,i.jsx)(kg,{nodes:s.nodes,edges:s.edges,onOpen:t,onDelete:S,onMerge:B,t:e,all:n,onAllChange:r,countLabel:`${s.nodes.length} ${e("nodes")} \xB7 ${wg(s.edges)} ${e("edges")}`,fitTrigger:g.current})]})}function wg(e){let t=new Set;for(let n of e||[])t.add([n.source,n.target].sort().join("|"));return t.size}var Pr={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 kg({nodes:e,edges:t,onOpen:n,onDelete:r,onMerge:l,t:o,countLabel:a,all:s,onAllChange:u,fitTrigger:p}){let v=(0,x.useRef)(null),y=(0,x.useRef)(null),g=(0,x.useRef)(null),C=(0,x.useRef)(null),_=(0,x.useRef)(null),S=(0,x.useRef)(n);(0,x.useEffect)(()=>{S.current=n},[n]);let B=(0,x.useRef)(r);(0,x.useEffect)(()=>{B.current=r},[r]);let d=(0,x.useRef)(l);(0,x.useEffect)(()=>{d.current=l},[l]);let[c,m]=(0,x.useState)(""),[k,N]=(0,x.useState)(null),O=(0,x.useRef)("");(0,x.useEffect)(()=>{O.current=c.trim().toLowerCase()},[c]),(0,x.useEffect)(()=>{let w=g.current;if(!w)return;let h=c.trim().toLowerCase();if(!h)return;let U=w.nodes.find(ce=>(ce.name||"").toLowerCase().includes(h));U&&(g.current.selectedId=U.id,N(U.id),w.panX=w.w/2-U.x*w.zoom,w.panY=w.h/2-U.y*w.zoom,w.render&&w.render())},[c]);let[E,F]=(0,x.useState)("all"),[I,A]=(0,x.useState)(!1),L=(0,x.useRef)("all"),[W,q]=(0,x.useState)(""),le=(0,x.useRef)(""),[Q,X]=(0,x.useState)(!1),ae=(0,x.useRef)(!1),[ie,$e]=(0,x.useState)(null);(0,x.useEffect)(()=>{L.current=E},[E]),(0,x.useEffect)(()=>{le.current=W},[W]),(0,x.useEffect)(()=>{ae.current=Q},[Q]);let Ut=(0,x.useMemo)(()=>{let w=new Map;for(let h of e)for(let U of h.tags||[]){let ce=String(U).trim();ce&&w.set(ce,(w.get(ce)||0)+1)}return[...w.entries()].sort((h,U)=>U[1]-h[1]).slice(0,24).map(([h,U])=>({tag:h,n:U}))},[e]),Tn=(()=>{let w=c.trim().toLowerCase();return!!w&&!e.some(h=>(h.title||h.name||"").toLowerCase().includes(w)||String(h.kind||"").toLowerCase().includes(w)||String(rn[h.kind]||"").toLowerCase().includes(w))})();(0,x.useEffect)(()=>{let w=g.current;w&&w.wake&&w.wake()},[c]),(0,x.useEffect)(()=>{let w=g.current;w&&w.render&&w.render()},[E,W,Q]);let ut=(0,x.useRef)(null),[Ne,se]=(0,x.useState)([]),[z,te]=(0,x.useState)(null),[re,ge]=(0,x.useState)(!1),[ct,Dt]=(0,x.useState)(null),[ht,_n]=(0,x.useState)(""),Pn=(0,x.useRef)(null),Ht=(0,x.useRef)(null),xe=(w,h=!0)=>{Pn.current&&clearTimeout(Pn.current),Dt({msg:w,ok:h}),Pn.current=setTimeout(()=>Dt(null),1900)},Gn=w=>{_n(w),Ht.current&&clearTimeout(Ht.current),Ht.current=setTimeout(()=>_n(""),1600)};(0,x.useEffect)(()=>()=>{Pn.current&&clearTimeout(Pn.current),Ht.current&&clearTimeout(Ht.current)},[]);let rt=(0,x.useMemo)(()=>e.reduce((w,h)=>(w[h.id]=h,w),{}),[e]);return(0,x.useEffect)(()=>{let w=v.current;if(!w||e.length===0)return;let h=w.getContext("2d");if(!h)return;let U=Math.max(1,window.devicePixelRatio||1),ce=()=>document.documentElement.getAttribute("data-theme")==="dark",ze={};t.forEach(b=>{ze[b.source]=(ze[b.source]||0)+1,ze[b.target]=(ze[b.target]||0)+1});let qe=Math.max(1,...Object.values(ze)),f={nodes:e.map(b=>({id:b.id,name:b.title||"",type:b.kind||"other",r:9+Math.min(10,(ze[b.id]||0)/qe*8),x:0,y:0,vx:0,vy:0})),edges:t.map(b=>({sourceNodeId:b.source,targetNodeId:b.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:U,ctx:h,multi:[],marquee:null};f.domain=e,f.domainById=e.reduce((b,j)=>(b[j.id]=j,b),{}),f.nodes.forEach((b,j)=>{let R=j/f.nodes.length*Math.PI*2-Math.PI/2;b.x=Math.cos(R)*60,b.y=Math.sin(R)*60});let Dr=[...new Set(f.nodes.map(b=>b.type))];f.clustered=Dr.length>1,f.typeCenters={},Dr.forEach((b,j)=>{let R=j/Dr.length*Math.PI*2-Math.PI/2;f.typeCenters[b]={x:Math.cos(R)*160,y:Math.sin(R)*160}}),g.current=f;let Il=0,Rl=0,P=()=>{let b=w.clientWidth,j=w.clientHeight;f.w=b,f.h=j,w.width=b*U,w.height=j*U,h.setTransform(U,0,0,U,0,0),(Il===0||Rl===0)&&b>0&&j>0&&f.tickCount>0&&requestAnimationFrame(()=>Le()),Il=b,Rl=j};P();let K=new ResizeObserver(P);K.observe(w.parentElement);let J=(b,j)=>b&&b.length>j?b.slice(0,j)+"\u2026":b,De=(b,j,R,$)=>{if(h.beginPath(),$==="rect")h.rect(b-R,j-R*.75,R*2,R*1.5);else if($==="diamond")h.moveTo(b,j-R),h.lineTo(b+R,j),h.lineTo(b,j+R),h.lineTo(b-R,j),h.closePath();else if($==="hexagon"){for(let H=0;H<6;H++){let ue=Math.PI/3*H-Math.PI/2,ne=b+R*Math.cos(ue),We=j+R*Math.sin(ue);H===0?h.moveTo(ne,We):h.lineTo(ne,We)}h.closePath()}else h.arc(b,j,R,0,Math.PI*2)},Le=()=>{if(!f.nodes.length)return;let b=1/0,j=-1/0,R=1/0,$=-1/0;f.nodes.forEach(M=>{b=Math.min(b,M.x),j=Math.max(j,M.x),R=Math.min(R,M.y),$=Math.max($,M.y)});let H=20,ue=j-b+H*2,ne=$-R+H*2,We=Math.min(f.w/ue,f.h/ne);f.zoom=Math.max(.35,Math.min(1.8,We)),f.panX=f.w/2-(b+j)/2*f.zoom,f.panY=f.h/2-(R+$)/2*f.zoom};C.current=Le;let Te=()=>{h.clearRect(0,0,f.w,f.h),f.searchTerm=O.current,f.kindFilter=L.current,f.timeMode=ae.current,f.tagFilter=le.current;let b=f.tagFilter,j=f.kindFilter,R=M=>String(M||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");h.save(),h.strokeStyle=ce()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",h.lineWidth=.5;for(let M=0;M<f.w;M+=24)h.beginPath(),h.moveTo(M,0),h.lineTo(M,f.h),h.stroke();for(let M=0;M<f.h;M+=24)h.beginPath(),h.moveTo(0,M),h.lineTo(f.w,M),h.stroke();h.restore(),h.save(),h.translate(f.panX,f.panY),h.scale(f.zoom,f.zoom);let $={};f.nodes.forEach(M=>$[M.id]=M);let H=f.nodes.length>40,ue=H?1.5:.55,ne=f.selectedId||f.hoverId;f.edges.forEach(M=>{let de=$[M.sourceNodeId],V=$[M.targetNodeId];if(!de||!V)return;if(j!=="all"){let Ol=f.domainById[M.sourceNodeId]&&f.domainById[M.sourceNodeId].kind,Ve=f.domainById[M.targetNodeId]&&f.domainById[M.targetNodeId].kind;if(Ol!==j&&Ve!==j)return}if(b){let Ol=f.domainById[M.sourceNodeId]&&(f.domainById[M.sourceNodeId].tags||[]).includes(b),Ve=f.domainById[M.targetNodeId]&&(f.domainById[M.targetNodeId].tags||[]).includes(b);if(!Ol&&!Ve)return}let Y=V.x-de.x,pe=V.y-de.y,Se=Math.sqrt(Y*Y+pe*pe)||1,Fe=H?12:18,Ue=-pe/Se*Fe,He=Y/Se*Fe,Nt=(de.x+V.x)/2+Ue,Et=(de.y+V.y)/2+He,Ot=Pr.colors[f.domainById[de.id]&&f.domainById[de.id].kind||"other"],In=ne&&(M.sourceNodeId===ne||M.targetNodeId===ne),si=ne?In?.6:.08:H?.14:.24,ui=parseInt(Ot.slice(1,3),16),Or=parseInt(Ot.slice(3,5),16),Dl=parseInt(Ot.slice(5,7),16);h.strokeStyle="rgba("+ui+","+Or+","+Dl+","+si+")",h.lineWidth=In?1.6+(M.weight||1):.8+(M.weight||1)*.5,h.beginPath(),h.moveTo(de.x,de.y),h.quadraticCurveTo(Nt,Et,V.x,V.y),h.stroke()});let We=[];if(f.nodes.forEach(M=>{let de=f.domainById[M.id]||{},V=de.kind||"other",Y=f.timeMode?bg(de.updated):Pr.colors[V],pe=Pr.shapes[V],Se=f.selectedId===M.id,Fe=f.hoverId===M.id,Ue=f.searchTerm||"",He=!Ue||(M.name||"").toLowerCase().includes(Ue)||String(rn[V]||"").toLowerCase().includes(Ue)||String(V).toLowerCase().includes(Ue),Nt=j==="all"||V===j,Et=!b||(de.tags||[]).includes(b),Ot=ne&&M.id!==ne&&!f.edges.some(Ve=>Ve.sourceNodeId===ne&&Ve.targetNodeId===M.id||Ve.targetNodeId===ne&&Ve.sourceNodeId===M.id)||Ue&&!He||!Nt||!Et;h.save(),h.globalAlpha=Ot?.08:1,(Se||Fe)&&(h.shadowColor=Y,h.shadowBlur=Se?20:14),De(M.x,M.y,M.r,pe);let In=parseInt(Y.slice(1,3),16),si=parseInt(Y.slice(3,5),16),ui=parseInt(Y.slice(5,7),16),Or=h.createRadialGradient(M.x-M.r*.3,M.y-M.r*.3,0,M.x,M.y,M.r*1.2);Or.addColorStop(0,"rgba("+Math.min(255,In+70)+","+Math.min(255,si+70)+","+Math.min(255,ui+70)+",0.95)"),Or.addColorStop(1,Y),h.fillStyle=Or,h.fill(),h.restore(),Se?(h.save(),De(M.x,M.y,M.r+3,pe),h.strokeStyle=Y,h.lineWidth=3,h.shadowColor=Y,h.shadowBlur=12,h.stroke(),h.restore()):Fe?(h.save(),De(M.x,M.y,M.r+2,pe),h.strokeStyle=Y,h.lineWidth=2,h.stroke(),h.restore()):Ue&&He?(h.save(),De(M.x,M.y,M.r+2,pe),h.strokeStyle="#e11d48",h.lineWidth=2,h.stroke(),h.restore()):f.multi.indexOf(M.id)>=0&&(h.save(),De(M.x,M.y,M.r+2,pe),h.strokeStyle="#60a5fa",h.lineWidth=2,h.shadowColor="#60a5fa",h.shadowBlur=8,h.stroke(),h.restore());let Dl=J(M.name,16);if((Se||Fe||f.zoom>ue||!H&&f.zoom>.6)&&Nt&&Et){let Ve=1/f.zoom;h.font="500 "+(12*Ve).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let an=h.measureText(Dl).width+16*Ve,Fl=18*Ve,Jn=M.y+M.r+8*Ve,As=!0;for(let er of We)if(M.x-an/2<er.x+er.w&&M.x+an/2>er.x&&Jn<er.y+er.h&&Jn+Fl>er.y){As=!1;break}if(!As&&!Se&&!Fe)return;We.push({x:M.x-an/2,y:Jn,w:an,h:Fl}),h.fillStyle=ce()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",h.beginPath(),h.roundRect?h.roundRect(M.x-an/2,Jn,an,Fl,4*Ve):h.rect(M.x-an/2,Jn,an,Fl),h.fill(),h.strokeStyle=ce()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",h.lineWidth=1*Ve,h.stroke(),h.fillStyle=ce()?Se||Fe?"#eee":"#bbb":Se||Fe?"#111":"#444",h.textAlign="center",h.fillText(Dl,M.x,Jn+13*Ve)}}),h.restore(),f.marquee){let M=f.marquee,de=Math.min(M.sx,M.ex),V=Math.min(M.sy,M.ey),Y=Math.abs(M.ex-M.sx),pe=Math.abs(M.ey-M.sy);h.save(),h.setLineDash([4,4]),h.strokeStyle="rgba(96,165,250,0.9)",h.lineWidth=1,h.fillStyle="rgba(96,165,250,0.12)",h.fillRect(de,V,Y,pe),h.strokeRect(de,V,Y,pe),h.restore()}if(f.hoverId&&ut.current){let M=f.domainById[f.hoverId],de=f.nodes.find(function(V){return V.id===f.hoverId});if(M&&de){let V=f.edges.filter(function(Se){return Se.sourceNodeId===M.id||Se.targetNodeId===M.id}).length,Y=de.x*f.zoom+f.panX,pe=de.y*f.zoom+f.panY;ut.current.style.display="block",ut.current.style.left=Y+14+"px",ut.current.style.top=pe-6+"px",ut.current.innerHTML="<b>"+R(M.title||M.name||"")+'</b><br/><span style="opacity:.8">'+R(M.kind||"")+" \xB7 "+tRef.current("connCount").replace("{n}",V)+"</span>"}}else ut.current&&(ut.current.style.display="none")},Oe=()=>{f.running=!0,f.raf||(f.raf=requestAnimationFrame(Vt))};f.wake=Oe,f.render=Te;let on=()=>{let b=f.nodes.length;f.tickCount++;let R=.9-Math.min(.4,f.tickCount/1500),$=b>1e3?3e3:b>100?2e3:b>50?1200:800,H=b>100?.002:.005,ue=b>1e3?.012:b>100?.005:.01,ne=b>1e3?6:b>200?12:24,We={};f.nodes.forEach(V=>We[V.id]=V);for(let V=0;V<b;V++){if(f.dragNode===f.nodes[V])continue;let Y=f.nodes[V],pe=0,Se=0;for(let He=0;He<b;He++){if(V===He)continue;let Nt=Y.x-f.nodes[He].x,Et=Y.y-f.nodes[He].y,Ot=Math.sqrt(Nt*Nt+Et*Et)||1,In=$/(Ot*Ot);pe+=Nt/Ot*In,Se+=Et/Ot*In}if(f.clustered&&f.typeCenters[Y.type]){let He=f.typeCenters[Y.type];pe+=(He.x-Y.x)*.006,Se+=(He.y-Y.y)*.006}else pe-=Y.x*ue,Se-=Y.y*ue;let Fe=(Y.vx+pe)*R,Ue=(Y.vy+Se)*R;Fe=Math.max(-ne,Math.min(ne,Fe)),Ue=Math.max(-ne,Math.min(ne,Ue)),Y.vx=Fe,Y.vy=Ue}f.edges.forEach(V=>{let Y=We[V.sourceNodeId],pe=We[V.targetNodeId];if(!Y||!pe)return;let Se=pe.x-Y.x,Fe=pe.y-Y.y,Ue=Math.sqrt(Se*Se+Fe*Fe)||1,He=(Ue-100)*H,Nt=Se/Ue*He,Et=Fe/Ue*He;f.dragNode!==Y&&(Y.vx+=Nt,Y.vy+=Et),f.dragNode!==pe&&(pe.vx-=Nt,pe.vy-=Et)});let M=0;f.nodes.forEach(V=>{f.dragNode!==V&&(V.x+=V.vx,V.y+=V.vy,M+=V.vx*V.vx+V.vy*V.vy)}),f.autoFitPending&&f.tickCount>45&&(f.autoFitPending=!1,Le()),(b?Math.sqrt(M/b):0)<.05&&f.tickCount>60&&!f.dragNode?f.quietTicks=(f.quietTicks|0)+1:f.quietTicks=0},Vt=()=>{if(f.running){try{on(),Te()}catch{}if(f.quietTicks>30){f.raf=0;return}f.raf=requestAnimationFrame(Vt)}},Ze=(b,j)=>{let R=w.getBoundingClientRect();return{x:(b-R.left-f.panX)/f.zoom,y:(j-R.top-f.panY)/f.zoom}},qn=b=>{let j=f.domainById[b];return!(!j||L.current!=="all"&&j.kind!==L.current||le.current&&!(j.tags||[]).includes(le.current))},Zn=(b,j,R)=>Math.max(j,Math.min(R,b)),Is=b=>{f.mouseX=b.clientX,f.mouseY=b.clientY;let j=Ze(b.clientX,b.clientY),R=null;for(let $=f.nodes.length-1;$>=0;$--){let H=f.nodes[$];if(!qn(H.id))continue;let ue=H.x-j.x,ne=H.y-j.y;if(ue*ue+ne*ne<H.r*H.r+36){R=H.id;break}}R!==f.hoverId&&(f.hoverId=R,Oe())},Rs=b=>{if(b.button!==0)return;let j=Ze(b.clientX,b.clientY),R=null;for(let $=f.nodes.length-1;$>=0;$--){let H=f.nodes[$];if(!qn(H.id))continue;let ue=H.x-j.x,ne=H.y-j.y;if(ue*ue+ne*ne<H.r*H.r+25){R=H;break}}if(b.shiftKey){if(R){f.shiftClick=R.id;return}f.marquee={sx:b.clientX,sy:b.clientY,ex:b.clientX,ey:b.clientY};return}f.dragStart={x:b.clientX,y:b.clientY,px:f.panX,py:f.panY},f.dragging=!1,f.dragNode=R||null,R&&(f.dragOffset={dx:R.x-j.x,dy:R.y-j.y})},Ds=b=>{if(f.marquee){f.marquee.ex=b.clientX,f.marquee.ey=b.clientY,Oe();return}if(!f.dragStart)return;let j=b.clientX-f.dragStart.x,R=b.clientY-f.dragStart.y;if(Math.abs(j)+Math.abs(R)>3&&(f.dragging=!0),f.dragNode){let $=Ze(b.clientX,b.clientY);f.dragNode.x=$.x+f.dragOffset.dx,f.dragNode.y=$.y+f.dragOffset.dy,Oe()}else f.dragging&&(f.panX=Zn(f.dragStart.px+j,-1e5,1e5),f.panY=Zn(f.dragStart.py+R,-1e5,1e5),Oe())},Os=b=>{if(f.marquee){let R=f.marquee;f.marquee=null;let $=w.getBoundingClientRect(),H=Math.min(R.sx,R.ex)-$.left,ue=Math.max(R.sx,R.ex)-$.left,ne=Math.min(R.sy,R.ey)-$.top,We=Math.max(R.sy,R.ey)-$.top,M=f.nodes.filter(de=>{let V=de.x*f.zoom+f.panX,Y=de.y*f.zoom+f.panY;return V>=H&&V<=ue&&Y>=ne&&Y<=We}).map(de=>de.id);f.multi=M,se(M),Oe();return}let j=f.dragStart&&!f.dragging;if(f.shiftClick){let R=f.shiftClick;f.shiftClick=null;let $=Array.isArray(f.multi)?f.multi.slice():[];$.includes(R)||$.push(R),f.multi=$,se($),Oe();return}if(j){let R=Ze(b.clientX,b.clientY),$=null;for(let H=f.nodes.length-1;H>=0;H--){let ue=f.nodes[H];if(!qn(ue.id))continue;let ne=ue.x-R.x,We=ue.y-R.y;if(ne*ne+We*We<ue.r*ue.r+20){$=ue;break}}$?(f.selectedId=$.id,N($.id),Oe()):(f.selectedId=null,f.hoverId=null,b.shiftKey||(f.multi=[],se([])),N(null),Oe())}f.dragStart=null,f.dragging=!1,f.dragNode=null},Fs=b=>{b.preventDefault();let j=Ze(b.clientX,b.clientY),R=null;for(let $=f.nodes.length-1;$>=0;$--){let H=f.nodes[$];if(!qn(H.id))continue;let ue=H.x-j.x,ne=H.y-j.y;if(ue*ue+ne*ne<H.r*H.r+25){R=H;break}}if(R){let $=f.domainById[R.id];$&&$e({x:b.clientX,y:b.clientY,id:R.id,path:$.id,title:$.title})}else $e(null)},js=b=>{b.preventDefault();let j=w.getBoundingClientRect(),R=(b.clientX-j.left-f.panX)/f.zoom,$=(b.clientY-j.top-f.panY)/f.zoom,H=Math.max(.3,Math.min(3,f.zoom*(b.deltaY<0?1.1:1/1.1)));f.panX=Zn(f.panX+R*(f.zoom-H),-1e5,1e5),f.panY=Zn(f.panY+$*(f.zoom-H),-1e5,1e5),f.zoom=H,Oe()};w.addEventListener("mousemove",Is),w.addEventListener("mousedown",Rs),window.addEventListener("mousemove",Ds),window.addEventListener("mouseup",Os),w.addEventListener("wheel",js,{passive:!1}),w.addEventListener("contextmenu",Fs),_.current=()=>{f.selectedId=null,f.hoverId=null,f.multi=[],se([]),Le(),Oe()};for(let b=0;b<200;b++)on();Le(),Oe();let Bs=()=>A(!1);return window.addEventListener("mousedown",Bs),()=>{f.running=!1,f.raf&&cancelAnimationFrame(f.raf),K.disconnect(),w.removeEventListener("mousemove",Is),w.removeEventListener("mousedown",Rs),window.removeEventListener("mousemove",Ds),window.removeEventListener("mouseup",Os),w.removeEventListener("wheel",js),w.removeEventListener("contextmenu",Fs),window.removeEventListener("mousedown",Bs)}},[e,t]),(0,x.useEffect)(()=>{p!==void 0&&C.current&&requestAnimationFrame(()=>C.current())},[p]),(0,i.jsxs)("div",{className:"me-graph",ref:y,children:[(0,i.jsxs)("div",{className:"me-graph-toolbar",children:[(0,i.jsxs)("span",{className:"me-graph-count",children:[e.length," ",o("nodes")," \xB7 ",t.length," ",o("edges")]}),(0,i.jsx)("span",{className:"spacer",style:{flex:1}}),(0,i.jsx)("input",{type:"text",placeholder:o("search"),value:c,onChange:w=>m(w.target.value)}),(0,i.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,i.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>A(w=>!w),"aria-expanded":I,title:o("filterLabel"),style:{borderRadius:8},children:["\u{1F50D} ",o("filterLabel")," ",E!=="all"||Q||W?"\u25CF":"\u25BE"]}),I&&(0,i.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:w=>w.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,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,i.jsx)("button",{type:"button",className:`lg${E==="all"&&!Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{F("all"),X(!1)},children:o("all")}),Object.keys(Ln).map(w=>(0,i.jsxs)("button",{type:"button",className:`lg${E===w?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>F(h=>h===w?"all":w),children:[(0,i.jsx)("span",{className:"mc-kind",style:{background:Pr.colors[w]||Ln[w]}}),o(rn[w])]},w)),(0,i.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,i.jsxs)("button",{type:"button",className:`lg${Q?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>X(w=>!w),children:["\u23F1 ",o("timeDim")]}),Ut.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,i.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:Ut.map(w=>(0,i.jsxs)("button",{type:"button",className:`lg${W===w.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>q(h=>h===w.tag?"":w.tag),title:w.tag,children:["#",w.tag," ",(0,i.jsx)("span",{style:{opacity:.55},children:w.n})]},w.tag))})]}),(E!=="all"||Q||W)&&(0,i.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{F("all"),X(!1),q("")},children:[o("clearFilter")," \u2715"]})]})})]}),(0,i.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:o("crossVault"),children:[(0,i.jsx)("input",{type:"checkbox",checked:!!s,onChange:w=>u&&u(w.target.checked)}),o("crossVault")]}),(0,i.jsx)("button",{type:"button",className:`mc-btn${Q?" me-on":""}`,onClick:()=>X(w=>!w),children:o("timeDim")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let w=v.current;if(w)try{w.toBlob(h=>{h&&te({url:URL.createObjectURL(h),blob:h})},"image/png")}catch{}},children:o("exportGraph")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>C.current&&C.current(),children:o("fit")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{N(null),F("all"),_.current&&_.current()},children:o("reset")})]}),(0,i.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,i.jsx)("canvas",{ref:v,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,i.jsx)("div",{className:"me-graph-tooltip",ref:ut,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)"}}),Tn&&(0,i.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:o("noMatch")}),ie&&(0,i.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>$e(null)}),ie&&(0,i.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:ie.x,top:ie.y,zIndex:31},onMouseDown:w=>w.stopPropagation(),children:[(0,i.jsx)("button",{type:"button",onClick:()=>{S.current({path:ie.path,title:ie.title}),$e(null)},children:o("openCard")}),(0,i.jsx)("button",{type:"button",onClick:()=>{ie.id&&(g.current.selectedId=ie.id,N(ie.id)),$e(null);let w=g.current;w&&w.wake&&w.wake()},children:o("focusNeighbors")}),(0,i.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(ie.title||"")}catch{}$e(null),xe(o("copied"))},children:o("copyName")}),(0,i.jsx)("button",{type:"button",onClick:()=>{let w=g.current,h=w&&Array.isArray(w.multi)?w.multi.slice():[],U=ie.id;if(U&&!h.includes(U)&&h.push(U),$e(null),h.length<2){xe(o("mergeNeed"),!1);return}if(!window.confirm(o("mergeConfirm")))return;let ce=d.current&&d.current(h);ce&&ce.then?ce.then(ze=>ze?xe(o("merged")):xe(o("mergeFail"),!1)).catch(()=>xe(o("mergeFail"),!1)):ce&&xe(o("merged"))},children:o("merge")}),(0,i.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let w=ie.path;$e(null),window.confirm(o("deleteConfirm"))&&(async()=>{try{(B.current?await B.current(w):!1)?xe(o("deleted")):xe(o("deleteFail"),!1)}catch{xe(o("deleteFail"),!1)}})()},children:o("delete")})]}),Ne.length>0&&(0,i.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,i.jsxs)("span",{style:{fontWeight:700},children:[Ne.length," ",o("nodes")]}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let h=Ne.map(qe=>rt[qe]).filter(Boolean).map(qe=>qe.title||qe.name).join(`
229
- `),U=new Blob([h],{type:"text/plain;charset=utf-8"}),ce=URL.createObjectURL(U),ze=document.createElement("a");ze.href=ce,ze.download="memory-selected.txt",document.body.appendChild(ze),ze.click(),document.body.removeChild(ze),setTimeout(()=>URL.revokeObjectURL(ce),1e3),xe(Ne.length+o("exportedSel"))},children:o("exportSel")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(Ne.length<2){xe(o("mergeNeed"),!1);return}let w=Ne.map(U=>rt[U]?rt[U].id:U);if(!window.confirm(o("mergeConfirm")))return;se([]);let h=g.current;h&&(h.multi=[]),fetch(`${Z}/merge?paths=${encodeURIComponent(w.join(","))}`).then(U=>U.json()).then(U=>{U&&U.ok?xe(o("merged")):xe(o("mergeFail"),!1)}).catch(()=>xe(o("mergeFail"),!1))},children:o("merge")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(o("deleteConfirm")))return;let w=Ne.map(U=>rt[U]?rt[U].id:U);se([]);let h=g.current;h&&(h.multi=[]),(async()=>{let U=0;for(let ce of w)try{(B.current?await B.current(ce):!1)&&U++}catch{}xe(U+o("deletedSelected"),U>0)})()},children:o("deleteSelected")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let w=g.current;w&&(w.multi=[]),se([]);let h=g.current;h&&h.render&&h.render()},children:o("clearSelection")})]}),k&&(0,i.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,i.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:rt[k]?rt[k].title||rt[k].name:k}),(0,i.jsx)("div",{style:{opacity:.8,marginBottom:8},children:rt[k]?o(rn[rt[k].kind]||"kindKnowledge"):"\u2014"}),(0,i.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:o("graphHint")}),(t.filter(w=>w.source===k||w.target===k)||[]).slice(0,8).map((w,h)=>{let U=w.source===k?w.target:w.source,ce=rt[U];return(0,i.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ze=>{ze.preventDefault();let qe=g.current;qe&&(qe.selectedId=U,qe.hoverId=U,qe.wake&&qe.wake()),N(U)},children:ce?(ce.title||ce.name).slice(0,28):U},h)})]})]}),(0,i.jsx)("div",{className:"me-graph-tip",children:o("graphTip")}),ct&&(0,i.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 "+(ct.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,i.jsx)("span",{style:{color:ct.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ct.ok?"\u2713":"\u2715"}),(0,i.jsx)("span",{style:{wordBreak:"break-all"},children:ct.msg})]}),z&&(0,i.jsxs)("div",{className:"me-overlay",onClick:()=>{z.url&&URL.revokeObjectURL(z.url),te(null),ge(!1)},children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{className:"me-dialog",style:{maxWidth:re?"100vw":900,width:re?"100vw":"92vw",maxHeight:re?"100vh":"90vh",height:re?"100vh":void 0,borderRadius:re?0:14},onClick:w=>w.stopPropagation(),children:[(0,i.jsxs)("div",{className:"me-dialog-head",children:[(0,i.jsx)("h3",{children:o("exportGraph")}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("a",{className:"mc-btn",href:z.url,download:"memory-graph.png",onClick:()=>{Gn("download"),xe(o("downloaded")+" \xB7 "+o("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:o(ht==="download"?"done":"download")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Gn("full"),ge(w=>!w),xe(o("fullscreen"))},children:o(ht==="full"?"done":re?"exitFull":"fullscreen")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let w=z.blob;w&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":w})]).then(()=>{Gn("copy"),xe(o("copied"))}).catch(()=>{xe(o("copyFail"),!1)}):xe(o("copyFail"),!1)},children:o(ht==="copy"?"done":"copyImage")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{z.url&&URL.revokeObjectURL(z.url),te(null),ge(!1)},children:o("close")})]})]}),(0,i.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:re?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,i.jsx)("img",{src:z.url,alt:o("exportGraph"),style:{maxWidth:"100%",maxHeight:re?"calc(100vh - 64px)":"70vh",borderRadius:re?0:8,cursor:"zoom-in"},onClick:()=>ge(w=>!w)})})]})]})]})}function bg(e){let t=new Date(e||0).getTime();if(!t)return"#94a3b8";let n=(Date.now()-t)/864e5;return n<3?"#10b981":n<14?"#f59e0b":n<30?"#f97316":"#94a3b8"}function Ep({label:e,value:t=[],options:n,onChange:r,placeholder:l,z:o=20}){let[a,s]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!a)return;let S=B=>{u.current&&!u.current.contains(B.target)&&s(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]);let p=Array.isArray(t)?t:[],v=p.includes("__all__"),y=v?n.find(S=>S.value==="__all__")?.label||"":p.length?p.map(S=>n.find(B=>B.value===S)?.label||S).join("\u3001"):"",g=(S,B)=>{if(S.value==="__all__"){r(B?["__all__"]:[]);return}let d=new Set(p);d.has("__all__")&&d.delete("__all__"),B?d.add(S.value):d.delete(S.value),r([...d])},C=n.find(S=>S.value==="__all__"),_=n.filter(S=>S.value!=="__all__");return(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,i.jsx)("span",{style:{opacity:.6},children:e}),(0,i.jsxs)("div",{ref:u,style:{position:"relative"},children:[(0,i.jsxs)("button",{type:"button",onClick:()=>s(S=>!S),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,i.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||l||"\u2014"}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),a&&(0,i.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:o,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[C&&(0,i.jsxs)("label",{onClick:S=>S.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,i.jsx)("input",{type:"checkbox",checked:v,onChange:S=>g(C,S.target.checked)}),(0,i.jsx)("span",{children:C.label})]}),_.map(S=>(0,i.jsxs)("label",{onClick:B=>B.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,i.jsx)("input",{type:"checkbox",checked:p.includes(S.value),onChange:B=>g(S,B.target.checked)}),(0,i.jsx)("span",{children:S.label})]},S.value))]})]})]})}function Sg(e){let t=new Date(e||0).getTime();return!!t&&(Date.now()-t)/864e5<3}async function Cg(e,t,n){if(n&&typeof window.showSaveFilePicker=="function")try{let o=await window.showSaveFilePicker({suggestedName:t}),a=await o.createWritable();return await a.write(e),await a.close(),{ok:!0,picked:!0,name:o.name}}catch(o){return o&&o.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(o.message||o)}}let r=URL.createObjectURL(e),l=document.createElement("a");return l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(r),1e3),{ok:!0,picked:!1,name:t}}function zp(e,t){if(!t||!e)return e;let n=e.toLowerCase(),r=t.toLowerCase(),l=[],o=0;for(;o<e.length;){let a=n.indexOf(r,o);if(a<0){l.push(e.slice(o));break}a>o&&l.push(e.slice(o,a)),l.push((0,i.jsx)("mark",{className:"mc-hl",children:e.slice(a,a+r.length)},a)),o=a+r.length}return l}function Ng(e){if(!e)return"";let t=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n=[];return t=t.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(r,l,o){return n.push("<pre><code>"+o+"</code></pre>"),"\0"+(n.length-1)+"\0"}),t=t.replace(/^(#{1,3})\s+(.+)$/gm,function(r,l,o){return"<h"+l.length+">"+o+"</h"+l.length+">"}),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/`([^`\n]+)`/g,"<code>$1</code>"),t=t.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(r,l,o){return/^(https?:|\/)/.test(o)?'<a href="'+o+'" target="_blank" rel="noopener noreferrer">'+l+"</a>":l}),t=t.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),t=t.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),t=t.replace(/\n/g,"<br/>"),t=t.replace(/\u0000(\d+)\u0000/g,function(r,l){return n[l]}),t}function Pl(e){if(!e)return"";let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let n=new Date,r=t.toDateString()===n.toDateString(),l=a=>String(a).padStart(2,"0"),o=`${l(t.getHours())}:${l(t.getMinutes())}`;return r?o:`${t.getMonth()+1}-${t.getDate()} ${o}`}var Ps=Rn(Tl(),1);function Eg(){try{let e=new URLSearchParams(window.location.search).get("lang");if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&String(navigator.language||"").toLowerCase().startsWith("zh")?"zh":"en"}function zg(){let[e,t]=(0,Rr.useState)(Eg);(0,Rr.useEffect)(()=>{let r=l=>{let o=l&&l.data;o&&o.source==="memory-eternal"&&o.type==="locale"&&(o.lang==="zh"||o.lang==="en")&&t(o.lang)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[]);let n=(0,Rr.useMemo)(()=>r=>(e==="zh"?Ts:Mp)[r]??Ts[r]??r,[e]);return document.documentElement.lang=e==="zh"?"zh-CN":"en",(0,Ps.jsx)(Tp,{t:n,inModal:!1})}var Mg=(0,_p.createRoot)(document.getElementById("root"));Mg.render((0,Ps.jsx)(zg,{}));})();
254
+ `),U=new Blob([h],{type:"text/plain;charset=utf-8"}),ce=URL.createObjectURL(U),ze=document.createElement("a");ze.href=ce,ze.download="memory-selected.txt",document.body.appendChild(ze),ze.click(),document.body.removeChild(ze),setTimeout(()=>URL.revokeObjectURL(ce),1e3),xe(Ne.length+o("exportedSel"))},children:o("exportSel")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(Ne.length<2){xe(o("mergeNeed"),!1);return}let w=Ne.map(U=>rt[U]?rt[U].id:U);if(!window.confirm(o("mergeConfirm")))return;se([]);let h=g.current;h&&(h.multi=[]),fetch(`${Z}/merge?paths=${encodeURIComponent(w.join(","))}`).then(U=>U.json()).then(U=>{U&&U.ok?xe(o("merged")):xe(o("mergeFail"),!1)}).catch(()=>xe(o("mergeFail"),!1))},children:o("merge")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(o("deleteConfirm")))return;let w=Ne.map(U=>rt[U]?rt[U].id:U);se([]);let h=g.current;h&&(h.multi=[]),(async()=>{let U=0;for(let ce of w)try{(B.current?await B.current(ce):!1)&&U++}catch{}xe(U+o("deletedSelected"),U>0)})()},children:o("deleteSelected")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let w=g.current;w&&(w.multi=[]),se([]);let h=g.current;h&&h.render&&h.render()},children:o("clearSelection")})]}),k&&(0,i.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,i.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:rt[k]?rt[k].title||rt[k].name:k}),(0,i.jsx)("div",{style:{opacity:.8,marginBottom:8},children:rt[k]?o(rn[rt[k].kind]||"kindKnowledge"):"\u2014"}),(0,i.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:o("graphHint")}),(t.filter(w=>w.source===k||w.target===k)||[]).slice(0,8).map((w,h)=>{let U=w.source===k?w.target:w.source,ce=rt[U];return(0,i.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:ze=>{ze.preventDefault();let qe=g.current;qe&&(qe.selectedId=U,qe.hoverId=U,qe.wake&&qe.wake()),N(U)},children:ce?(ce.title||ce.name).slice(0,28):U},h)})]})]}),(0,i.jsx)("div",{className:"me-graph-tip",children:o("graphTip")}),ct&&(0,i.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 "+(ct.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,i.jsx)("span",{style:{color:ct.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ct.ok?"\u2713":"\u2715"}),(0,i.jsx)("span",{style:{wordBreak:"break-all"},children:ct.msg})]}),z&&(0,i.jsxs)("div",{className:"me-overlay",onClick:()=>{z.url&&URL.revokeObjectURL(z.url),te(null),ge(!1)},children:[(0,i.jsx)("style",{children:ln}),(0,i.jsxs)("div",{className:"me-dialog",style:{maxWidth:re?"100vw":900,width:re?"100vw":"92vw",maxHeight:re?"100%":"90vh",height:re?"100%":void 0,borderRadius:re?0:14},onClick:w=>w.stopPropagation(),children:[(0,i.jsxs)("div",{className:"me-dialog-head",children:[(0,i.jsx)("h3",{children:o("exportGraph")}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("a",{className:"mc-btn",href:z.url,download:"memory-graph.png",onClick:()=>{Gn("download"),xe(o("downloaded")+" \xB7 "+o("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:o(ht==="download"?"done":"download")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{Gn("full"),ge(w=>!w),xe(o("fullscreen"))},children:o(ht==="full"?"done":re?"exitFull":"fullscreen")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let w=z.blob;w&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":w})]).then(()=>{Gn("copy"),xe(o("copied"))}).catch(()=>{xe(o("copyFail"),!1)}):xe(o("copyFail"),!1)},children:o(ht==="copy"?"done":"copyImage")}),(0,i.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{z.url&&URL.revokeObjectURL(z.url),te(null),ge(!1)},children:o("close")})]})]}),(0,i.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:re?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,i.jsx)("img",{src:z.url,alt:o("exportGraph"),style:{maxWidth:"100%",maxHeight:re?"calc(100% - 64px)":"70vh",borderRadius:re?0:8,cursor:"zoom-in"},onClick:()=>ge(w=>!w)})})]})]})]})}function bg(e){let t=new Date(e||0).getTime();if(!t)return"#94a3b8";let n=(Date.now()-t)/864e5;return n<3?"#10b981":n<14?"#f59e0b":n<30?"#f97316":"#94a3b8"}function Ep({label:e,value:t=[],options:n,onChange:r,placeholder:l,z:o=20}){let[a,s]=(0,x.useState)(!1),u=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!a)return;let S=B=>{u.current&&!u.current.contains(B.target)&&s(!1)};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]);let p=Array.isArray(t)?t:[],v=p.includes("__all__"),y=v?n.find(S=>S.value==="__all__")?.label||"":p.length?p.map(S=>n.find(B=>B.value===S)?.label||S).join("\u3001"):"",g=(S,B)=>{if(S.value==="__all__"){r(B?["__all__"]:[]);return}let d=new Set(p);d.has("__all__")&&d.delete("__all__"),B?d.add(S.value):d.delete(S.value),r([...d])},C=n.find(S=>S.value==="__all__"),_=n.filter(S=>S.value!=="__all__");return(0,i.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:3,fontSize:12},children:[(0,i.jsx)("span",{style:{opacity:.6},children:e}),(0,i.jsxs)("div",{ref:u,style:{position:"relative"},children:[(0,i.jsxs)("button",{type:"button",onClick:()=>s(S=>!S),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,i.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y||l||"\u2014"}),(0,i.jsx)("span",{style:{fontSize:10,opacity:.7},children:"\u25BE"})]}),a&&(0,i.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:o,marginTop:2,borderRadius:8,border:"1px solid var(--dsw-alias-border-l2, #d1d5db)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"inherit",boxShadow:"0 6px 20px rgba(0,0,0,0.14)",maxHeight:180,overflow:"auto"},children:[C&&(0,i.jsxs)("label",{onClick:S=>S.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,i.jsx)("input",{type:"checkbox",checked:v,onChange:S=>g(C,S.target.checked)}),(0,i.jsx)("span",{children:C.label})]}),_.map(S=>(0,i.jsxs)("label",{onClick:B=>B.stopPropagation(),style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px",cursor:"pointer"},children:[(0,i.jsx)("input",{type:"checkbox",checked:p.includes(S.value),onChange:B=>g(S,B.target.checked)}),(0,i.jsx)("span",{children:S.label})]},S.value))]})]})]})}function Sg(e){let t=new Date(e||0).getTime();return!!t&&(Date.now()-t)/864e5<3}async function Cg(e,t,n){if(n&&typeof window.showSaveFilePicker=="function")try{let o=await window.showSaveFilePicker({suggestedName:t}),a=await o.createWritable();return await a.write(e),await a.close(),{ok:!0,picked:!0,name:o.name}}catch(o){return o&&o.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(o.message||o)}}let r=URL.createObjectURL(e),l=document.createElement("a");return l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(r),1e3),{ok:!0,picked:!1,name:t}}function zp(e,t){if(!t||!e)return e;let n=e.toLowerCase(),r=t.toLowerCase(),l=[],o=0;for(;o<e.length;){let a=n.indexOf(r,o);if(a<0){l.push(e.slice(o));break}a>o&&l.push(e.slice(o,a)),l.push((0,i.jsx)("mark",{className:"mc-hl",children:e.slice(a,a+r.length)},a)),o=a+r.length}return l}function Ng(e){if(!e)return"";let t=String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),n=[];return t=t.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(r,l,o){return n.push("<pre><code>"+o+"</code></pre>"),"\0"+(n.length-1)+"\0"}),t=t.replace(/^(#{1,3})\s+(.+)$/gm,function(r,l,o){return"<h"+l.length+">"+o+"</h"+l.length+">"}),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/`([^`\n]+)`/g,"<code>$1</code>"),t=t.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(r,l,o){return/^(https?:|\/)/.test(o)?'<a href="'+o+'" target="_blank" rel="noopener noreferrer">'+l+"</a>":l}),t=t.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),t=t.replace(/^\s*(&gt;)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),t=t.replace(/\n/g,"<br/>"),t=t.replace(/\u0000(\d+)\u0000/g,function(r,l){return n[l]}),t}function Pl(e){if(!e)return"";let t=new Date(e);if(Number.isNaN(t.getTime()))return"";let n=new Date,r=t.toDateString()===n.toDateString(),l=a=>String(a).padStart(2,"0"),o=`${l(t.getHours())}:${l(t.getMinutes())}`;return r?o:`${t.getMonth()+1}-${t.getDate()} ${o}`}var Ps=Rn(Tl(),1);function Eg(){try{let e=new URLSearchParams(window.location.search).get("lang");if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&String(navigator.language||"").toLowerCase().startsWith("zh")?"zh":"en"}function zg(){let[e,t]=(0,Rr.useState)(Eg);(0,Rr.useEffect)(()=>{let r=l=>{let o=l&&l.data;o&&o.source==="memory-eternal"&&o.type==="locale"&&(o.lang==="zh"||o.lang==="en")&&t(o.lang)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)},[]);let n=(0,Rr.useMemo)(()=>r=>(e==="zh"?Ts:Mp)[r]??Ts[r]??r,[e]);return document.documentElement.lang=e==="zh"?"zh-CN":"en",(0,Ps.jsx)(Tp,{t:n,inModal:!1})}var Mg=(0,_p.createRoot)(document.getElementById("root"));Mg.render((0,Ps.jsx)(zg,{}));})();
230
255
  /*! Bundled license information:
231
256
 
232
257
  react/cjs/react.production.min.js: