dsh-mnemon-source-documents 0.5.13 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -4,37 +4,15 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
- //#region \0rolldown/runtime.js
8
- var __create = Object.create;
9
- var __defProp = Object.defineProperty;
10
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
- var __getOwnPropNames = Object.getOwnPropertyNames;
12
- var __getProtoOf = Object.getPrototypeOf;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
16
- key = keys[i];
17
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: ((k) => from[k]).bind(null, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
25
- value: mod,
26
- enumerable: true
27
- }) : target, mod));
28
- //#endregion
29
7
  let react = require("react");
30
- react = __toESM(react, 1);
31
8
  let dsh_mnemon_client = require("dsh-mnemon/client");
9
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
32
10
  let react_jsx_runtime = require("react/jsx-runtime");
33
11
  //#region presentation/locales.json
34
12
  var zh = {
35
13
  "nav.documents": "档案",
36
14
  "documents.title": "项目档案",
37
- "documents.description": "当前工作区的项目文档:先检索,再按需阅读全文;接近容量上限时,最久未用的档案会归档。",
15
+ "documents.description": "按需检索的工作区文档,超限时自动归档。",
38
16
  "documents.capacity": "{used} / {limit}",
39
17
  "documents.summary": "档案存储摘要",
40
18
  "documents.active": "活跃档案",
@@ -44,13 +22,13 @@ window.__ModuleLoader__.load({
44
22
  "documents.activeCapacity": "活跃容量",
45
23
  "documents.capacityHint": "按实际 UTF-8 文件大小计算",
46
24
  "documents.searchAria": "检索项目档案",
47
- "documents.searchPlaceholder": "搜索设计、调查、流程或交接记录…",
25
+ "documents.searchPlaceholder": "搜索档案…",
48
26
  "documents.search": "检索",
49
27
  "documents.scope": "档案范围",
50
- "documents.new": "新建档案",
28
+ "documents.new": "新建",
51
29
  "documents.newTitle": "创建托管档案",
52
30
  "documents.editTitle": "编辑活跃档案",
53
- "documents.editorHint": "控制层会生成 frontmatter、哈希与修订号;原项目文件始终只读。",
31
+ "documents.editorHint": "自动维护元数据与修订号,不修改项目源文件。",
54
32
  "documents.managedCopy": "托管副本",
55
33
  "documents.name": "标题",
56
34
  "documents.routing": "检索说明",
@@ -58,8 +36,8 @@ window.__ModuleLoader__.load({
58
36
  "documents.sourcesPlaceholder": "src/index.ts, docs/architecture.md",
59
37
  "documents.markdown": "Markdown 内容",
60
38
  "documents.saving": "保存中…",
61
- "documents.create": "创建档案",
62
- "documents.save": "保存修订",
39
+ "documents.create": "创建",
40
+ "documents.save": "保存",
63
41
  "documents.created": "已创建活跃档案。",
64
42
  "documents.createdAfterArchive": "已先迁移 {count} 份旧档案,再创建活跃档案。",
65
43
  "documents.updated": "已保存新的档案修订。",
@@ -80,6 +58,12 @@ window.__ModuleLoader__.load({
80
58
  "documents.selectText": "在左侧查看活跃项目知识或沿 Mnemon 引用打开归档原文。",
81
59
  "documents.coldArchive": "归档原文",
82
60
  "documents.edit": "编辑",
61
+ "documents.delete": "删除",
62
+ "documents.deleteConfirm": "永久删除这份档案?",
63
+ "documents.deleteDescription": "永久移除托管副本,项目源文件与记忆空间不受影响,且无法撤销。",
64
+ "documents.deleteNow": "确认删除",
65
+ "documents.deleting": "删除中…",
66
+ "documents.deleted": "档案已永久删除。",
83
67
  "documents.path": "托管路径",
84
68
  "documents.revision": "修订",
85
69
  "documents.hash": "内容哈希",
@@ -87,17 +71,16 @@ window.__ModuleLoader__.load({
87
71
  "documents.archiveReceipt": "Mnemon 冷索引回执",
88
72
  "documents.archiveNote": "归档说明",
89
73
  "documents.archiveTitle": "迁入归档",
90
- "documents.archiveDescription": "独立任务 Agent 先拟定摘要和目标空间;Host 校验后写入冷索引,再移动原文。没有已启用且支持精确写入与删除的记忆空间时,原文直接移入本地归档,不建立索引。",
74
+ "documents.archiveDescription": "生成摘要索引并移入归档,释放活跃容量。",
91
75
  "documents.archive": "归档",
92
76
  "documents.archiveConfirm": "确认归档这份档案?",
93
77
  "documents.archiving": "归档中…",
94
- "documents.archiveNow": "确认归档",
95
- "documents.footnote": "`.mnemon/documents/index.json` 是控制面事实源;active 总量固定不超过 10 MB,archived 不计入上限,项目源文件不会被修改。"
78
+ "documents.archiveNow": "确认归档"
96
79
  };
97
80
  var en = {
98
81
  "nav.documents": "Documents",
99
82
  "documents.title": "Project Documents",
100
- "documents.description": "Project documents for this workspace: searched first, read in full when needed; near the limit the least-used ones are archived.",
83
+ "documents.description": "Workspace documents searched on demand and archived when full.",
101
84
  "documents.capacity": "{used} / {limit}",
102
85
  "documents.summary": "Document storage summary",
103
86
  "documents.active": "Active",
@@ -107,13 +90,13 @@ window.__ModuleLoader__.load({
107
90
  "documents.activeCapacity": "Active capacity",
108
91
  "documents.capacityHint": "Measured from actual UTF-8 files",
109
92
  "documents.searchAria": "Search project documents",
110
- "documents.searchPlaceholder": "Search designs, investigations, procedures, or handoffs…",
93
+ "documents.searchPlaceholder": "Search documents…",
111
94
  "documents.search": "Search",
112
95
  "documents.scope": "Document scope",
113
- "documents.new": "New document",
96
+ "documents.new": "New",
114
97
  "documents.newTitle": "Create managed document",
115
98
  "documents.editTitle": "Edit active document",
116
- "documents.editorHint": "The control plane generates frontmatter, hashes, and revisions. Project source files stay read only.",
99
+ "documents.editorHint": "Metadata and revisions are managed automatically; source files stay untouched.",
117
100
  "documents.managedCopy": "Managed copy",
118
101
  "documents.name": "Title",
119
102
  "documents.routing": "Retrieval description",
@@ -121,8 +104,8 @@ window.__ModuleLoader__.load({
121
104
  "documents.sourcesPlaceholder": "src/index.ts, docs/architecture.md",
122
105
  "documents.markdown": "Markdown content",
123
106
  "documents.saving": "Saving…",
124
- "documents.create": "Create document",
125
- "documents.save": "Save revision",
107
+ "documents.create": "Create",
108
+ "documents.save": "Save",
126
109
  "documents.created": "Active document created.",
127
110
  "documents.createdAfterArchive": "Archived {count} older document(s), then created the active document.",
128
111
  "documents.updated": "New document revision saved.",
@@ -143,6 +126,12 @@ window.__ModuleLoader__.load({
143
126
  "documents.selectText": "Read active project knowledge or follow a Mnemon reference to an archived original.",
144
127
  "documents.coldArchive": "Archived original",
145
128
  "documents.edit": "Edit",
129
+ "documents.delete": "Delete",
130
+ "documents.deleteConfirm": "Permanently delete this document?",
131
+ "documents.deleteDescription": "Permanently removes the managed copy; project files and Memory Space notes stay untouched. This cannot be undone.",
132
+ "documents.deleteNow": "Confirm delete",
133
+ "documents.deleting": "Deleting…",
134
+ "documents.deleted": "Document permanently deleted.",
146
135
  "documents.path": "Managed path",
147
136
  "documents.revision": "Revision",
148
137
  "documents.hash": "Content hash",
@@ -150,16 +139,15 @@ window.__ModuleLoader__.load({
150
139
  "documents.archiveReceipt": "Mnemon cold-index receipt",
151
140
  "documents.archiveNote": "Archive note",
152
141
  "documents.archiveTitle": "Move to archive",
153
- "documents.archiveDescription": "An independent task Agent proposes a summary and destination. The Host validates and writes the cold index before moving the original. Without an active Memory Space that has exact writes and safe deletion, the original moves to the local archive without an index.",
142
+ "documents.archiveDescription": "Index a summary in Memory Spaces and move the full text to archive.",
154
143
  "documents.archive": "Archive",
155
144
  "documents.archiveConfirm": "Archive this document?",
156
145
  "documents.archiving": "Archiving…",
157
- "documents.archiveNow": "Confirm archive",
158
- "documents.footnote": "`.mnemon/documents/index.json` is the control-plane source of truth. active stays at or below 10 MB, archived is excluded, and project source files are never modified."
146
+ "documents.archiveNow": "Confirm archive"
159
147
  };
160
148
  //#endregion
161
149
  //#region \0source-css:/home/runner/work/dsh-mnemon/dsh-mnemon/plugins/dsh-mnemon-source-documents/presentation/page.module.css.mjs
162
- const css$2 = ".IIa07q_documentSummary{grid-template-columns:.7fr .7fr 1.6fr;gap:12px;margin-bottom:12px;display:grid}.IIa07q_documentSummary article{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);min-width:0;min-height:92px;padding:14px 16px}.IIa07q_documentSummary article>span{color:var(--mn-faint);font-size:12px;line-height:18px;display:block}.IIa07q_documentSummary article>strong{font-variant-numeric:tabular-nums;margin:4px 0 2px;font-size:20px;font-weight:500;line-height:28px;display:block}.IIa07q_documentSummary article>small{color:var(--mn-faint);font-size:12px;line-height:18px}.IIa07q_documentCapacity>div{background:var(--mn-fill);border-radius:999px;height:4px;margin:8px 0 6px;overflow:hidden}.IIa07q_documentCapacity>div i{border-radius:inherit;background:var(--dsw-alias-brand-primary);height:100%;transition:width .3s;display:block}.IIa07q_documentToolbar{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);align-items:center;gap:8px;margin-bottom:12px;padding:8px;display:flex}.IIa07q_documentToolbar form{flex:1;align-items:center;gap:8px;min-width:260px;display:flex}.IIa07q_documentSearch{flex:1}.IIa07q_documentEditor input,.IIa07q_documentEditor textarea{border:.5px solid var(--mn-field-line);border-radius:var(--dsw-radius-md);width:100%;color:var(--mn-text);background:var(--mn-input);outline:0;padding:6px 10px;font-size:13px;line-height:20px}.IIa07q_documentEditor input:focus,.IIa07q_documentEditor textarea:focus{border-color:var(--mn-accent)}.IIa07q_documentToolbar>div{border-radius:var(--dsw-radius-md);background:var(--mn-hover);align-items:center;gap:2px;padding:3px;display:flex}.IIa07q_documentToolbar>div button{border-radius:var(--dsw-radius-sm);min-height:28px;color:var(--mn-muted);cursor:pointer;background:0 0;border:0;padding:0 12px;font-size:13px;font-weight:500;line-height:20px}.IIa07q_documentToolbar>div button:hover{color:var(--mn-text)}.IIa07q_documentToolbar>div button[data-active]{color:var(--mn-text);background:var(--mn-layer-1);box-shadow:var(--dsw-elevation-soft)}.IIa07q_documentToolbar>div b{color:var(--mn-faint);font-variant-numeric:tabular-nums;margin-left:6px;font-size:12px;font-weight:400}.IIa07q_documentWorkspace{grid-template-columns:minmax(250px,310px) minmax(0,1fr);gap:12px;min-height:590px;display:grid}.IIa07q_documentList,.IIa07q_documentReader{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);min-width:0;overflow:hidden}.IIa07q_documentList{align-self:stretch}.IIa07q_documentList>header{border-bottom:.5px solid var(--mn-line);min-height:44px;color:var(--mn-faint);justify-content:space-between;align-items:center;padding:0 14px;font-size:12px;line-height:18px;display:flex}.IIa07q_documentList>header code{color:var(--mn-muted)}.IIa07q_documentList>button{--mn-provider-color:var(--mn-faint);border-radius:var(--dsw-radius-md);width:calc(100% - 12px);color:var(--mn-text);text-align:left;cursor:pointer;background:0 0;border:0;margin:6px 6px 0;padding:10px 12px;transition:background-color .15s;display:block}.IIa07q_documentList>button:hover{background:var(--mn-hover)}.IIa07q_documentList>button[data-selected]{background:var(--mn-fill)}.IIa07q_documentList>button>div{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.IIa07q_documentList>button strong{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;line-height:20px;overflow:hidden}.IIa07q_documentList>button time{color:var(--mn-faint);font-variant-numeric:tabular-nums;flex:none;font-size:11px}.IIa07q_documentList>button p{color:var(--mn-faint);-webkit-line-clamp:2;-webkit-box-orient:vertical;margin:4px 0 6px;font-size:12px;line-height:18px;display:-webkit-box;overflow:hidden}.IIa07q_documentList>button footer{color:var(--mn-faint);align-items:center;gap:8px;font-size:11px;line-height:16px;display:flex}.IIa07q_documentList>button footer code{margin-left:auto}.IIa07q_documentList>button footer em{color:var(--mn-danger);font-style:normal}.IIa07q_documentListEmpty{min-height:230px;color:var(--mn-muted);text-align:center;align-content:center;place-items:center;gap:4px;padding:24px;display:grid}.IIa07q_documentListEmpty>span{color:var(--mn-faint);margin-bottom:6px;font-size:24px;line-height:1}.IIa07q_documentListEmpty p{color:var(--mn-faint);margin:0;font-size:12px;line-height:18px}.IIa07q_documentReader{padding:clamp(16px,2vw,24px)}.IIa07q_documentReader>.IIa07q_emptyState{background:0 0;border:0;height:100%}.IIa07q_documentDetail>header{border-bottom:.5px solid var(--mn-line);justify-content:space-between;align-items:flex-start;gap:16px;padding-bottom:14px;display:flex}.IIa07q_documentDetail>header span{color:var(--mn-faint);font-size:12px;line-height:18px}.IIa07q_documentDetail>header h3{margin:2px 0;font-size:16px;font-weight:500;line-height:24px}.IIa07q_documentDetail>header p{color:var(--mn-faint);margin:0;font-size:12px;line-height:18px}.IIa07q_documentDetail>dl{border:.5px solid var(--mn-line);border-radius:var(--dsw-radius-md);grid-template-columns:2fr .45fr .8fr .55fr;margin:12px 0;display:grid;overflow:hidden}.IIa07q_documentDetail>dl>div{min-width:0;padding:8px 10px}.IIa07q_documentDetail>dl>div+div{border-left:.5px solid var(--mn-line)}.IIa07q_documentDetail dt{color:var(--mn-faint);margin-bottom:2px;font-size:11px;line-height:16px}.IIa07q_documentDetail dd{text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:12px;line-height:18px;overflow:hidden}.IIa07q_documentSources{flex-wrap:wrap;align-items:center;gap:6px;margin:12px 0;display:flex}.IIa07q_documentSources>span{color:var(--mn-faint);margin-right:4px;font-size:12px}.IIa07q_documentSources code,.IIa07q_documentArchiveReceipt code{color:var(--mn-muted);background:var(--mn-fill);border-radius:999px;padding:1px 8px;font-size:11px;line-height:17px}.IIa07q_markdownBody{overflow-wrap:anywhere;border:.5px solid var(--mn-line);border-radius:var(--dsw-radius-md);min-height:310px;color:var(--mn-text);margin:16px 0 0;padding:clamp(16px,2.5vw,28px);font-size:14px;line-height:1.75}.IIa07q_markdownBody>:first-child{margin-top:0}.IIa07q_markdownBody>:last-child{margin-bottom:0}.IIa07q_markdownBody h1,.IIa07q_markdownBody h2,.IIa07q_markdownBody h3,.IIa07q_markdownBody h4{color:var(--mn-text);margin:1.5em 0 .6em;font-weight:500;line-height:1.35}.IIa07q_markdownBody h1{border-bottom:.5px solid var(--mn-line);padding-bottom:.35em;font-size:1.6em}.IIa07q_markdownBody h2{border-bottom:.5px solid var(--mn-line);padding-bottom:.3em;font-size:1.35em}.IIa07q_markdownBody h3{font-size:1.15em}.IIa07q_markdownBody p,.IIa07q_markdownBody ul,.IIa07q_markdownBody ol,.IIa07q_markdownBody blockquote,.IIa07q_markdownBody table,.IIa07q_markdownBody pre{margin:.85em 0}.IIa07q_markdownBody ul,.IIa07q_markdownBody ol{padding-left:1.6em}.IIa07q_markdownBody li+li{margin-top:.3em}.IIa07q_markdownBody blockquote{border-left:2px solid var(--mn-line-strong);color:var(--mn-muted);margin-inline:0;padding:.1em 1em}.IIa07q_markdownBody code{border-radius:var(--dsw-radius-xs);color:var(--mn-text);background:var(--dsw-alias-markdown-inline-code,var(--mn-fill));font:.88em/1.55 var(--mn-code);padding:.15em .4em}.IIa07q_markdownBody pre{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block,var(--mn-fill));max-width:100%;padding:12px 16px;overflow:auto}.IIa07q_markdownBody pre code{background:0 0;padding:0;font-size:12px}.IIa07q_markdownBody a{color:var(--dsw-alias-link,var(--mn-accent));text-underline-offset:3px;text-decoration-thickness:1px}.IIa07q_markdownBody hr{border:0;border-top:.5px solid var(--mn-line);margin:1.8em 0}.IIa07q_markdownBody table{border-collapse:collapse;max-width:100%;display:block;overflow-x:auto}.IIa07q_markdownBody th,.IIa07q_markdownBody td{border:.5px solid var(--mn-line);text-align:left;vertical-align:top;padding:8px 10px}.IIa07q_markdownBody th{background:var(--mn-fill);font-weight:500}.IIa07q_markdownBody img{border-radius:var(--dsw-radius-sm);max-width:100%;height:auto}.IIa07q_documentArchiveReceipt{border-radius:var(--dsw-radius-md);background:color-mix(in srgb, var(--mn-success) 8%, transparent);margin:12px 0;padding:10px 12px}.IIa07q_documentArchiveReceipt p{color:var(--mn-muted);margin:2px 0 8px;font-size:12px;line-height:18px}.IIa07q_documentArchiveReceipt div{flex-wrap:wrap;gap:6px;display:flex}.IIa07q_documentDanger{border-top:.5px solid var(--mn-line);justify-content:flex-end;align-items:center;gap:8px;min-height:56px;margin-top:12px;padding-top:12px;display:flex}.IIa07q_documentDanger>div{margin-right:auto}.IIa07q_documentDanger strong{font-size:13px;font-weight:500;line-height:20px;display:block}.IIa07q_documentDanger p{color:var(--mn-faint);margin:2px 0 0;font-size:12px;line-height:18px}.IIa07q_documentDanger>span{color:var(--mn-danger);margin-right:auto;font-size:12px}.IIa07q_documentEditor{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);margin-bottom:12px;padding:16px}.IIa07q_documentReader>.IIa07q_documentEditor{background:0 0;border:0;margin:0;padding:0}.IIa07q_documentEditor>header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.IIa07q_documentEditor h3{margin:0;font-size:14px;font-weight:500;line-height:22px}.IIa07q_documentEditor header p{color:var(--mn-faint);margin:2px 0 0;font-size:12px;line-height:18px}.IIa07q_documentEditor header>span,.IIa07q_documentEditor header>code{color:var(--mn-muted);background:var(--mn-fill);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.IIa07q_documentEditor label{color:var(--mn-muted);gap:6px;margin-top:12px;font-size:12px;font-weight:500;line-height:18px;display:grid}.IIa07q_documentEditor textarea{resize:vertical;line-height:1.65}.IIa07q_documentEditorMeta{grid-template-columns:.8fr 1.2fr;gap:12px;display:grid}.IIa07q_documentEditorMeta label{margin:0}.IIa07q_documentEditor footer{justify-content:flex-end;gap:8px;margin-top:12px;display:flex}@media (width<=1000px){.IIa07q_documentWorkspace{grid-template-columns:minmax(220px,270px) minmax(0,1fr)}.IIa07q_documentDetail>dl{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentDetail>dl>div+div{border-left:0}.IIa07q_documentDetail>dl>div:nth-child(2n){border-left:.5px solid var(--mn-line)}.IIa07q_documentDetail>dl>div:nth-child(n+3){border-top:.5px solid var(--mn-line)}}@media (width<=760px){.IIa07q_documentSummary{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentCapacity{grid-column:1/-1}.IIa07q_documentToolbar{flex-direction:column;align-items:stretch}.IIa07q_documentToolbar form{min-width:0}.IIa07q_documentToolbar>div,.IIa07q_documentToolbar>button{width:100%}.IIa07q_documentToolbar>div button{flex:1}.IIa07q_documentWorkspace{grid-template-columns:1fr;min-height:0}.IIa07q_documentList{-webkit-overflow-scrolling:touch;max-height:330px;overflow:auto}.IIa07q_documentReader{min-height:430px}.IIa07q_documentEditorMeta{grid-template-columns:1fr}}@media (width<=520px){.IIa07q_documentDetail>header,.IIa07q_documentDanger{flex-direction:column;align-items:flex-start}.IIa07q_documentDetail>header>div:last-child,.IIa07q_documentDetail>header button{width:100%}.IIa07q_documentDanger>div,.IIa07q_documentDanger>span{margin-right:0}.IIa07q_documentDanger>button{width:100%}.IIa07q_documentDetail>dl{grid-template-columns:1fr}.IIa07q_documentDetail>dl>div:nth-child(2n){border-left:0}.IIa07q_documentDetail>dl>div+div{border-top:.5px solid var(--mn-line)}.IIa07q_markdownBody{padding:16px;font-size:13px}}";
150
+ const css$2 = ".IIa07q_documentSummary{grid-template-columns:.7fr .7fr 1.6fr;gap:12px;margin-bottom:12px;display:grid}.IIa07q_documentSummary article{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);min-width:0;min-height:92px;padding:14px 16px}.IIa07q_documentSummary article>span{color:var(--mn-faint);font-size:12px;line-height:18px;display:block}.IIa07q_documentSummary article>strong{font-variant-numeric:tabular-nums;margin:4px 0 2px;font-size:20px;font-weight:500;line-height:28px;display:block}.IIa07q_documentSummary article>small{color:var(--mn-faint);font-size:12px;line-height:18px}.IIa07q_documentCapacity>div{background:var(--mn-fill);border-radius:999px;height:4px;margin:8px 0 6px;overflow:hidden}.IIa07q_documentCapacity>div i{border-radius:inherit;background:var(--dsw-alias-brand-primary);height:100%;transition:width .3s;display:block}.IIa07q_documentToolbar{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);align-items:center;gap:8px;margin-bottom:12px;padding:10px 12px;display:flex}.IIa07q_documentToolbar form{flex:1;align-items:center;gap:8px;min-width:260px;display:flex}.IIa07q_documentSearch{flex:1}.IIa07q_documentEditor input,.IIa07q_documentEditor textarea{border:.5px solid var(--mn-field-line);border-radius:var(--dsw-radius-md);width:100%;color:var(--mn-text);background:var(--mn-input);outline:0;padding:6px 10px;font-size:13px;line-height:20px}.IIa07q_documentEditor input:focus,.IIa07q_documentEditor textarea:focus{border-color:var(--mn-accent)}.IIa07q_documentToolbar>div{--dsh-segment-count:2;--dsh-segment-index:0;border-radius:var(--dsw-radius-md);background:var(--mn-hover);grid-auto-columns:1fr;grid-auto-flow:column;align-items:center;gap:2px;padding:4px;display:inline-grid;position:relative}.IIa07q_documentToolbar>div:before{content:\"\";width:calc((100% - 8px - 2px * (var(--dsh-segment-count) - 1)) / var(--dsh-segment-count));border-radius:var(--dsw-radius-sm);background:var(--mn-layer-1);height:calc(100% - 8px);box-shadow:var(--dsw-elevation-soft);transform:translateX(calc(var(--dsh-segment-index) * (100% + 2px)));pointer-events:none;transition:transform .16s cubic-bezier(.22,1,.36,1);position:absolute;top:4px;left:4px}.IIa07q_documentToolbar>div button{z-index:1;border-radius:var(--dsw-radius-sm);height:28px;color:var(--mn-muted);white-space:nowrap;cursor:pointer;background:0 0;border:0;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;line-height:20px;transition:color .12s;display:inline-flex;position:relative}.IIa07q_documentToolbar>div button:hover,.IIa07q_documentToolbar>div button[data-active]{color:var(--mn-text)}.IIa07q_documentToolbar>div button:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--mn-focus);outline-offset:-2px}.IIa07q_documentToolbar>div b{color:var(--mn-faint);font-variant-numeric:tabular-nums;margin-left:6px;font-size:12px;font-weight:400}.IIa07q_documentWorkspace{grid-template-columns:minmax(250px,310px) minmax(0,1fr);gap:12px;min-height:590px;display:grid}.IIa07q_documentList,.IIa07q_documentReader{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);min-width:0;overflow:hidden}.IIa07q_documentList{align-self:stretch}.IIa07q_documentList>header{border-bottom:.5px solid var(--mn-line);min-height:44px;color:var(--mn-faint);justify-content:space-between;align-items:center;padding:0 14px;font-size:12px;line-height:18px;display:flex}.IIa07q_documentList>header code{color:var(--mn-muted);font-variant-numeric:tabular-nums}.IIa07q_documentList>button{--mn-provider-color:var(--mn-faint);border-radius:var(--dsw-radius-md);width:calc(100% - 12px);color:var(--mn-text);text-align:left;cursor:pointer;background:0 0;border:0;margin:6px 6px 0;padding:10px 12px;transition:background-color .15s;display:block}.IIa07q_documentList>button:hover{background:var(--mn-hover)}.IIa07q_documentList>button[data-selected]{background:var(--mn-fill)}.IIa07q_documentList>button>div{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.IIa07q_documentList>button strong{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;line-height:20px;overflow:hidden}.IIa07q_documentList>button time{color:var(--mn-faint);font-variant-numeric:tabular-nums;flex:none;font-size:11px}.IIa07q_documentList>button p{color:var(--mn-faint);-webkit-line-clamp:2;-webkit-box-orient:vertical;margin:4px 0 6px;font-size:12px;line-height:18px;display:-webkit-box;overflow:hidden}.IIa07q_documentList>button footer{color:var(--mn-faint);font-variant-numeric:tabular-nums;align-items:center;gap:8px;font-size:11px;line-height:16px;display:flex}.IIa07q_documentList>button footer code{margin-left:auto}.IIa07q_documentList>button footer em{color:var(--mn-danger);font-style:normal}.IIa07q_documentListEmpty{min-height:230px;color:var(--mn-muted);text-align:center;align-content:center;place-items:center;gap:4px;padding:24px;display:grid}.IIa07q_documentListEmpty>span{color:var(--mn-faint);margin-bottom:6px;font-size:24px;line-height:1}.IIa07q_documentListEmpty p{color:var(--mn-faint);margin:0;font-size:12px;line-height:18px}.IIa07q_documentReader{padding:clamp(16px,2vw,24px)}.IIa07q_documentReader>.IIa07q_emptyState{background:0 0;border:0;height:100%}.IIa07q_documentReader>.IIa07q_loading{justify-content:center;align-items:center;gap:8px;height:100%;min-height:240px;display:flex}.IIa07q_documentReader>.IIa07q_loading [class*=sectionSpinner]{position:static}.IIa07q_documentDetail>header{border-bottom:.5px solid var(--mn-line);justify-content:space-between;align-items:flex-start;gap:16px;padding-bottom:14px;display:flex}.IIa07q_documentDetail>header span{color:var(--mn-faint);font-size:12px;line-height:18px}.IIa07q_documentDetail>header h3{margin:2px 0;font-size:16px;font-weight:500;line-height:24px}.IIa07q_documentDetail>header p{color:var(--mn-faint);margin:0;font-size:12px;line-height:18px}.IIa07q_documentActions{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.IIa07q_documentDetail>dl{border:.5px solid var(--mn-line);border-radius:var(--dsw-radius-md);grid-template-columns:2fr .45fr .8fr .55fr;margin:12px 0;display:grid;overflow:hidden}.IIa07q_documentDetail>dl>div{min-width:0;padding:8px 10px}.IIa07q_documentDetail>dl>div+div{border-left:.5px solid var(--mn-line)}.IIa07q_documentDetail dt{color:var(--mn-faint);margin-bottom:2px;font-size:11px;line-height:16px}.IIa07q_documentDetail dd{text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums;margin:0;font-size:12px;line-height:18px;overflow:hidden}.IIa07q_documentSources{flex-wrap:wrap;align-items:center;gap:6px;margin:12px 0;display:flex}.IIa07q_documentSources>span{color:var(--mn-faint);margin-right:4px;font-size:12px}.IIa07q_documentSources code,.IIa07q_documentArchiveReceipt code{max-width:100%;color:var(--mn-muted);background:var(--mn-fill);border-radius:999px;align-items:center;padding:1px 8px;font-size:11px;line-height:17px;display:inline-flex}.IIa07q_markdownBody{overflow-wrap:anywhere;border:.5px solid var(--mn-line);border-radius:var(--dsw-radius-md);min-height:310px;color:var(--mn-text);margin:16px 0 0;padding:clamp(16px,2.5vw,28px);font-size:14px;line-height:1.75}.IIa07q_markdownBody>:first-child{margin-top:0}.IIa07q_markdownBody>:last-child{margin-bottom:0}.IIa07q_markdownBody h1,.IIa07q_markdownBody h2,.IIa07q_markdownBody h3,.IIa07q_markdownBody h4{color:var(--mn-text);margin:1.5em 0 .6em;font-weight:500;line-height:1.35}.IIa07q_markdownBody h1{border-bottom:.5px solid var(--mn-line);padding-bottom:.35em;font-size:1.6em}.IIa07q_markdownBody h2{border-bottom:.5px solid var(--mn-line);padding-bottom:.3em;font-size:1.35em}.IIa07q_markdownBody h3{font-size:1.15em}.IIa07q_markdownBody p,.IIa07q_markdownBody ul,.IIa07q_markdownBody ol,.IIa07q_markdownBody blockquote,.IIa07q_markdownBody table,.IIa07q_markdownBody pre{margin:.85em 0}.IIa07q_markdownBody ul,.IIa07q_markdownBody ol{padding-left:1.6em}.IIa07q_markdownBody li+li{margin-top:.3em}.IIa07q_markdownBody blockquote{border-left:2px solid var(--mn-line-strong);color:var(--mn-muted);margin-inline:0;padding:.1em 1em}.IIa07q_markdownBody code{border-radius:var(--dsw-radius-xs);color:var(--mn-text);background:var(--dsw-alias-markdown-inline-code,var(--mn-fill));font:.88em/1.55 var(--mn-code);padding:.15em .4em}.IIa07q_markdownBody pre{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-markdown-code-block,var(--mn-fill));max-width:100%;padding:12px 16px;overflow:auto}.IIa07q_markdownBody pre code{background:0 0;padding:0;font-size:12px}.IIa07q_markdownBody a{color:var(--dsw-alias-link,var(--mn-accent));text-underline-offset:3px;text-decoration-thickness:1px}.IIa07q_markdownBody hr{border:0;border-top:.5px solid var(--mn-line);margin:1.8em 0}.IIa07q_markdownBody table{border-collapse:collapse;max-width:100%;display:block;overflow-x:auto}.IIa07q_markdownBody th,.IIa07q_markdownBody td{border:.5px solid var(--mn-line);text-align:left;vertical-align:top;padding:8px 10px}.IIa07q_markdownBody th{background:var(--mn-fill);font-weight:500}.IIa07q_markdownBody img{border-radius:var(--dsw-radius-sm);max-width:100%;height:auto}.IIa07q_documentArchiveReceipt{border-radius:var(--dsw-radius-md);background:color-mix(in srgb, var(--mn-success) 8%, transparent);margin:12px 0;padding:10px 12px}.IIa07q_documentArchiveReceipt p{color:var(--mn-muted);margin:2px 0 8px;font-size:12px;line-height:18px}.IIa07q_documentArchiveReceipt div{flex-wrap:wrap;gap:6px;display:flex}.IIa07q_documentDanger{border-top:.5px solid var(--mn-line);justify-content:flex-end;align-items:center;gap:8px;min-height:56px;margin-top:12px;padding-top:12px;display:flex}.IIa07q_documentDanger>div{margin-right:auto}.IIa07q_documentDanger strong{font-size:13px;font-weight:500;line-height:20px;display:block}.IIa07q_documentDanger p{color:var(--mn-faint);margin:2px 0 0;font-size:12px;line-height:18px}.IIa07q_documentDanger>span{color:var(--mn-danger);margin-right:auto;font-size:12px}.IIa07q_documentEditor{border:.5px solid var(--mn-card-line);border-radius:var(--dsw-radius-lg);margin-bottom:12px;padding:16px}.IIa07q_documentReader>.IIa07q_documentEditor{background:0 0;border:0;margin:0;padding:0}.IIa07q_documentEditor>header{justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:12px;display:flex}.IIa07q_documentEditor h3{margin:0;font-size:14px;font-weight:500;line-height:22px}.IIa07q_documentEditor header p{color:var(--mn-faint);margin:2px 0 0;font-size:12px;line-height:18px}.IIa07q_documentEditor header>span,.IIa07q_documentEditor header>code{color:var(--mn-muted);background:var(--mn-fill);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.IIa07q_documentEditor label{color:var(--mn-muted);gap:6px;margin-top:12px;font-size:12px;font-weight:500;line-height:18px;display:grid}.IIa07q_documentEditor textarea{resize:vertical;line-height:1.65}.IIa07q_documentEditorMeta{grid-template-columns:.8fr 1.2fr;gap:12px;display:grid}.IIa07q_documentEditorMeta label{margin:0}.IIa07q_documentEditor footer{justify-content:flex-end;gap:8px;margin-top:12px;display:flex}@container IIa07q_mnemon-workbench (width<=880px){.IIa07q_documentWorkspace{grid-template-columns:minmax(220px,270px) minmax(0,1fr)}.IIa07q_documentDetail>dl{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentDetail>dl>div+div{border-left:0}.IIa07q_documentDetail>dl>div:nth-child(2n){border-left:.5px solid var(--mn-line)}.IIa07q_documentDetail>dl>div:nth-child(n+3){border-top:.5px solid var(--mn-line)}}@container IIa07q_mnemon-workbench (width<=640px){.IIa07q_documentSummary{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentCapacity{grid-column:1/-1}.IIa07q_documentToolbar{flex-direction:column;align-items:stretch}.IIa07q_documentToolbar form{min-width:0}.IIa07q_documentToolbar>div,.IIa07q_documentToolbar>button{width:100%}.IIa07q_documentToolbar>div button{flex:1}.IIa07q_documentWorkspace{grid-template-columns:1fr;min-height:0}.IIa07q_documentList{-webkit-overflow-scrolling:touch;max-height:330px;overflow:auto}.IIa07q_documentReader{min-height:430px}.IIa07q_documentEditorMeta{grid-template-columns:1fr}}@media (width<=1000px){.IIa07q_documentWorkspace{grid-template-columns:minmax(220px,270px) minmax(0,1fr)}.IIa07q_documentDetail>dl{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentDetail>dl>div+div{border-left:0}.IIa07q_documentDetail>dl>div:nth-child(2n){border-left:.5px solid var(--mn-line)}.IIa07q_documentDetail>dl>div:nth-child(n+3){border-top:.5px solid var(--mn-line)}}@media (width<=760px){.IIa07q_documentSummary{grid-template-columns:repeat(2,minmax(0,1fr))}.IIa07q_documentCapacity{grid-column:1/-1}.IIa07q_documentToolbar{flex-direction:column;align-items:stretch}.IIa07q_documentToolbar form{min-width:0}.IIa07q_documentToolbar>div,.IIa07q_documentToolbar>button{width:100%}.IIa07q_documentToolbar>div button{flex:1}.IIa07q_documentWorkspace{grid-template-columns:1fr;min-height:0}.IIa07q_documentList{-webkit-overflow-scrolling:touch;max-height:330px;overflow:auto}.IIa07q_documentReader{min-height:430px}.IIa07q_documentEditorMeta{grid-template-columns:1fr}}@media (width<=520px){.IIa07q_documentDetail>header,.IIa07q_documentDanger{flex-direction:column;align-items:flex-start}.IIa07q_documentDetail>header>div:last-child,.IIa07q_documentDetail>header button{width:100%}.IIa07q_documentDanger>div,.IIa07q_documentDanger>span{margin-right:0}.IIa07q_documentDanger>button{width:100%}.IIa07q_documentDetail>dl{grid-template-columns:1fr}.IIa07q_documentDetail>dl>div:nth-child(2n){border-left:0}.IIa07q_documentDetail>dl>div+div{border-top:.5px solid var(--mn-line)}.IIa07q_markdownBody{padding:16px;font-size:13px}}@media (prefers-reduced-motion:reduce){.IIa07q_documentCapacity>div i,.IIa07q_documentToolbar>div:before,.IIa07q_documentToolbar>div button,.IIa07q_documentList>button{transition:none}}";
163
151
  const id$1 = "dsh-mnemon-source-documents/presentation/page.module.css";
164
152
  if (typeof document !== "undefined") {
165
153
  let tag = document.querySelector("style[data-plugin-css=" + JSON.stringify(id$1) + "]");
@@ -171,6 +159,7 @@ window.__ModuleLoader__.load({
171
159
  if (tag.textContent !== css$2) tag.textContent = css$2;
172
160
  }
173
161
  var page_module_css_default = {
162
+ "documentActions": "IIa07q_documentActions",
174
163
  "documentArchiveReceipt": "IIa07q_documentArchiveReceipt",
175
164
  "documentCapacity": "IIa07q_documentCapacity",
176
165
  "documentDanger": "IIa07q_documentDanger",
@@ -186,11 +175,13 @@ window.__ModuleLoader__.load({
186
175
  "documentToolbar": "IIa07q_documentToolbar",
187
176
  "documentWorkspace": "IIa07q_documentWorkspace",
188
177
  "emptyState": "IIa07q_emptyState",
189
- "markdownBody": "IIa07q_markdownBody"
178
+ "loading": "IIa07q_loading",
179
+ "markdownBody": "IIa07q_markdownBody",
180
+ "mnemon-workbench": "IIa07q_mnemon-workbench"
190
181
  };
191
182
  //#endregion
192
183
  //#region \0source-css:/home/runner/work/dsh-mnemon/dsh-mnemon/plugins/dsh-mnemon-source-documents/presentation/sidebar.module.css.mjs
193
- const css$1 = "._Bh55G_shell ._Bh55G_modal form[class*=documentEditor]{background:0 0;border:0;border-radius:0;margin:0;padding:0}._Bh55G_shell ._Bh55G_modal form[class*=documentEditor]>header{display:none}._Bh55G_shell [class*=documentWorkspace]{align-items:stretch;height:clamp(520px,100dvh - 220px,760px);min-height:520px}._Bh55G_shell [class*=documentList],._Bh55G_shell [class*=documentReader]{overscroll-behavior:contain;scrollbar-gutter:stable;min-height:0;overflow-y:auto}@media (width<=760px){._Bh55G_shell [class*=documentWorkspace]{height:auto;min-height:0}._Bh55G_shell [class*=documentList]{scrollbar-gutter:auto;overflow-y:auto}._Bh55G_shell [class*=documentReader]{scrollbar-gutter:auto;overflow:visible}}";
184
+ const css$1 = "._Bh55G_shell ._Bh55G_modal{flex-direction:column;max-height:min(86dvh,760px);display:flex;overflow:hidden}._Bh55G_shell ._Bh55G_modal>[class*=modalBody]{overscroll-behavior:contain;flex:auto;min-height:0;overflow-y:auto}._Bh55G_shell ._Bh55G_modal>[class*=modalFooter]{z-index:1;background:var(--dsw-alias-bg-layer-2,var(--mn-surface));flex:none;position:relative}._Bh55G_shell ._Bh55G_modal form[class*=documentEditor]{background:0 0;border:0;border-radius:0;flex-shrink:0;margin:0;padding:0}._Bh55G_shell ._Bh55G_modal form[class*=documentEditor]>header{display:none}._Bh55G_shell [class*=documentWorkspace]{height:clamp(420px, calc(100dvh - var(--dsh-frame-top-clearance,0px) - 344px), 720px);align-items:stretch;min-height:420px}._Bh55G_shell [class*=documentList],._Bh55G_shell [class*=documentReader]{overscroll-behavior:contain;scrollbar-gutter:stable;min-height:0;overflow-y:auto}@container _Bh55G_mnemon-workbench (width<=640px){._Bh55G_shell [class*=documentWorkspace]{height:auto;min-height:0}._Bh55G_shell [class*=documentList]{scrollbar-gutter:auto;overflow-y:auto}._Bh55G_shell [class*=documentReader]{scrollbar-gutter:auto;overflow:visible}}@media (width<=760px){._Bh55G_shell [class*=documentWorkspace]{height:auto;min-height:0}._Bh55G_shell [class*=documentList]{scrollbar-gutter:auto;overflow-y:auto}._Bh55G_shell [class*=documentReader]{scrollbar-gutter:auto;overflow:visible}}";
194
185
  const id = "dsh-mnemon-source-documents/presentation/sidebar.module.css";
195
186
  if (typeof document !== "undefined") {
196
187
  let tag = document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]");
@@ -202,6 +193,7 @@ window.__ModuleLoader__.load({
202
193
  if (tag.textContent !== css$1) tag.textContent = css$1;
203
194
  }
204
195
  var sidebar_module_css_default = {
196
+ "mnemon-workbench": "_Bh55G_mnemon-workbench",
205
197
  "modal": "_Bh55G_modal",
206
198
  "shell": "_Bh55G_shell"
207
199
  };
@@ -219,953 +211,42 @@ window.__ModuleLoader__.load({
219
211
  const fallback = (0, dsh_mnemon_client.useT)();
220
212
  const locale = (0, dsh_mnemon_client.useLocale)();
221
213
  return (0, react.useMemo)(() => (key, params) => {
222
- const dictionary = locale.startsWith("en") ? en : zh;
214
+ const dictionary = locale.toLowerCase().startsWith("zh") ? zh : en;
215
+ if (!/^(en|zh)(-|$)/i.test(locale)) {
216
+ const translated = fallback(key, params);
217
+ if (translated !== key) return translated;
218
+ }
223
219
  if (!Object.hasOwn(dictionary, key)) return fallback(key, params);
224
220
  const text = dictionary[key];
225
221
  return params === void 0 ? text : text.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match);
226
222
  }, [locale, fallback]);
227
223
  }
228
224
  //#endregion
229
- //#region ../../node_modules/.pnpm/markdown-to-jsx@7.7.17_react@18.3.1/node_modules/markdown-to-jsx/dist/index.module.js
230
- function n() {
231
- return n = Object.assign ? Object.assign.bind() : function(r) {
232
- for (var n = 1; n < arguments.length; n++) {
233
- var e = arguments[n];
234
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = e[t]);
235
- }
236
- return r;
237
- }, n.apply(this, arguments);
238
- }
239
- var e = ["children", "options"];
240
- var u = [
241
- "allowFullScreen",
242
- "allowTransparency",
243
- "autoComplete",
244
- "autoFocus",
245
- "autoPlay",
246
- "cellPadding",
247
- "cellSpacing",
248
- "charSet",
249
- "classId",
250
- "colSpan",
251
- "contentEditable",
252
- "contextMenu",
253
- "crossOrigin",
254
- "encType",
255
- "formAction",
256
- "formEncType",
257
- "formMethod",
258
- "formNoValidate",
259
- "formTarget",
260
- "frameBorder",
261
- "hrefLang",
262
- "inputMode",
263
- "keyParams",
264
- "keyType",
265
- "marginHeight",
266
- "marginWidth",
267
- "maxLength",
268
- "mediaGroup",
269
- "minLength",
270
- "noValidate",
271
- "radioGroup",
272
- "readOnly",
273
- "rowSpan",
274
- "spellCheck",
275
- "srcDoc",
276
- "srcLang",
277
- "srcSet",
278
- "tabIndex",
279
- "useMap"
280
- ].reduce(function(r, n) {
281
- return r[n.toLowerCase()] = n, r;
282
- }, {
283
- class: "className",
284
- for: "htmlFor"
285
- });
286
- var a = {
287
- amp: "&",
288
- apos: "'",
289
- gt: ">",
290
- lt: "<",
291
- nbsp: "\xA0",
292
- quot: "“"
293
- };
294
- var i = [
295
- "style",
296
- "script",
297
- "pre"
298
- ];
299
- var o = [
300
- "src",
301
- "href",
302
- "data",
303
- "formAction",
304
- "srcDoc",
305
- "action"
306
- ];
307
- var c = /([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi;
308
- var f = /\n{2,}$/;
309
- var l = /^(\s*>[\s\S]*?)(?=\n\n|$)/;
310
- var _ = /^ *> ?/gm;
311
- var d = /^(?:\[!([^\]]*)\]\n)?([\s\S]*)/;
312
- var s = /^ {2,}\n/;
313
- var v = /^(?:([-*_])( *\1){2,}) *(?:\n *)+\n/;
314
- var p = /^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/;
315
- var y = /^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/;
316
- var h = /^(`+)((?:\\`|(?!\1)`|[^`])+)\1/;
317
- var g = /^(?:\n *)*\n/;
318
- var m = /\r\n?/g;
319
- var k = /^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/;
320
- var x = /^\[\^([^\]]+)]/;
321
- var q = /\f/g;
322
- var b = /^---[ \t]*\n(.|\n)*\n---[ \t]*\n/;
323
- var S = /^\s*?\[(x|\s)\]/;
324
- var z = /^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/;
325
- var $ = /^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/;
326
- var E = /^([^\n]+)\n *(=|-)\2{2,} *\n/;
327
- var A = /^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i;
328
- var R = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi;
329
- var B = /^<!--[\s\S]*?(?:-->)/;
330
- var L = /^(data|aria|x)-[a-z_][a-z\d_.-]*$/;
331
- var O = /^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i;
332
- var j = /^\{.*\}$/;
333
- var C = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/;
334
- var I = /^<([^ >]+[:@\/][^ >]+)>/;
335
- var T = /-([a-z])?/gi;
336
- var M = /^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/;
337
- var w = /^[^\n]+(?: \n|\n{2,})/;
338
- var D = /^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/;
339
- var F = /^!\[([^\]]*)\] ?\[([^\]]*)\]/;
340
- var P = /^\[([^\]]*)\] ?\[([^\]]*)\]/;
341
- var Z = /(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/;
342
- var N = /\t/g;
343
- var G = /(^ *\||\| *$)/g;
344
- var U = /^ *:-+: *$/;
345
- var V = /^ *:-+ *$/;
346
- var H = /^ *-+: *$/;
347
- var Q = function(r) {
348
- return "(?=[\\s\\S]+?\\1" + (r ? "\\1" : "") + ")";
349
- };
350
- var W = "((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)";
351
- var J = RegExp("^([*_])\\1" + Q(1) + W + "\\1\\1(?!\\1)");
352
- var K = RegExp("^([*_])" + Q(0) + W + "\\1(?!\\1)");
353
- var X = RegExp("^(==)" + Q(0) + W + "\\1");
354
- var Y = RegExp("^(~~)" + Q(0) + W + "\\1");
355
- var rr = /^(:[a-zA-Z0-9-_]+:)/;
356
- var nr = /^\\([^0-9A-Za-z\s])/;
357
- var er = /\\([^0-9A-Za-z\s])/g;
358
- var tr = /^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/;
359
- var ur = /^\n+/;
360
- var ar = /^([ \t]*)/;
361
- var ir = /(?:^|\n)( *)$/;
362
- var or = "(?:\\d+\\.)";
363
- var cr = "(?:[*+-])";
364
- function fr(r) {
365
- return "( *)(" + (1 === r ? or : cr) + ") +";
366
- }
367
- var lr = fr(1);
368
- var _r = fr(2);
369
- function dr(r) {
370
- return RegExp("^" + (1 === r ? lr : _r));
371
- }
372
- var sr = dr(1);
373
- var vr = dr(2);
374
- function pr(r) {
375
- return RegExp("^" + (1 === r ? lr : _r) + "[^\\n]*(?:\\n(?!\\1" + (1 === r ? or : cr) + " )[^\\n]*)*(\\n|$)", "gm");
376
- }
377
- var yr = pr(1);
378
- var hr = pr(2);
379
- function gr(r) {
380
- var n = 1 === r ? or : cr;
381
- return RegExp("^( *)(" + n + ") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1" + n + " (?!" + n + " ))\\n*|\\s*\\n*$)");
382
- }
383
- var mr = gr(1);
384
- var kr = gr(2);
385
- function xr(r, n) {
386
- var e = 1 === n, t = e ? mr : kr, u = e ? yr : hr, a = e ? sr : vr;
387
- return {
388
- t: function(r) {
389
- return a.test(r);
390
- },
391
- u: jr(function(r, n) {
392
- var e = ir.exec(n.prevCapture);
393
- return e && (n.list || !n.inline && !n.simple) ? t.exec(r = e[1] + r) : null;
394
- }),
395
- i: 1,
396
- o: function(r, n, t) {
397
- var i = e ? +r[2] : void 0, o = r[0].replace(f, "\n").match(u), c = !1;
398
- return {
399
- items: o.map(function(r, e) {
400
- var u = a.exec(r)[0].length, i = RegExp("^ {1," + u + "}", "gm"), f = r.replace(i, "").replace(a, ""), l = e === o.length - 1, _ = -1 !== f.indexOf("\n\n") || l && c;
401
- c = _;
402
- var d, s = t.inline, v = t.list;
403
- t.list = !0, _ ? (t.inline = !1, d = zr(f) + "\n\n") : (t.inline = !0, d = zr(f));
404
- var p = n(d, t);
405
- return t.inline = s, t.list = v, p;
406
- }),
407
- ordered: e,
408
- start: i
409
- };
410
- },
411
- l: function(n, e, t) {
412
- return r(n.ordered ? "ol" : "ul", {
413
- key: t.key,
414
- start: "20" === n.type ? n.start : void 0
415
- }, n.items.map(function(n, u) {
416
- return r("li", { key: u }, e(n, t));
417
- }));
418
- }
419
- };
420
- }
421
- var qr = RegExp("^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)");
422
- var br = /^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;
423
- function Sr(r) {
424
- return "string" == typeof r;
425
- }
426
- function zr(r) {
427
- for (var n = r.length; n > 0 && r[n - 1] <= " ";) n--;
428
- return r.slice(0, n);
429
- }
430
- function $r(r, n) {
431
- return r.startsWith(n);
432
- }
433
- function Er(r, n, e) {
434
- if (Array.isArray(e)) {
435
- for (var t = 0; t < e.length; t++) if ($r(r, e[t])) return !0;
436
- return !1;
437
- }
438
- return e(r, n);
439
- }
440
- function Ar(r) {
441
- return r.replace(/[ÀÁÂÃÄÅàáâãä忯]/g, "a").replace(/[çÇ]/g, "c").replace(/[ðÐ]/g, "d").replace(/[ÈÉÊËéèêë]/g, "e").replace(/[ÏïÎîÍíÌì]/g, "i").replace(/[Ññ]/g, "n").replace(/[øØœŒÕõÔôÓóÒò]/g, "o").replace(/[ÜüÛûÚúÙù]/g, "u").replace(/[ŸÿÝý]/g, "y").replace(/[^a-z0-9- ]/gi, "").replace(/ /gi, "-").toLowerCase();
442
- }
443
- function Rr(r) {
444
- return H.test(r) ? "right" : U.test(r) ? "center" : V.test(r) ? "left" : null;
445
- }
446
- function Br(r, n, e, t) {
447
- var u = e.inTable;
448
- e.inTable = !0;
449
- var a = [[]], i = "";
450
- function o() {
451
- if (i) {
452
- var r = a[a.length - 1];
453
- r.push.apply(r, n(i, e)), i = "";
454
- }
455
- }
456
- return r.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach(function(r, n, e) {
457
- "|" === r.trim() && (o(), t) ? 0 !== n && n !== e.length - 1 && a.push([]) : i += r;
458
- }), o(), e.inTable = u, a;
459
- }
460
- function Lr(r, n, e) {
461
- e.inline = !0;
462
- var t = r[2] ? r[2].replace(G, "").split("|").map(Rr) : [], u = r[3] ? function(r, n, e) {
463
- return r.trim().split("\n").map(function(r) {
464
- return Br(r, n, e, !0);
465
- });
466
- }(r[3], n, e) : [], a = Br(r[1], n, e, !!u.length);
467
- return e.inline = !1, u.length ? {
468
- align: t,
469
- cells: u,
470
- header: a,
471
- type: "25"
472
- } : {
473
- children: a,
474
- type: "21"
475
- };
476
- }
477
- function Or(r, n) {
478
- return null == r.align[n] ? {} : { textAlign: r.align[n] };
479
- }
480
- function jr(r) {
481
- return r.inline = 1, r;
482
- }
483
- function Cr(r) {
484
- return jr(function(n, e) {
485
- return e.inline ? r.exec(n) : null;
486
- });
487
- }
488
- function Ir(r) {
489
- return jr(function(n, e) {
490
- return e.inline || e.simple ? r.exec(n) : null;
491
- });
492
- }
493
- function Tr(r) {
494
- return function(n, e) {
495
- return e.inline || e.simple ? null : r.exec(n);
496
- };
497
- }
498
- function Mr(r) {
499
- return jr(function(n) {
500
- return r.exec(n);
501
- });
502
- }
503
- var wr = /(javascript|vbscript|data(?!:image)):/i;
504
- function Dr(r) {
505
- try {
506
- var n = decodeURIComponent(r).replace(/[^A-Za-z0-9/:]/g, "");
507
- if (wr.test(n)) return null;
508
- } catch (r) {
509
- return null;
510
- }
511
- return r;
512
- }
513
- function Fr(r) {
514
- return r ? r.replace(er, "$1") : r;
515
- }
516
- function Pr(r, n, e) {
517
- var t = e.inline || !1, u = e.simple || !1;
518
- e.inline = !0, e.simple = !0;
519
- var a = r(n, e);
520
- return e.inline = t, e.simple = u, a;
521
- }
522
- function Zr(r, n, e) {
523
- var t = e.inline || !1, u = e.simple || !1;
524
- e.inline = !1, e.simple = !0;
525
- var a = r(n, e);
526
- return e.inline = t, e.simple = u, a;
527
- }
528
- function Nr(r, n, e) {
529
- var t = e.inline || !1;
530
- e.inline = !1;
531
- var u = r(n, e);
532
- return e.inline = t, u;
533
- }
534
- var Gr = function(r, n, e) {
535
- return { children: Pr(n, r[2], e) };
536
- };
537
- function Ur() {
538
- return {};
539
- }
540
- function Vr() {
541
- return null;
542
- }
543
- function Hr() {
544
- return [].slice.call(arguments).filter(Boolean).join(" ");
545
- }
546
- function Qr(r, n, e) {
547
- for (var t = r, u = n.split("."); u.length && void 0 !== (t = t[u[0]]);) u.shift();
548
- return t || e;
549
- }
550
- function Wr(r, n) {
551
- var e = Qr(n, r);
552
- return e ? "function" == typeof e || "object" == typeof e && "render" in e ? e : Qr(n, r + ".component", r) : r;
553
- }
554
- function Jr(e, t) {
555
- var f;
556
- void 0 === e && (e = ""), void 0 === t && (t = {}), t.overrides = t.overrides || {}, t.namedCodesToUnicode = t.namedCodesToUnicode ? n({}, a, t.namedCodesToUnicode) : a;
557
- var G = t.slugify || Ar, U = t.sanitizer || Dr, V = t.createElement || react.createElement, H = [
558
- l,
559
- p,
560
- y,
561
- t.enforceAtxHeadings ? $ : z,
562
- E,
563
- M,
564
- mr,
565
- kr
566
- ], Q = [].concat(H, [
567
- w,
568
- A,
569
- B,
570
- O
571
- ]);
572
- function W(r, n) {
573
- for (var e = 0; e < r.length; e++) if (r[e].test(n)) return !0;
574
- return !1;
575
- }
576
- function er(r, e) {
577
- var u = Qr(t.overrides, r + ".props", {});
578
- return V.apply(void 0, [Wr(r, t.overrides), n({}, e, u, { className: Hr(null == e ? void 0 : e.className, u.className) || void 0 })].concat([].slice.call(arguments, 2)));
579
- }
580
- function ir(r) {
581
- r = r.replace(b, "");
582
- var n = !1;
583
- t.forceInline ? n = !0 : t.forceBlock || (n = !1 === Z.test(r));
584
- for (var e = dr(_r(n ? r : zr(r).replace(ur, "") + "\n\n", { inline: n })); Sr(e[e.length - 1]) && !e[e.length - 1].trim();) e.pop();
585
- if (null === t.wrapper) return e;
586
- var u, a = t.wrapper || (n ? "span" : "div");
587
- if (e.length > 1 || t.forceWrapper) u = e;
588
- else {
589
- if (1 === e.length) return "string" == typeof (u = e[0]) ? er("span", { key: "outer" }, u) : u;
590
- u = null;
591
- }
592
- return V(a, { key: "outer" }, u);
593
- }
594
- function or(r, n) {
595
- if (!n || !n.trim()) return null;
596
- var e = n.match(c);
597
- return e ? e.reduce(function(n, e) {
598
- var t = e.indexOf("=");
599
- if (-1 !== t) {
600
- var a = function(r) {
601
- return -1 !== r.indexOf("-") && null === r.match(L) && (r = r.replace(T, function(r, n) {
602
- return n.toUpperCase();
603
- })), r;
604
- }(e.slice(0, t)).trim(), i = function(r) {
605
- var n = r[0];
606
- return ("\"" === n || "'" === n) && r.length >= 2 && r[r.length - 1] === n ? r.slice(1, -1) : r;
607
- }(e.slice(t + 1).trim()), c = u[a] || a;
608
- if ("ref" === c) return n;
609
- var f = n[c] = function(r, n, e, t) {
610
- return "style" === n ? function(r) {
611
- var n = [], e = "", t = !1, u = !1, a = "";
612
- if (!r) return n;
613
- for (var i = 0; i < r.length; i++) {
614
- var o = r[i];
615
- if ("\"" !== o && "'" !== o || t || (u ? o === a && (u = !1, a = "") : (u = !0, a = o)), "(" === o && e.endsWith("url") ? t = !0 : ")" === o && t && (t = !1), ";" !== o || u || t) e += o;
616
- else {
617
- var c = e.trim();
618
- if (c) {
619
- var f = c.indexOf(":");
620
- if (f > 0) {
621
- var l = c.slice(0, f).trim(), _ = c.slice(f + 1).trim();
622
- n.push([l, _]);
623
- }
624
- }
625
- e = "";
626
- }
627
- }
628
- var d = e.trim();
629
- if (d) {
630
- var s = d.indexOf(":");
631
- if (s > 0) {
632
- var v = d.slice(0, s).trim(), p = d.slice(s + 1).trim();
633
- n.push([v, p]);
634
- }
635
- }
636
- return n;
637
- }(e).reduce(function(n, e) {
638
- var u = e[0], a = e[1];
639
- return n[u.replace(/(-[a-z])/g, function(r) {
640
- return r[1].toUpperCase();
641
- })] = t(a, r, u), n;
642
- }, {}) : -1 !== o.indexOf(n) ? t(Fr(e), r, n) : (e.match(j) && (e = Fr(e.slice(1, e.length - 1))), "true" === e || "false" !== e && e);
643
- }(r, a, i, U);
644
- "string" == typeof f && (A.test(f) || O.test(f)) && (n[c] = ir(f.trim()));
645
- } else "style" !== e && (n[u[e] || e] = !0);
646
- return n;
647
- }, {}) : null;
648
- }
649
- var cr = [], fr = {}, lr = ((f = {})[0] = {
650
- t: [">"],
651
- u: Tr(l),
652
- i: 1,
653
- o: function(r, n, e) {
654
- var t = r[0].replace(_, "").match(d);
655
- return {
656
- alert: t[1],
657
- children: n(t[2], e)
658
- };
659
- },
660
- l: function(r, n, e) {
661
- var t = { key: e.key };
662
- return r.alert && (t.className = "markdown-alert-" + G(r.alert.toLowerCase(), Ar), r.children.unshift({
663
- attrs: {},
664
- children: [{
665
- type: "27",
666
- text: r.alert
667
- }],
668
- noInnerParse: !0,
669
- type: "11",
670
- tag: "header"
671
- })), er("blockquote", t, n(r.children, e));
672
- }
673
- }, f[1] = {
674
- t: [" "],
675
- u: Mr(s),
676
- i: 1,
677
- o: Ur,
678
- l: function(r, n, e) {
679
- return er("br", { key: e.key });
680
- }
681
- }, f[2] = {
682
- t: [
683
- "--",
684
- "__",
685
- "**",
686
- "- ",
687
- "* ",
688
- "_ "
689
- ],
690
- u: Tr(v),
691
- i: 1,
692
- o: Ur,
693
- l: function(r, n, e) {
694
- return er("hr", { key: e.key });
695
- }
696
- }, f[3] = {
697
- t: [" "],
698
- u: Tr(y),
699
- i: 0,
700
- o: function(r) {
701
- return {
702
- lang: void 0,
703
- text: Fr(zr(r[0].replace(/^ {4}/gm, "")))
704
- };
705
- },
706
- l: function(r, e, t) {
707
- return er("pre", { key: t.key }, er("code", n({}, r.attrs, { className: r.lang ? "lang-" + r.lang : "" }), r.text));
708
- }
709
- }, f[4] = {
710
- t: ["```", "~~~"],
711
- u: Tr(p),
712
- i: 0,
713
- o: function(r) {
714
- return {
715
- attrs: or("code", r[3] || ""),
716
- lang: r[2] || void 0,
717
- text: r[4],
718
- type: "3"
719
- };
720
- }
721
- }, f[5] = {
722
- t: ["`"],
723
- u: Ir(h),
724
- i: 3,
725
- o: function(r) {
726
- return { text: Fr(r[2]) };
727
- },
728
- l: function(r, n, e) {
729
- return er("code", { key: e.key }, r.text);
730
- }
731
- }, f[6] = {
732
- t: ["[^"],
733
- u: Tr(k),
734
- i: 0,
735
- o: function(r) {
736
- return cr.push({
737
- footnote: r[2],
738
- identifier: r[1]
739
- }), {};
740
- },
741
- l: Vr
742
- }, f[7] = {
743
- t: ["[^"],
744
- u: Cr(x),
745
- i: 1,
746
- o: function(r) {
747
- return {
748
- target: "#" + G(r[1], Ar),
749
- text: r[1]
750
- };
751
- },
752
- l: function(r, n, e) {
753
- return er("a", {
754
- key: e.key,
755
- href: U(r.target, "a", "href")
756
- }, er("sup", { key: e.key }, r.text));
757
- }
758
- }, f[8] = {
759
- t: ["[ ]", "[x]"],
760
- u: Cr(S),
761
- i: 1,
762
- o: function(r) {
763
- return { completed: "x" === r[1].toLowerCase() };
764
- },
765
- l: function(r, n, e) {
766
- return er("input", {
767
- checked: r.completed,
768
- key: e.key,
769
- readOnly: !0,
770
- type: "checkbox"
771
- });
772
- }
773
- }, f[9] = {
774
- t: ["#"],
775
- u: Tr(t.enforceAtxHeadings ? $ : z),
776
- i: 1,
777
- o: function(r, n, e) {
778
- return {
779
- children: Pr(n, r[2], e),
780
- id: G(r[2], Ar),
781
- level: r[1].length
782
- };
783
- },
784
- l: function(r, n, e) {
785
- return er("h" + r.level, {
786
- id: r.id,
787
- key: e.key
788
- }, n(r.children, e));
789
- }
790
- }, f[10] = {
791
- t: function(r) {
792
- var n = r.indexOf("\n");
793
- return n > 0 && n < r.length - 1 && ("=" === r[n + 1] || "-" === r[n + 1]);
794
- },
795
- u: Tr(E),
796
- i: 1,
797
- o: function(r, n, e) {
798
- return {
799
- children: Pr(n, r[1], e),
800
- level: "=" === r[2] ? 1 : 2,
801
- type: "9"
802
- };
803
- }
804
- }, f[11] = {
805
- t: ["<"],
806
- u: Mr(A),
807
- i: 1,
808
- o: function(r, n, e) {
809
- var t = r[3].match(ar), u = RegExp("^" + t[1], "gm"), a = r[3].replace(u, ""), o = W(Q, a) ? Nr : Pr, c = r[1].toLowerCase(), f = -1 !== i.indexOf(c), l = (f ? c : r[1]).trim(), _ = {
810
- attrs: or(l, r[2]),
811
- noInnerParse: f,
812
- tag: l
813
- };
814
- if (e.inAnchor = e.inAnchor || "a" === c, f) _.text = r[3];
815
- else {
816
- var d = e.inHTML;
817
- e.inHTML = !0, _.children = o(n, a, e), e.inHTML = d;
818
- }
819
- return e.inAnchor = !1, _;
820
- },
821
- l: function(r, e, t) {
822
- return er(r.tag, n({ key: t.key }, r.attrs), r.text || (r.children ? e(r.children, t) : ""));
823
- }
824
- }, f[13] = {
825
- t: ["<"],
826
- u: Mr(O),
827
- i: 1,
828
- o: function(r) {
829
- var n = r[1].trim();
830
- return {
831
- attrs: or(n, r[2] || ""),
832
- tag: n
833
- };
834
- },
835
- l: function(r, e, t) {
836
- return er(r.tag, n({}, r.attrs, { key: t.key }));
837
- }
838
- }, f[12] = {
839
- t: ["<!--"],
840
- u: Mr(B),
841
- i: 1,
842
- o: function() {
843
- return {};
844
- },
845
- l: Vr
846
- }, f[14] = {
847
- t: ["!["],
848
- u: Ir(br),
849
- i: 1,
850
- o: function(r) {
851
- return {
852
- alt: Fr(r[1]),
853
- target: Fr(r[2]),
854
- title: Fr(r[3])
855
- };
856
- },
857
- l: function(r, n, e) {
858
- return er("img", {
859
- key: e.key,
860
- alt: r.alt || void 0,
861
- title: r.title || void 0,
862
- src: U(r.target, "img", "src")
863
- });
864
- }
865
- }, f[15] = {
866
- t: ["["],
867
- u: Cr(qr),
868
- i: 3,
869
- o: function(r, n, e) {
870
- return {
871
- children: Zr(n, r[1], e),
872
- target: Fr(r[2]),
873
- title: Fr(r[3])
874
- };
875
- },
876
- l: function(r, n, e) {
877
- return er("a", {
878
- key: e.key,
879
- href: U(r.target, "a", "href"),
880
- title: r.title
881
- }, n(r.children, e));
882
- }
883
- }, f[16] = {
884
- t: ["<"],
885
- u: Cr(I),
886
- i: 0,
887
- o: function(r) {
888
- var n = r[1], e = !1;
889
- return -1 !== n.indexOf("@") && -1 === n.indexOf("//") && (e = !0, n = n.replace("mailto:", "")), {
890
- children: [{
891
- text: n,
892
- type: "27"
893
- }],
894
- target: e ? "mailto:" + n : n,
895
- type: "15"
896
- };
897
- }
898
- }, f[17] = {
899
- t: function(r, n) {
900
- return !n.inAnchor && !t.disableAutoLink && ($r(r, "http://") || $r(r, "https://"));
901
- },
902
- u: Cr(C),
903
- i: 0,
904
- o: function(r) {
905
- return {
906
- children: [{
907
- text: r[1],
908
- type: "27"
909
- }],
910
- target: r[1],
911
- title: void 0,
912
- type: "15"
913
- };
914
- }
915
- }, f[20] = xr(er, 1), f[33] = xr(er, 2), f[19] = {
916
- t: ["\n"],
917
- u: Tr(g),
918
- i: 3,
919
- o: Ur,
920
- l: function() {
921
- return "\n";
922
- }
923
- }, f[21] = {
924
- u: jr(function(r, n) {
925
- if (n.inline || n.simple || n.inHTML && -1 === r.indexOf("\n\n") && -1 === n.prevCapture.indexOf("\n\n")) return null;
926
- for (var e = "", t = 0;;) {
927
- var u = r.indexOf("\n", t), a = r.slice(t, -1 === u ? void 0 : u + 1);
928
- if (W(H, a)) break;
929
- if (e += a, -1 === u || !a.trim()) break;
930
- t = u + 1;
931
- }
932
- var i = zr(e);
933
- return "" === i ? null : [
934
- e,
935
- ,
936
- i
937
- ];
938
- }),
939
- i: 3,
940
- o: Gr,
941
- l: function(r, n, e) {
942
- return er("p", { key: e.key }, n(r.children, e));
943
- }
944
- }, f[22] = {
945
- t: ["["],
946
- u: Cr(D),
947
- i: 0,
948
- o: function(r) {
949
- return fr[r[1]] = {
950
- target: r[2],
951
- title: r[4]
952
- }, {};
953
- },
954
- l: Vr
955
- }, f[23] = {
956
- t: ["!["],
957
- u: Ir(F),
958
- i: 0,
959
- o: function(r) {
960
- return {
961
- alt: r[1] ? Fr(r[1]) : void 0,
962
- ref: r[2]
963
- };
964
- },
965
- l: function(r, n, e) {
966
- return fr[r.ref] ? er("img", {
967
- key: e.key,
968
- alt: r.alt,
969
- src: U(fr[r.ref].target, "img", "src"),
970
- title: fr[r.ref].title
971
- }) : null;
972
- }
973
- }, f[24] = {
974
- t: function(r) {
975
- return "[" === r[0] && -1 === r.indexOf("](");
976
- },
977
- u: Cr(P),
978
- i: 0,
979
- o: function(r, n, e) {
980
- return {
981
- children: n(r[1], e),
982
- fallbackChildren: r[0],
983
- ref: r[2]
984
- };
985
- },
986
- l: function(r, n, e) {
987
- return fr[r.ref] ? er("a", {
988
- key: e.key,
989
- href: U(fr[r.ref].target, "a", "href"),
990
- title: fr[r.ref].title
991
- }, n(r.children, e)) : er("span", { key: e.key }, r.fallbackChildren);
992
- }
993
- }, f[25] = {
994
- t: ["|"],
995
- u: Tr(M),
996
- i: 1,
997
- o: Lr,
998
- l: function(r, n, e) {
999
- var t = r;
1000
- return er("table", { key: e.key }, er("thead", null, er("tr", null, t.header.map(function(r, u) {
1001
- return er("th", {
1002
- key: u,
1003
- style: Or(t, u)
1004
- }, n(r, e));
1005
- }))), er("tbody", null, t.cells.map(function(r, u) {
1006
- return er("tr", { key: u }, r.map(function(r, u) {
1007
- return er("td", {
1008
- key: u,
1009
- style: Or(t, u)
1010
- }, n(r, e));
1011
- }));
1012
- })));
1013
- }
1014
- }, f[27] = {
1015
- u: jr(function(r, n) {
1016
- var e;
1017
- return $r(r, ":") && (e = rr.exec(r)), e || tr.exec(r);
1018
- }),
1019
- i: 4,
1020
- o: function(r) {
1021
- var n = r[0];
1022
- return { text: -1 === n.indexOf("&") ? n : n.replace(R, function(r, n) {
1023
- return t.namedCodesToUnicode[n] || r;
1024
- }) };
1025
- },
1026
- l: function(r) {
1027
- return r.text;
1028
- }
1029
- }, f[28] = {
1030
- t: ["**", "__"],
1031
- u: Ir(J),
1032
- i: 2,
1033
- o: function(r, n, e) {
1034
- return { children: n(r[2], e) };
1035
- },
1036
- l: function(r, n, e) {
1037
- return er("strong", { key: e.key }, n(r.children, e));
1038
- }
1039
- }, f[29] = {
1040
- t: function(r) {
1041
- var n = r[0];
1042
- return ("*" === n || "_" === n) && r[1] !== n;
1043
- },
1044
- u: Ir(K),
1045
- i: 3,
1046
- o: function(r, n, e) {
1047
- return { children: n(r[2], e) };
1048
- },
1049
- l: function(r, n, e) {
1050
- return er("em", { key: e.key }, n(r.children, e));
1051
- }
1052
- }, f[30] = {
1053
- t: ["\\"],
1054
- u: Ir(nr),
1055
- i: 1,
1056
- o: function(r) {
1057
- return {
1058
- text: r[1],
1059
- type: "27"
1060
- };
1061
- }
1062
- }, f[31] = {
1063
- t: ["=="],
1064
- u: Ir(X),
1065
- i: 3,
1066
- o: Gr,
1067
- l: function(r, n, e) {
1068
- return er("mark", { key: e.key }, n(r.children, e));
1069
- }
1070
- }, f[32] = {
1071
- t: ["~~"],
1072
- u: Ir(Y),
1073
- i: 3,
1074
- o: Gr,
1075
- l: function(r, n, e) {
1076
- return er("del", { key: e.key }, n(r.children, e));
1077
- }
1078
- }, f);
1079
- !0 === t.disableParsingRawHTML && (delete lr[11], delete lr[13]);
1080
- var _r = function(r) {
1081
- var n = Object.keys(r);
1082
- function e(t, u) {
1083
- var a = [];
1084
- if (u.prevCapture = u.prevCapture || "", t.trim()) for (; t;) for (var i = 0; i < n.length;) {
1085
- var o = n[i], c = r[o];
1086
- if (!c.t || Er(t, u, c.t)) {
1087
- var f = c.u(t, u);
1088
- if (f && f[0]) {
1089
- t = t.substring(f[0].length);
1090
- var l = c.o(f, e, u);
1091
- u.prevCapture += f[0], l.type || (l.type = o), a.push(l);
1092
- break;
1093
- }
1094
- i++;
1095
- } else i++;
1096
- }
1097
- return u.prevCapture = "", a;
1098
- }
1099
- return n.sort(function(n, e) {
1100
- return r[n].i - r[e].i || (n < e ? -1 : 1);
1101
- }), function(r, n) {
1102
- return e(function(r) {
1103
- return r.replace(m, "\n").replace(q, "").replace(N, " ");
1104
- }(r), n);
1105
- };
1106
- }(lr), dr = function(r, n) {
1107
- return function e(t, u) {
1108
- if (void 0 === u && (u = {}), Array.isArray(t)) {
1109
- for (var a = u.key, i = [], o = !1, c = 0; c < t.length; c++) {
1110
- u.key = c;
1111
- var f = e(t[c], u), l = Sr(f);
1112
- l && o ? i[i.length - 1] += f : null !== f && i.push(f), o = l;
1113
- }
1114
- return u.key = a, i;
1115
- }
1116
- return function(e, t, u) {
1117
- var a = r[e.type].l;
1118
- return n ? n(function() {
1119
- return a(e, t, u);
1120
- }, e, t, u) : a(e, t, u);
1121
- }(t, e, u);
1122
- };
1123
- }(lr, t.renderRule), sr = ir(e);
1124
- return cr.length ? er("div", null, sr, er("footer", { key: "footer" }, cr.map(function(r) {
1125
- return er("div", {
1126
- id: G(r.identifier, Ar),
1127
- key: r.identifier
1128
- }, r.identifier, dr(_r(r.footnote, { inline: !0 })));
1129
- }))) : sr;
1130
- }
1131
- function index_module_default(n) {
1132
- var t = n.children, u = n.options, a = function(r, n) {
1133
- if (null == r) return {};
1134
- var e, t, u = {}, a = Object.keys(r);
1135
- for (t = 0; t < a.length; t++) n.indexOf(e = a[t]) >= 0 || (u[e] = r[e]);
1136
- return u;
1137
- }(n, e);
1138
- return react.cloneElement(Jr(null == t ? "" : t, u), a);
1139
- }
1140
- //#endregion
1141
225
  //#region src/client/pages.tsx
1142
- const SAFE_LINK_PATTERN = /^(?:https?:|mailto:|#|\/)/iu;
1143
- function safeLink(href) {
1144
- if (href == null) return void 0;
1145
- const value = href.trim();
1146
- return SAFE_LINK_PATTERN.test(value) ? value : void 0;
226
+ const canRenderMarkdown = typeof _deepseek_ai_dsh_client_ui_primitives.MarkdownText === "function" || typeof _deepseek_ai_dsh_client_ui_primitives.MarkdownText === "object" && _deepseek_ai_dsh_client_ui_primitives.MarkdownText !== null;
227
+ const canRenderPathLabel = typeof _deepseek_ai_dsh_client_ui_primitives.PathLabel === "function" || typeof _deepseek_ai_dsh_client_ui_primitives.PathLabel === "object" && _deepseek_ai_dsh_client_ui_primitives.PathLabel !== null;
228
+ function PathText(props) {
229
+ return canRenderPathLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.PathLabel, { path: props.path }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.path });
1147
230
  }
1148
- /** Render managed Markdown without raw HTML and with a deliberately small link surface. */
231
+ /** Render managed Markdown through the official DSH Markdown pipeline without raw HTML or unsafe links. */
1149
232
  function DocumentMarkdown(props) {
233
+ const locale = (0, dsh_mnemon_client.useLocale)();
234
+ const labels = (0, react.useMemo)(() => {
235
+ const zh = locale.startsWith("zh");
236
+ return {
237
+ code: {
238
+ copyLabel: zh ? "复制" : "Copy",
239
+ copiedLabel: zh ? "已复制" : "Copied"
240
+ },
241
+ footnotes: zh ? "脚注" : "Footnotes"
242
+ };
243
+ }, [locale]);
1150
244
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1151
245
  className: css.markdownBody,
1152
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(index_module_default, {
1153
- options: {
1154
- disableParsingRawHTML: true,
1155
- forceBlock: true,
1156
- overrides: { a: { component: ({ href, children, ...rest }) => {
1157
- const target = safeLink(href);
1158
- return target === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1159
- ...rest,
1160
- href: target,
1161
- target: target.startsWith("http") ? "_blank" : void 0,
1162
- rel: target.startsWith("http") ? "noreferrer noopener" : void 0,
1163
- children
1164
- });
1165
- } } }
1166
- },
1167
- children: props.content
1168
- })
246
+ children: canRenderMarkdown ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.MarkdownText, {
247
+ text: props.content,
248
+ labels
249
+ }) : props.content
1169
250
  });
1170
251
  }
1171
252
  function DocumentsPage(props) {
@@ -1176,10 +257,12 @@ window.__ModuleLoader__.load({
1176
257
  const pageSize = 8;
1177
258
  const readerRef = (0, react.useRef)(null);
1178
259
  const [snapshot, setSnapshot] = (0, react.useState)(null);
260
+ const [loadedRevision, setLoadedRevision] = (0, react.useState)(props.revision);
1179
261
  const [items, setItems] = (0, react.useState)([]);
1180
262
  const [visibleLimit, setVisibleLimit] = (0, react.useState)(pageSize);
1181
263
  const [selectedId, setSelectedId] = (0, react.useState)(props.documentId ?? null);
1182
264
  const [selected, setSelected] = (0, react.useState)(null);
265
+ const [failedSelectedId, setFailedSelectedId] = (0, react.useState)(null);
1183
266
  const [status, setStatus] = (0, react.useState)("active");
1184
267
  const [query, setQuery] = (0, react.useState)("");
1185
268
  const [loading, setLoading] = (0, react.useState)(true);
@@ -1189,25 +272,90 @@ window.__ModuleLoader__.load({
1189
272
  const [composing, setComposing] = (0, react.useState)(false);
1190
273
  const [editing, setEditing] = (0, react.useState)(false);
1191
274
  const [confirmArchive, setConfirmArchive] = (0, react.useState)(false);
275
+ const [deleteTarget, setDeleteTarget] = (0, react.useState)(null);
276
+ const [deleteError, setDeleteError] = (0, react.useState)(null);
1192
277
  const [title, setTitle] = (0, react.useState)("");
1193
278
  const [description, setDescription] = (0, react.useState)("");
1194
279
  const [content, setContent] = (0, react.useState)("");
1195
280
  const [sources, setSources] = (0, react.useState)("");
1196
281
  const displayRequests = (0, dsh_mnemon_client.useRequestVersion)();
1197
- const display = (0, react.useCallback)(async (nextQuery, nextStatus) => {
282
+ const snapshotRef = (0, react.useRef)(null);
283
+ snapshotRef.current = snapshot;
284
+ const selectedRef = (0, react.useRef)(null);
285
+ selectedRef.current = selected;
286
+ const revisionRef = (0, react.useRef)(props.revision);
287
+ revisionRef.current = props.revision;
288
+ const fetchedSignatureRef = (0, react.useRef)(null);
289
+ const queryRef = (0, react.useRef)(query);
290
+ queryRef.current = query;
291
+ const statusRef = (0, react.useRef)(status);
292
+ statusRef.current = status;
293
+ const activeSearchRef = (0, react.useRef)(false);
294
+ const adoptMutatedDocument = (0, react.useCallback)((candidate) => {
295
+ if (typeof candidate === "object" && candidate !== null && "content" in candidate && typeof candidate.content === "string") {
296
+ const view = candidate;
297
+ selectedRef.current = view;
298
+ if (view.fileRevision !== void 0 || props.client.deleteDocument === void 0) fetchedSignatureRef.current = `${revisionRef.current}:${view.id}:${view.revision}:${view.contentHash}`;
299
+ setSelected(view);
300
+ }
301
+ }, [props.client.deleteDocument]);
302
+ const display = (0, react.useCallback)(async (nextQuery, nextStatus, preferred, reloadIndex = false) => {
1198
303
  const request = displayRequests.begin();
304
+ activeSearchRef.current = nextQuery.trim() !== "";
1199
305
  setLoading(true);
1200
306
  setError(null);
1201
307
  setVisibleLimit(pageSize);
1202
308
  try {
1203
- const current = await props.client.documents();
1204
- const filtered = (nextQuery.trim() === "" ? current.documents : (await props.client.searchDocuments(nextQuery, nextStatus === "archived")).results).filter((record) => record.status === nextStatus).sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt));
309
+ let current;
310
+ let records;
311
+ if (nextQuery.trim() === "") {
312
+ current = await props.client.documents();
313
+ records = current.documents;
314
+ } else if (snapshotRef.current !== null && !reloadIndex) {
315
+ const existing = snapshotRef.current;
316
+ const searchResponse = await props.client.searchDocuments(nextQuery, nextStatus === "archived");
317
+ const byId = new Map(searchResponse.results.map((item) => [item.id, item]));
318
+ const mergedDocuments = existing.documents.map((document) => {
319
+ const hit = byId.get(document.id);
320
+ return hit === void 0 ? document : {
321
+ ...document,
322
+ ...hit,
323
+ healthy: document.healthy
324
+ };
325
+ });
326
+ for (const item of searchResponse.results) if (!existing.documents.some((document) => document.id === item.id)) mergedDocuments.push({
327
+ ...item,
328
+ healthy: true
329
+ });
330
+ current = {
331
+ ...existing,
332
+ ...typeof searchResponse.revision === "string" ? { revision: searchResponse.revision } : {},
333
+ documents: mergedDocuments
334
+ };
335
+ records = searchResponse.results;
336
+ } else {
337
+ const [searchResponse, loadedSnapshot] = await Promise.all([props.client.searchDocuments(nextQuery, nextStatus === "archived"), props.client.documents()]);
338
+ current = typeof searchResponse.revision === "string" ? {
339
+ ...loadedSnapshot,
340
+ revision: searchResponse.revision
341
+ } : loadedSnapshot;
342
+ records = searchResponse.results;
343
+ }
344
+ const filtered = records.filter((record) => record.status === nextStatus).sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt));
1205
345
  if (!displayRequests.isCurrent(request)) return;
346
+ const refreshStamp = revisionRef.current;
347
+ snapshotRef.current = current;
1206
348
  setSnapshot(current);
349
+ setLoadedRevision(refreshStamp);
1207
350
  setItems(filtered);
1208
- setSelectedId((previous) => previous !== null && filtered.some((record) => record.id === previous) ? previous : filtered[0]?.id ?? null);
351
+ if (preferred?.document !== void 0 && filtered.some((record) => record.id === preferred.id)) adoptMutatedDocument(preferred.document);
352
+ setSelectedId((previous) => {
353
+ const candidate = preferred?.id ?? previous;
354
+ return candidate !== null && filtered.some((record) => record.id === candidate) ? candidate : filtered[0]?.id ?? null;
355
+ });
1209
356
  } catch (reason) {
1210
357
  if (!displayRequests.isCurrent(request)) return;
358
+ snapshotRef.current = null;
1211
359
  setError((0, dsh_mnemon_client.message)(reason));
1212
360
  setSnapshot(null);
1213
361
  setItems([]);
@@ -1216,33 +364,49 @@ window.__ModuleLoader__.load({
1216
364
  if (displayRequests.isCurrent(request)) setLoading(false);
1217
365
  }
1218
366
  }, [
367
+ adoptMutatedDocument,
1219
368
  displayRequests,
1220
369
  pageSize,
1221
370
  props.client
1222
371
  ]);
1223
372
  (0, react.useEffect)(() => {
1224
- display(query, status);
1225
- }, [
1226
- display,
1227
- props.revision,
1228
- status
1229
- ]);
373
+ display(queryRef.current, statusRef.current, void 0, true);
374
+ }, [display, props.revision]);
1230
375
  (0, react.useEffect)(() => {
1231
- setSelected(null);
1232
- if (selectedId === null) return;
376
+ if (selectedId === null) {
377
+ setSelected(null);
378
+ return;
379
+ }
380
+ if (snapshot === null) return;
381
+ const record = snapshot.documents.find((document) => document.id === selectedId);
382
+ if (record === void 0) {
383
+ setSelected(null);
384
+ return;
385
+ }
386
+ const currentSelected = selectedRef.current;
387
+ const recordSignature = `${loadedRevision}:${record.id}:${record.revision}:${record.contentHash}`;
388
+ if (currentSelected !== null && currentSelected.id === record.id && fetchedSignatureRef.current === recordSignature && currentSelected.revision === record.revision && currentSelected.contentHash === record.contentHash && currentSelected.updatedAt === record.updatedAt && currentSelected.status === record.status && currentSelected.title === record.title && currentSelected.description === record.description) return;
1233
389
  let active = true;
390
+ const requestRevision = loadedRevision;
391
+ setFailedSelectedId(null);
1234
392
  props.client.document(selectedId).then((value) => {
1235
- if (active) setSelected(value);
393
+ if (!active) return;
394
+ fetchedSignatureRef.current = `${requestRevision}:${value.id}:${value.revision}:${value.contentHash}`;
395
+ selectedRef.current = value;
396
+ setSelected(value);
1236
397
  }).catch((reason) => {
1237
- if (active) setError((0, dsh_mnemon_client.message)(reason));
398
+ if (!active) return;
399
+ setFailedSelectedId(selectedId);
400
+ setError((0, dsh_mnemon_client.message)(reason));
1238
401
  });
1239
402
  return () => {
1240
403
  active = false;
1241
404
  };
1242
405
  }, [
406
+ loadedRevision,
1243
407
  props.client,
1244
408
  selectedId,
1245
- props.revision
409
+ snapshot
1246
410
  ]);
1247
411
  (0, react.useLayoutEffect)(() => {
1248
412
  if (readerRef.current !== null) readerRef.current.scrollTop = 0;
@@ -1273,6 +437,11 @@ window.__ModuleLoader__.load({
1273
437
  setComposing(true);
1274
438
  };
1275
439
  const sourcePaths = (value) => value.split(/\r?\n|,/gu).map((path) => path.trim()).filter(Boolean);
440
+ const changeStatus = (nextStatus) => {
441
+ if (status === nextStatus) return;
442
+ setStatus(nextStatus);
443
+ display(query, nextStatus);
444
+ };
1276
445
  const create = async (event) => {
1277
446
  event.preventDefault();
1278
447
  setSaving(true);
@@ -1290,35 +459,39 @@ window.__ModuleLoader__.load({
1290
459
  setStatus("active");
1291
460
  setQuery("");
1292
461
  resetComposer();
1293
- props.onMutate();
1294
- await display("", "active");
1295
- setSelectedId(result.document.id);
462
+ await display("", "active", {
463
+ id: result.document.id,
464
+ document: result.document
465
+ });
466
+ props.onMutate?.();
1296
467
  } catch (reason) {
1297
468
  setError((0, dsh_mnemon_client.message)(reason));
1298
469
  } finally {
1299
470
  setSaving(false);
1300
471
  }
1301
472
  };
473
+ const activeSelected = selected !== null && selected.id === selectedId ? selected : null;
474
+ const loadingSelected = selectedId !== null && failedSelectedId !== selectedId && (selected === null || selected.id !== selectedId) && items.some((item) => item.id === selectedId);
1302
475
  const beginEdit = () => {
1303
- if (selected === null) return;
1304
- setTitle(selected.title);
1305
- setDescription(selected.description);
1306
- setContent(selected.content);
1307
- setSources(selected.sourcePaths.join("\n"));
476
+ if (activeSelected === null) return;
477
+ setTitle(activeSelected.title);
478
+ setDescription(activeSelected.description);
479
+ setContent(activeSelected.content);
480
+ setSources(activeSelected.sourcePaths.join("\n"));
1308
481
  setEditing(true);
1309
482
  setComposing(false);
1310
483
  setConfirmArchive(false);
1311
484
  };
1312
485
  const update = async (event) => {
1313
486
  event.preventDefault();
1314
- if (selected === null) return;
487
+ if (activeSelected === null) return;
1315
488
  setSaving(true);
1316
489
  setError(null);
1317
490
  setNotice(null);
1318
491
  try {
1319
492
  const result = await props.client.mutateDocument({
1320
493
  action: "update",
1321
- id: selected.id,
494
+ id: activeSelected.id,
1322
495
  title,
1323
496
  description,
1324
497
  content,
@@ -1326,9 +499,11 @@ window.__ModuleLoader__.load({
1326
499
  });
1327
500
  setNotice(result.maintenance === void 0 ? t("documents.updated") : t("documents.updatedAfterArchive", { count: result.maintenance.archivedDocumentIds.length }));
1328
501
  setEditing(false);
1329
- props.onMutate();
1330
- await display(query, status);
1331
- setSelectedId(result.document.id);
502
+ await display(query, status, {
503
+ id: result.document.id,
504
+ document: result.document
505
+ });
506
+ props.onMutate?.();
1332
507
  } catch (reason) {
1333
508
  setError((0, dsh_mnemon_client.message)(reason));
1334
509
  } finally {
@@ -1336,29 +511,53 @@ window.__ModuleLoader__.load({
1336
511
  }
1337
512
  };
1338
513
  const archive = async () => {
1339
- if (selected === null) return;
514
+ if (activeSelected === null) return;
1340
515
  setSaving(true);
1341
516
  setError(null);
1342
517
  setNotice(null);
1343
518
  try {
1344
- const result = await props.client.archiveDocument(selected.id);
519
+ const result = await props.client.archiveDocument(activeSelected.id);
1345
520
  const spaces = result.maintenance?.memoryBodyIds ?? [];
1346
521
  setNotice(spaces.length === 0 ? t("documents.archivedLocally") : t("documents.archived", { spaces: spaces.join(", ") }));
1347
522
  setConfirmArchive(false);
1348
523
  setStatus("archived");
1349
524
  setQuery("");
1350
- props.onMutate();
1351
- await display("", "archived");
1352
- setSelectedId(result.document.id);
525
+ await display("", "archived", {
526
+ id: result.document.id,
527
+ document: result.document
528
+ });
529
+ props.onMutate?.();
1353
530
  } catch (reason) {
1354
531
  setError((0, dsh_mnemon_client.message)(reason));
1355
532
  } finally {
1356
533
  setSaving(false);
1357
534
  }
1358
535
  };
536
+ const remove = async () => {
537
+ if (!props.writeEnabled || deleteTarget?.document.fileRevision === void 0 || props.client.deleteDocument === void 0) return;
538
+ setSaving(true);
539
+ setDeleteError(null);
540
+ setError(null);
541
+ setNotice(null);
542
+ try {
543
+ await props.client.deleteDocument(deleteTarget.document.id, deleteTarget.revision, deleteTarget.document.fileRevision);
544
+ setDeleteTarget(null);
545
+ setSelected(null);
546
+ setSelectedId(null);
547
+ setNotice(t("documents.deleted"));
548
+ await display(query, status);
549
+ props.onMutate?.();
550
+ } catch (reason) {
551
+ setDeleteError((0, dsh_mnemon_client.message)(reason));
552
+ } finally {
553
+ setSaving(false);
554
+ }
555
+ };
1359
556
  const usage = snapshot === null ? 0 : Math.min(100, snapshot.activeBytes / snapshot.limitBytes * 100);
1360
557
  const activeCount = snapshot?.activeCount ?? 0;
1361
558
  const archivedCount = snapshot?.archivedCount ?? 0;
559
+ const selectedRecord = snapshot?.documents.find((document) => document.id === activeSelected?.id);
560
+ const selectedIsCurrent = activeSelected?.fileRevision !== void 0 && selectedRecord?.revision === activeSelected.revision && selectedRecord.contentHash === activeSelected.contentHash && selectedRecord.status === activeSelected.status;
1362
561
  const composer = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
1363
562
  id: documentCreateFormId,
1364
563
  className: css.documentEditor,
@@ -1389,12 +588,12 @@ window.__ModuleLoader__.load({
1389
588
  })] })
1390
589
  ]
1391
590
  });
1392
- const editComposer = selected === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
591
+ const editComposer = activeSelected === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
1393
592
  id: documentEditFormId,
1394
593
  className: css.documentEditor,
1395
594
  onSubmit: (event) => void update(event),
1396
595
  children: [
1397
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("documents.editTitle") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("documents.editorHint") })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: selected.id })] }),
596
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("documents.editTitle") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("documents.editorHint") })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: activeSelected.id })] }),
1398
597
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1399
598
  className: css.documentEditorMeta,
1400
599
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [t("documents.name"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
@@ -1424,9 +623,11 @@ window.__ModuleLoader__.load({
1424
623
  const selectDocument = (documentId) => {
1425
624
  if (selectedId === documentId) return;
1426
625
  setSelected(null);
626
+ setFailedSelectedId(null);
1427
627
  setSelectedId(documentId);
1428
628
  setEditing(false);
1429
629
  setConfirmArchive(false);
630
+ setDeleteTarget(null);
1430
631
  };
1431
632
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1432
633
  className: css.page,
@@ -1445,16 +646,16 @@ window.__ModuleLoader__.load({
1445
646
  children: t("documents.new")
1446
647
  }) } : {}
1447
648
  }),
1448
- error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
649
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.Reveal, { children: error === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1449
650
  className: css.inlineError,
1450
651
  role: "alert",
1451
652
  children: error
1452
- }),
1453
- notice !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
653
+ }) }),
654
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.Reveal, { children: notice === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1454
655
  className: css.runtimeNotice,
1455
656
  role: "status",
1456
657
  children: notice
1457
- }),
658
+ }) }),
1458
659
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1459
660
  className: css.documentSummary,
