@huoweifang/dsh-mindmap 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/README.zh-CN.md +90 -0
- package/cordis.patch.yml +7 -0
- package/icon.svg +12 -0
- package/lib/client.js +160 -0
- package/lib/index.js +840 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +81 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- First public release. npm package `@huoweifang/dsh-mindmap`, plugin id `dsh-mindmap`.
|
|
6
|
+
- Outline editor: unlimited levels, keyboard editing, drag and drop, focus mode, undo/redo, checkboxes, inline Markdown.
|
|
7
|
+
- Mind-map view over the same document: collapse, zoom, pan, fit, edit in place.
|
|
8
|
+
- Documents: folders, favorites, trash, search, Markdown/OPML import and export, PNG/SVG export.
|
|
9
|
+
- Local storage under `~/.dsh/dsh-mindmap` with atomic writes, autosave and daily backups.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Weifang Huo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,90 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-mindmap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Outline notes with a live mind-map view for the [DeepSeek Harness](https://github.com/deepseek-ai) (DSH) web GUI. Both views edit the same document. Everything is stored locally: no account, no cloud, no AI, no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
[简体中文](README.zh-CN.md)
|
|
6
|
+
|
|
7
|
+
| Outline | Mind map (dark) |
|
|
8
|
+
|---|---|
|
|
9
|
+
|  |  |
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Outline** — unlimited levels; Enter splits/creates a sibling, Shift+Enter inserts a line break, Tab / Shift+Tab indent / outdent, Backspace deletes an empty node or merges with the previous one, Delete merges the next one, ↑/↓ move across nodes, Alt+↑/↓ move a node, Ctrl+. collapse, Ctrl+Enter toggle done, Alt+→ focus a subtree (breadcrumb to go back), Ctrl+Z / Ctrl+Shift+Z / Ctrl+Y undo/redo. Drag the bullet to reorder or change level. Multi-line paste becomes a tree. Inline Markdown (bold, italic, strikethrough, code, links, #tags) and checkboxes. IME composition is never intercepted.
|
|
14
|
+
- **Mind map** — horizontal tree with connectors, collapse/expand, Ctrl+wheel zoom (20%–300%), drag to pan, center / fit / 100%, double-click or F2 to edit, Tab adds a child, Enter adds a sibling.
|
|
15
|
+
- **Documents** — create, rename, trash and restore, folders, favorites, last-edited time, search across titles and node text.
|
|
16
|
+
- **Import / export** — import Markdown and OPML; export Markdown, OPML, PNG and SVG (whole document or the focused subtree).
|
|
17
|
+
- **Storage** — autosave 800 ms after typing stops and immediately on document switch / page hide; atomic writes; revision-based conflict detection; daily automatic backups (last 30 kept), manual backup, download and restore.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- DSH `>=0.2.2-rc.1 <0.3.0` (declared in `engines.dsh`; DSH checks it at install and at profile start)
|
|
22
|
+
- The web GUI (the page is a web client plugin)
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
Replace `desktop` with your profile name. `dsh plugin --profile <name> ...` forwards the arguments to pnpm inside that profile.
|
|
27
|
+
|
|
28
|
+
From npm (published as the scoped package `@huoweifang/dsh-mindmap`; the plugin itself is named `dsh-mindmap`):
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
dsh plugin --profile desktop add @huoweifang/dsh-mindmap
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
From GitHub (pin a tag; `lib/` is committed, so no build step runs on install):
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
dsh plugin --profile desktop add github:IsaacHuo/dsh-mindmap#v0.1.0
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Restart DSH. A **思维导图** entry appears in the sidebar.
|
|
41
|
+
|
|
42
|
+
### Update
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile desktop add @huoweifang/dsh-mindmap@latest # npm
|
|
46
|
+
dsh plugin --profile desktop add github:IsaacHuo/dsh-mindmap#v0.2.0 # GitHub
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
npm installs can also be updated from the DSH plugin manager. Restart DSH afterwards.
|
|
50
|
+
|
|
51
|
+
### Uninstall
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
dsh plugin --profile desktop remove @huoweifang/dsh-mindmap
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Uninstalling keeps your documents. Delete the data directory below by hand if you want them gone.
|
|
58
|
+
|
|
59
|
+
## Data and security
|
|
60
|
+
|
|
61
|
+
- Data directory: `~/.dsh/dsh-mindmap/` (or `$DSH_HOME/dsh-mindmap`; override with `DSH_MINDMAP_DIR`). It holds `library.json`, `docs/<id>.json` and `backups/`.
|
|
62
|
+
- Documents are plain, unencrypted JSON. Anyone with access to your user account can read them; don't store secrets.
|
|
63
|
+
- The plugin only registers HTTP routes under `/dsh-mindmap/api` on the DSH web server and inherits its access control. Write requests must be `application/json` (blocks simple cross-site form posts); bodies are capped at 8 MB; document ids are validated before touching the file system.
|
|
64
|
+
- No network requests, telemetry, agent tools or model calls. Links in notes open only for `http(s)` URLs, and notes are never rendered as HTML.
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm ci
|
|
70
|
+
npm run typecheck # tsc --noEmit
|
|
71
|
+
npm test # unit tests (node:test)
|
|
72
|
+
npm run build # lib/index.js (host) + lib/client.js (web page)
|
|
73
|
+
npm run pack:check # verify the npm tarball contents
|
|
74
|
+
npm run harness # local test page: real host routes + mocked DSH slots
|
|
75
|
+
npm run e2e # headless end-to-end test (Chromium/Edge via EDGE_PATH)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
To try a working copy in DSH: `dsh plugin --profile <name> add link:<path-to-this-repo>`.
|
|
79
|
+
|
|
80
|
+
The client does not bundle React — the DSH page provides it. `lib/` is committed so GitHub installs work; CI fails if it is out of date, so run `npm run build` before committing.
|
|
81
|
+
|
|
82
|
+
## Release
|
|
83
|
+
|
|
84
|
+
1. Update `version` in `package.json` and `CHANGELOG.md`, run `npm run check`, commit.
|
|
85
|
+
2. `git tag v<version> && git push origin v<version>`.
|
|
86
|
+
3. The Release workflow checks the tag against `package.json`, rebuilds, publishes to npm with provenance (`next` tag for prereleases) and creates a GitHub Release with the tarball. It needs the `NPM_TOKEN` repository secret.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
[MIT](LICENSE). Not affiliated with DeepSeek or any outliner product; no third-party brand assets are included.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# dsh-mindmap(思维导图)
|
|
2
|
+
|
|
3
|
+
[DeepSeek Harness](https://github.com/deepseek-ai)(DSH)Web 界面插件:大纲笔记 + 思维导图,两种视图编辑同一份文档。数据全部保存在本机:无账号、无云端、无 AI、无运行时依赖。
|
|
4
|
+
|
|
5
|
+
[English](README.md)
|
|
6
|
+
|
|
7
|
+
| 大纲 | 导图(深色) |
|
|
8
|
+
|---|---|
|
|
9
|
+
|  |  |
|
|
10
|
+
|
|
11
|
+
## 功能
|
|
12
|
+
|
|
13
|
+
- **大纲**:无限层级;Enter 拆分 / 新建同级,Shift+Enter 换行,Tab / Shift+Tab 缩进 / 反缩进,Backspace 删除空节点或与上一行合并,Delete 合并下一行,↑/↓ 跨节点移动,Alt+↑/↓ 移动节点,Ctrl+. 折叠,Ctrl+Enter 完成,Alt+→ 聚焦子树(面包屑返回),Ctrl+Z / Ctrl+Shift+Z / Ctrl+Y 撤销重做;拖动圆点调整顺序或层级;多行粘贴自动生成层级;行内 Markdown(粗体、斜体、删除线、代码、链接、#标签)与复选框;输入法组字期间不拦截按键。
|
|
14
|
+
- **导图**:水平树、连线、折叠 / 展开、Ctrl+滚轮缩放(20%–300%)、拖动平移、居中 / 适应窗口 / 100%;双击或 F2 编辑,Tab 加子节点,Enter 加同级。
|
|
15
|
+
- **文档管理**:新建、重命名、删除到回收站并可恢复、文件夹、收藏、最近编辑时间、搜索标题与节点内容。
|
|
16
|
+
- **导入导出**:导入 Markdown、OPML;导出 Markdown、OPML、PNG、SVG(整篇或聚焦的子树)。
|
|
17
|
+
- **存储**:停止输入 800 ms 后自动保存,切换文档 / 离开页面时立即保存;原子写入;修订号冲突检测;每日自动备份(保留 30 份),可手动备份、下载、恢复。
|
|
18
|
+
|
|
19
|
+
## 环境要求
|
|
20
|
+
|
|
21
|
+
- DSH `>=0.2.2-rc.1 <0.3.0`(声明在 `engines.dsh`,DSH 在安装和启动 profile 时检查)
|
|
22
|
+
- 使用 Web 界面(页面是 Web 客户端插件)
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
把 `desktop` 换成你的 profile 名。`dsh plugin --profile <名称> ...` 会把参数转给该 profile 内的 pnpm。
|
|
27
|
+
|
|
28
|
+
从 npm 安装(npm 包名为 `@huoweifang/dsh-mindmap`,插件本身名为 `dsh-mindmap`):
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
dsh plugin --profile desktop add @huoweifang/dsh-mindmap
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
从 GitHub 安装(固定到 tag;仓库提交了 `lib/`,安装时不需要构建):
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
dsh plugin --profile desktop add github:IsaacHuo/dsh-mindmap#v0.1.0
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
重启 DSH,侧边栏出现「思维导图」。
|
|
41
|
+
|
|
42
|
+
### 更新
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dsh plugin --profile desktop add @huoweifang/dsh-mindmap@latest # npm
|
|
46
|
+
dsh plugin --profile desktop add github:IsaacHuo/dsh-mindmap#v0.2.0 # GitHub
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
npm 安装的版本也可以在 DSH 插件管理里更新。更新后重启 DSH。
|
|
50
|
+
|
|
51
|
+
### 卸载
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
dsh plugin --profile desktop remove @huoweifang/dsh-mindmap
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
卸载不会删除文档;如需彻底清除,手动删除下面的数据目录。
|
|
58
|
+
|
|
59
|
+
## 数据与安全
|
|
60
|
+
|
|
61
|
+
- 数据目录:`~/.dsh/dsh-mindmap/`(或 `$DSH_HOME/dsh-mindmap`,可用 `DSH_MINDMAP_DIR` 覆盖),包含 `library.json`、`docs/<id>.json`、`backups/`。
|
|
62
|
+
- 文档是未加密的 JSON 文件,能访问你系统账号的人都能读到,请勿存放机密。
|
|
63
|
+
- 插件只在 DSH Web 服务上注册 `/dsh-mindmap/api` 路由,沿用 DSH 自身的访问控制;写请求必须是 `application/json`(挡住简单的跨站表单提交),请求体上限 8 MB,文档 id 在访问文件系统前校验。
|
|
64
|
+
- 不发起网络请求、无遥测、不注册 Agent 工具、不调用模型。笔记中的链接只允许 `http(s)`,笔记内容从不作为 HTML 渲染。
|
|
65
|
+
|
|
66
|
+
## 开发
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm ci
|
|
70
|
+
npm run typecheck # tsc --noEmit
|
|
71
|
+
npm test # 单元测试(node:test)
|
|
72
|
+
npm run build # lib/index.js(宿主)+ lib/client.js(页面)
|
|
73
|
+
npm run pack:check # 检查 npm 包内容
|
|
74
|
+
npm run harness # 本地测试页:真实宿主路由 + 模拟 DSH 插槽
|
|
75
|
+
npm run e2e # 无头端到端测试(Chromium/Edge,路径用 EDGE_PATH 指定)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
在 DSH 里试用工作副本:`dsh plugin --profile <名称> add link:<本仓库路径>`。
|
|
79
|
+
|
|
80
|
+
客户端不打包 React,由 DSH 页面提供。`lib/` 随仓库提交以支持 GitHub 安装;CI 会检查它是否与源码一致,提交前请先 `npm run build`。
|
|
81
|
+
|
|
82
|
+
## 发布
|
|
83
|
+
|
|
84
|
+
1. 修改 `package.json` 的 `version` 和 `CHANGELOG.md`,运行 `npm run check` 后提交。
|
|
85
|
+
2. `git tag v<版本> && git push origin v<版本>`。
|
|
86
|
+
3. Release 工作流校验 tag 与 `package.json` 一致,重新构建,带 provenance 发布到 npm(预发布版用 `next` 标签),并创建附带 tarball 的 GitHub Release。需要仓库 secret `NPM_TOKEN`。
|
|
87
|
+
|
|
88
|
+
## 许可证
|
|
89
|
+
|
|
90
|
+
[MIT](LICENSE)。与 DeepSeek 及任何大纲笔记产品无隶属关系,不含第三方品牌素材。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# dsh-mindmap bundle patch: inserts the plugin row into the profile roster.
|
|
2
|
+
# The node half (exports ".") registers the /dsh-mindmap/api routes on the
|
|
3
|
+
# shared DSH webserver; the dsh.client declaration loads exports "./client"
|
|
4
|
+
# in the web GUI, which registers the 思维导图 sidebar row and main page.
|
|
5
|
+
- insert:
|
|
6
|
+
- id: dsh-mindmap
|
|
7
|
+
name: '@huoweifang/dsh-mindmap'
|
package/icon.svg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#3964fe"/>
|
|
3
|
+
<g fill="none" stroke="#fff" stroke-width="3.5" stroke-linecap="round">
|
|
4
|
+
<path d="M22 32 C30 32 30 18 38 18"/>
|
|
5
|
+
<path d="M22 32 H38"/>
|
|
6
|
+
<path d="M22 32 C30 32 30 46 38 46"/>
|
|
7
|
+
</g>
|
|
8
|
+
<circle cx="18" cy="32" r="6" fill="#fff"/>
|
|
9
|
+
<rect x="38" y="14" width="14" height="8" rx="4" fill="#fff"/>
|
|
10
|
+
<rect x="38" y="28" width="14" height="8" rx="4" fill="#fff"/>
|
|
11
|
+
<rect x="38" y="42" width="14" height="8" rx="4" fill="#fff"/>
|
|
12
|
+
</svg>
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({id:"@huoweifang/dsh-mindmap",factory:function(require){var module={exports:{}},exports=module.exports;
|
|
2
|
+
"use strict";var Le=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Kt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var Ht=(e,t)=>{for(var n in t)Le(e,n,{get:t[n],enumerable:!0})},_t=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Kt(t))!Ft.call(e,r)&&r!==n&&Le(e,r,{get:()=>t[r],enumerable:!(o=zt(t,r))||o.enumerable});return e};var Bt=e=>_t(Le({},"__esModule",{value:!0}),e);var bn={};Ht(bn,{apply:()=>hn,inject:()=>pn,name:()=>mn});module.exports=Bt(bn);var O=require("react");var ze=0;function xe(){ze=(ze+1)%1296;let e=Math.random().toString(36).slice(2,10).padEnd(8,"0");return`${Date.now().toString(36)}-${ze.toString(36).padStart(2,"0")}${e}`}function Qe(e){let t={};for(let n of Object.values(e.nodes))for(let o of n.children)t[o]=n.id;return t}function et(e,t,n){let o=[],r=(i,a)=>{let f=e.nodes[i];if(f!==void 0)for(let u of f.children){o.push({id:u,depth:a});let c=e.nodes[u];c!==void 0&&(!n||!c.collapsed)&&r(u,a+1)}};return r(t,0),o}function he(e,t){let n=Qe(e),o=[],r=n[t];for(;r!==void 0;)o.unshift(r),r=n[r];return o}function ke(e,t,n){return t===n?!0:he(e,n).includes(t)}function Ke(e,t){return t.map(n=>{let o=e.nodes[n],r={text:o.text,children:Ke(e,o.children)};return typeof o.checked=="boolean"&&(r.checked=o.checked),r})}function ee(e,t,n=[]){let o={...e.nodes};for(let r of n)delete o[r];for(let r of t)o[r.id]=r;return{...e,nodes:o}}function re(e,t){let n=e.nodes[t];if(n===void 0)throw new Error(`unknown node ${t}`);return n}function le(e,t){for(let n of Object.values(e.nodes))if(n.children.includes(t))return n}function tt(e,t){let n=[],o=[t];for(;o.length>0;){let r=o.pop();n.push(r),o.push(...e.nodes[r]?.children??[])}return n}function de(e,t,n){let o=re(e,t);return o.text===n?e:ee(e,[{...o,text:n}])}function se(e,t,n,o=""){let r=re(e,t),i=xe(),a=r.children.slice();return a.splice(Math.max(0,Math.min(n,a.length)),0,i),{doc:ee(e,[{...r,children:a,collapsed:!1},{id:i,text:o,children:[]}]),focusId:i,caret:0}}function Me(e,t,n=""){let o=le(e,t);return o===void 0?se(e,t,0,n):se(e,o.id,o.children.indexOf(t)+1,n)}function nt(e,t,n){let o=re(e,t),r=le(e,t),i=typeof o.checked=="boolean",a=w=>i?{id:xe(),text:w,children:[],checked:!1}:{id:xe(),text:w,children:[]};if(r===void 0)return se(e,t,0);let f=r.children.indexOf(t);if(n<=0&&o.text.length>0){let w=a(""),E=r.children.slice();return E.splice(f,0,w.id),{doc:ee(e,[{...r,children:E},w]),focusId:t,caret:0}}let u=o.text.slice(0,n),c=o.text.slice(n),D=a(c);if(c.length===0&&o.children.length>0&&!o.collapsed)return{doc:ee(e,[{...o,children:[D.id,...o.children]},D]),focusId:D.id,caret:0};let M=r.children.slice();return M.splice(f+1,0,D.id),{doc:ee(e,[{...r,children:M},{...o,text:u},D]),focusId:D.id,caret:0}}function Fe(e,t){let n=le(e,t);if(n===void 0)return e;let o=n.children.indexOf(t);if(o<=0)return e;let r=re(e,n.children[o-1]);return ee(e,[{...n,children:n.children.filter(i=>i!==t)},{...r,children:[...r.children,t],collapsed:!1}])}function He(e,t,n=e.rootId){let o=le(e,t);if(o===void 0||o.id===n)return e;let r=le(e,o.id);if(r===void 0)return e;let i=r.children.slice();return i.splice(i.indexOf(o.id)+1,0,t),ee(e,[{...o,children:o.children.filter(a=>a!==t)},{...r,children:i}])}function fe(e,t){let n=le(e,t);return n===void 0?e:ee(e,[{...n,children:n.children.filter(o=>o!==t)}],tt(e,t))}function ot(e,t,n){let o=re(e,t),r=le(e,t);if(r===void 0)return null;if(o.text.length===0&&o.children.length===0){if(n===void 0)return null;let c=fe(e,t);return{doc:c,focusId:n,caret:c.nodes[n]?.text.length??0}}let i=r.children.indexOf(t),a=i>0?re(e,r.children[i-1]):void 0;if(a===void 0||a.children.length>0&&!a.collapsed){if(o.children.length>0||n===void 0||n===r.id)return null;let c=e.nodes[n];if(c===void 0||c.children.length>0)return null;let D=fe(e,t);return{doc:ee(D,[{...D.nodes[c.id],text:c.text+o.text}],[]),focusId:c.id,caret:c.text.length}}let f=a,u={...f,text:f.text+o.text,children:[...f.children,...o.children]};return{doc:ee(e,[u,{...r,children:r.children.filter(c=>c!==t)}],[t]),focusId:f.id,caret:f.text.length}}function rt(e,t){let n=re(e,t),o=le(e,t);if(o===void 0||n.children.length>0)return null;let r=o.children.indexOf(t),i=o.children[r+1];if(i===void 0)return null;let a=re(e,i);return{doc:ee(e,[{...n,text:n.text+a.text,children:a.children.slice(),collapsed:a.collapsed},{...o,children:o.children.filter(f=>f!==i)}],[i]),focusId:t,caret:n.text.length}}function _e(e,t,n,o){return!(t===e.rootId||e.nodes[t]===void 0||e.nodes[n]===void 0||ke(e,t,n)||o!=="inside"&&n===e.rootId)}function Be(e,t,n,o){if(!_e(e,t,n,o))return e;let r=le(e,t),i=ee(e,[{...r,children:r.children.filter(u=>u!==t)}]);if(o==="inside"){let u=re(i,n);return ee(i,[{...u,children:[...u.children,t],collapsed:!1}])}let a=le(i,n),f=a.children.slice();return f.splice(f.indexOf(n)+(o==="after"?1:0),0,t),ee(i,[{...a,children:f}])}function De(e,t,n){let o=le(e,t);if(o===void 0)return e;let r=o.children.indexOf(t),i=r+n;if(i<0||i>=o.children.length)return e;let a=o.children.slice();return a[r]=a[i],a[i]=t,ee(e,[{...o,children:a}])}function ae(e,t,n){let o=re(e,t);return n&&o.children.length===0||!!o.collapsed===n?e:ee(e,[{...o,collapsed:n}])}function $e(e,t,n){let o=[];for(let r of tt(e,t)){if(r===t)continue;let i=e.nodes[r];i.children.length>0&&!!i.collapsed!==n&&o.push({...i,collapsed:n})}return o.length===0?e:ee(e,o)}function Ee(e,t){let n=re(e,t);return ee(e,[{...n,checked:n.checked!==!0}])}function it(e,t){let n=re(e,t),o={...n};return typeof n.checked=="boolean"?delete o.checked:o.checked=!1,ee(e,[o])}function lt(e,t,n){if(t.length===0)throw new Error("no items");let o=[],r=D=>{let M=xe(),w={id:M,text:D.text,children:[]};return typeof D.checked=="boolean"&&(w.checked=D.checked),o.push(w),w.children=D.children.map(r),M},i=t.map(r),a,f;"afterId"in n?(a=le(e,n.afterId)??re(e,e.rootId),f=a.children.indexOf(n.afterId)+1):(a=re(e,n.parentId),f=n.index);let u=a.children.slice();u.splice(f,0,...i);let c=o.find(D=>D.id===i[i.length-1]);return{doc:ee(e,[...o,{...a,children:u,collapsed:!1}]),focusId:c.id,caret:c.text.length}}function st(e,t,n){let o=[],r=a=>{for(let f of e.nodes[a]?.children??[])o.push(f),e.nodes[f]?.collapsed||r(f)};r(t);let i=o.indexOf(n);return{prev:i>0?o[i-1]:void 0,next:i>=0?o[i+1]:void 0}}function Ie(e,t=e.rootId,n=e.title){let o=[];n!==null&&n.length>0&&o.push(`# ${n}`,"");let r=(i,a)=>{for(let f of i){let u=e.nodes[f];if(u===void 0)continue;let c=" ".repeat(a),D=u.checked===!0?"[x] ":u.checked===!1?"[ ] ":"",[M="",...w]=u.text.split(`
|
|
3
|
+
`),E=`${c}- ${D}${$t(M)}`;o.push(M.length===0&&D.length===0?`${c}-`:E);for(let k of w)o.push(`${c} ${jt(k)}`);r(u.children,a+1)}};return r(e.nodes[t]?.children??[],0),o.join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`}function $t(e){let t=/^ +/.exec(e)?.[0].length??0,n=e.slice(t);return" ".repeat(t)+(t===0&&/^\[( |x|X)\]/.test(n)?"\\":"")+n}function jt(e){let t=e.trimStart();return t.length>0&&(Ne.test(t)||Se.test(t)||t.startsWith("\\"))?e.slice(0,e.length-t.length)+"\\"+t:e}function Ut(e){let t=/^(?: )+/.exec(e);return t!==null?" ".repeat(t[0].length/5)+e.slice(t[0].length):/^\\\[( |x|X)\]/.test(e)?e.slice(1):e}function Xt(e){let t=e.trimStart();if(!t.startsWith("\\"))return e;let n=t.slice(1);return Ne.test(n)||Se.test(n)||n.startsWith("\\")?e.slice(0,e.length-t.length)+n:e}var Ne=/^(\s*)([-*+]|\d{1,9}[.)])(\s+|$)(.*)$/,Se=/^(#{1,6})\s+(.*?)\s*#*\s*$/,Yt=/^\[( |x|X)\](?:\s+|$)([\s\S]*)$/;function at(e){return e.length-e.trimStart().length}function Ue(e,t={}){let n=t.detectTitle??!0,o=e.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
6
|
+
`).split(`
|
|
7
|
+
`).map(w=>w.replace(/\t/g," ")),r=o.filter(w=>/^#\s+\S/.test(w)).length,i=[],a=[],f=[],u=null,c=0,D,M=()=>a.length>0?a[a.length-1].item.children:i;for(let w of o){if(w.trim().length===0){c++;continue}let E=Se.exec(w);if(E!==null){let X=E[1].length;if(n&&D===void 0&&X===1&&r===1&&i.length===0)D=E[2];else{for(;a.length>0&&a[a.length-1].level>=X;)a.pop();let z={text:E[2],children:[]};M().push(z),a.push({level:X,item:z})}f=[],u=null,c=0;continue}let k=Ne.exec(w);if(k!==null){let X=k[1].length,z=k[4]??"",Y,F=Yt.exec(z);for(F!==null&&(Y=F[1]!==" ",z=F[2]),z=Ut(z);f.length>0&&f[f.length-1].indent>=X;)f.pop();let B={text:z,children:[]};Y!==void 0&&(B.checked=Y),(f.length>0?f[f.length-1].item.children:M()).push(B),f.push({indent:X,item:B}),u={marker:X,content:X+k[2].length+Math.max(1,k[3].length),item:B},c=0;continue}let L=at(w);if(u!==null&&L>u.marker){u.item.text+=`
|
|
8
|
+
`.repeat(c+1)+Xt(w.slice(Math.min(L,u.content))),c=0;continue}M().push({text:w.trim(),children:[]}),f=[],u=null,c=0}return D===void 0?{items:i}:{title:D,items:i}}function qt(e){let t=[],n=[];for(let o of e.replace(/\r\n?/g,`
|
|
9
|
+
`).split(`
|
|
10
|
+
`)){let r=o.replace(/\t/g," ");if(r.trim().length===0)continue;let i=at(r);for(;n.length>0&&n[n.length-1].indent>=i;)n.pop();let a={text:r.trim(),children:[]};(n.length>0?n[n.length-1].item.children:t).push(a),n.push({indent:i,item:a})}return t}function ct(e){return e.replace(/\r\n?/g,`
|
|
11
|
+
`).split(`
|
|
12
|
+
`).filter(o=>o.trim().length>0).some(o=>Ne.test(o.replace(/\t/g," "))||Se.test(o))?Ue(e,{detectTitle:!1}).items:qt(e)}function dt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\n/g," ").replace(/\r/g,"")}function ut(e){return e.replace(/&(#x[0-9a-fA-F]+|#\d+|lt|gt|quot|apos|amp);/g,(t,n)=>{if(n==="lt")return"<";if(n==="gt")return">";if(n==="quot")return'"';if(n==="apos")return"'";if(n==="amp")return"&";let o=n[1]==="x"?Number.parseInt(n.slice(2),16):Number.parseInt(n.slice(1),10);return Number.isFinite(o)&&o>0&&o<=1114111?String.fromCodePoint(o):""})}function mt(e,t=e.rootId,n=e.title){let o=['<?xml version="1.0" encoding="UTF-8"?>','<opml version="2.0">',` <head><title>${dt(n)}</title></head>`," <body>"],r=(i,a)=>{for(let f of i){let u=e.nodes[f];if(u===void 0)continue;let c=" ".repeat(a+2),D=`text="${dt(u.text)}"${typeof u.checked=="boolean"?` _checked="${u.checked}"`:""}`;u.children.length===0?o.push(`${c}<outline ${D}/>`):(o.push(`${c}<outline ${D}>`),r(u.children,a+1),o.push(`${c}</outline>`))}};return r(e.nodes[t]?.children??[],0),o.push(" </body>","</opml>"),o.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
`}function pt(e){if(!/<opml[\s>]/i.test(e))throw new Error("\u4E0D\u662F\u6709\u6548\u7684 OPML \u6587\u4EF6");let t=/<title>([\s\S]*?)<\/title>/i.exec(e),n=e.search(/<body[\s>\/]/i),o=n>=0?e.slice(n):e,r=[],i=[],a=/<outline\b([^>]*?)(\/?)>|<\/outline\s*>/gi,f;for(;(f=a.exec(o))!==null;){if(f[0].startsWith("</")){i.pop();continue}let c={},D=/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,M;for(;(M=D.exec(f[1]??""))!==null;)c[M[1]]=ut(M[2]??M[3]??"");let w={text:(c.text??c.title??"").replace(/\r/g,""),children:[]};(c._checked??c._complete)==="true"?w.checked=!0:c._checked==="false"&&(w.checked=!1),(i.length>0?i[i.length-1].children:r).push(w),f[2]!=="/"&&i.push(w)}let u=t!==null?ut(t[1].trim()):void 0;return u!==void 0&&u.length>0?{title:u,items:r}:{items:r}}var Xe="/dsh-mindmap/api";var ue=class extends Error{code;current;constructor(t,n,o){super(n),this.code=t,o!==void 0&&(this.current=o)}};async function ne(e,t,n={}){let o;try{o=await fetch(Xe+e,t===void 0?{cache:"no-store"}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),keepalive:n.keepalive===!0})}catch(i){throw new ue("network","\u65E0\u6CD5\u8FDE\u63A5\u5230\u601D\u7EF4\u5BFC\u56FE\u670D\u52A1\uFF1A"+(i instanceof Error?i.message:String(i)))}let r;try{r=await o.json()}catch{throw new ue("internal",`\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94 (HTTP ${o.status})`)}if(!r.ok)throw new ue(r.error.code,r.error.message,r.error.current);return r.value}var te={library:()=>ne("/library"),doc:e=>ne(`/docs/${e}`),createDoc:e=>ne("/docs",e),saveDoc:(e,t,n=!1)=>ne(`/docs/${e.id}/save`,{doc:e,baseRevision:t},{keepalive:n}),patchMeta:(e,t)=>ne(`/docs/${e}/meta`,t),trash:e=>ne(`/docs/${e}/trash`,{}),restore:e=>ne(`/docs/${e}/restore`,{}),purge:e=>ne(`/docs/${e}/purge`,{}),createFolder:e=>ne("/folders",{name:e}),renameFolder:(e,t)=>ne(`/folders/${e}/rename`,{name:t}),deleteFolder:e=>ne(`/folders/${e}/delete`,{}),search:e=>ne("/search?q="+encodeURIComponent(e)),backups:()=>ne("/backups"),backupNow:()=>ne("/backups/now",{}),restoreBackup:e=>ne(`/backups/${e}/restore`,{}),restoreFile:e=>ne("/restore",e),backupUrl:e=>`${Xe}/backups/${encodeURIComponent(e)}`};var $=require("react");var Ce=class{past=[];future=[];lastKey=null;lastAt=0;limit;constructor(t=200){this.limit=t}record(t,n,o=null,r=Date.now()){this.future=[];let i=o!==null&&o===this.lastKey&&r-this.lastAt<1e3;return this.lastKey=o,this.lastAt=r,i?!1:(this.past.push({state:t,selection:n}),this.past.length>this.limit&&this.past.shift(),!0)}breakMerge(){this.lastKey=null}undo(t,n){let o=this.past.pop();return o===void 0?null:(this.future.push({state:t,selection:n}),this.lastKey=null,o)}redo(t,n){let o=this.future.pop();return o===void 0?null:(this.past.push({state:t,selection:n}),this.lastKey=null,o)}canUndo(){return this.past.length>0}canRedo(){return this.future.length>0}clear(){this.past=[],this.future=[],this.lastKey=null}};var ft=800,gt=6e4;function ht(e,t){let[n,o]=(0,$.useState)(null),[r,i]=(0,$.useState)(!1),[a,f]=(0,$.useState)(null),[u,c]=(0,$.useState)("saved"),[D,M]=(0,$.useState)(null),[w,E]=(0,$.useState)(null),[k,L]=(0,$.useState)(null),[,X]=(0,$.useState)(0),[z,Y]=(0,$.useState)(0),F=(0,$.useRef)(null),B=(0,$.useRef)({rev:0}),S=(0,$.useRef)(null),h=(0,$.useRef)(!1),d=(0,$.useRef)(null),y=(0,$.useRef)(void 0),v=(0,$.useRef)(0),b=(0,$.useRef)(!1),T=(0,$.useRef)(null),I=(0,$.useRef)(new Ce(200)),R=(0,$.useRef)(0),N=(0,$.useRef)(t);N.current=t;let P=(0,$.useCallback)(async g=>{if(window.clearTimeout(y.current),y.current=void 0,d.current!==null){await d.current,h.current&&!b.current&&await P(g);return}let p=F.current;if(p===null||!h.current||b.current)return;let C=B.current,H={...p,revision:C.rev},G=g&&JSON.stringify(H).length<gt;c("saving"),S.current=p;let W=(async()=>{try{let Q=await te.saveDoc(H,C.rev,G);if(C.rev=Q.revision,N.current(Q),B.current!==C)return;v.current=0,M(null),F.current===p?(h.current=!1,c("saved")):c("dirty")}catch(Q){if(B.current!==C){console.warn("[dsh-mindmap] save of a closed document failed:",Q);return}Q instanceof ue&&Q.code==="conflict"&&Q.current!==void 0?(b.current=!0,E(Q.current),c("conflict"),M(Q.message)):Q instanceof ue&&Q.code==="invalid_input"?(b.current=!0,c("error"),M("\u4FDD\u5B58\u88AB\u62D2\u7EDD\uFF1A"+Q.message)):(c("error"),M((Q instanceof Error?Q.message:String(Q))+"\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5"),v.current=Math.min(v.current+1,6),window.clearTimeout(y.current),y.current=window.setTimeout(()=>{P(!1)},1e3*2**v.current))}})();d.current=W;try{await W}finally{d.current=null,S.current=null}h.current&&!b.current&&F.current!==p&&y.current===void 0&&(y.current=window.setTimeout(()=>{P(!1)},ft))},[]),K=(0,$.useCallback)(()=>P(!1),[P]);(0,$.useEffect)(()=>{let g=!0;if(window.clearTimeout(y.current),y.current=void 0,I.current.clear(),b.current=!1,h.current=!1,v.current=0,F.current=null,o(null),E(null),L(null),c("saved"),M(null),f(null),e===null){i(!1);return}return i(!0),te.doc(e).then(p=>{g&&(F.current=p,B.current={rev:p.revision},o(p),i(!1))},p=>{g&&(f(p instanceof Error?p.message:String(p)),i(!1))}),()=>{g=!1;let p=F.current,C=B.current,H=d.current,G=H!==null&&S.current===p;p!==null&&h.current&&!b.current&&!G&&(async()=>{H!==null&&await H.catch(()=>{});try{let W=await te.saveDoc({...p,revision:C.rev},C.rev,JSON.stringify(p).length<gt);C.rev=W.revision,N.current(W)}catch(W){console.warn("[dsh-mindmap] flush on close failed:",W)}})(),B.current={rev:0}}},[e,z,P]),(0,$.useEffect)(()=>{let g=()=>{document.visibilityState==="hidden"&&h.current&&P(!0)},p=()=>{h.current&&P(!0)};return document.addEventListener("visibilitychange",g),window.addEventListener("pagehide",p),window.addEventListener("beforeunload",p),()=>{document.removeEventListener("visibilitychange",g),window.removeEventListener("pagehide",p),window.removeEventListener("beforeunload",p)}},[P]);let _=(0,$.useCallback)(g=>{F.current=g,o(g),h.current=!0,b.current||(c(p=>p==="saving"?p:"dirty"),window.clearTimeout(y.current),y.current=window.setTimeout(()=>{P(!1)},ft))},[P]),A=(0,$.useCallback)((g,p)=>{R.current++,L({id:g,caret:p,nonce:R.current})},[]),l=(0,$.useCallback)((g,p={})=>{let C=F.current;C===null||g===C||(p.noHistory!==!0&&I.current.record(C,T.current,p.key??null),_(g),p.focus!==void 0&&A(p.focus.id,p.focus.caret),X(H=>H+1))},[_,A]),x=(0,$.useCallback)(g=>{let p=F.current;if(p===null)return;let C=g==="undo"?I.current.undo(p,T.current):I.current.redo(p,T.current);if(C===null)return;_({...C.state,revision:p.revision});let H=C.selection;H!==null&&C.state.nodes[H.nodeId]!==void 0&&A(H.nodeId,H.caret),X(G=>G+1)},[_,A]),s=(0,$.useCallback)(g=>{E(p=>(p===null||(b.current=!1,B.current.rev=p.revision,M(null),g==="theirs"?(I.current.clear(),h.current=!1,F.current=p,o(p),c("saved")):(h.current=!0,c("dirty"),window.setTimeout(()=>{P(!1)},0))),null))},[P]);return{doc:n,loading:r,loadError:a,status:u,statusMessage:D,conflict:w,focus:k,canUndo:I.current.canUndo(),canRedo:I.current.canRedo(),apply:l,setSelection:g=>{T.current=g},requestFocus:A,breakMerge:()=>I.current.breakMerge(),undo:()=>x("undo"),redo:()=>x("redo"),flush:K,resolveConflict:s,reload:()=>Y(g=>g+1)}}var Z=require("react");function Ye(e){return e.replace(/\[([^\]\n]+)\]\((https?:\/\/[^)\s]+)\)/g,"$1").replace(/\*\*([^*\n]+?)\*\*/g,"$1").replace(/~~([^~\n]+?)~~/g,"$1").replace(/`([^`\n]+)`/g,"$1").replace(/(^|[^*])\*([^*\s][^*\n]*?)\*/g,"$1$2")}var me=require("react/jsx-runtime"),Vt=/(`[^`\n]+`)|(\*\*[^*\n]+?\*\*)|(~~[^~\n]+?~~)|(\*[^*\s][^*\n]*?\*)|(\[[^\]\n]+\]\(https?:\/\/[^)\s]+\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?,。;:!?])|((?:^|(?<=\s))#[^\s#]{1,40})/g;function bt(e){return t=>{t.preventDefault(),t.stopPropagation(),window.open(e,"_blank","noopener,noreferrer")}}function ge(e,t="i"){let n=[],o=0,r=0;for(let i of e.matchAll(Vt)){let a=i.index??0;a>o&&n.push(e.slice(o,a));let f=i[0],u=t+"-"+r++;if(i[1]!==void 0)n.push((0,me.jsx)("code",{className:"mm-code",children:f.slice(1,-1)},u));else if(i[2]!==void 0)n.push((0,me.jsx)("strong",{children:ge(f.slice(2,-2),u)},u));else if(i[3]!==void 0)n.push((0,me.jsx)("s",{children:ge(f.slice(2,-2),u)},u));else if(i[4]!==void 0)n.push((0,me.jsx)("em",{children:ge(f.slice(1,-1),u)},u));else if(i[5]!==void 0){let c=f.indexOf("]("),D=f.slice(c+2,-1);n.push((0,me.jsx)("a",{href:D,className:"mm-link",onMouseDown:M=>M.stopPropagation(),onClick:bt(D),children:f.slice(1,c)},u))}else i[6]!==void 0?n.push((0,me.jsx)("a",{href:f,className:"mm-link",onMouseDown:c=>c.stopPropagation(),onClick:bt(f),children:f},u)):n.push((0,me.jsx)("span",{className:"mm-tag",children:f},u));o=a+f.length}return o<e.length&&n.push(e.slice(o)),n}var q=require("react"),J=require("react/jsx-runtime"),Zt={plus:"M12 5v14M5 12h14",folderPlus:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM12 11v5M9.5 13.5h5",folder:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",doc:"M7 3h7l5 5v11a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM14 3v5h5",star:"M12 3.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8-5.2-2.7-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z",search:"M11 4a7 7 0 1 1 0 14 7 7 0 0 1 0-14zM20 20l-4-4",chevron:"M6 9l6 6 6-6",chevronRight:"M9 6l6 6-6 6",undo:"M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3",redo:"M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3",more:"M5 12h.01M12 12h.01M19 12h.01",download:"M12 4v11M7 10l5 5 5-5M5 20h14",upload:"M12 20V9M7 14l5-5 5 5M5 4h14",trash:"M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13",menu:"M4 6h16M4 12h16M4 18h16",fit:"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5",center:"M12 8a4 4 0 1 1 0 8 4 4 0 0 1 0-8zM12 2v3M12 19v3M2 12h3M19 12h3",minus:"M5 12h14",expand:"M7 10l5-5 5 5M7 14l5 5 5-5",collapse:"M7 5l5 5 5-5M7 19l5-5 5 5",backup:"M4 7c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zM4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",x:"M6 6l12 12M18 6L6 18",mindmap:"M9 12h3M12 12c2 0 2-5 4-5h1M12 12c2 0 2 5 4 5h1M4 10h5v4H4zM17 5h4v4h-4zM17 15h4v4h-4z",outline:"M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01"};function V(e){let t=e.size??16;return(0,J.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,J.jsx)("path",{d:Zt[e.name]??""})})}function vt(e){let t=(0,q.useRef)(null),[n,o]=(0,q.useState)({x:e.x,y:e.y}),r=e.onClose;return(0,q.useLayoutEffect)(()=>{let i=t.current;if(i===null)return;let a=i.getBoundingClientRect();o({x:Math.max(4,Math.min(e.x,window.innerWidth-a.width-4)),y:Math.max(4,Math.min(e.y,window.innerHeight-a.height-4))}),i.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})},[e.x,e.y]),(0,q.useEffect)(()=>{let i=f=>{t.current!==null&&!t.current.contains(f.target)&&r()},a=f=>{if(f.key==="Escape"){f.preventDefault(),f.stopPropagation(),r();return}if(f.key==="ArrowDown"||f.key==="ArrowUp"){f.preventDefault();let u=Array.from(t.current?.querySelectorAll("button:not(:disabled)")??[]);if(u.length===0)return;let c=u.indexOf(document.activeElement);u[(c+(f.key==="ArrowDown"?1:u.length-1)+u.length)%u.length]?.focus()}};return window.addEventListener("mousedown",i,!0),window.addEventListener("keydown",a,!0),window.addEventListener("blur",r),window.addEventListener("resize",r),()=>{window.removeEventListener("mousedown",i,!0),window.removeEventListener("keydown",a,!0),window.removeEventListener("blur",r),window.removeEventListener("resize",r)}},[r]),(0,J.jsx)("div",{ref:t,className:"mm-menu",role:"menu",style:{left:n.x,top:n.y},onContextMenu:i=>i.preventDefault(),children:e.items.map((i,a)=>i.kind==="sep"?(0,J.jsx)("div",{className:"mm-menu-sep",role:"separator"},a):i.kind==="label"?(0,J.jsx)("div",{className:"mm-menu-label",children:i.label},a):(0,J.jsxs)("button",{type:"button",role:"menuitem",disabled:i.disabled,className:"mm-menu-item"+(i.danger===!0?" mm-danger":""),onClick:()=>{r(),i.onSelect()},children:[i.label,i.shortcut!==void 0?(0,J.jsx)("span",{className:"mm-menu-key",children:i.shortcut}):null]},a))})}var xt=(0,q.createContext)(null);function be(){let e=(0,q.useContext)(xt);if(e===null)throw new Error("useDialogs outside DialogHost");return e}function yt(e){let[t,n]=(0,q.useState)(null),[o,r]=(0,q.useState)(null),i=(0,q.useRef)(void 0),a=(0,q.useMemo)(()=>({confirm:u=>new Promise(c=>n({kind:"confirm",title:u.title,message:u.message,ok:u.ok??"\u786E\u5B9A",danger:u.danger===!0,resolve:c})),prompt:u=>new Promise(c=>n({kind:"prompt",title:u.title,value:u.value??"",placeholder:u.placeholder??"",ok:u.ok??"\u786E\u5B9A",resolve:c})),show:u=>n({kind:"custom",title:u.title,body:u.body}),toast:u=>{r(u),window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(null),2600)}}),[]);(0,q.useEffect)(()=>()=>window.clearTimeout(i.current),[]);let f=(0,q.useCallback)(()=>n(null),[]);return(0,J.jsxs)(xt.Provider,{value:a,children:[e.children,t!==null?(0,J.jsx)(Wt,{pending:t,onDone:f}):null,o!==null?(0,J.jsx)("div",{className:"mm-toast",role:"status",children:o}):null]})}function Wt(e){let t=e.pending,[n,o]=(0,q.useState)(t.kind==="prompt"?t.value:""),r=(0,q.useRef)(null),i=(0,q.useRef)(null),a=(0,q.useRef)(null);(0,q.useEffect)(()=>{let c=document.activeElement;return t.kind==="prompt"?(r.current?.focus(),r.current?.select()):i.current!==null?i.current.focus():a.current?.querySelector("button")?.focus(),()=>{c!==null&&document.contains(c)&&c.focus({preventScroll:!0})}},[t]);let f=c=>{e.onDone(),t.kind==="confirm"?t.resolve(c):t.kind==="prompt"&&t.resolve(c?n:null)};return(0,J.jsx)("div",{className:"mm-modal-mask",onMouseDown:c=>{c.target===c.currentTarget&&f(!1)},onKeyDown:c=>{c.key==="Escape"?(c.preventDefault(),c.stopPropagation(),f(!1)):c.key==="Enter"&&t.kind!=="custom"&&!c.nativeEvent.isComposing&&c.keyCode!==229&&(c.preventDefault(),f(!0))},children:(0,J.jsxs)("div",{ref:a,className:"mm-modal",role:"dialog","aria-modal":"true","aria-label":t.title,children:[(0,J.jsx)("h3",{children:t.title}),(0,J.jsxs)("div",{className:"mm-modal-body",children:[t.kind==="confirm"&&t.message!==void 0?(0,J.jsx)("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:t.message}):null,t.kind==="prompt"?(0,J.jsx)("input",{ref:r,type:"text","aria-label":t.title,value:n,placeholder:t.placeholder,onChange:c=>o(c.target.value)}):null,t.kind==="custom"?t.body(e.onDone):null]}),t.kind!=="custom"?(0,J.jsxs)("div",{className:"mm-modal-foot",children:[(0,J.jsx)("button",{type:"button",className:"mm-btn",onClick:()=>f(!1),children:"\u53D6\u6D88"}),(0,J.jsx)("button",{ref:i,type:"button",className:"mm-btn mm-primary"+(t.kind==="confirm"&&t.danger?" mm-danger":""),onClick:()=>f(!0),children:t.ok})]}):(0,J.jsx)("div",{className:"mm-modal-foot",children:(0,J.jsx)("button",{type:"button",className:"mm-btn",onClick:e.onDone,children:"\u5173\u95ED"})})]})})}function wt(e,t=Date.now()){let n=Math.max(0,t-e);if(n<6e4)return"\u521A\u521A";if(n<36e5)return Math.floor(n/6e4)+" \u5206\u949F\u524D";if(n<864e5)return Math.floor(n/36e5)+" \u5C0F\u65F6\u524D";if(n<7*864e5)return Math.floor(n/864e5)+" \u5929\u524D";let o=new Date(e);return(new Date(t).getFullYear()===o.getFullYear()?"":o.getFullYear()+"/")+(o.getMonth()+1)+"/"+o.getDate()}function ye(e,t){let n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),o.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)}function we(e,t){return(e.replace(/[\/:*?"<>|\u0000-\u001f]+/g,"_").trim().slice(0,80)||"\u672A\u547D\u540D\u6587\u6863")+"."+t}var oe=require("react/jsx-runtime"),qe=24,Gt="application/x-dsh-mindmap-node";function Jt(e,t,n,o){let r=e.ownerDocument,i=null,a=0;if(typeof r.caretPositionFromPoint=="function"){let c=r.caretPositionFromPoint(t,n);c!==null&&(i=c.offsetNode,a=c.offset)}else if(typeof r.caretRangeFromPoint=="function"){let c=r.caretRangeFromPoint(t,n);c!==null&&(i=c.startContainer,a=c.startOffset)}if(i===null||!e.contains(i)||e.textContent!==o)return"end";let f=r.createTreeWalker(e,NodeFilter.SHOW_TEXT),u=0;for(let c=f.nextNode();c!==null;c=f.nextNode()){if(c===i)return u+a;u+=c.textContent?.length??0}return"end"}var Qt=(0,Z.memo)(function(t){let{node:n,depth:o,ctl:r}=t,i=n.children.length>0,a=(0,Z.useRef)(null),f="mm-node"+(n.checked===!0?" mm-done":"")+(t.drop!==null?" mm-drop-"+t.drop:"")+(t.dragging?" mm-dragging":"");return(0,oe.jsxs)("div",{className:f,"data-node-id":n.id,role:"treeitem","aria-level":o+1,"aria-expanded":i?!n.collapsed:void 0,style:{paddingLeft:o*qe,"--mm-drop-left":o*qe+40+"px"},onDragOver:u=>r.dragOver(u,n.id,o),onDrop:r.drop,onContextMenu:u=>r.menu(u,n.id),children:[(0,oe.jsx)("button",{type:"button",tabIndex:-1,className:"mm-fold"+(n.collapsed===!0?" mm-closed mm-show":""),style:{visibility:i?"visible":"hidden"},"aria-label":n.collapsed===!0?"\u5C55\u5F00":"\u6298\u53E0",onClick:()=>r.toggleFold(n.id),children:(0,oe.jsx)(V,{name:"chevron",size:14})}),(0,oe.jsx)("button",{type:"button",tabIndex:-1,className:"mm-bullet"+(i&&n.collapsed===!0?" mm-collapsed":""),draggable:!0,title:"\u70B9\u51FB\u805A\u7126\uFF0C\u62D6\u52A8\u79FB\u52A8","aria-label":"\u805A\u7126\u6B64\u8282\u70B9",onClick:()=>r.zoom(n.id),onDragStart:u=>r.dragStart(u,n.id),onDragEnd:r.dragEnd,children:(0,oe.jsx)("span",{className:"mm-dot"})}),typeof n.checked=="boolean"?(0,oe.jsx)("input",{type:"checkbox",className:"mm-check",tabIndex:-1,checked:n.checked,"aria-label":"\u5B8C\u6210",onChange:()=>r.toggleCheck(n.id)}):null,t.editing?(0,oe.jsx)("textarea",{ref:r.bindInput,className:"mm-input",rows:1,value:n.text,spellCheck:!1,"aria-label":"\u8282\u70B9\u5185\u5BB9",onChange:u=>r.change(n.id,u.target.value,u.target.selectionStart),onKeyDown:u=>r.key(u,n.id),onSelect:u=>r.select(n.id,u.currentTarget.selectionStart),onPaste:u=>r.paste(u,n.id),onBlur:()=>r.blur(n.id)}):(0,oe.jsx)("div",{ref:a,className:"mm-text",onMouseDown:u=>{u.button===0&&(u.preventDefault(),r.startEdit(n.id,a.current!==null?Jt(a.current,u.clientX,u.clientY,n.text):"end"))},children:ge(n.text)})]})});function kt(e){let{state:t,doc:n,rootId:o}=e,r=be(),[i,a]=(0,Z.useState)(null),[f,u]=(0,Z.useState)(null),[c,D]=(0,Z.useState)(null),M=(0,Z.useRef)(null);M.current=i;let w=(0,Z.useRef)(null),E=(0,Z.useRef)(null),k=(0,Z.useRef)(n);k.current=n;let L=(0,Z.useRef)(e);L.current=e;let X=(0,Z.useMemo)(()=>et(n,o,!0),[n,o]);(0,Z.useEffect)(()=>{let h=t.focus;h===null||n.nodes[h.id]===void 0||(w.current=h.caret,a(h.id),M.current===h.id&&z())},[t.focus]);function z(){let h=E.current;if(h===null)return;let d=w.current;if(document.activeElement!==h&&h.focus({preventScroll:!0}),d!==null){let y=d==="end"?h.value.length:d==="start"?0:Math.min(d,h.value.length);h.setSelectionRange(y,y),w.current=null}h.scrollIntoView({block:"nearest"})}(0,Z.useLayoutEffect)(()=>{let h=E.current;h!==null&&(h.style.height="0px",h.style.height=h.scrollHeight+"px")}),(0,Z.useLayoutEffect)(()=>{i!==null&&z()},[i]);let Y=(0,Z.useMemo)(()=>{let h=(v,b,T)=>{L.current.state.apply(v,{focus:b,key:T})},d=v=>st(k.current,L.current.rootId,v),y=(v,b)=>{v!==void 0&&(w.current=b,a(v))};return{startEdit(v,b){w.current=b,M.current===v&&z(),a(v)},toggleFold(v){let b=k.current;L.current.state.apply(ae(b,v,b.nodes[v]?.collapsed!==!0),{noHistory:!0})},toggleCheck(v){h(Ee(k.current,v))},zoom(v){L.current.onZoom(v)},bindInput(v){E.current=v},change(v,b,T){L.current.state.setSelection({nodeId:v,caret:T}),h(de(k.current,v,b),void 0,"text:"+v)},select(v,b){L.current.state.setSelection({nodeId:v,caret:b})},blur(v){L.current.state.breakMerge(),window.setTimeout(()=>{M.current===v&&document.activeElement!==E.current&&a(null)},0)},key(v,b){if(v.nativeEvent.isComposing||v.keyCode===229)return;let T=v.currentTarget,I=k.current,R=L.current.rootId,N=T.selectionStart,P=T.selectionEnd,K=T.value,_=v.ctrlKey||v.metaKey,A=v.key,l=()=>{v.preventDefault(),v.stopPropagation()};if(L.current.state.setSelection({nodeId:b,caret:N}),_&&!v.altKey&&(A==="z"||A==="Z")){l(),v.shiftKey?L.current.state.redo():L.current.state.undo();return}if(_&&!v.altKey&&(A==="y"||A==="Y")){l(),L.current.state.redo();return}if(_&&(A==="b"||A==="i")){l();let x=A==="b"?"**":"*",s=K.slice(0,N)+x+K.slice(N,P)+x+K.slice(P);h(de(I,b,s),{id:b,caret:P+x.length*(N===P?1:2)});return}if(_&&A==="."){l(),h(ae(I,b,I.nodes[b]?.collapsed!==!0),{id:b,caret:N});return}if(A==="Enter"&&_){l(),h(Ee(I,b),{id:b,caret:N});return}if(A==="Enter"&&!v.shiftKey&&!v.altKey){l();let x=N!==P?de(I,b,K.slice(0,N)+K.slice(P)):I,s=nt(x,b,N);h(s.doc,{id:s.focusId,caret:s.caret});return}if(A==="Tab"&&!_&&!v.altKey){l();let x=v.shiftKey?He(I,b,R):Fe(I,b);x!==I&&h(x,{id:b,caret:N});return}if(A==="Escape"){l(),T.blur(),a(null);return}if(v.altKey&&!_&&(A==="ArrowUp"||A==="ArrowDown")){l();let x=De(I,b,A==="ArrowUp"?-1:1);x!==I&&h(x,{id:b,caret:N});return}if(v.altKey&&!_&&A==="ArrowRight"){l(),L.current.onZoom(b);return}if(v.altKey&&!_&&A==="ArrowLeft"){if(l(),R!==I.rootId){let x=he(I,R);L.current.onZoom(x[x.length-1]??I.rootId)}return}if(!(v.altKey||_||v.shiftKey)){if(A==="Backspace"&&N===0&&P===0){let x=ot(I,b,d(b).prev);x!==null&&(l(),h(x.doc,{id:x.focusId,caret:x.caret}));return}if(A==="Delete"&&N===K.length&&P===K.length){let x=rt(I,b);x!==null&&(l(),h(x.doc,{id:x.focusId,caret:x.caret}));return}if(A==="ArrowUp"&&N===P&&K.lastIndexOf(`
|
|
15
|
+
`,N-1)===-1){let x=d(b).prev;if(x!==void 0){l();let s=I.nodes[x].text,g=s.lastIndexOf(`
|
|
16
|
+
`)+1;y(x,Math.min(g+N,s.length))}return}if(A==="ArrowDown"&&N===P&&K.indexOf(`
|
|
17
|
+
`,N)===-1){let x=d(b).next;if(x!==void 0){l();let s=N-(K.lastIndexOf(`
|
|
18
|
+
`,N-1)+1),g=I.nodes[x].text,p=g.indexOf(`
|
|
19
|
+
`);y(x,Math.min(s,p===-1?g.length:p))}return}if(A==="ArrowLeft"&&N===0&&P===0){let x=d(b).prev;x!==void 0&&(l(),y(x,"end"));return}if(A==="ArrowRight"&&N===K.length&&P===K.length){let x=d(b).next;x!==void 0&&(l(),y(x,"start"))}}},paste(v,b){let T=v.clipboardData.getData("text/plain").replace(/\r\n?/g,`
|
|
20
|
+
`).replace(/\n+$/,"");if(!T.includes(`
|
|
21
|
+
`))return;let I=ct(T);if(I.length===0||I.length===1&&I[0].children.length===0)return;v.preventDefault();let R=k.current,N=R.nodes[b],P=lt(R,I,{afterId:b}),K=P.doc;N.text.length===0&&N.children.length===0&&(K=fe(K,b)),P={...P,doc:K},h(P.doc,{id:P.focusId,caret:"end"})},menu(v,b){v.preventDefault();let T=L.current,I=k.current,R=I.nodes[b],N=(K,_=b)=>{let A=K();A!==k.current&&h(A,{id:_,caret:"end"})},P=(K,_)=>{navigator.clipboard.writeText(K).then(()=>r.toast(_),()=>r.toast("\u65E0\u6CD5\u5199\u5165\u526A\u8D34\u677F"))};T.onMenu({x:v.clientX,y:v.clientY,items:[{label:"\u5728\u4E0B\u65B9\u6DFB\u52A0\u8282\u70B9",shortcut:"Enter",onSelect:()=>{let K=Me(k.current,b);h(K.doc,{id:K.focusId,caret:0})}},{label:"\u6DFB\u52A0\u5B50\u8282\u70B9",onSelect:()=>{let K=se(k.current,b,R.children.length);h(K.doc,{id:K.focusId,caret:0})}},{kind:"sep"},{label:"\u7F29\u8FDB",shortcut:"Tab",onSelect:()=>N(()=>Fe(k.current,b))},{label:"\u53D6\u6D88\u7F29\u8FDB",shortcut:"Shift+Tab",onSelect:()=>N(()=>He(k.current,b,T.rootId))},{label:"\u4E0A\u79FB",shortcut:"Alt+\u2191",onSelect:()=>N(()=>De(k.current,b,-1))},{label:"\u4E0B\u79FB",shortcut:"Alt+\u2193",onSelect:()=>N(()=>De(k.current,b,1))},{kind:"sep"},{label:R.children.length===0?"\u6298\u53E0\uFF08\u65E0\u5B50\u8282\u70B9\uFF09":R.collapsed===!0?"\u5C55\u5F00":"\u6298\u53E0",shortcut:"Ctrl+.",disabled:R.children.length===0,onSelect:()=>N(()=>ae(k.current,b,R.collapsed!==!0))},{label:typeof R.checked=="boolean"?"\u53D6\u6D88\u5F85\u529E":"\u8BBE\u4E3A\u5F85\u529E",onSelect:()=>N(()=>it(k.current,b))},{label:R.checked===!0?"\u6807\u8BB0\u4E3A\u672A\u5B8C\u6210":"\u6807\u8BB0\u4E3A\u5B8C\u6210",shortcut:"Ctrl+Enter",onSelect:()=>N(()=>Ee(k.current,b))},{label:"\u805A\u7126\u6B64\u8282\u70B9",shortcut:"Alt+\u2192",onSelect:()=>T.onZoom(b)},{kind:"sep"},{label:"\u590D\u5236\u4E3A Markdown",onSelect:()=>P(Ie({...I,nodes:{...I.nodes,__copy:{id:"__copy",text:"",children:[b]}}},"__copy",null),"\u5DF2\u590D\u5236 Markdown\uFF08\u542B\u5B50\u8282\u70B9\uFF09")},{label:"\u590D\u5236\u6587\u672C",onSelect:()=>P(R.text,"\u5DF2\u590D\u5236")},{kind:"sep"},{label:R.children.length>0?"\u5220\u9664\u8282\u70B9\u53CA\u5176\u5B50\u8282\u70B9":"\u5220\u9664\u8282\u70B9",danger:!0,onSelect:()=>{let{prev:K,next:_}=d(b),A=fe(k.current,b);T.state.apply(A,K!==void 0?{focus:{id:K,caret:"end"}}:_!==void 0&&A.nodes[_]!==void 0?{focus:{id:_,caret:0}}:{}),r.toast("\u5DF2\u5220\u9664\uFF0C\u53EF\u6309 Ctrl+Z \u64A4\u9500")}}]})},dragStart(v,b){let T=k.current;v.dataTransfer.effectAllowed="move",v.dataTransfer.setData(Gt,b),v.dataTransfer.setData("text/plain",Ke(T,[b]).map(R=>R.text).join(`
|
|
22
|
+
`));let I=v.currentTarget.closest(".mm-node");I!==null&&v.dataTransfer.setDragImage(I,20,15),F.current=b,D(b),a(null)},dragOver(v,b,T){let I=F.current;if(I===null)return;let R=v.currentTarget.getBoundingClientRect(),N=(v.clientY-R.top)/R.height,P=v.clientX-R.left-T*qe,K=k.current,_=K.nodes[b],A=N<.3?"before":N>.7?"after":"inside";if(A==="after"&&P>64&&(_.children.length===0||_.collapsed===!0)&&(A="inside"),A==="after"&&_.children.length>0&&_.collapsed!==!0&&(A="inside"),!_e(K,I,b,A)){B.current=null,u(null);return}B.current={id:b,pos:A},v.preventDefault(),v.dataTransfer.dropEffect="move",u(l=>l?.id===b&&l.pos===A?l:{id:b,pos:A})},drop(v){let b=F.current,T=B.current;if(F.current=null,B.current=null,u(null),D(null),b===null||T===null)return;v.preventDefault();let I=k.current,R=T.pos==="inside"?ae(I,T.id,!1):I;if(R=Be(R,b,T.id,T.pos),T.pos==="inside"){let N=R.nodes[T.id].children;N[N.length-1]===b&&N.length>1&&(R=Be(R,b,N[0],"before"))}R!==I&&h(R)},dragEnd(){F.current=null,B.current=null,u(null),D(null)}}},[]),F=(0,Z.useRef)(null);F.current=c;let B=(0,Z.useRef)(null);B.current=f;let S=(0,Z.useCallback)(()=>{let h=se(k.current,L.current.rootId,k.current.nodes[L.current.rootId]?.children.length??0);L.current.state.apply(h.doc,{focus:{id:h.focusId,caret:0}})},[]);return(0,oe.jsxs)("div",{className:"mm-outline",role:"tree","aria-label":"\u5927\u7EB2",onDragLeave:h=>{h.currentTarget===h.target&&u(null)},children:[X.map(h=>{let d=n.nodes[h.id];return(0,oe.jsx)(Qt,{node:d,depth:h.depth,editing:i===h.id,drop:f?.id===h.id?f.pos:null,dragging:c===h.id,ctl:Y},h.id)}),X.length===0?(0,oe.jsxs)("button",{type:"button",className:"mm-add",onClick:S,children:[(0,oe.jsx)(V,{name:"plus",size:14}),"\u6DFB\u52A0\u8282\u70B9"]}):(0,oe.jsx)("div",{style:{height:40,cursor:"text"},onMouseDown:h=>{h.preventDefault();let d=n.nodes[o]?.children??[],y=d[d.length-1];y!==void 0&&n.nodes[y].text.length===0&&n.nodes[y].children.length===0?Y.startEdit(y,"end"):S()}})]})}var j=require("react");var ve=20,Oe=12,Re=7,Te=260,en=56,Mt=12;function Ae(e){let n=(typeof document<"u"?document.createElement("canvas"):null)?.getContext("2d")??null;return(o,r)=>n===null?o.length*8:(n.font=(r?"600 ":"")+"14px "+e,n.measureText(o).width)}function tn(e,t,n){let o=[];for(let r of Ye(e).split(`
|
|
23
|
+
`)){if(t(r,n)<=Te){o.push(r);continue}let i="";for(let a of r.match(/[\u2e80-\u9fff\uac00-\ud7af\uff00-\uffef]|[^\s\u2e80-\u9fff\uac00-\ud7af\uff00-\uffef]+|\s+/g)??[])if(t(i+a,n)<=Te||i.length===0)if(t(a,n)>Te&&i.length===0)for(let f of a)t(i+f,n)>Te&&i.length>0&&(o.push(i),i=""),i+=f;else i+=a;else o.push(i.trimEnd()),i=a.trimStart();o.push(i)}return o.length===0?[""]:o}function Pe(e,t,n,o){let r=[],i=new Map,a=0,f=(c,D,M,w,E)=>{let k=e.nodes[c],L=D===0,X=L?n:k.text,z=tn(X.length>0?X:" ",o,L),Y=Math.max(...z.map(R=>o(R,L)),24),F=Math.ceil(Y)+Oe*2,B=z.length*ve+Re*2,S=L||k.collapsed!==!0?k.children:[],h={id:c,depth:D,x:M,y:0,w:F,h:B,lines:z,parent:E,hasKids:k.children.length>0,collapsed:!L&&k.collapsed===!0&&k.children.length>0,hidden:0,done:k.checked===!0};if(h.collapsed){let R=0,N=P=>{for(let K of e.nodes[P]?.children??[])R++,N(K)};N(c),h.hidden=R}r.push(h),i.set(c,h),a=Math.max(a,M+F);let d=M+F+en,y=w,v=[];for(let R of S){let N=f(R,D+1,d,y,c);v.push(i.get(R).y+i.get(R).h/2),y+=N+Mt}let b=S.length>0?y-Mt-w:0,T=Math.max(B,b),I=v.length>0?(v[0]+v[v.length-1])/2:w+T/2;if(h.y=I-B/2,h.y<w){let R=w-h.y;h.y=w;let N=P=>{let K=i.get(P);K.y+=R;for(let _ of K.collapsed?[]:e.nodes[P].children)i.has(_)&&N(_)};for(let P of S)N(P)}return Math.max(T,h.y+B-w)},u=f(t,0,0,0,null);return{nodes:r,byId:i,width:a,height:u}}function Ve(e,t){let n=e.x+e.w,o=e.y+e.h/2,r=t.x,i=t.y+t.h/2,a=(n+r)/2;return"M"+n+","+o+" C"+a+","+o+" "+a+","+i+" "+r+","+i}var ce=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function Dt(e,t){let o=Math.ceil(e.width+64+40),r=Math.ceil(e.height+64),i=[];i.push('<svg xmlns="http://www.w3.org/2000/svg" width="'+o+'" height="'+r+'" viewBox="0 0 '+o+" "+r+'" font-family="'+ce(t.font)+'" font-size="14">'),i.push('<rect width="100%" height="100%" fill="'+ce(t.bg)+'"/>'),i.push('<g transform="translate(32,32)">');for(let a of e.nodes)a.parent!==null&&i.push('<path d="'+Ve(e.byId.get(a.parent),a)+'" fill="none" stroke="'+ce(t.border)+'" stroke-width="1.5"/>');for(let a of e.nodes){let f=a.depth===0,u=f?t.accent:a.depth===1?t.panel:t.card,c=f?t.accent:t.border,D=f?"#ffffff":a.done?t.sub:t.text;if(i.push('<rect x="'+a.x+'" y="'+a.y+'" width="'+a.w+'" height="'+a.h+'" rx="6" fill="'+ce(u)+'" stroke="'+ce(c)+'"/>'),a.lines.forEach((M,w)=>{i.push('<text x="'+(a.x+Oe)+'" y="'+(a.y+Re+ve*w+ve/2)+'" dominant-baseline="central" fill="'+ce(D)+'"'+(f?' font-weight="600"':"")+(a.done?' text-decoration="line-through"':"")+' xml:space="preserve">'+ce(M)+"</text>")}),a.collapsed){let M=a.x+a.w+10,w=a.y+a.h/2;i.push('<circle cx="'+M+'" cy="'+w+'" r="8" fill="'+ce(t.card)+'" stroke="'+ce(t.border)+'"/>'),i.push('<text x="'+M+'" y="'+w+'" font-size="10" text-anchor="middle" dominant-baseline="central" fill="'+ce(t.sub)+'">'+(a.hidden>99?"99+":a.hidden)+"</text>")}}return i.push("</g></svg>"),{svg:i.join(""),width:o,height:r}}async function Et(e,t,n,o=2){let r=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"}));try{let i=new Image;await new Promise((D,M)=>{i.onload=()=>D(),i.onerror=()=>M(new Error("\u56FE\u7247\u6E32\u67D3\u5931\u8D25")),i.src=r});let a=16e3,f=Math.min(o,a/t,a/n),u=document.createElement("canvas");u.width=Math.max(1,Math.floor(t*f)),u.height=Math.max(1,Math.floor(n*f));let c=u.getContext("2d");if(c===null)throw new Error("\u65E0\u6CD5\u521B\u5EFA\u753B\u5E03");return c.scale(f,f),c.drawImage(i,0,0,t,n),await new Promise((D,M)=>u.toBlob(w=>w!==null?D(w):M(new Error("PNG \u7F16\u7801\u5931\u8D25")),"image/png"))}finally{URL.revokeObjectURL(r)}}function It(e){let t=getComputedStyle(e),n=(o,r)=>t.getPropertyValue(o).trim()||r;return{bg:n("--mm-bg","#ffffff"),text:n("--mm-text","#1f2329"),sub:n("--mm-sub","#8a8f99"),border:n("--mm-border-strong","#c9ccd1"),accent:n("--mm-accent","#3964fe"),panel:n("--mm-panel","#f7f7f8"),card:n("--mm-elev","#ffffff"),font:t.fontFamily||"sans-serif"}}var U=require("react/jsx-runtime"),nn=.2,on=3,Nt=e=>Math.min(on,Math.max(nn,e));function St(e){let{doc:t,rootId:n,state:o}=e,r=(0,j.useRef)(null),[i,a]=(0,j.useState)({x:40,y:40,k:1}),[f,u]=(0,j.useState)(null),[c,D]=(0,j.useState)(!1),M=(0,j.useRef)(null),w=(0,j.useRef)(null),E=(0,j.useRef)(i);E.current=i;let[k,L]=(0,j.useState)("");(0,j.useLayoutEffect)(()=>{r.current!==null&&L(getComputedStyle(r.current).fontFamily||"sans-serif")},[]);let X=(0,j.useMemo)(()=>Ae(k||"sans-serif"),[k]),z=(0,j.useMemo)(()=>Pe(t,n,e.rootLabel,X),[t,n,e.rootLabel,X]),Y=e.selected!==null&&z.byId.has(e.selected)?e.selected:null,F=()=>{let l=r.current?.getBoundingClientRect();return{w:l?.width??800,h:l?.height??600}},B=(0,j.useCallback)(()=>{let{w:l,h:x}=F(),s=Nt(Math.min((l-80)/Math.max(z.width+40,1),(x-80)/Math.max(z.height,1),1));a({k:s,x:(l-(z.width+20)*s)/2,y:(x-z.height*s)/2})},[z]),S=(0,j.useCallback)((l,x=E.current.k)=>{let s=z.byId.get(l);if(s===void 0)return;let{w:g,h:p}=F();a({k:x,x:g/2-(s.x+s.w/2)*x,y:p/2-(s.y+s.h/2)*x})},[z]),h=(0,j.useCallback)((l,x,s)=>{let g=E.current,{w:p,h:C}=F(),H=x??p/2,G=s??C/2,W=Nt(g.k*l);a({k:W,x:H-(H-g.x)/g.k*W,y:G-(G-g.y)/g.k*W})},[]);(0,j.useLayoutEffect)(()=>{if(k==="")return;let l=t.id+":"+n;w.current!==l&&(w.current=l,B())},[t.id,n,B,k]),(0,j.useEffect)(()=>{if(Y===null)return;let l=z.byId.get(Y),x=E.current,{w:s,h:g}=F(),p=x.x+l.x*x.k,C=x.y+l.y*x.k,H=24,G=0,W=0;p<H?G=H-p:p+l.w*x.k>s-H&&(G=s-H-(p+l.w*x.k)),C<H?W=H-C:C+l.h*x.k>g-H&&(W=g-H-(C+l.h*x.k)),(G!==0||W!==0)&&a({...x,x:x.x+G,y:x.y+W})},[Y,z]),(0,j.useEffect)(()=>{let l=r.current;if(l===null)return;let x=s=>{s.preventDefault();let g=l.getBoundingClientRect();s.ctrlKey||s.metaKey?h(Math.exp(-s.deltaY*.0025),s.clientX-g.left,s.clientY-g.top):a(p=>({...p,x:p.x-(s.shiftKey?s.deltaY:s.deltaX),y:p.y-(s.shiftKey?0:s.deltaY)}))};return l.addEventListener("wheel",x,{passive:!1}),()=>l.removeEventListener("wheel",x)},[h]);let d=(0,j.useCallback)(l=>{u(null),l!==null&&(l.id===n&&n===t.rootId?l.text.trim()!==t.title&&o.apply({...t,title:l.text.replace(/\n/g," ").trim()||t.title}):t.nodes[l.id]!==void 0&&t.nodes[l.id].text!==l.text&&o.apply(de(t,l.id,l.text)),r.current?.focus({preventScroll:!0}))},[t,n,o]),y=(l,x)=>{let s=l===t.rootId?t.title:t.nodes[l]?.text??"";e.onSelect(l),u({id:l,text:x??s})},v=l=>{let x=t.nodes[l],s=ae(t,l,!1),g=se(s,l,x.children.length);o.apply(g.doc),e.onSelect(g.focusId),u({id:g.focusId,text:""})},b=l=>{if(l===n){v(l);return}let x=Me(t,l);o.apply(x.doc),e.onSelect(x.focusId),u({id:x.focusId,text:""})},T=l=>{if(l===n)return;let s=z.byId.get(l)?.parent??null,g=s!==null?t.nodes[s].children:[],p=g.indexOf(l),C=g[p+1]??g[p-1]??s;o.apply(fe(t,l)),e.onSelect(C)},I=l=>{let x=t.nodes[l];x===void 0||x.children.length===0||l===n||o.apply(ae(t,l,x.collapsed!==!0),{noHistory:!0})},R=l=>{if(f!==null||l.target!==l.currentTarget||l.nativeEvent.isComposing||l.keyCode===229)return;let x=l.ctrlKey||l.metaKey,s=l.key;if(x&&(s==="z"||s==="Z")){l.preventDefault(),l.shiftKey?o.redo():o.undo();return}if(x&&(s==="y"||s==="Y")){l.preventDefault(),o.redo();return}if(x&&(s==="="||s==="+")){l.preventDefault(),h(1.2);return}if(x&&s==="-"){l.preventDefault(),h(1/1.2);return}if(x&&s==="0"){l.preventDefault(),B();return}let g=Y??n,p=z.byId.get(g);if(p!==void 0){if(s==="Tab"){l.preventDefault(),v(g);return}if(s==="Enter"){l.preventDefault(),b(g);return}if(s==="F2"){l.preventDefault(),y(g);return}if(s==="Delete"||s==="Backspace"){l.preventDefault(),T(g);return}if(s===" "){l.preventDefault(),I(g);return}if(s==="Escape"){e.onSelect(null);return}if(s==="ArrowLeft"){l.preventDefault(),p.parent!==null&&e.onSelect(p.parent);return}if(s==="ArrowRight"){if(l.preventDefault(),p.collapsed){I(g);return}let C=t.nodes[g]?.children.find(H=>z.byId.has(H));C!==void 0&&e.onSelect(C);return}if(s==="ArrowUp"||s==="ArrowDown"){l.preventDefault();let C=s==="ArrowUp"?-1:1,H=p.y+p.h/2,G=null,W=1/0;for(let Q of z.nodes){if(Q.id===g)continue;let Ge=Q.y+Q.h/2;if((Ge-H)*C<=0)continue;let Je=Math.abs(Ge-H)+Math.abs(Q.x-p.x)*2+(Q.depth===p.depth?0:400);Je<W&&(W=Je,G=Q.id)}G!==null&&e.onSelect(G);return}!x&&!l.altKey&&s.length===1&&g!==n&&(l.preventDefault(),y(g,s))}},N=(l,x,s)=>{e.onSelect(l);let g=t.nodes[l],p=l===n;e.onMenu({x,y:s,items:[{label:"\u7F16\u8F91",shortcut:"F2",onSelect:()=>y(l)},{label:"\u6DFB\u52A0\u5B50\u8282\u70B9",shortcut:"Tab",onSelect:()=>v(l)},{label:"\u6DFB\u52A0\u540C\u7EA7\u8282\u70B9",shortcut:"Enter",disabled:p,onSelect:()=>b(l)},{label:g.collapsed===!0?"\u5C55\u5F00":"\u6298\u53E0",shortcut:"\u7A7A\u683C",disabled:p||g.children.length===0,onSelect:()=>I(l)},{label:"\u5728\u5927\u7EB2\u4E2D\u7F16\u8F91",disabled:p&&n===t.rootId,onSelect:()=>e.onEditInOutline(l)},{label:"\u4EE5\u6B64\u4E3A\u4E2D\u5FC3",onSelect:()=>S(l)},{kind:"sep"},{label:g.children.length>0?"\u5220\u9664\u8282\u70B9\u53CA\u5176\u5B50\u8282\u70B9":"\u5220\u9664\u8282\u70B9",shortcut:"Delete",danger:!0,disabled:p,onSelect:()=>T(l)}]})},P=l=>{l.button!==0||l.target.closest("[data-map-node],.mm-map-ctrl,.mm-map-edit")!==null||(M.current={px:l.clientX,py:l.clientY,vx:i.x,vy:i.y,moved:!1},l.currentTarget.setPointerCapture(l.pointerId),D(!0))},K=l=>{let x=M.current;if(x===null)return;let s=l.clientX-x.px,g=l.clientY-x.py;Math.abs(s)+Math.abs(g)>3&&(x.moved=!0),a(p=>({...p,x:x.vx+s,y:x.vy+g}))},_=()=>{let l=M.current;M.current=null,D(!1),l!==null&&!l.moved&&e.onSelect(null)},A=f!==null?z.byId.get(f.id):void 0;return(0,U.jsxs)("div",{ref:r,className:"mm-map"+(c?" mm-panning":""),tabIndex:0,role:"application","aria-label":"\u601D\u7EF4\u5BFC\u56FE",onKeyDown:R,onPointerDown:P,onPointerMove:K,onPointerUp:_,onPointerCancel:_,onContextMenu:l=>{l.target.closest("[data-map-node]")===null&&l.preventDefault()},children:[(0,U.jsx)("svg",{children:(0,U.jsxs)("g",{transform:"translate("+i.x+","+i.y+") scale("+i.k+")",children:[z.nodes.map(l=>l.parent===null?null:(0,U.jsx)("path",{className:"mm-map-edge",d:Ve(z.byId.get(l.parent),l)},"e"+l.id)),z.nodes.map(l=>{let x="mm-map-node"+(l.depth===0?" mm-root":l.depth===1?" mm-depth1":"")+(l.done?" mm-done":"")+(Y===l.id?" mm-sel":"");return(0,U.jsxs)("g",{className:x,"data-map-node":l.id,onMouseDown:s=>{s.button===0&&(s.stopPropagation(),e.onSelect(l.id),r.current?.focus({preventScroll:!0}))},onDoubleClick:s=>{s.stopPropagation(),y(l.id)},onContextMenu:s=>{s.preventDefault(),s.stopPropagation(),N(l.id,s.clientX,s.clientY)},children:[(0,U.jsx)("rect",{x:l.x,y:l.y,width:l.w,height:l.h,rx:6}),f?.id===l.id?null:l.lines.map((s,g)=>(0,U.jsx)("text",{x:l.x+Oe,y:l.y+Re+ve*g+ve/2,xmlSpace:"preserve",children:s},g))]},l.id)}),z.nodes.map(l=>l.depth===0||!l.hasKids?null:(0,U.jsxs)("g",{className:"mm-map-toggle","data-map-node":l.id,role:"button","aria-label":l.collapsed?"\u5C55\u5F00":"\u6298\u53E0",onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),I(l.id)},children:[(0,U.jsx)("circle",{cx:l.x+l.w+10,cy:l.y+l.h/2,r:8}),(0,U.jsx)("text",{x:l.x+l.w+10,y:l.y+l.h/2,children:l.collapsed?l.hidden>99?"99+":String(l.hidden):"\u2212"})]},"t"+l.id))]})}),f!==null&&A!==void 0?(0,U.jsx)(rn,{value:f.text,left:i.x+A.x*i.k,top:i.y+A.y*i.k,width:Math.max(A.w,160),scale:i.k,onChange:l=>u({id:f.id,text:l}),onCommit:()=>d(f),onCancel:()=>{u(null),r.current?.focus({preventScroll:!0})},onTab:()=>{let l=f.id,x=t;l===t.rootId?x={...t,title:f.text.replace(/\n/g," ").trim()||t.title}:t.nodes[l]!==void 0&&(x=de(t,l,f.text));let s=se(ae(x,l,!1),l,x.nodes[l].children.length);o.apply(s.doc),e.onSelect(s.focusId),u({id:s.focusId,text:""})}},f.id):null,(0,U.jsx)("div",{className:"mm-map-hint mm-hide-narrow",children:"\u53CC\u51FB\u7F16\u8F91 \xB7 Tab \u5B50\u8282\u70B9 \xB7 Enter \u540C\u7EA7 \xB7 \u7A7A\u683C\u6298\u53E0 \xB7 \u62D6\u52A8\u753B\u5E03\u5E73\u79FB \xB7 Ctrl+\u6EDA\u8F6E\u7F29\u653E"}),(0,U.jsxs)("div",{className:"mm-map-ctrl",onPointerDown:l=>l.stopPropagation(),children:[(0,U.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u7F29\u5C0F","aria-label":"\u7F29\u5C0F",onClick:()=>h(1/1.2),children:(0,U.jsx)(V,{name:"minus"})}),(0,U.jsxs)("span",{"aria-live":"polite",children:[Math.round(i.k*100),"%"]}),(0,U.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u653E\u5927","aria-label":"\u653E\u5927",onClick:()=>h(1.2),children:(0,U.jsx)(V,{name:"plus"})}),(0,U.jsx)("button",{type:"button",className:"mm-btn",style:{height:26,padding:"0 8px",border:0},title:"\u5B9E\u9645\u5927\u5C0F",onClick:()=>S(Y??n,1),children:"100%"}),(0,U.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u9002\u5E94\u7A97\u53E3","aria-label":"\u9002\u5E94\u7A97\u53E3",onClick:B,children:(0,U.jsx)(V,{name:"fit"})}),(0,U.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u5C45\u4E2D","aria-label":"\u5C45\u4E2D",onClick:()=>S(Y??n),children:(0,U.jsx)(V,{name:"center"})})]})]})}function rn(e){let t=(0,j.useRef)(null),n=(0,j.useRef)(!1);(0,j.useLayoutEffect)(()=>{let r=t.current;if(r===null)return;r.focus({preventScroll:!0});let i=r.value.length;i>1?r.select():r.setSelectionRange(i,i)},[]),(0,j.useLayoutEffect)(()=>{let r=t.current;r!==null&&(r.style.height="0px",r.style.height=r.scrollHeight+"px")});let o=r=>{n.current||(n.current=!0,r())};return(0,U.jsx)("textarea",{ref:t,className:"mm-map-edit",rows:1,value:e.value,spellCheck:!1,"aria-label":"\u7F16\u8F91\u8282\u70B9",style:{left:e.left,top:e.top,width:e.width,transform:"scale("+e.scale+")"},onPointerDown:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),onDoubleClick:r=>r.stopPropagation(),onChange:r=>e.onChange(r.target.value),onBlur:()=>o(e.onCommit),onKeyDown:r=>{r.stopPropagation(),!(r.nativeEvent.isComposing||r.keyCode===229)&&(r.key==="Enter"&&!r.shiftKey?(r.preventDefault(),o(e.onCommit)):r.key==="Escape"?(r.preventDefault(),o(e.onCancel)):r.key==="Tab"&&(r.preventDefault(),o(e.onTab)))}})}var m=require("react/jsx-runtime"),Ct="dsh-mindmap:last-doc",Tt="dsh-mindmap:view",Ot="dsh-mindmap:open-folders";function Ze(e){try{return window.localStorage.getItem(e)}catch{return null}}function We(e,t){try{t===null?window.localStorage.removeItem(e):window.localStorage.setItem(e,t)}catch{}}var ie=e=>e instanceof Error?e.message:String(e);function Rt(){return(0,m.jsx)(yt,{children:(0,m.jsx)(ln,{})})}function ln(){let e=be(),t=(0,O.useRef)(null),[n,o]=(0,O.useState)(null),[r,i]=(0,O.useState)(null),[a,f]=(0,O.useState)(()=>Ze(Ct)),[u,c]=(0,O.useState)(()=>Ze(Tt)==="map"?"map":"outline"),[D,M]=(0,O.useState)(null),[w,E]=(0,O.useState)(null),[k,L]=(0,O.useState)(null),[X,z]=(0,O.useState)(!1),Y=(0,O.useRef)(null),F=(0,O.useCallback)(async()=>{try{let s=await te.library();return o(s.library),i(null),s.warnings.length>0&&e.toast(s.warnings.join("\uFF1B")),s.library}catch(s){return i(ie(s)),null}},[e]);(0,O.useEffect)(()=>{F()},[F]),(0,O.useEffect)(()=>{if(n===null)return;let s=a===null?void 0:n.docs.find(g=>g.id===a);if(s===void 0||s.trashedAt!==void 0){let g=n.docs.filter(p=>p.trashedAt===void 0).sort((p,C)=>C.updatedAt-p.updatedAt)[0];f(g?.id??null)}},[n,a]),(0,O.useEffect)(()=>{We(Ct,a)},[a]);let B=(0,O.useCallback)(s=>{o(g=>g===null?g:{...g,docs:g.docs.map(p=>p.id===s.id?{...p,title:s.title,updatedAt:s.updatedAt}:p)})},[]),S=ht(a,B),h=S.doc;(0,O.useEffect)(()=>{M(null),E(null)},[a]);let d=h!==null&&D!==null&&h.nodes[D]!==void 0?D:h?.rootId??null,y=s=>{c(s),We(Tt,s)},v=(0,O.useCallback)((s,g)=>{let p=s;for(let C of he(s,g))p=ae(p,C,!1);p!==s&&S.apply(p,{noHistory:!0}),d!==null&&!ke(s,d,g)&&M(null),window.setTimeout(()=>S.requestFocus(g,"end"),0)},[S,d]);(0,O.useEffect)(()=>{if(h===null||Y.current===null)return;let s=Y.current;Y.current=null,h.nodes[s]!==void 0&&(y("outline"),v(h,s))},[h?.id]);let b=(0,O.useCallback)((s,g=null)=>{if(z(!1),s===a){g!==null&&h!==null&&h.nodes[g]!==void 0&&(y("outline"),v(h,g));return}Y.current=g,f(s)},[a,h,v]),T=(0,O.useCallback)(async(s={})=>{try{let g=await te.createDoc(s);return o(p=>p===null?p:{...p,docs:[...p.docs,g.meta]}),f(g.doc.id),y("outline"),z(!1),g.doc}catch(g){return e.toast("\u65B0\u5EFA\u5931\u8D25\uFF1A"+ie(g)),null}},[e]),I=(0,O.useCallback)(async(s,g)=>{if(g.title!==void 0&&h!==null&&h.id===s){let p=g.title.trim();p.length>0&&p!==h.title&&S.apply({...h,title:p});let C={...g};if(delete C.title,Object.keys(C).length===0)return;g=C}try{let p=await te.patchMeta(s,g);o(C=>C===null?C:{...C,docs:C.docs.map(H=>H.id===s?p.meta:H)})}catch(p){e.toast("\u64CD\u4F5C\u5931\u8D25\uFF1A"+ie(p))}},[h,S,e]),R=(0,O.useCallback)(async s=>{try{s===a&&await S.flush();let g=await te.trash(s);o(p=>p===null?p:{...p,docs:p.docs.map(C=>C.id===s?g:C)}),e.toast("\u5DF2\u79FB\u5230\u56DE\u6536\u7AD9")}catch(g){e.toast("\u5220\u9664\u5931\u8D25\uFF1A"+ie(g))}},[a,S,e]),N=(0,O.useCallback)(async s=>{if(h===null||d===null)return;let g=d,p=g===h.rootId?h.title:h.nodes[g].text.split(`
|
|
24
|
+
`)[0];try{if(s==="md"||s==="copy-md"){let C=Ie(h,g,p);if(s==="copy-md"){await navigator.clipboard.writeText(C),e.toast("\u5DF2\u590D\u5236 Markdown");return}ye(we(p,"md"),new Blob([C],{type:"text/markdown;charset=utf-8"}))}else if(s==="opml")ye(we(p,"opml"),new Blob([mt(h,g,p)],{type:"text/x-opml;charset=utf-8"}));else{let C=t.current,H=It(C),G=Pe(h,g,p,Ae(H.font)),W=Dt(G,H);s==="svg"?ye(we(p,"svg"),new Blob([W.svg],{type:"image/svg+xml;charset=utf-8"})):ye(we(p,"png"),await Et(W.svg,W.width,W.height,2))}}catch(C){e.toast("\u5BFC\u51FA\u5931\u8D25\uFF1A"+ie(C))}},[h,d,e]),P=(0,O.useRef)(null),K=(0,O.useCallback)(async s=>{if(s!==null)for(let g of Array.from(s))try{if(g.size>8*1024*1024)throw new Error("\u6587\u4EF6\u8D85\u8FC7 8 MB");let p=await g.text(),C=g.name.replace(/\.[^.]+$/,"");if(/\.(opml|xml)$/i.test(g.name)||/^\s*<\?xml|^\s*<opml/i.test(p)){let G=pt(p);await T({opml:p,title:G.title??C})}else{let G=Ue(p);await T({markdown:p,title:G.title??C})}e.toast("\u5DF2\u5BFC\u5165\u300C"+g.name+"\u300D")}catch(p){e.toast("\u5BFC\u5165\u5931\u8D25\uFF1A"+ie(p))}},[T,e]),_=(0,O.useCallback)(()=>{e.show({title:"\u5907\u4EFD\u4E0E\u6062\u590D",body:s=>(0,m.jsx)(dn,{close:s,onRestored:async()=>{s(),await F(),S.reload()}})})},[e,F,S]),A=s=>{if(s.target.closest("textarea,input,.mm-map,.mm-modal")!==null)return;let p=s.ctrlKey||s.metaKey;p&&(s.key==="z"||s.key==="Z")?(s.preventDefault(),s.shiftKey?S.redo():S.undo()):p&&(s.key==="y"||s.key==="Y")&&(s.preventDefault(),S.redo())},l=S.status==="saved"?"\u5DF2\u4FDD\u5B58":S.status==="saving"?"\u4FDD\u5B58\u4E2D\u2026":S.status==="dirty"?"\u672A\u4FDD\u5B58":S.status==="conflict"?"\u4FDD\u5B58\u51B2\u7A81":"\u4FDD\u5B58\u5931\u8D25",x=n?.docs.find(s=>s.id===a);return(0,m.jsxs)("div",{ref:t,className:"mm-app"+(X?" mm-side-open":""),onKeyDown:A,children:[(0,m.jsx)("div",{className:"mm-scrim",onClick:()=>z(!1)}),(0,m.jsx)(an,{library:n,error:r,activeId:a,onOpen:b,onCreate:s=>{T({folderId:s})},onPatch:I,onTrash:R,onRefresh:F,onMenu:L,onImport:()=>P.current?.click(),onBackups:_,onChanged:o}),(0,m.jsx)("input",{ref:P,type:"file",accept:".md,.markdown,.txt,.opml,.xml",multiple:!0,hidden:!0,onChange:s=>{K(s.target.files),s.target.value=""}}),(0,m.jsxs)("main",{className:"mm-main",children:[(0,m.jsxs)("div",{className:"mm-toolbar",children:[(0,m.jsx)("button",{type:"button",className:"mm-icon-btn mm-side-toggle","aria-label":"\u6587\u6863\u5217\u8868",onClick:()=>z(s=>!s),children:(0,m.jsx)(V,{name:"menu"})}),h!==null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("div",{className:"mm-seg",role:"tablist","aria-label":"\u89C6\u56FE",children:[(0,m.jsx)("button",{type:"button",role:"tab","aria-selected":u==="outline",className:u==="outline"?"mm-on":"",onClick:()=>y("outline"),children:"\u5927\u7EB2"}),(0,m.jsx)("button",{type:"button",role:"tab","aria-selected":u==="map",className:u==="map"?"mm-on":"",onClick:()=>y("map"),children:"\u5BFC\u56FE"})]}),(0,m.jsx)("span",{className:"mm-sep"}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u64A4\u9500 (Ctrl+Z)","aria-label":"\u64A4\u9500",disabled:!S.canUndo,onMouseDown:s=>s.preventDefault(),onClick:S.undo,children:(0,m.jsx)(V,{name:"undo"})}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u91CD\u505A (Ctrl+Shift+Z)","aria-label":"\u91CD\u505A",disabled:!S.canRedo,onMouseDown:s=>s.preventDefault(),onClick:S.redo,children:(0,m.jsx)(V,{name:"redo"})}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u5168\u90E8\u5C55\u5F00","aria-label":"\u5168\u90E8\u5C55\u5F00",onClick:()=>d!==null&&S.apply($e(h,d,!1),{noHistory:!0}),children:(0,m.jsx)(V,{name:"expand"})}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u5168\u90E8\u6298\u53E0","aria-label":"\u5168\u90E8\u6298\u53E0",onClick:()=>d!==null&&S.apply($e(h,d,!0),{noHistory:!0}),children:(0,m.jsx)(V,{name:"collapse"})}),(0,m.jsx)("span",{className:"mm-grow"}),(0,m.jsx)("span",{className:"mm-status"+(S.status==="error"||S.status==="conflict"?" mm-err":""),title:S.statusMessage??void 0,"aria-live":"polite",children:l}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u5BFC\u51FA","aria-label":"\u5BFC\u51FA",onClick:s=>{let g=s.currentTarget.getBoundingClientRect();L({x:g.right-180,y:g.bottom+4,items:[{kind:"label",label:d!==h.rootId?"\u5BFC\u51FA\u5F53\u524D\u805A\u7126\u7684\u8282\u70B9":"\u5BFC\u51FA\u6574\u7BC7\u6587\u6863"},{label:"\u5BFC\u51FA Markdown (.md)",onSelect:()=>{N("md")}},{label:"\u5BFC\u51FA OPML (.opml)",onSelect:()=>{N("opml")}},{label:"\u5BFC\u51FA\u56FE\u7247 (.png)",onSelect:()=>{N("png")}},{label:"\u5BFC\u51FA\u77E2\u91CF\u56FE (.svg)",onSelect:()=>{N("svg")}},{kind:"sep"},{label:"\u590D\u5236\u4E3A Markdown",onSelect:()=>{N("copy-md")}}]})},children:(0,m.jsx)(V,{name:"download"})}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u66F4\u591A","aria-label":"\u66F4\u591A",onClick:s=>{let g=s.currentTarget.getBoundingClientRect(),p=x;L({x:g.right-180,y:g.bottom+4,items:[{label:p?.favorite===!0?"\u53D6\u6D88\u6536\u85CF":"\u6536\u85CF",disabled:p===void 0,onSelect:()=>p!==void 0&&void I(p.id,{favorite:!p.favorite})},{label:"\u7ACB\u5373\u4FDD\u5B58",onSelect:()=>{S.flush()}},{kind:"sep"},{label:"\u5220\u9664\u6587\u6863",danger:!0,onSelect:()=>{R(h.id)}}]})},children:(0,m.jsx)(V,{name:"more"})})]}):(0,m.jsx)("span",{className:"mm-grow"})]}),S.conflict!==null?(0,m.jsxs)("div",{className:"mm-banner",role:"alert",children:[(0,m.jsx)("span",{className:"mm-grow",children:"\u8FD9\u7BC7\u6587\u6863\u5728\u522B\u5904\u88AB\u4FEE\u6539\u8FC7\uFF08\u4F8B\u5982\u53E6\u4E00\u4E2A\u7A97\u53E3\uFF09\u3002\u4F60\u7684\u4FEE\u6539\u5C1A\u672A\u4FDD\u5B58\u3002"}),(0,m.jsx)("button",{type:"button",className:"mm-btn",onClick:()=>S.resolveConflict("theirs"),children:"\u4F7F\u7528\u78C1\u76D8\u4E0A\u7684\u7248\u672C"}),(0,m.jsx)("button",{type:"button",className:"mm-btn mm-primary",onClick:()=>S.resolveConflict("mine"),children:"\u4FDD\u7559\u6211\u7684\u4FEE\u6539"})]}):null,S.status==="error"&&S.statusMessage!==null?(0,m.jsxs)("div",{className:"mm-banner",role:"alert",children:[(0,m.jsx)("span",{className:"mm-grow",children:S.statusMessage}),(0,m.jsx)("button",{type:"button",className:"mm-btn",onClick:()=>{S.flush()},children:"\u91CD\u8BD5"})]}):null,h===null||d===null?(0,m.jsx)("div",{className:"mm-blank",children:S.loading?"\u52A0\u8F7D\u4E2D\u2026":S.loadError!==null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("span",{children:["\u65E0\u6CD5\u6253\u5F00\u6587\u6863\uFF1A",S.loadError]}),(0,m.jsx)("button",{type:"button",className:"mm-btn",onClick:S.reload,children:"\u91CD\u8BD5"})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{children:n!==null&&n.docs.some(s=>s.trashedAt===void 0)?"\u4ECE\u5DE6\u4FA7\u9009\u62E9\u4E00\u7BC7\u6587\u6863":"\u8FD8\u6CA1\u6709\u6587\u6863"}),(0,m.jsx)("button",{type:"button",className:"mm-btn mm-primary",onClick:()=>{T()},children:"\u65B0\u5EFA\u6587\u6863"})]})}):u==="outline"?(0,m.jsx)("div",{className:"mm-doc",children:(0,m.jsxs)("div",{className:"mm-doc-inner",children:[(0,m.jsx)(sn,{doc:h,rootId:d,state:S,onZoom:s=>M(s===h.rootId?null:s)}),(0,m.jsx)(kt,{state:S,doc:h,rootId:d,onZoom:s=>M(s===h.rootId?null:s),onMenu:L})]})}):(0,m.jsx)(St,{state:S,doc:h,rootId:d,rootLabel:d===h.rootId?h.title:h.nodes[d].text,onMenu:L,selected:w,onSelect:E,onEditInOutline:s=>{y("outline"),v(h,s)}})]}),k!==null?(0,m.jsx)(vt,{x:k.x,y:k.y,items:k.items,onClose:()=>L(null)}):null]})}function sn(e){let{doc:t,rootId:n,state:o}=e,r=(0,O.useRef)(null),i=n!==t.rootId,a=i?t.nodes[n].text:t.title,[f,u]=(0,O.useState)(a),c=(0,O.useRef)(!1);(0,O.useEffect)(()=>{c.current||u(a)},[a]),(0,O.useEffect)(()=>{let E=r.current;E!==null&&(E.style.height="0px",E.style.height=E.scrollHeight+"px")}),(0,O.useEffect)(()=>{let E=t.nodes[t.rootId].children;!i&&t.title==="\u672A\u547D\u540D\u6587\u6863"&&E.length===1&&t.nodes[E[0]].text===""&&t.revision===0&&(r.current?.focus(),r.current?.select())},[t.id]);let D=E=>{i?o.apply(de(t,n,E),{key:"text:"+n}):o.apply({...t,title:E},{key:"title"})},M=()=>{let E=t.nodes[n].children;if(E.length>0)o.requestFocus(E[0],"end");else{let k=se(t,n,0);o.apply(k.doc,{focus:{id:k.focusId,caret:0}})}},w=i?[...he(t,n)]:[];return(0,m.jsxs)(m.Fragment,{children:[i?(0,m.jsx)("nav",{className:"mm-crumbs","aria-label":"\u8DEF\u5F84",children:w.map((E,k)=>(0,m.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[k>0?(0,m.jsx)(V,{name:"chevronRight",size:12}):null,(0,m.jsx)("button",{type:"button",onClick:()=>e.onZoom(E),children:E===t.rootId?t.title:t.nodes[E].text.split(`
|
|
25
|
+
`)[0]||"\uFF08\u7A7A\uFF09"})]},E))}):null,(0,m.jsx)("textarea",{ref:r,className:i?"mm-title mm-zoom-title":"mm-title",rows:1,value:i?a:f,placeholder:i?"\uFF08\u7A7A\u8282\u70B9\uFF09":"\u6587\u6863\u6807\u9898","aria-label":i?"\u8282\u70B9\u5185\u5BB9":"\u6587\u6863\u6807\u9898",spellCheck:!1,onFocus:()=>{c.current=!0},onBlur:()=>{c.current=!1,o.breakMerge(),!i&&f.trim().length===0&&u(t.title)},onChange:E=>{let k=i?E.target.value:E.target.value.replace(/\n/g," ");i?D(k):(u(k),k.trim().length>0&&D(k))},onKeyDown:E=>{if(!(E.nativeEvent.isComposing||E.keyCode===229)){if(E.key==="Enter"&&!E.shiftKey)E.preventDefault(),M();else if(E.key==="ArrowDown"){let k=E.currentTarget;k.selectionStart===k.value.length&&(E.preventDefault(),M())}}}})]})}function an(e){let t=be(),[n,o]=(0,O.useState)(""),[r,i]=(0,O.useState)(null),[a,f]=(0,O.useState)(null),[u,c]=(0,O.useState)(()=>new Set((Ze(Ot)??"").split(",").filter(Boolean))),[D,M]=(0,O.useState)(!1),w=e.library;(0,O.useEffect)(()=>{We(Ot,Array.from(u).join(","))},[u]),(0,O.useEffect)(()=>{let d=n.trim();if(d.length===0){i(null);return}let y=!0,v=window.setTimeout(()=>{te.search(d).then(b=>{y&&i(b)},()=>{y&&i([])})},220);return()=>{y=!1,window.clearTimeout(v)}},[n,w]);let E=(0,O.useMemo)(()=>(w?.docs??[]).filter(d=>d.trashedAt===void 0).sort((d,y)=>y.updatedAt-d.updatedAt),[w]),k=(0,O.useMemo)(()=>(w?.docs??[]).filter(d=>d.trashedAt!==void 0).sort((d,y)=>(y.trashedAt??0)-(d.trashedAt??0)),[w]),L=(0,O.useMemo)(()=>[...w?.folders??[]].sort((d,y)=>d.name.localeCompare(y.name,"zh-CN")),[w]),X=d=>c(y=>{let v=new Set(y);return v.has(d)?v.delete(d):v.add(d),v}),z=async()=>{let d=await t.prompt({title:"\u65B0\u5EFA\u6587\u4EF6\u5939",placeholder:"\u6587\u4EF6\u5939\u540D\u79F0",ok:"\u521B\u5EFA"});if(!(d===null||d.trim().length===0))try{let y=await te.createFolder(d.trim());w!==null&&e.onChanged({...w,folders:[...w.folders,y]}),c(v=>new Set(v).add(y.id))}catch(y){t.toast("\u521B\u5EFA\u5931\u8D25\uFF1A"+ie(y))}},Y=(d,y,v)=>{let b=[{label:"\u6253\u5F00",onSelect:()=>e.onOpen(d.id)},{label:"\u91CD\u547D\u540D",onSelect:()=>f(d.id)},{label:d.favorite?"\u53D6\u6D88\u6536\u85CF":"\u6536\u85CF",onSelect:()=>{e.onPatch(d.id,{favorite:!d.favorite})}},{kind:"sep"},{kind:"label",label:"\u79FB\u52A8\u5230"},{label:(d.folderId===null?"\u2713 ":"")+"\u672A\u5206\u7C7B",disabled:d.folderId===null,onSelect:()=>{e.onPatch(d.id,{folderId:null})}},...L.map(T=>({label:(d.folderId===T.id?"\u2713 ":"")+T.name,disabled:d.folderId===T.id,onSelect:()=>{e.onPatch(d.id,{folderId:T.id})}})),{kind:"sep"},{label:"\u5220\u9664",danger:!0,onSelect:()=>{e.onTrash(d.id)}}];e.onMenu({x:y,y:v,items:b})},F=(d,y,v,b)=>{e.onMenu({x:v,y:b,items:[{label:"\u5728\u6B64\u65B0\u5EFA\u6587\u6863",onSelect:()=>e.onCreate(d)},{label:"\u91CD\u547D\u540D",onSelect:async()=>{let T=await t.prompt({title:"\u91CD\u547D\u540D\u6587\u4EF6\u5939",value:y,ok:"\u4FDD\u5B58"});if(!(T===null||T.trim().length===0||T.trim()===y))try{let I=await te.renameFolder(d,T.trim());w!==null&&e.onChanged({...w,folders:w.folders.map(R=>R.id===d?I:R)})}catch(I){t.toast("\u91CD\u547D\u540D\u5931\u8D25\uFF1A"+ie(I))}}},{label:"\u5220\u9664\u6587\u4EF6\u5939",danger:!0,onSelect:async()=>{if(await t.confirm({title:"\u5220\u9664\u6587\u4EF6\u5939\u300C"+y+"\u300D\uFF1F",message:"\u6587\u4EF6\u5939\u91CC\u7684\u6587\u6863\u4E0D\u4F1A\u88AB\u5220\u9664\uFF0C\u4F1A\u79FB\u5230\u300C\u672A\u5206\u7C7B\u300D\u3002",ok:"\u5220\u9664",danger:!0}))try{await te.deleteFolder(d),await e.onRefresh()}catch(I){t.toast("\u5220\u9664\u5931\u8D25\uFF1A"+ie(I))}}}]})},B=(d,y,v)=>(0,m.jsx)("div",{className:"mm-row"+(y?" mm-indent":"")+(d.id===e.activeId?" mm-active":""),role:"button",tabIndex:0,"aria-current":d.id===e.activeId?"page":void 0,onClick:()=>{a!==d.id&&e.onOpen(d.id)},onKeyDown:b=>{b.key==="Enter"&&a!==d.id?e.onOpen(d.id):b.key==="F2"&&f(d.id)},onDoubleClick:()=>f(d.id),onContextMenu:b=>{b.preventDefault(),Y(d,b.clientX,b.clientY)},children:a===d.id?(0,m.jsx)(cn,{value:d.title,onDone:b=>{f(null),b!==null&&b.trim().length>0&&b.trim()!==d.title&&e.onPatch(d.id,{title:b.trim()})}}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{className:"mm-row-title",title:d.title,children:d.title}),(0,m.jsx)("span",{className:"mm-row-time",title:new Date(d.updatedAt).toLocaleString(),children:wt(d.updatedAt)})]})},v+d.id),S=E.filter(d=>d.favorite),h=E.filter(d=>d.folderId===null);return(0,m.jsxs)("aside",{className:"mm-side","aria-label":"\u6587\u6863",children:[(0,m.jsxs)("div",{className:"mm-side-head",children:[(0,m.jsx)("span",{className:"mm-side-title",children:"\u601D\u7EF4\u5BFC\u56FE"}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u65B0\u5EFA\u6587\u4EF6\u5939","aria-label":"\u65B0\u5EFA\u6587\u4EF6\u5939",onClick:()=>{z()},children:(0,m.jsx)(V,{name:"folderPlus"})}),(0,m.jsx)("button",{type:"button",className:"mm-icon-btn",title:"\u65B0\u5EFA\u6587\u6863","aria-label":"\u65B0\u5EFA\u6587\u6863",onClick:()=>e.onCreate(null),children:(0,m.jsx)(V,{name:"plus"})})]}),(0,m.jsxs)("label",{className:"mm-search",children:[(0,m.jsx)(V,{name:"search",size:14}),(0,m.jsx)("input",{type:"search",placeholder:"\u641C\u7D22\u6587\u6863\u548C\u5185\u5BB9","aria-label":"\u641C\u7D22\u6587\u6863\u548C\u5185\u5BB9",value:n,onChange:d=>o(d.target.value),onKeyDown:d=>{d.key==="Escape"&&o("")}})]}),(0,m.jsxs)("div",{className:"mm-side-scroll",children:[e.error!==null?(0,m.jsxs)("div",{className:"mm-empty",children:["\u65E0\u6CD5\u8BFB\u53D6\u6587\u6863\u5217\u8868\uFF1A",e.error," ",(0,m.jsx)("button",{type:"button",className:"mm-btn",onClick:()=>{e.onRefresh()},children:"\u91CD\u8BD5"})]}):null,r!==null?(0,m.jsxs)("div",{className:"mm-section",children:[(0,m.jsxs)("div",{className:"mm-section-head",children:["\u641C\u7D22\u7ED3\u679C \xB7 ",r.length]}),r.length===0?(0,m.jsx)("div",{className:"mm-empty",children:"\u6CA1\u6709\u5339\u914D\u7684\u5185\u5BB9"}):r.map((d,y)=>(0,m.jsxs)("div",{className:"mm-hit",role:"button",tabIndex:0,onClick:()=>e.onOpen(d.docId,d.nodeId),onKeyDown:v=>{v.key==="Enter"&&e.onOpen(d.docId,d.nodeId)},children:[(0,m.jsx)("div",{className:"mm-hit-title",children:d.title}),d.nodeId!==null?(0,m.jsx)("div",{className:"mm-hit-snip",children:ge(d.snippet)}):null]},y))]}):w===null&&e.error===null?(0,m.jsx)("div",{className:"mm-empty",children:"\u52A0\u8F7D\u4E2D\u2026"}):(0,m.jsxs)(m.Fragment,{children:[S.length>0?(0,m.jsxs)("div",{className:"mm-section",children:[(0,m.jsx)("div",{className:"mm-section-head",children:"\u6536\u85CF"}),S.map(d=>B(d,!1,"fav-"))]}):null,L.length>0?(0,m.jsxs)("div",{className:"mm-section",children:[(0,m.jsx)("div",{className:"mm-section-head",children:"\u6587\u4EF6\u5939"}),L.map(d=>{let y=E.filter(b=>b.folderId===d.id),v=u.has(d.id);return(0,m.jsxs)("div",{children:[(0,m.jsxs)("div",{className:"mm-row",role:"button",tabIndex:0,"aria-expanded":v,onClick:()=>X(d.id),onKeyDown:b=>{b.key==="Enter"&&X(d.id)},onContextMenu:b=>{b.preventDefault(),F(d.id,d.name,b.clientX,b.clientY)},children:[(0,m.jsx)("span",{style:{display:"inline-flex",transform:v?"none":"rotate(-90deg)",color:"var(--mm-sub)"},children:(0,m.jsx)(V,{name:"chevron",size:12})}),(0,m.jsx)(V,{name:"folder",size:14}),(0,m.jsx)("span",{className:"mm-row-title",children:d.name}),(0,m.jsx)("span",{className:"mm-row-time",children:y.length})]}),v?y.length===0?(0,m.jsx)("div",{className:"mm-empty mm-indent",children:"\u7A7A\u6587\u4EF6\u5939"}):y.map(b=>B(b,!0,"f-")):null]},d.id)})]}):null,(0,m.jsxs)("div",{className:"mm-section",children:[(0,m.jsxs)("div",{className:"mm-section-head",children:[(0,m.jsx)("span",{className:"mm-grow",children:L.length>0?"\u672A\u5206\u7C7B":"\u6587\u6863"}),(0,m.jsx)("span",{children:"\u6700\u8FD1\u7F16\u8F91"})]}),h.length===0?(0,m.jsx)("div",{className:"mm-empty",children:E.length===0?"\u70B9\u51FB\u53F3\u4E0A\u89D2 + \u65B0\u5EFA\u6587\u6863":"\u6CA1\u6709\u672A\u5206\u7C7B\u7684\u6587\u6863"}):h.map(d=>B(d,!1,"d-"))]}),k.length>0?(0,m.jsxs)("div",{className:"mm-section",children:[(0,m.jsxs)("div",{className:"mm-row",role:"button",tabIndex:0,"aria-expanded":D,onClick:()=>M(d=>!d),onKeyDown:d=>{d.key==="Enter"&&M(y=>!y)},children:[(0,m.jsx)(V,{name:"trash",size:14}),(0,m.jsx)("span",{className:"mm-row-title",style:{color:"var(--mm-sub)"},children:"\u56DE\u6536\u7AD9"}),(0,m.jsx)("span",{className:"mm-row-time",children:k.length})]}),D?k.map(d=>(0,m.jsxs)("div",{className:"mm-row mm-indent",onContextMenu:y=>y.preventDefault(),children:[(0,m.jsx)("span",{className:"mm-row-title",style:{color:"var(--mm-sub)"},title:d.title,children:d.title}),(0,m.jsx)("button",{type:"button",className:"mm-btn",style:{height:22,padding:"0 6px",fontSize:12},onClick:async()=>{try{let y=await te.restore(d.id);w!==null&&e.onChanged({...w,docs:w.docs.map(v=>v.id===d.id?y:v)})}catch(y){t.toast("\u6062\u590D\u5931\u8D25\uFF1A"+ie(y))}},children:"\u6062\u590D"}),(0,m.jsx)("button",{type:"button",className:"mm-btn mm-danger",style:{height:22,padding:"0 6px",fontSize:12},onClick:async()=>{if(await t.confirm({title:"\u6C38\u4E45\u5220\u9664\u300C"+d.title+"\u300D\uFF1F",message:"\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u9500\uFF08\u6BCF\u65E5\u5907\u4EFD\u4E2D\u4ECD\u53EF\u80FD\u4FDD\u7559\u65E7\u7248\u672C\uFF09\u3002",ok:"\u6C38\u4E45\u5220\u9664",danger:!0}))try{await te.purge(d.id),await e.onRefresh()}catch(v){t.toast("\u5220\u9664\u5931\u8D25\uFF1A"+ie(v))}},children:"\u5220\u9664"})]},"t-"+d.id)):null]}):null]})]}),(0,m.jsxs)("div",{className:"mm-side-head",style:{borderTop:"1px solid var(--mm-border)",padding:"8px 12px"},children:[(0,m.jsxs)("button",{type:"button",className:"mm-btn",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},onClick:e.onImport,children:[(0,m.jsx)(V,{name:"upload",size:14}),"\u5BFC\u5165"]}),(0,m.jsxs)("button",{type:"button",className:"mm-btn",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},onClick:e.onBackups,children:[(0,m.jsx)(V,{name:"backup",size:14}),"\u5907\u4EFD"]})]})]})}function cn(e){let[t,n]=(0,O.useState)(e.value),o=(0,O.useRef)(!1),r=i=>{o.current||(o.current=!0,e.onDone(i))};return(0,m.jsx)("input",{autoFocus:!0,value:t,"aria-label":"\u6587\u6863\u540D\u79F0",onFocus:i=>i.currentTarget.select(),onClick:i=>i.stopPropagation(),onChange:i=>n(i.target.value),onBlur:()=>r(t),onKeyDown:i=>{i.stopPropagation(),!(i.nativeEvent.isComposing||i.keyCode===229)&&(i.key==="Enter"?r(t):i.key==="Escape"&&r(null))}})}function dn(e){let t=be(),[n,o]=(0,O.useState)(null),[r,i]=(0,O.useState)(!1),a=(0,O.useRef)(null),f=(0,O.useCallback)(()=>{te.backups().then(o,c=>t.toast("\u8BFB\u53D6\u5907\u4EFD\u5931\u8D25\uFF1A"+ie(c)))},[t]);(0,O.useEffect)(f,[f]);let u=async(c,D)=>{if(window.confirm("\u7528"+D+`\u8986\u76D6\u5F53\u524D\u6240\u6709\u6587\u6863\uFF1F
|
|
26
|
+
\u6062\u590D\u524D\u4F1A\u81EA\u52A8\u5907\u4EFD\u5F53\u524D\u6570\u636E\uFF0C\u53EF\u4EE5\u518D\u6062\u590D\u56DE\u6765\u3002`)){i(!0);try{let M=await c();t.toast("\u5DF2\u6062\u590D "+M.docs+" \u7BC7\u6587\u6863\uFF1B\u539F\u6570\u636E\u5DF2\u5907\u4EFD\u4E3A "+M.preRestore),await e.onRestored()}catch(M){t.toast("\u6062\u590D\u5931\u8D25\uFF1A"+ie(M))}finally{i(!1)}}};return(0,m.jsxs)("div",{children:[(0,m.jsx)("p",{style:{margin:"0 0 10px",color:"var(--mm-sub)"},children:"\u6BCF\u5929\u9996\u6B21\u4FDD\u5B58\u65F6\u81EA\u52A8\u5907\u4EFD\u4E00\u6B21\uFF0C\u4FDD\u7559\u6700\u8FD1 30 \u4EFD\u3002\u6570\u636E\u4FDD\u5B58\u5728\u672C\u673A ~/.dsh/dsh-mindmap\u3002"}),(0,m.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:10},children:[(0,m.jsx)("button",{type:"button",className:"mm-btn mm-primary",disabled:r,onClick:async()=>{i(!0);try{let c=await te.backupNow();t.toast("\u5DF2\u5907\u4EFD\uFF1A"+c.name),f()}catch(c){t.toast("\u5907\u4EFD\u5931\u8D25\uFF1A"+ie(c))}finally{i(!1)}},children:"\u7ACB\u5373\u5907\u4EFD"}),(0,m.jsx)("button",{type:"button",className:"mm-btn",disabled:r,onClick:()=>a.current?.click(),children:"\u4ECE\u6587\u4EF6\u6062\u590D\u2026"}),(0,m.jsx)("input",{ref:a,type:"file",accept:".json,application/json",hidden:!0,onChange:async c=>{let D=c.target.files?.[0];if(c.target.value="",D===void 0)return;let M;try{M=JSON.parse(await D.text())}catch{t.toast("\u4E0D\u662F\u6709\u6548\u7684\u5907\u4EFD\u6587\u4EF6");return}await u(()=>te.restoreFile(M),"\u6587\u4EF6\u300C"+D.name+"\u300D")}})]}),n===null?(0,m.jsx)("div",{className:"mm-empty",children:"\u52A0\u8F7D\u4E2D\u2026"}):n.length===0?(0,m.jsx)("div",{className:"mm-empty",children:"\u8FD8\u6CA1\u6709\u5907\u4EFD"}):n.map(c=>(0,m.jsxs)("div",{className:"mm-backup-row",children:[(0,m.jsxs)("span",{title:c.name,children:[new Date(c.createdAt).toLocaleString(),(0,m.jsx)("br",{}),(0,m.jsxs)("small",{style:{color:"var(--mm-sub)"},children:[c.name," \xB7 ",(c.size/1024).toFixed(1)," KB"]})]}),(0,m.jsx)("a",{className:"mm-btn",style:{display:"inline-flex",alignItems:"center",textDecoration:"none"},href:te.backupUrl(c.name),download:c.name,children:"\u4E0B\u8F7D"}),(0,m.jsx)("button",{type:"button",className:"mm-btn",disabled:r,onClick:()=>{u(()=>te.restoreBackup(c.name),"\u5907\u4EFD "+c.name)},children:"\u6062\u590D"})]},c.name))]})}var un=`/* dsh-mindmap (\u601D\u7EF4\u5BFC\u56FE) \u2014 scoped under .mm-app */
|
|
27
|
+
.mm-app{--mm-bg:var(--dsw-bg,#fff);--mm-panel:var(--dsw-bg-panel,#f7f7f8);--mm-hover:var(--dsw-bg-hover,rgba(0,0,0,.05));--mm-elev:var(--dsw-bg-elevated,#fff);--mm-text:var(--dsw-text-primary,var(--dsw-text,#1f2329));--mm-sub:var(--dsw-text-secondary,#8a8f99);--mm-border:var(--dsw-border,rgba(0,0,0,.08));--mm-border-strong:var(--dsw-border-strong,rgba(0,0,0,.16));--mm-accent:var(--dsw-alias-brand-primary,var(--dsw-accent,#3964fe));--mm-danger:var(--dsw-alias-state-error-primary,#e5484d);--mm-shadow:var(--dsw-shadow-lv3,0 8px 24px rgba(0,0,0,.12));--mm-mono:var(--dsw-font-mono,ui-monospace,Consolas,monospace);
|
|
28
|
+
position:relative;display:flex;height:100%;width:100%;min-height:0;background:var(--mm-bg);color:var(--mm-text);font-size:14px;line-height:1.6;overflow:hidden;padding-top:var(--dsh-atb-viewport-top,0px);box-sizing:border-box}
|
|
29
|
+
.mm-app *{box-sizing:border-box}
|
|
30
|
+
.mm-app button{font:inherit;color:inherit}
|
|
31
|
+
.mm-side{width:248px;flex:0 0 248px;display:flex;flex-direction:column;background:var(--mm-panel);border-right:1px solid var(--mm-border);min-height:0}
|
|
32
|
+
.mm-side-head{display:flex;align-items:center;gap:6px;padding:12px 12px 8px}
|
|
33
|
+
.mm-side-title{font-weight:600;font-size:15px;flex:1}
|
|
34
|
+
.mm-search{margin:0 12px 8px;display:flex;align-items:center;gap:6px;background:var(--mm-bg);border:1px solid var(--mm-border);border-radius:8px;padding:0 8px;height:32px}
|
|
35
|
+
.mm-search input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:inherit;font:inherit;font-size:13px}
|
|
36
|
+
.mm-side-scroll{flex:1;overflow:auto;padding:0 6px 12px}
|
|
37
|
+
.mm-section{margin-top:10px}
|
|
38
|
+
.mm-section-head{display:flex;align-items:center;gap:4px;padding:2px 8px;color:var(--mm-sub);font-size:12px;user-select:none;cursor:default}
|
|
39
|
+
.mm-section-head .mm-grow{flex:1}
|
|
40
|
+
.mm-row{display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:6px;cursor:pointer;user-select:none;min-height:30px}
|
|
41
|
+
.mm-row:hover{background:var(--mm-hover)}
|
|
42
|
+
.mm-row.mm-active{background:var(--dsw-active,rgba(57,100,254,.1));}
|
|
43
|
+
.mm-row-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
|
|
44
|
+
.mm-row-time{color:var(--mm-sub);font-size:11px;flex:none}
|
|
45
|
+
.mm-row input{flex:1;min-width:0;font:inherit;font-size:13px;border:1px solid var(--mm-accent);border-radius:4px;padding:1px 4px;background:var(--mm-bg);color:inherit;outline:0}
|
|
46
|
+
.mm-indent{padding-left:22px}
|
|
47
|
+
.mm-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;background:transparent;border-radius:6px;cursor:pointer;color:var(--mm-sub);flex:none;padding:0}
|
|
48
|
+
.mm-icon-btn:hover{background:var(--mm-hover);color:var(--mm-text)}
|
|
49
|
+
.mm-icon-btn:disabled{opacity:.35;cursor:default;background:transparent}
|
|
50
|
+
.mm-icon-btn.mm-on{color:var(--mm-accent)}
|
|
51
|
+
.mm-btn{height:28px;padding:0 10px;border-radius:6px;border:1px solid var(--mm-border-strong);background:var(--mm-bg);cursor:pointer;font-size:13px}
|
|
52
|
+
.mm-btn:hover{background:var(--mm-hover)}
|
|
53
|
+
.mm-btn.mm-primary{background:var(--mm-accent);border-color:var(--mm-accent);color:#fff}
|
|
54
|
+
.mm-btn.mm-danger{color:var(--mm-danger)}
|
|
55
|
+
.mm-btn.mm-primary.mm-danger{background:var(--mm-danger);border-color:var(--mm-danger);color:#fff}
|
|
56
|
+
.mm-hit{padding:6px 8px;border-radius:6px;cursor:pointer}
|
|
57
|
+
.mm-hit:hover{background:var(--mm-hover)}
|
|
58
|
+
.mm-hit-title{font-size:13px;font-weight:500}
|
|
59
|
+
.mm-hit-snip{font-size:12px;color:var(--mm-sub);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
60
|
+
.mm-empty{color:var(--mm-sub);font-size:12px;padding:8px}
|
|
61
|
+
.mm-main{flex:1;min-width:0;display:flex;flex-direction:column;min-height:0}
|
|
62
|
+
.mm-toolbar{display:flex;align-items:center;gap:4px;padding:8px 16px;min-height:48px;border-bottom:1px solid var(--mm-border)}
|
|
63
|
+
.mm-toolbar .mm-grow{flex:1;min-width:8px}
|
|
64
|
+
.mm-seg{display:inline-flex;background:var(--mm-panel);border-radius:8px;padding:2px;gap:2px}
|
|
65
|
+
.mm-seg button{border:0;background:transparent;padding:3px 12px;border-radius:6px;cursor:pointer;font-size:13px;color:var(--mm-sub)}
|
|
66
|
+
.mm-seg button.mm-on{background:var(--mm-elev);color:var(--mm-text);box-shadow:0 1px 2px rgba(0,0,0,.08)}
|
|
67
|
+
.mm-status{font-size:12px;color:var(--mm-sub);padding:0 6px;white-space:nowrap}
|
|
68
|
+
.mm-status.mm-err{color:var(--mm-danger)}
|
|
69
|
+
.mm-sep{width:1px;height:18px;background:var(--mm-border);margin:0 4px}
|
|
70
|
+
.mm-banner{display:flex;align-items:center;gap:8px;padding:8px 16px;background:rgba(229,72,77,.08);color:var(--mm-text);font-size:13px;border-bottom:1px solid var(--mm-border)}
|
|
71
|
+
.mm-banner .mm-grow{flex:1}
|
|
72
|
+
.mm-doc{flex:1;overflow:auto;min-height:0}
|
|
73
|
+
.mm-doc-inner{max-width:860px;margin:0 auto;padding:28px 40px 120px}
|
|
74
|
+
.mm-crumbs{display:flex;flex-wrap:wrap;align-items:center;gap:4px;font-size:12px;color:var(--mm-sub);margin-bottom:8px}
|
|
75
|
+
.mm-crumbs button{border:0;background:transparent;padding:0 2px;cursor:pointer;color:var(--mm-sub);font-size:12px;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
76
|
+
.mm-crumbs button:hover{color:var(--mm-accent)}
|
|
77
|
+
.mm-title{width:100%;border:0;outline:0;background:transparent;color:var(--mm-text);font:inherit;font-size:26px;font-weight:700;line-height:1.35;padding:0;margin:0 0 16px;resize:none;overflow:hidden}
|
|
78
|
+
.mm-title::placeholder{color:var(--mm-sub)}
|
|
79
|
+
.mm-zoom-title{font-size:22px;font-weight:700;margin:0 0 14px;white-space:pre-wrap;word-break:break-word}
|
|
80
|
+
.mm-outline{position:relative}
|
|
81
|
+
.mm-node{position:relative;display:flex;align-items:flex-start;min-height:30px;border-radius:4px}
|
|
82
|
+
.mm-node.mm-drop-before::before,.mm-node.mm-drop-after::after{content:'';position:absolute;left:var(--mm-drop-left,0);right:0;height:2px;background:var(--mm-accent);border-radius:2px;pointer-events:none}
|
|
83
|
+
.mm-node.mm-drop-before::before{top:-1px}
|
|
84
|
+
.mm-node.mm-drop-after::after{bottom:-1px}
|
|
85
|
+
.mm-node.mm-drop-inside .mm-text,.mm-node.mm-drop-inside .mm-input{background:rgba(57,100,254,.1);border-radius:4px}
|
|
86
|
+
.mm-node.mm-dragging{opacity:.4}
|
|
87
|
+
.mm-guide{position:absolute;top:30px;bottom:0;width:1px;background:var(--mm-border)}
|
|
88
|
+
.mm-fold{width:18px;height:30px;flex:none;display:flex;align-items:center;justify-content:center;color:var(--mm-sub);cursor:pointer;opacity:0;border:0;background:transparent;padding:0}
|
|
89
|
+
.mm-node:hover>.mm-fold,.mm-fold.mm-show{opacity:1}
|
|
90
|
+
.mm-fold svg{transition:transform .12s}
|
|
91
|
+
.mm-fold.mm-closed svg{transform:rotate(-90deg)}
|
|
92
|
+
.mm-bullet{width:22px;height:30px;flex:none;display:flex;align-items:center;justify-content:center;cursor:grab;border:0;background:transparent;padding:0}
|
|
93
|
+
.mm-dot{width:6px;height:6px;border-radius:50%;background:var(--mm-text);opacity:.75}
|
|
94
|
+
.mm-bullet.mm-collapsed .mm-dot{box-shadow:0 0 0 4px var(--mm-border-strong)}
|
|
95
|
+
.mm-bullet:hover .mm-dot{box-shadow:0 0 0 4px rgba(57,100,254,.25);background:var(--mm-accent);opacity:1}
|
|
96
|
+
.mm-check{flex:none;width:16px;height:16px;margin:7px 6px 0 0;accent-color:var(--mm-accent);cursor:pointer}
|
|
97
|
+
.mm-text,.mm-input{flex:1;min-width:0;padding:3px 2px;font:inherit;line-height:24px;white-space:pre-wrap;word-break:break-word;color:var(--mm-text);min-height:30px}
|
|
98
|
+
.mm-text{cursor:text}
|
|
99
|
+
.mm-text:empty::before{content:'\\200b'}
|
|
100
|
+
.mm-input{border:0;outline:0;background:transparent;resize:none;overflow:hidden;display:block;margin:0}
|
|
101
|
+
.mm-done>.mm-text,.mm-done>.mm-input{color:var(--mm-sub);text-decoration:line-through}
|
|
102
|
+
.mm-code{font-family:var(--mm-mono);font-size:.9em;background:var(--mm-hover);padding:1px 4px;border-radius:4px}
|
|
103
|
+
.mm-link{color:var(--mm-accent);text-decoration:none}
|
|
104
|
+
.mm-link:hover{text-decoration:underline}
|
|
105
|
+
.mm-tag{color:var(--mm-accent);background:rgba(57,100,254,.08);padding:0 4px;border-radius:4px}
|
|
106
|
+
.mm-add{display:flex;align-items:center;gap:6px;color:var(--mm-sub);font-size:13px;padding:4px 0 4px 18px;cursor:pointer;border:0;background:transparent}
|
|
107
|
+
.mm-add:hover{color:var(--mm-accent)}
|
|
108
|
+
.mm-blank{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;flex:1;color:var(--mm-sub)}
|
|
109
|
+
.mm-menu{position:fixed;z-index:1000;min-width:180px;background:var(--mm-elev);border:1px solid var(--mm-border);border-radius:8px;box-shadow:var(--mm-shadow);padding:4px;font-size:13px;max-height:70vh;overflow:auto}
|
|
110
|
+
.mm-menu-item{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:5px;cursor:pointer;white-space:nowrap;border:0;background:transparent;width:100%;text-align:left}
|
|
111
|
+
.mm-menu-item:hover,.mm-menu-item:focus-visible{background:var(--mm-hover);outline:0}
|
|
112
|
+
.mm-menu-item.mm-danger{color:var(--mm-danger)}
|
|
113
|
+
.mm-menu-item:disabled{opacity:.4;cursor:default}
|
|
114
|
+
.mm-menu-key{margin-left:auto;color:var(--mm-sub);font-size:11px;padding-left:16px}
|
|
115
|
+
.mm-menu-sep{height:1px;background:var(--mm-border);margin:4px 2px}
|
|
116
|
+
.mm-menu-label{padding:4px 10px;color:var(--mm-sub);font-size:11px}
|
|
117
|
+
.mm-modal-mask{position:fixed;inset:0;z-index:1001;background:rgba(0,0,0,.25);display:flex;align-items:center;justify-content:center}
|
|
118
|
+
.mm-modal{background:var(--mm-elev);color:var(--mm-text);border-radius:12px;box-shadow:var(--mm-shadow);width:min(440px,calc(100vw - 32px));max-height:80vh;display:flex;flex-direction:column;padding:20px}
|
|
119
|
+
.mm-modal h3{margin:0 0 12px;font-size:16px}
|
|
120
|
+
.mm-modal-body{overflow:auto;font-size:13px;color:var(--mm-text)}
|
|
121
|
+
.mm-modal-body input[type=text]{width:100%;height:32px;border:1px solid var(--mm-border-strong);border-radius:6px;padding:0 8px;font:inherit;background:var(--mm-bg);color:inherit;outline:0}
|
|
122
|
+
.mm-modal-body input[type=text]:focus{border-color:var(--mm-accent)}
|
|
123
|
+
.mm-modal-foot{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
|
|
124
|
+
.mm-backup-row{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid var(--mm-border)}
|
|
125
|
+
.mm-backup-row span{flex:1}
|
|
126
|
+
.mm-toast{position:absolute;left:50%;bottom:24px;transform:translateX(-50%);background:var(--mm-text);color:var(--mm-bg);padding:8px 14px;border-radius:8px;font-size:13px;z-index:1002;box-shadow:var(--mm-shadow);max-width:80%}
|
|
127
|
+
.mm-map{flex:1;position:relative;overflow:hidden;min-height:0;background:var(--mm-bg);cursor:grab;touch-action:none}
|
|
128
|
+
.mm-map.mm-panning{cursor:grabbing}
|
|
129
|
+
.mm-map>svg{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
130
|
+
.mm-map:focus{outline:0}
|
|
131
|
+
.mm-map-edge{fill:none;stroke:var(--mm-border-strong);stroke-width:1.5}
|
|
132
|
+
.mm-map-node rect{fill:var(--mm-elev);stroke:var(--mm-border-strong);stroke-width:1}
|
|
133
|
+
.mm-map-node.mm-root rect{fill:var(--mm-accent);stroke:var(--mm-accent)}
|
|
134
|
+
.mm-map-node.mm-root text{fill:#fff;font-weight:600}
|
|
135
|
+
.mm-map-node.mm-depth1 rect{fill:var(--mm-panel)}
|
|
136
|
+
.mm-map-node text{fill:var(--mm-text);font-size:14px;dominant-baseline:central}
|
|
137
|
+
.mm-map-node.mm-done text{fill:var(--mm-sub);text-decoration:line-through}
|
|
138
|
+
.mm-map-node.mm-sel rect{stroke:var(--mm-accent);stroke-width:2}
|
|
139
|
+
.mm-map-node{cursor:pointer}
|
|
140
|
+
.mm-map-toggle circle{fill:var(--mm-elev);stroke:var(--mm-border-strong)}
|
|
141
|
+
.mm-map-toggle text{fill:var(--mm-sub);font-size:10px;text-anchor:middle;dominant-baseline:central}
|
|
142
|
+
.mm-map-toggle{cursor:pointer}
|
|
143
|
+
.mm-map-toggle:hover circle{stroke:var(--mm-accent)}
|
|
144
|
+
.mm-map-ctrl{position:absolute;right:16px;bottom:16px;display:flex;align-items:center;gap:2px;background:var(--mm-elev);border:1px solid var(--mm-border);border-radius:8px;padding:2px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
|
|
145
|
+
.mm-map-ctrl span{font-size:12px;color:var(--mm-sub);min-width:44px;text-align:center}
|
|
146
|
+
.mm-map-edit{position:absolute;z-index:5;border:2px solid var(--mm-accent);border-radius:6px;background:var(--mm-elev);color:var(--mm-text);font:inherit;font-size:14px;line-height:20px;padding:6px 10px;resize:none;outline:0;overflow:hidden;transform-origin:0 0}
|
|
147
|
+
.mm-map-hint{position:absolute;left:16px;bottom:16px;font-size:12px;color:var(--mm-sub);pointer-events:none}
|
|
148
|
+
.mm-side-toggle{display:none}
|
|
149
|
+
.mm-scrim{display:none}
|
|
150
|
+
@media (max-width:760px){
|
|
151
|
+
.mm-side{position:absolute;z-index:20;top:var(--dsh-atb-viewport-top,0px);bottom:0;left:0;transform:translateX(-100%);transition:transform .18s;box-shadow:var(--mm-shadow)}
|
|
152
|
+
.mm-app.mm-side-open .mm-side{transform:none}
|
|
153
|
+
.mm-app.mm-side-open .mm-scrim{display:block;position:absolute;inset:0;z-index:19;background:rgba(0,0,0,.2)}
|
|
154
|
+
.mm-side-toggle{display:inline-flex}
|
|
155
|
+
.mm-doc-inner{padding:20px 16px 120px}
|
|
156
|
+
.mm-hide-narrow{display:none}
|
|
157
|
+
}
|
|
158
|
+
`,At="dsh-mindmap-style";function Pt(){if(typeof document>"u")return()=>{};let e=document.getElementById(At);e===null&&(e=document.createElement("style"),e.id=At,e.textContent=un,document.head.appendChild(e));let t=e;return()=>{t.remove()}}var pe=require("react/jsx-runtime"),mn="dsh-mindmap/client",pn=["slots"],Lt="dsh-mindmap";function fn(e){let t=typeof e.size=="number"?e.size:16;return(0,pe.jsxs)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,pe.jsx)("rect",{x:"1.5",y:"6",width:"4.5",height:"4",rx:"1"}),(0,pe.jsx)("rect",{x:"10",y:"2",width:"4.5",height:"3.2",rx:"1"}),(0,pe.jsx)("rect",{x:"10",y:"10.8",width:"4.5",height:"3.2",rx:"1"}),(0,pe.jsx)("path",{d:"M6 8h1.5c1 0 1-4.4 2.5-4.4M7.5 8c1 0 1 4.4 2.5 4.4"})]})}function gn(){return(0,pe.jsx)(Rt,{})}function hn(e){let t=[];try{t.push(Pt());let n=e.get?.("slots");if(n===void 0)throw new Error("DSH panel service (slots) unavailable");t.push(n.inject("main",()=>n.register({name:"main",key:Lt},gn))),t.push(n.inject("sidebar.panellist",()=>n.register({name:"sidebar.panellist",id:Lt,order:20,label:()=>"\u601D\u7EF4\u5BFC\u56FE"},fn)))}catch(n){console.error("[dsh-mindmap] client mount failed:",n)}try{e.effect?.(()=>()=>{for(let n of t.splice(0).reverse())try{n()}catch(o){console.warn("[dsh-mindmap] dispose failed:",o)}},"dsh-mindmap: client mount")}catch(n){console.error("[dsh-mindmap] client effect failed:",n)}}
|
|
159
|
+
|
|
160
|
+
return module.exports}});
|