1460
661
  "aria-label": t("documents.summary"),
@@ -1491,7 +692,12 @@ window.__ModuleLoader__.load({
1491
692
  className: css.documentSearch,
1492
693
  label: t("documents.searchAria"),
1493
694
  value: query,
1494
- onChange: (event) => setQuery(event.target.value),
695
+ onChange: (event) => {
696
+ const next = event.target.value;
697
+ const hadQuery = query.trim() !== "";
698
+ setQuery(next);
699
+ if (hadQuery && next === "" && activeSearchRef.current) display("", status);
700
+ },
1495
701
  placeholder: t("documents.searchPlaceholder")
1496
702
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1497
703
  type: "submit",
@@ -1501,10 +707,14 @@ window.__ModuleLoader__.load({
1501
707
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1502
708
  role: "group",
1503
709
  "aria-label": t("documents.scope"),
710
+ style: {
711
+ "--dsh-segment-count": 2,
712
+ "--dsh-segment-index": status === "active" ? 0 : 1
713
+ },
1504
714
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1505
715
  type: "button",
1506
716
  "data-active": status === "active" || void 0,
1507
- onClick: () => setStatus("active"),
717
+ onClick: () => changeStatus("active"),
1508
718
  children: [
1509
719
  t("documents.active"),
1510
720
  " ",
@@ -1513,7 +723,7 @@ window.__ModuleLoader__.load({
1513
723
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1514
724
  type: "button",
1515
725
  "data-active": status === "archived" || void 0,
1516
- onClick: () => setStatus("archived"),
726
+ onClick: () => changeStatus("archived"),
1517
727
  children: [
1518
728
  t("documents.archivedCount"),
1519
729
  " ",
@@ -1568,43 +778,54 @@ window.__ModuleLoader__.load({
1568
778
  className: css.documentReader,
1569
779
  "aria-label": t("documents.reader"),
1570
780
  "data-scroll-region": "",
1571
- children: selected === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.EmptyState, {
1572
- glyph: "▤",
1573
- title: t("documents.selectTitle"),
1574
- children: t("documents.selectText")
1575
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
781
+ children: activeSelected !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
1576
782
  className: css.documentDetail,
1577
783
  children: [
1578
784
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
1579
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selected.status === "active" ? t("documents.active") : t("documents.coldArchive") }),
1580
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: selected.title }),
1581
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: selected.description || t("documents.noDescription") })
1582
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: props.writeEnabled && selected.status === "active" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1583
- type: "button",
1584
- className: documentEditActionClass,
1585
- onClick: beginEdit,
1586
- children: t("documents.edit")
1587
- }) })] }),
785
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: activeSelected.status === "active" ? t("documents.active") : t("documents.coldArchive") }),
786
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: activeSelected.title }),
787
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: activeSelected.description || t("documents.noDescription") })
788
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
789
+ className: css.documentActions,
790
+ children: [props.writeEnabled && activeSelected.status === "active" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
791
+ type: "button",
792
+ className: documentEditActionClass,
793
+ onClick: beginEdit,
794
+ children: t("documents.edit")
795
+ }), props.writeEnabled && props.client.deleteDocument !== void 0 && snapshot !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
796
+ type: "button",
797
+ className: documentArchiveActionClass,
798
+ disabled: !selectedIsCurrent,
799
+ onClick: () => {
800
+ setDeleteError(null);
801
+ setDeleteTarget({
802
+ document: activeSelected,
803
+ revision: snapshot.revision
804
+ });
805
+ },
806
+ children: t("documents.delete")
807
+ })]
808
+ })] }),
1588
809
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", { children: [
1589
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.path") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: selected.relativePath }) })] }),
1590
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.revision") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: selected.revision })] }),
1591
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.hash") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: selected.contentHash.slice(0, 16) }) })] }),
1592
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.size") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: (0, dsh_mnemon_client.humanBytes)(selected.sizeBytes) })] })
810
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.path") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PathText, { path: activeSelected.relativePath }) }) })] }),
811
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.revision") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: activeSelected.revision })] }),
812
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.hash") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: activeSelected.contentHash.slice(0, 16) }) })] }),
813
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("documents.size") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: (0, dsh_mnemon_client.humanBytes)(activeSelected.sizeBytes) })] })
1593
814
  ] }),
1594
- selected.sourcePaths.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
815
+ activeSelected.sourcePaths.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1595
816
  className: css.documentSources,
1596
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("documents.sources") }), selected.sourcePaths.map((path) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: path }, path))]
817
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("documents.sources") }), activeSelected.sourcePaths.map((path) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PathText, { path }) }, path))]
1597
818
  }),
1598
- selected.status === "archived" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
819
+ activeSelected.status === "archived" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1599
820
  className: css.documentArchiveReceipt,
1600
821
  children: [
1601
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t(selected.memoryBodyIds.length === 0 ? "documents.archiveNote" : "documents.archiveReceipt") }),
1602
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: selected.archiveSummary }),
1603
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: selected.memoryBodyIds.map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: id }, id)) })
822
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t(activeSelected.memoryBodyIds.length === 0 ? "documents.archiveNote" : "documents.archiveReceipt") }),
823
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: activeSelected.archiveSummary }),
824
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: activeSelected.memoryBodyIds.map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: id }, id)) })
1604
825
  ]
1605
826
  }),
1606
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentMarkdown, { content: selected.content }),
1607
- props.writeEnabled && selected.status === "active" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
827
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentMarkdown, { content: activeSelected.content }),
828
+ props.writeEnabled && activeSelected.status === "active" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
1608
829
  className: css.documentDanger,
1609
830
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t("documents.archiveTitle") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("documents.archiveDescription") })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1610
831
  type: "button",
@@ -1614,13 +835,16 @@ window.__ModuleLoader__.load({
1614
835
  })] })
1615
836
  })
1616
837
  ]
838
+ }) : loadingSelected || loading && items.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
839
+ className: css.loading,
840
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SectionSpinner, { label: t("common.loading") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("common.loading") })]
841
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.EmptyState, {
842
+ glyph: "▤",
843
+ title: t("documents.selectTitle"),
844
+ children: t("documents.selectText")
1617
845
  })
1618
846
  })]
1619
847
  }),
1620
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1621
- className: css.runtimeFootnote,
1622
- children: t("documents.footnote")
1623
- }),
1624
848
  composing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
1625
849
  title: t("documents.newTitle"),
1626
850
  description: t("documents.editorHint"),
@@ -1645,9 +869,9 @@ window.__ModuleLoader__.load({
1645
869
  }),
1646
870
  children: composer
1647
871
  }),
1648
- editing && selected !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
872
+ editing && activeSelected !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
1649
873
  title: t("documents.editTitle"),
1650
- description: selected.title,
874
+ description: activeSelected.title,
1651
875
  busy: saving,
1652
876
  onClose: () => setEditing(false),
1653
877
  footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1669,9 +893,9 @@ window.__ModuleLoader__.load({
1669
893
  }),
1670
894
  children: editComposer
1671
895
  }),
1672
- confirmArchive && selected !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
896
+ confirmArchive && activeSelected !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
1673
897
  title: t("documents.archiveConfirm"),
1674
- description: selected.title,
898
+ description: activeSelected.title,
1675
899
  busy: saving,
1676
900
  onClose: () => setConfirmArchive(false),
1677
901
  footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1696,13 +920,56 @@ window.__ModuleLoader__.load({
1696
920
  className: css.bodyDeleteConfirm,
1697
921
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("documents.archiveDescription") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1698
922
  className: css.bodyDeleteSummary,
1699
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: selected.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
1700
- selected.relativePath,
923
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: activeSelected.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
924
+ activeSelected.relativePath,
1701
925
  " · ",
1702
- (0, dsh_mnemon_client.humanBytes)(selected.sizeBytes)
926
+ (0, dsh_mnemon_client.humanBytes)(activeSelected.sizeBytes)
1703
927
  ] })]
1704
928
  })]
1705
929
  })
930
+ }),
931
+ deleteTarget !== null && props.writeEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(dsh_mnemon_client.SidebarModal, {
932
+ title: t("documents.deleteConfirm"),
933
+ description: deleteTarget.document.title,
934
+ busy: saving,
935
+ onClose: () => setDeleteTarget(null),
936
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
937
+ className: css.modalFooterActions,
938
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
939
+ type: "button",
940
+ "data-dialog-close": true,
941
+ "data-autofocus": true,
942
+ className: css.secondaryButton,
943
+ disabled: saving,
944
+ onClick: () => setDeleteTarget(null),
945
+ children: t("common.cancel")
946
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
947
+ type: "button",
948
+ className: css.dangerSolidButton,
949
+ disabled: saving,
950
+ onClick: () => void remove(),
951
+ children: saving ? t("documents.deleting") : t("documents.deleteNow")
952
+ })]
953
+ }),
954
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
955
+ className: css.bodyDeleteConfirm,
956
+ children: [
957
+ deleteError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
958
+ className: css.inlineError,
959
+ role: "alert",
960
+ children: deleteError
961
+ }),
962
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("documents.deleteDescription") }),
963
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
964
+ className: css.bodyDeleteSummary,
965
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: deleteTarget.document.title }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
966
+ deleteTarget.document.relativePath,
967
+ " · ",
968
+ (0, dsh_mnemon_client.humanBytes)(deleteTarget.document.sizeBytes)
969
+ ] })]
970
+ })
971
+ ]
972
+ })
1706
973
  })
1707
974
  ]
1708
975
  });
@@ -1710,28 +977,66 @@ window.__ModuleLoader__.load({
1710
977
  //#endregion
1711
978
  //#region src/client/ui.tsx
1712
979
  function documentsPageClient(management) {
1713
- const client = (0, dsh_mnemon_client.createMemorySourcePageClient)(management);
980
+ let latestRevision = management.revision;
981
+ const tracked = {
982
+ ...management,
983
+ read: async (operation, input, options) => {
984
+ const response = await management.read(operation, input, options);
985
+ if (typeof response.revision === "string") latestRevision = response.revision;
986
+ return response;
987
+ }
988
+ };
989
+ const client = (0, dsh_mnemon_client.createMemorySourcePageClient)(tracked);
1714
990
  return {
1715
991
  documents: () => client.read("snapshot", null, { coalesce: true }),
1716
992
  document: (id) => client.read("document", { id }),
1717
- searchDocuments: (query, includeArchived = false, limit = 50) => client.read("search", {
1718
- query,
1719
- includeArchived,
1720
- limit
1721
- }),
1722
- mutateDocument: (input) => client.canAssist("mutate") ? client.assist("mutate", { ...input }, true) : client.mutate("mutate", { ...input }, true),
1723
- archiveDocument: (id) => client.canAssist("archive") ? client.assist("archive", { id }, true) : client.mutate("archive", { id }, true)
993
+ searchDocuments: async (query, includeArchived = false, limit = 50) => {
994
+ const result = await client.read("search", {
995
+ query,
996
+ includeArchived,
997
+ limit
998
+ });
999
+ return latestRevision === void 0 ? result : {
1000
+ ...result,
1001
+ revision: latestRevision
1002
+ };
1003
+ },
1004
+ mutateDocument: (input) => input.action === "delete" ? client.mutate("delete", {
1005
+ id: input.id,
1006
+ ...input.fileRevision === void 0 ? {} : { fileRevision: input.fileRevision }
1007
+ }, true) : client.canAssist("mutate") ? client.assist("mutate", { ...input }, true) : client.mutate("mutate", { ...input }, true),
1008
+ archiveDocument: (id) => client.canAssist("archive") ? client.assist("archive", { id }, true) : client.mutate("archive", { id }, true),
1009
+ deleteDocument: async (id, expectedRevision, fileRevision) => (await management.mutate("delete", {
1010
+ id,
1011
+ fileRevision
1012
+ }, {
1013
+ confirmed: true,
1014
+ expectedRevision
1015
+ })).value
1724
1016
  };
1725
1017
  }
1726
1018
  function DocumentsSourceView(props) {
1727
1019
  const client = (0, react.useMemo)(() => props.management === void 0 ? void 0 : documentsPageClient(props.management), [props.management]);
1728
1020
  const [revision, setRevision] = (0, react.useState)(0);
1729
- const refreshKey = (0, react.useRef)(props.refreshKey);
1021
+ const lastRefreshKey = (0, react.useRef)(props.refreshKey);
1022
+ const suppressRefreshEcho = (0, react.useRef)(false);
1730
1023
  (0, react.useEffect)(() => {
1731
- if (refreshKey.current === props.refreshKey) return;
1732
- refreshKey.current = props.refreshKey;
1024
+ if (lastRefreshKey.current === props.refreshKey) return;
1025
+ lastRefreshKey.current = props.refreshKey;
1026
+ if (suppressRefreshEcho.current) {
1027
+ suppressRefreshEcho.current = false;
1028
+ return;
1029
+ }
1733
1030
  setRevision((value) => value + 1);
1734
1031
  }, [props.refreshKey]);
1032
+ const handleMutate = (0, react.useCallback)(() => {
1033
+ if (props.onRefresh === void 0) return;
1034
+ suppressRefreshEcho.current = true;
1035
+ props.onRefresh();
1036
+ setTimeout(() => {
1037
+ suppressRefreshEcho.current = false;
1038
+ }, 0);
1039
+ }, [props.onRefresh]);
1735
1040
  if (client === void 0) return null;
1736
1041
  const navigation = props.navigationInput;
1737
1042
  const focus = typeof navigation === "object" && navigation !== null && !Array.isArray(navigation) && typeof navigation.seed === "string" && navigation.seed !== "" ? navigation : void 0;
@@ -1741,10 +1046,7 @@ window.__ModuleLoader__.load({
1741
1046
  client,
1742
1047
  revision,
1743
1048
  writeEnabled: props.writable === true,
1744
- onMutate: () => {
1745
- setRevision((value) => value + 1);
1746
- props.onRefresh?.();
1747
- }
1049
+ onMutate: handleMutate
1748
1050
  }, typeof focus?.nonce === "number" ? focus.nonce : 0);
1749
1051
  }
1750
1052
  function DocumentsSourcePage(props) {