@takboo/dsh-coopanion 0.4.6 → 0.4.7
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/README.md +6 -6
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/desktop/tray-state.cjs +1 -1
- package/docs/licenses/dompurify.txt +202 -0
- package/docs/licenses/marked.txt +44 -0
- package/docs/release-notes.md +16 -0
- package/npm-shrinkwrap.json +32 -2
- package/package.json +5 -2
- package/scripts/build.mjs +1 -0
- package/scripts/check-package.mjs +1 -1
- package/tests/desktop.mjs +9 -7
- package/tests/inbox-ui.mjs +4 -4
- package/tests/notification-ui.mjs +1 -1
- package/tests/presentation.test.js +21 -2
- package/tests/session-replies-ui.mjs +108 -0
- package/tests/ui.mjs +5 -5
- package/web/markdown-runtime.js +73 -0
- package/web/pet.js +21 -13
- package/web/reply-markdown.js +27 -0
- package/web/session-ui.js +16 -2
- package/web/style.css +18 -1
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
给 [DeepSeek Harness Desktop](https://github.com/deepseek-ai/deepseek-harness) 加一只桌面伙伴。她会陪你工作,在任务完成、出错或需要确认时提醒你;双击角色,可以向已打开的 Harness 会话发送消息。
|
|
4
4
|
|
|
5
|
-
**v0.4.
|
|
5
|
+
**v0.4.7 使用 Coopanion 的原生动画与角色运行时,组合程序采用 AGPL-3.0-or-later。** 大肥鱼的网格变形、弹簧动作、动态五官、物理拖拽和八套配色直接复用上游固定版本。角色贴图保留独立权利声明,见 [第三方声明](THIRD_PARTY_NOTICES.md) 和 [上游版本记录](web/upstream/UPSTREAM.md)。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
本次更新将同一会话的未读回合合并为最新回复,并为完整阅读提供 Markdown 标题、粗体、表格、列表和代码块渲染。查看 [最新修改记录](https://github.com/takboo/dsh-coopanion/releases/latest) 或 [完整版本记录](docs/release-notes.md)。
|
|
8
8
|
|
|
9
9
|
## 功能
|
|
10
10
|
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
|
|
27
27
|
桌宠不作出审批,也不单独收集 API Key。聊天始终发给明确选中的关注会话,新建会话和后台任务不会自动切换目标。关注会话进行中时优先展示它的动作;空闲时用动作反映后台工作或确认 / 异常。状态栏图形优先提示任一会话的确认 / 异常,菜单显示详情。
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
信封直接打开回复与待办收件箱:同一会话的多个未读回合合并展示最新回复,未读数量按会话计算。只有一份回复时展开全文;多份回复显示摘要和各自的 **继续对话 ↗**,审批、提问及异常提供 **去处理 ↗**。全文支持 Markdown 标题、粗体、列表、表格和代码块。阅读不会切换正在聊天的会话;收件箱阅读器可连续读不同会话的结果,并返回收件箱查看新内容。正在阅读的回复不会被新结果替换。保留最近 200 份完整结果,优先淘汰已读;只有本次 Harness 运行中实时完成的回复计入未读,打开历史会话或重启 Harness 不会把旧回复重新标为未读。重启后原始对话仍由 Harness 保存;任务动画根据当前 Agent 的运行状态恢复。
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
回复气泡展示或自动收起、查看收件箱摘要及收起收件箱均不会标记已读;主动展开阅读、关闭单份回复气泡或通过该回复回到源会话时,确认展示时合并的未读回合。阅读期间新到的回合继续保留未读,旧回合的完整结果仍可通过历史导航查看。审批与 AI 提问由 Harness 的实际答复、决定或取消结果结算;查看、收起互动提示或打开源会话均不会代替处理请求。
|
|
32
32
|
|
|
33
33
|
高频流式事件仅发送动画元数据,完整结果只在结果列表或已读状态变化时传输,避免长回复和多会话拖慢桌面更新。
|
|
34
34
|
|
|
@@ -44,7 +44,7 @@ v0.4.0 移除了旧 Canvas 关键帧引擎、`dsh-character` v1 协议、`.dshpe
|
|
|
44
44
|
|
|
45
45
|
支持 **DSH 0.2.0-rc.2 和 0.2.1-alpha.1**;其他版本未声明兼容。
|
|
46
46
|
|
|
47
|
-
1. 下载对应 [Release](https://github.com/takboo/dsh-coopanion/releases) 的 `dsh-coopanion-0.4.
|
|
47
|
+
1. 下载对应 [Release](https://github.com/takboo/dsh-coopanion/releases) 的 `dsh-coopanion-0.4.7.tgz`,或按下面步骤构建 `takboo-dsh-coopanion-0.4.7.tgz`。npm 包名为 `@takboo/dsh-coopanion`;本地 `npm pack` 的文件名包含 scope。
|
|
48
48
|
2. 在 Harness 侧边栏 **插件** 页安装压缩包的绝对路径,启用 `dsh-coopanion`。
|
|
49
49
|
3. 完全退出再重新打开 Harness。首次启动时会下载并校验 Electron 44 运行时。
|
|
50
50
|
4. 打开一段 Harness 会话,双击角色聊天,或从 **Settings → 桌宠** 管理角色。
|
|
@@ -52,7 +52,7 @@ v0.4.0 移除了旧 Canvas 关键帧引擎、`dsh-character` v1 协议、`.dshpe
|
|
|
52
52
|
也可使用 Desktop 自带的 CLI。先启动 Desktop 一次初始化 profile,完全退出应用,再执行:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
dsh plugin --profile desktop add /absolute/path/dsh-coopanion-0.4.
|
|
55
|
+
dsh plugin --profile desktop add /absolute/path/dsh-coopanion-0.4.7.tgz
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
npm 安装的 dsh 不能管理 Desktop 所拥有的 profile。Desktop 完全退出后执行包管理命令,再重新打开应用。
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -16,6 +16,10 @@ This integration follows the project user's existing statement that the communit
|
|
|
16
16
|
|
|
17
17
|
Electron 44.7.0 is installed as a dependency and retains its MIT license and Chromium's accompanying notices. Runtime download and verification remain unchanged.
|
|
18
18
|
|
|
19
|
+
## Marked 18.1.1 and DOMPurify 3.4.17
|
|
20
|
+
|
|
21
|
+
The full-reply reader bundles [Marked](https://github.com/markedjs/marked) and [DOMPurify](https://github.com/cure53/DOMPurify) into `web/markdown-runtime.js` at build time. Marked is distributed under the MIT license; DOMPurify is used under its Apache-2.0 license option. Their complete upstream license and copyright notices are retained in [docs/licenses/marked.txt](docs/licenses/marked.txt) and [docs/licenses/dompurify.txt](docs/licenses/dompurify.txt). Neither dependency is modified.
|
|
22
|
+
|
|
19
23
|
## fflate 0.8.3
|
|
20
24
|
|
|
21
25
|
MIT License
|
package/desktop/tray-state.cjs
CHANGED
|
@@ -9,7 +9,7 @@ function trayState(snapshot = {}, presentation = {}, options = {}, visible = fal
|
|
|
9
9
|
const name = presentation.name || 'DeepSeek 大肥鱼';
|
|
10
10
|
return { name, characterId: presentation.characterId || 'whale', scheme: presentation.scheme || '', iconReady: !!presentation.ready, icon: mood === 'sleeping' ? 'sleeping' : activity.icon, mood, stateLabel: labels[mood] ?? labels.idle, activity, active, sleeping: mood === 'sleeping', visible, roam: options.roam ?? true, notifications: options.notifications ?? true, sound: presentation.sound ?? true,
|
|
11
11
|
sessionId: snapshot.sessionId ?? null, sessionLabel: selected?.label ?? '还没有会话',
|
|
12
|
-
sessions: [...(snapshot.sessions ?? [])].sort((a, b) => Number(b.id === snapshot.sessionId) - Number(a.id === snapshot.sessionId) || (b.updatedAt ?? 0) - (a.updatedAt ?? 0)).map(session => ({ id: session.id, label: session.label, project: session.project, selected: session.id === snapshot.sessionId, mood: session.mood, unread: session.unread
|
|
12
|
+
sessions: [...(snapshot.sessions ?? [])].sort((a, b) => Number(b.id === snapshot.sessionId) - Number(a.id === snapshot.sessionId) || (b.updatedAt ?? 0) - (a.updatedAt ?? 0)).map(session => ({ id: session.id, label: session.label, project: session.project, selected: session.id === snapshot.sessionId, mood: session.mood, unread: Number(!!session.unread) })),
|
|
13
13
|
tooltip: `${name} · ${labels[mood] ?? labels.idle}\n关注:${selected?.label ?? '还没有会话'}\n${activity.busy} 段进行中 · ${activity.waiting + activity.errors} 段需要你 · ${activity.unread} 份未读回复`,
|
|
14
14
|
title: '',
|
|
15
15
|
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# License information
|
|
2
|
+
|
|
3
|
+
## Contribution License Agreement
|
|
4
|
+
|
|
5
|
+
If you contribute code to this project, you are implicitly allowing your code
|
|
6
|
+
to be distributed under the MIT license. You are also implicitly verifying that
|
|
7
|
+
all code is your original work. `</legalese>`
|
|
8
|
+
|
|
9
|
+
## Marked
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
|
12
|
+
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in
|
|
22
|
+
all copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
## Markdown
|
|
33
|
+
|
|
34
|
+
Copyright © 2004, John Gruber
|
|
35
|
+
http://daringfireball.net/
|
|
36
|
+
All rights reserved.
|
|
37
|
+
|
|
38
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
39
|
+
|
|
40
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
41
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
42
|
+
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
43
|
+
|
|
44
|
+
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
package/docs/release-notes.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# v0.4.7
|
|
2
|
+
|
|
3
|
+
## 未读回复按会话去重
|
|
4
|
+
|
|
5
|
+
- 同一会话的多个未读回合合并展示最新回复,信封、收件箱、会话列表及托盘的未读数量按会话计算。仅有一个未读会话且没有其他待办时,一次点击直接打开最新全文。
|
|
6
|
+
- 主动阅读、关闭回复气泡或通过回复继续对话时,确认展示时包含的未读回合,避免旧回复再次进入收件箱。阅读期间新完成的回合继续保留未读,不替换当前内容;完整历史结果仍保留。
|
|
7
|
+
|
|
8
|
+
## 完整回复渲染 Markdown
|
|
9
|
+
|
|
10
|
+
- 全文支持标题、粗体、列表、引用、表格、链接及代码块,表格和长代码可横向滚动,窄屏阅读面板保持在窗口内。
|
|
11
|
+
- 原始 HTML 作为文字显示,过滤可执行链接,图片保留替代文字。渲染资源随安装包分发,回复原文继续保留。
|
|
12
|
+
|
|
13
|
+
新增同会话多回合、已读确认与新回复到达、单会话一键阅读、Markdown 格式、安全渲染及窄屏浏览器回归;原生 IPC 回归覆盖合并回复的完整身份和粗体渲染。
|
|
14
|
+
|
|
15
|
+
安装包:`dsh-coopanion-0.4.7.tgz`。npm、版本化 Release 包及固定别名 `dsh-coopanion.tgz` 使用同一份通过 CI 的压缩包。
|
|
16
|
+
|
|
1
17
|
# v0.4.6
|
|
2
18
|
|
|
3
19
|
## 修复历史会话与重启状态
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takboo/dsh-coopanion",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@takboo/dsh-coopanion",
|
|
9
|
-
"version": "0.4.
|
|
9
|
+
"version": "0.4.7",
|
|
10
10
|
"license": "AGPL-3.0-or-later",
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"dompurify": "3.4.17",
|
|
12
13
|
"electron": "44.7.0",
|
|
13
14
|
"fflate": "0.8.3",
|
|
15
|
+
"marked": "18.1.1",
|
|
14
16
|
"zod": "4.6.5"
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
@@ -2260,6 +2262,13 @@
|
|
|
2260
2262
|
"@types/react": "*"
|
|
2261
2263
|
}
|
|
2262
2264
|
},
|
|
2265
|
+
"node_modules/@types/trusted-types": {
|
|
2266
|
+
"version": "2.0.7",
|
|
2267
|
+
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
|
2268
|
+
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
|
2269
|
+
"license": "MIT",
|
|
2270
|
+
"optional": true
|
|
2271
|
+
},
|
|
2263
2272
|
"node_modules/@vitest/expect": {
|
|
2264
2273
|
"version": "3.2.7",
|
|
2265
2274
|
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.7.tgz",
|
|
@@ -2481,6 +2490,15 @@
|
|
|
2481
2490
|
"node": ">=6"
|
|
2482
2491
|
}
|
|
2483
2492
|
},
|
|
2493
|
+
"node_modules/dompurify": {
|
|
2494
|
+
"version": "3.4.17",
|
|
2495
|
+
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.17.tgz",
|
|
2496
|
+
"integrity": "sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==",
|
|
2497
|
+
"license": "(MPL-2.0 OR Apache-2.0)",
|
|
2498
|
+
"optionalDependencies": {
|
|
2499
|
+
"@types/trusted-types": "^2.0.7"
|
|
2500
|
+
}
|
|
2501
|
+
},
|
|
2484
2502
|
"node_modules/electron": {
|
|
2485
2503
|
"version": "44.7.0",
|
|
2486
2504
|
"resolved": "https://registry.npmjs.org/electron/-/electron-44.7.0.tgz",
|
|
@@ -2726,6 +2744,18 @@
|
|
|
2726
2744
|
"@jridgewell/sourcemap-codec": "^1.5.5"
|
|
2727
2745
|
}
|
|
2728
2746
|
},
|
|
2747
|
+
"node_modules/marked": {
|
|
2748
|
+
"version": "18.1.1",
|
|
2749
|
+
"resolved": "https://registry.npmjs.org/marked/-/marked-18.1.1.tgz",
|
|
2750
|
+
"integrity": "sha512-zEGgrtUG8crk+TrMacJSVABU4DYDDkS8uqgU3ohrn/2fW9C2AEfUrO3m6IhpIpQpl7YcVpiXXC9cSMWDANT3dg==",
|
|
2751
|
+
"license": "MIT",
|
|
2752
|
+
"bin": {
|
|
2753
|
+
"marked": "bin/marked.js"
|
|
2754
|
+
},
|
|
2755
|
+
"engines": {
|
|
2756
|
+
"node": ">= 20"
|
|
2757
|
+
}
|
|
2758
|
+
},
|
|
2729
2759
|
"node_modules/mime-db": {
|
|
2730
2760
|
"version": "1.54.0",
|
|
2731
2761
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takboo/dsh-coopanion",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "DeepSeek Whale desktop companion and task notifications for DeepSeek Harness",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-or-later",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dist",
|
|
37
37
|
"desktop",
|
|
38
38
|
"web",
|
|
39
|
+
"web/markdown-runtime.js",
|
|
39
40
|
"src",
|
|
40
41
|
"scripts",
|
|
41
42
|
"tests",
|
|
@@ -84,11 +85,13 @@
|
|
|
84
85
|
"demo": "node scripts/demo.mjs",
|
|
85
86
|
"prepack": "npm run build",
|
|
86
87
|
"test:notification-ui": "node tests/notification-ui.mjs",
|
|
87
|
-
"test:inbox-ui": "node tests/inbox-ui.mjs"
|
|
88
|
+
"test:inbox-ui": "node tests/inbox-ui.mjs && node --test tests/session-replies-ui.mjs"
|
|
88
89
|
},
|
|
89
90
|
"dependencies": {
|
|
91
|
+
"dompurify": "3.4.17",
|
|
90
92
|
"electron": "44.7.0",
|
|
91
93
|
"fflate": "0.8.3",
|
|
94
|
+
"marked": "18.1.1",
|
|
92
95
|
"zod": "4.6.5"
|
|
93
96
|
},
|
|
94
97
|
"peerDependencies": {
|
package/scripts/build.mjs
CHANGED
|
@@ -4,6 +4,7 @@ const manifest = JSON.parse(await readFile('package.json', 'utf8'));
|
|
|
4
4
|
await rm('dist', { recursive: true, force: true });
|
|
5
5
|
await build({ entryPoints: ['src/index.ts', 'src/bridge.ts', 'src/model.ts'], outdir: 'dist', bundle: true, packages: 'external', platform: 'node', format: 'esm', target: 'node22', sourcemap: true });
|
|
6
6
|
await build({ entryPoints: ['src/character-store.ts', 'src/figure-server.ts'], outdir: 'dist', outExtension: { '.js': '.cjs' }, bundle: true, platform: 'node', format: 'cjs', target: 'node22' });
|
|
7
|
+
await build({ entryPoints: ['web/reply-markdown.js'], outfile: 'web/markdown-runtime.js', bundle: true, platform: 'browser', format: 'esm', target: 'chrome130', minify: true });
|
|
7
8
|
await build({ entryPoints: ['src/client/index.ts'], outfile: 'dist/client.js', bundle: true,
|
|
8
9
|
// DSH supplies its public peers and React. Runtime dependencies such as zod
|
|
9
10
|
// must be bundled because they have no DSH browser module factory.
|
|
@@ -25,7 +25,7 @@ assert.ok(unpack('dist/client.js').includes(`id: ${JSON.stringify(packed.name)}`
|
|
|
25
25
|
if (values['expected-version']) assert.equal(packed.version, values['expected-version'], 'archive version differs from tag');
|
|
26
26
|
else assert.equal(packed.version, pkg.version);
|
|
27
27
|
assert.equal(packed.repository.url, pkg.repository.url);
|
|
28
|
-
for (const required of ['dist/client.js', 'dist/index.js', 'dist/character-store.cjs', 'dist/figure-server.cjs', 'cordis.patch.yml', 'desktop/main.cjs', 'desktop/tray-state.cjs', 'desktop/preload.cjs', 'web/index.html', 'web/pet.js', 'web/speech.js', 'web/session-ui.js', 'web/tray-icon.js', 'web/upstream/kit/rig.js', 'web/upstream/kit/body.js', 'web/upstream/figure-frame.html', 'web/upstream/body-host.js', 'web/upstream/whale/figure.json', 'web/upstream/whale/model.json', 'web/upstream/whale/tex/face.png', 'web/upstream/UPSTREAM.md', 'web/upstream/THIRD_PARTY_NOTICES.md', 'src/figure-server.ts', 'src/upstream/packs.ts', 'scripts/build.mjs', 'npm-shrinkwrap.json', 'tsconfig.json', 'tsconfig.client.json', '.node-version', 'docs/characters.md', 'examples/star/figure.json', 'examples/star/figure.js', 'tests/figures.test.ts', 'THIRD_PARTY_NOTICES.md', 'LICENSE', 'LICENSE-MIT', 'README.md']) assert.ok(entries.includes(`package/${required}`), `missing ${required}`);
|
|
28
|
+
for (const required of ['dist/client.js', 'dist/index.js', 'dist/character-store.cjs', 'dist/figure-server.cjs', 'cordis.patch.yml', 'desktop/main.cjs', 'desktop/tray-state.cjs', 'desktop/preload.cjs', 'web/index.html', 'web/pet.js', 'web/speech.js', 'web/session-ui.js', 'web/reply-markdown.js', 'web/markdown-runtime.js', 'web/tray-icon.js', 'web/upstream/kit/rig.js', 'web/upstream/kit/body.js', 'web/upstream/figure-frame.html', 'web/upstream/body-host.js', 'web/upstream/whale/figure.json', 'web/upstream/whale/model.json', 'web/upstream/whale/tex/face.png', 'web/upstream/UPSTREAM.md', 'web/upstream/THIRD_PARTY_NOTICES.md', 'src/figure-server.ts', 'src/upstream/packs.ts', 'scripts/build.mjs', 'npm-shrinkwrap.json', 'tsconfig.json', 'tsconfig.client.json', '.node-version', 'docs/characters.md', 'examples/star/figure.json', 'examples/star/figure.js', 'tests/figures.test.ts', 'docs/licenses/marked.txt', 'docs/licenses/dompurify.txt', 'THIRD_PARTY_NOTICES.md', 'LICENSE', 'LICENSE-MIT', 'README.md']) assert.ok(entries.includes(`package/${required}`), `missing ${required}`);
|
|
29
29
|
assert.ok(!entries.some(path => path.includes('node_modules/') || path.includes('.cache/')));
|
|
30
30
|
assert.ok(!entries.some(path => /character-runtime|character.schema|\/animation\.|\/character-pack\.|\/web\/characters\//.test(path)), 'old engine and format must not be packaged');
|
|
31
31
|
const bytes = readFileSync(archive);
|
package/tests/desktop.mjs
CHANGED
|
@@ -132,25 +132,27 @@ try {
|
|
|
132
132
|
await page.waitForSelector('#bubble-expand:not([hidden])');
|
|
133
133
|
await page.locator('#bubble-reveal').click();
|
|
134
134
|
await page.locator('#bubble-expand').click();
|
|
135
|
-
assert.equal(await page.locator('#reader-text').
|
|
135
|
+
assert.equal(await page.locator('#reader-text').innerText(), long.text, 'full native reply survives IPC and is not truncated');
|
|
136
136
|
const newer = { ...long, id: 'native-newer', text: '下一份回复' };
|
|
137
137
|
bridge.update({ ...finalFrame, results: [long, newer], sessions: [{ ...finalFrame.sessions[0], reply: newer.text, replyId: newer.id, unread: 2 }] });
|
|
138
138
|
await page.waitForFunction(() => document.getElementById('reader-count').textContent === '1 / 2');
|
|
139
|
-
assert.equal(await page.locator('#reader-text').
|
|
139
|
+
assert.equal(await page.locator('#reader-text').innerText(), long.text, 'new completion does not interrupt the reader');
|
|
140
140
|
await page.locator('#reader-next').click();
|
|
141
|
-
assert.equal(await page.locator('#reader-text').
|
|
141
|
+
assert.equal(await page.locator('#reader-text').innerText(), newer.text);
|
|
142
142
|
await page.keyboard.press('Escape');
|
|
143
|
-
const backgroundReply = { id: 'native-inbox-background-full', sessionId: 'native-inbox-source-full', time: Date.now(), text: '
|
|
143
|
+
const backgroundReply = { id: 'native-inbox-background-full', sessionId: 'native-inbox-source-full', time: Date.now(), text: '从后台捎回来的**完整回复**。\n当前聊天对象保持不变。', read: false };
|
|
144
|
+
const olderBackgroundReply = { ...backgroundReply, id: 'native-inbox-background-older', time: backgroundReply.time - 1, text: '同一会话的旧回合。' };
|
|
144
145
|
const actionStart = actions.length;
|
|
145
|
-
bridge.update({ ...idleFrame, results: [backgroundReply], sessions: [{ ...idleFrame.sessions[0], unread: 0 }, { id: backgroundReply.sessionId, label: '后台检查', mood: 'idle', active: false, unread:
|
|
146
|
+
bridge.update({ ...idleFrame, results: [olderBackgroundReply, backgroundReply], sessions: [{ ...idleFrame.sessions[0], unread: 0 }, { id: backgroundReply.sessionId, label: '后台检查', mood: 'idle', active: false, unread: 2, replyId: backgroundReply.id, reply: backgroundReply.text }] });
|
|
146
147
|
await page.locator('#attention:not([hidden])').waitFor();
|
|
147
148
|
await page.locator('#attention').click();
|
|
148
149
|
await page.locator('#reader:not([hidden])').waitFor();
|
|
149
|
-
assert.equal(await page.locator('#reader-text').
|
|
150
|
+
assert.equal(await page.locator('#reader-text').innerText(), '从后台捎回来的完整回复。\n当前聊天对象保持不变。', 'multiple native turns of one session open the latest reply directly');
|
|
151
|
+
assert.equal(await page.locator('#reader-text strong').innerText(), '完整回复', 'Markdown is rendered after native IPC');
|
|
150
152
|
assert.equal(await page.locator('#chat-session-name').innerText(), '桌面测试会话');
|
|
151
153
|
await page.locator('#reader-session').click();
|
|
152
154
|
for (let n = 0; n < 30 && !actions.slice(actionStart).some(action => action.type === 'open-session'); n++) await pause(50);
|
|
153
|
-
assert.deepEqual(actions.slice(actionStart).filter(action => ['select', 'read', 'open-session'].includes(action.type)), [{ type: 'read', resultId: backgroundReply.id }, { type: 'open-session', sessionId: backgroundReply.sessionId }], 'native inbox
|
|
155
|
+
assert.deepEqual(actions.slice(actionStart).filter(action => ['select', 'read', 'open-session'].includes(action.type)), [{ type: 'read', resultId: olderBackgroundReply.id }, { type: 'read', resultId: backgroundReply.id }, { type: 'open-session', sessionId: backgroundReply.sessionId }], 'native inbox acknowledges every captured turn and carries the exact source identity');
|
|
154
156
|
for (let n = 0; n < 100 && !trayIcons.some(icon => icon.icon === 'talking'); n++) await pause(50);
|
|
155
157
|
assert.ok(trayIcons.some(icon => icon.icon === 'talking' && icon.title === '' && icon.template === (process.platform === 'darwin')), 'native icon is rendered with the state glyph and macOS template appearance');
|
|
156
158
|
bridge.configure({ size: 150, roam: false, notifications: false, bubbleDurationMs: 12000 });
|
package/tests/inbox-ui.mjs
CHANGED
|
@@ -36,7 +36,7 @@ try {
|
|
|
36
36
|
await resetActions();
|
|
37
37
|
await page.locator('#attention').click();
|
|
38
38
|
await page.locator('#reader:not([hidden])').waitFor();
|
|
39
|
-
assert.equal(await page.locator('#reader-text').
|
|
39
|
+
assert.equal(await page.locator('#reader-text').innerText(), first.text, 'one reply opens in full with one click');
|
|
40
40
|
assert.equal(await page.locator('#conversations').isVisible(), false);
|
|
41
41
|
assert.equal(await page.locator('#chat-session-name').innerText(), focus.label);
|
|
42
42
|
assert.deepEqual(await actions(), [{ type: 'read', resultId: first.id }], 'reading acknowledges the exact reply and keeps chat focus');
|
|
@@ -68,14 +68,14 @@ try {
|
|
|
68
68
|
await page.locator(`[data-result-id="${fourth.id}"][data-action=read]`).focus();
|
|
69
69
|
assert.deepEqual(await actions(), [], 'keyboard focus on a summary does not mark it read');
|
|
70
70
|
await page.keyboard.press('Enter');
|
|
71
|
-
assert.equal(await page.locator('#reader-text').
|
|
71
|
+
assert.equal(await page.locator('#reader-text').innerText(), fourth.text);
|
|
72
72
|
assert.equal(await page.locator('#reader-count').innerText(), '1 / 2');
|
|
73
73
|
const incoming = reply('arrives-while-reading', b, 5, '读到一半新收到的回复。');
|
|
74
74
|
await receive({ type: 'snapshot', snapshot: frame([waitingA, b, issue], [third, fourth, incoming]) });
|
|
75
|
-
assert.equal(await page.locator('#reader-text').
|
|
75
|
+
assert.equal(await page.locator('#reader-text').innerText(), fourth.text, 'incoming messages cannot replace the open reply');
|
|
76
76
|
assert.equal(await page.locator('#reader-count').innerText(), '1 / 2', 'the active reading order remains stable');
|
|
77
77
|
await page.locator('#reader-next').click();
|
|
78
|
-
assert.equal(await page.locator('#reader-text').
|
|
78
|
+
assert.equal(await page.locator('#reader-text').innerText(), third.text, 'read consecutively across source sessions');
|
|
79
79
|
assert.equal(await page.locator('#chat-session-name').innerText(), focus.label);
|
|
80
80
|
assert.ok(!(await actions()).some(action => action.type === 'select'));
|
|
81
81
|
await page.locator('#reader-inbox').click();
|
|
@@ -53,7 +53,7 @@ try {
|
|
|
53
53
|
await page.locator('#bubble-expand').click();
|
|
54
54
|
await receive({ type: 'notice', notice: notice('reading-reminder', 'question', 'reminder') });
|
|
55
55
|
await page.waitForTimeout(100); assert.equal(await page.locator('#interaction').isVisible(), false);
|
|
56
|
-
assert.equal(await page.locator('#reader-text').innerText(), reply.text);
|
|
56
|
+
assert.equal(await page.locator('#reader-text').innerText(), reply.text.trim());
|
|
57
57
|
await page.keyboard.press('Escape'); await page.locator('#interaction:not([hidden])').waitFor();
|
|
58
58
|
assert.equal(await page.locator('#interaction-title').innerText(), 'That earlier request is still waiting for you.');
|
|
59
59
|
await page.locator('#interaction-close').click();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { it, expect } from 'vitest';
|
|
2
2
|
import { createSpeech, replyPreview } from '../web/speech.js';
|
|
3
|
-
import { shortSessionIds, sessionActivity } from '../web/session-ui.js';
|
|
3
|
+
import { shortSessionIds, sessionActivity, inboxContents } from '../web/session-ui.js';
|
|
4
4
|
import tray from '../desktop/tray-state.cjs';
|
|
5
5
|
|
|
6
6
|
it('keeps the visible Unicode prefix and punctuation pause when live speech is extended', () => {
|
|
@@ -44,12 +44,31 @@ it('bounds preview typing time while preserving full Unicode text for the reader
|
|
|
44
44
|
|
|
45
45
|
it('shares background attention and active work between the character and tray without changing focus', () => {
|
|
46
46
|
const snapshot = { sessionId: 'a', mood: 'thinking', active: true, sessions: [{ id: 'a', mood: 'thinking', active: true }, { id: 'b', mood: 'waiting', active: true, unread: 2 }, { id: 'c', mood: 'idle', unread: 1 }] };
|
|
47
|
-
expect(sessionActivity(snapshot)).toMatchObject({ mood: 'thinking', icon: 'waiting', waiting: 1, unread:
|
|
47
|
+
expect(sessionActivity(snapshot)).toMatchObject({ mood: 'thinking', icon: 'waiting', waiting: 1, unread: 2, busy: 2, pending: 2 });
|
|
48
48
|
const state = tray.trayState(snapshot);
|
|
49
49
|
expect(state.activity).toEqual(sessionActivity(snapshot)); expect(state.sessionId).toBe('a');
|
|
50
50
|
expect(tray.trayState({ ...snapshot, mood: 'idle', active: false, sessions: snapshot.sessions.slice(1) }, { sleeping: true })).toMatchObject({ mood: 'waiting', sleeping: false });
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
it('coalesces unread turns by exact session identity without mutating retained history', () => {
|
|
54
|
+
const results = [
|
|
55
|
+
{ id: 'b:1', sessionId: 'b', time: 3, read: false, text: 'other session' },
|
|
56
|
+
{ id: 'a:2', sessionId: 'a', time: 2, read: false, text: 'newest' },
|
|
57
|
+
{ id: 'a:1', sessionId: 'a', time: 1, read: false, text: 'oldest, delivered out of order' },
|
|
58
|
+
{ id: 'a:3', sessionId: 'a', time: 2, read: false, text: 'later completion at the same timestamp' },
|
|
59
|
+
{ id: 'a:0', sessionId: 'a', time: 0, read: true, text: 'already read' },
|
|
60
|
+
];
|
|
61
|
+
const snapshot = { results, sessions: [{ id: 'a', unread: 3 }, { id: 'b', unread: 1 }] };
|
|
62
|
+
const contents = inboxContents(snapshot);
|
|
63
|
+
expect(contents.replies.map(reply => reply.id)).toEqual(['b:1', 'a:3']);
|
|
64
|
+
expect(contents.replies[1].unreadIds).toEqual(['a:2', 'a:1', 'a:3']);
|
|
65
|
+
expect(contents.total).toBe(2); expect(sessionActivity(snapshot).unread).toBe(2);
|
|
66
|
+
expect(inboxContents(snapshot, [], new Set(contents.replies[1].unreadIds)).replies.map(reply => reply.id)).toEqual(['b:1']);
|
|
67
|
+
expect(results.filter(result => !result.read)).toHaveLength(4);
|
|
68
|
+
expect(results.every(result => !('unreadIds' in result))).toBe(true);
|
|
69
|
+
expect(tray.trayState(snapshot).activity.unread).toBe(2);
|
|
70
|
+
});
|
|
71
|
+
|
|
53
72
|
import { notificationCopy, notificationPresentation, createNoticeQueue } from '../web/notification-ui.js';
|
|
54
73
|
const taskNotice = (id, category = 'question', stage = 'initial', requestIds = ['question-full']) => ({ id, sessionId: 'session-full', category, stage, title: 'Title', body: 'Full question preview', requestIds });
|
|
55
74
|
it('maps every event and grouped reminder into character language with supported vocabulary fallback', () => {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { once } from 'node:events';
|
|
3
|
+
import { mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { after, before, test } from 'node:test';
|
|
8
|
+
import { chromium } from 'playwright-core';
|
|
9
|
+
import { previewServer } from '../scripts/preview.mjs';
|
|
10
|
+
|
|
11
|
+
let directory, server, browser;
|
|
12
|
+
before(async () => {
|
|
13
|
+
directory = await mkdtemp(join(tmpdir(), 'dsh-session-replies-'));
|
|
14
|
+
server = previewServer({ dataDir: directory }); server.listen(0, '127.0.0.1'); await once(server, 'listening');
|
|
15
|
+
browser = await chromium.launch({ executablePath: process.env.CHROMIUM_PATH ?? (existsSync('/usr/bin/chromium') ? '/usr/bin/chromium' : chromium.executablePath()), headless: true, args: ['--no-sandbox', '--enable-unsafe-swiftshader'] });
|
|
16
|
+
});
|
|
17
|
+
after(async () => {
|
|
18
|
+
await browser?.close();
|
|
19
|
+
if (server) await new Promise(resolve => server.close(resolve));
|
|
20
|
+
if (directory) await rm(directory, { recursive: true, force: true });
|
|
21
|
+
});
|
|
22
|
+
const focus = { id: 'focus', label: '正在聊', mood: 'idle', unread: 0 };
|
|
23
|
+
const source = { id: 'source', label: '后台会话', mood: 'idle', unread: 2 };
|
|
24
|
+
const other = { ...source, id: 'other', label: '另一段会话', unread: 1 };
|
|
25
|
+
const reply = (id, sessionId, time, text) => ({ id, sessionId, time, text, read: false });
|
|
26
|
+
const frame = results => ({ mood: 'idle', active: false, sessionId: focus.id, sessions: [focus, source, other], results });
|
|
27
|
+
async function fixture(t, results) {
|
|
28
|
+
const page = await browser.newPage({ viewport: { width: 1000, height: 800 }, reducedMotion: 'reduce' });
|
|
29
|
+
t.after(() => page.close());
|
|
30
|
+
page.setDefaultTimeout(5000);
|
|
31
|
+
const errors = []; page.on('pageerror', error => errors.push(error.message));
|
|
32
|
+
t.after(() => assert.deepEqual(errors, []));
|
|
33
|
+
await page.addInitScript(() => {
|
|
34
|
+
window.replyActions = [];
|
|
35
|
+
window.dshPetBridge = { subscribe(fn) { window.replyReceive = fn; }, action(action) { window.replyActions.push(action); }, hit() {} };
|
|
36
|
+
});
|
|
37
|
+
await page.goto(`http://127.0.0.1:${server.address().port}`);
|
|
38
|
+
await page.waitForSelector('#pet[data-character=whale][data-mode]');
|
|
39
|
+
const receive = snapshot => page.evaluate(snapshot => window.replyReceive({ type: 'snapshot', snapshot }), snapshot);
|
|
40
|
+
await receive(frame(results));
|
|
41
|
+
return { page, receive };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
test('unread replies coalesce by session and reading does not expose old turns again', async t => {
|
|
45
|
+
const old = reply('source:1:3', source.id, 1, '旧回合的回复');
|
|
46
|
+
const latest = reply('source:2:6', source.id, 2, '最新回合的回复');
|
|
47
|
+
const separate = reply('other:1:3', other.id, 3, '另一段会话的回复');
|
|
48
|
+
const { page, receive } = await fixture(t, [old, latest, separate]);
|
|
49
|
+
await page.locator('#attention').click();
|
|
50
|
+
assert.equal(await page.locator('#inbox-replies .inbox-reply').count(), 2, 'one card per session');
|
|
51
|
+
assert.equal(await page.locator('#inbox-count').innerText(), '0 件待处理 · 2 份未读回复');
|
|
52
|
+
assert.equal(await page.locator('#attention-count').innerText(), '2');
|
|
53
|
+
assert.equal(await page.locator(`[data-result-id="${old.id}"]`).count(), 0);
|
|
54
|
+
await page.locator(`[data-result-id="${latest.id}"][data-action=read]`).click();
|
|
55
|
+
assert.equal(await page.locator('#reader-text').innerText(), latest.text);
|
|
56
|
+
assert.equal(await page.locator('#reader-count').innerText(), '2 / 2');
|
|
57
|
+
const reads = await page.evaluate(() => window.replyActions.filter(action => action.type === 'read').map(action => action.resultId));
|
|
58
|
+
assert.deepEqual(new Set(reads), new Set([old.id, latest.id]), 'reading the card acknowledges its captured turns');
|
|
59
|
+
const incoming = reply('source:3:9', source.id, 4, '阅读期间的新回合');
|
|
60
|
+
await receive(frame([old, latest, separate, incoming]));
|
|
61
|
+
assert.equal(await page.locator('#reader-text').innerText(), latest.text, 'new turns keep the reader stable');
|
|
62
|
+
await page.locator('#reader-inbox').click();
|
|
63
|
+
assert.equal(await page.locator('#inbox-replies .inbox-reply').count(), 2);
|
|
64
|
+
assert.equal(await page.locator(`[data-result-id="${incoming.id}"][data-action=read]`).count(), 1, 'newer turns stay unread');
|
|
65
|
+
await receive(frame([{ ...old, read: true }, { ...latest, read: true }, { ...incoming, read: true }, separate]));
|
|
66
|
+
assert.equal(await page.locator('#inbox-replies .inbox-reply').count(), 1, 'acknowledged older turns never resurface');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('full replies render Markdown headings, emphasis, tables and fenced code', async t => {
|
|
70
|
+
const text = '## Docker vs VM\n\n**已经直连**,看看 `opencode.ai`。\n\n| 诉求 | 方案 |\n| --- | --- |\n| 隔离 | VM |\n\n```sh\necho "🐳"\n```\n\n- 第一项\n- 第二项\n\n[官方文档](https://example.com/docs)';
|
|
71
|
+
const { page } = await fixture(t, [reply('source:1:3', source.id, 1, text)]);
|
|
72
|
+
await page.locator('#attention').click();
|
|
73
|
+
assert.equal(await page.locator('#reader-text h2').count(), 1, 'Markdown heading is rendered');
|
|
74
|
+
assert.equal(await page.locator('#reader-text strong').innerText(), '已经直连');
|
|
75
|
+
assert.equal(await page.locator('#reader-text table tbody td').count(), 2);
|
|
76
|
+
assert.equal(await page.locator('#reader-text pre code').textContent(), 'echo "🐳"\n');
|
|
77
|
+
assert.equal(await page.locator('#reader-text li').count(), 2);
|
|
78
|
+
assert.equal(await page.locator('#reader-text a').getAttribute('href'), 'https://example.com/docs');
|
|
79
|
+
await mkdir('artifacts', { recursive: true });
|
|
80
|
+
await page.locator('#reader').screenshot({ path: 'artifacts/reply-markdown.png' });
|
|
81
|
+
await page.setViewportSize({ width: 320, height: 640 });
|
|
82
|
+
await page.waitForFunction(() => { const r = document.getElementById('reader').getBoundingClientRect(); return r.left >= 0 && r.right <= innerWidth && r.top >= 0 && r.bottom <= innerHeight; });
|
|
83
|
+
assert.equal(await page.locator('#reader').evaluate(node => node.scrollWidth <= node.clientWidth), true, 'Markdown fits a narrow reader');
|
|
84
|
+
await page.screenshot({ path: 'artifacts/reply-markdown-narrow.png' });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('multiple turns of a single session still open directly with one click', async t => {
|
|
88
|
+
const old = reply('source:1:3', source.id, 1, '旧回合');
|
|
89
|
+
const latest = reply('source:2:6', source.id, 2, '最新回合');
|
|
90
|
+
const { page } = await fixture(t, [old, latest]);
|
|
91
|
+
await page.locator('#attention').click();
|
|
92
|
+
assert.equal(await page.locator('#reader').isVisible(), true);
|
|
93
|
+
assert.equal(await page.locator('#reader-text').innerText(), latest.text);
|
|
94
|
+
assert.equal(await page.locator('#reader-count').innerText(), '1 / 1');
|
|
95
|
+
await page.keyboard.press('Escape');
|
|
96
|
+
assert.equal(await page.locator('#attention').isVisible(), false, 'all captured turns are acknowledged locally');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('reply markup cannot inject HTML, active URLs or external images', async t => {
|
|
100
|
+
const text = '**正常格式**\n\n<img src=x onerror="window.injected=true">\n\n<script>window.injected=true</script>\n\n[危险链接](javascript:alert(1))\n\n\n\n<iframe src="https://example.com"></iframe>';
|
|
101
|
+
const { page } = await fixture(t, [reply('source:1:3', source.id, 1, text)]);
|
|
102
|
+
await page.locator('#attention').click();
|
|
103
|
+
assert.equal(await page.locator('#reader-text strong').innerText(), '正常格式');
|
|
104
|
+
assert.equal(await page.locator('#reader-text img, #reader-text script, #reader-text iframe').count(), 0);
|
|
105
|
+
assert.equal(await page.locator('#reader-text a[href]').count(), 0);
|
|
106
|
+
assert.ok((await page.locator('#reader-text').innerText()).includes('<img src=x onerror="window.injected=true">'), 'raw HTML remains readable content');
|
|
107
|
+
assert.equal(await page.evaluate(() => window.injected), undefined);
|
|
108
|
+
});
|
package/tests/ui.mjs
CHANGED
|
@@ -182,16 +182,16 @@ try {
|
|
|
182
182
|
await page.locator('[data-demo=long]').click(); await speechDone(page);
|
|
183
183
|
assert.ok((await page.locator('#bubble-text').textContent()).length < 200, 'a long final reply has a bounded preview');
|
|
184
184
|
await page.locator('#bubble-expand').click();
|
|
185
|
-
const fullReply = await page.locator('#reader-text').
|
|
185
|
+
const fullReply = await page.locator('#reader-text').innerText();
|
|
186
186
|
assert.ok(fullReply.length > 1200); assert.ok(fullReply.endsWith('最后一句:这份回复完整地保留下来了。'));
|
|
187
187
|
await page.locator('[data-demo=background]').click();
|
|
188
|
-
assert.equal(await page.locator('#reader-text').
|
|
188
|
+
assert.equal(await page.locator('#reader-text').innerText(), fullReply, 'a background reply cannot interrupt reading');
|
|
189
189
|
assert.equal(await page.locator('#chat-session-name').innerText(), '演示会话', 'background completion keeps the chat target fixed');
|
|
190
190
|
await page.keyboard.press('Escape');
|
|
191
191
|
await page.locator('#attention').click();
|
|
192
|
-
await page.locator('#
|
|
193
|
-
await page.
|
|
194
|
-
assert.equal(await page.locator('#reader-text').
|
|
192
|
+
await page.locator('#reader:not([hidden])').waitFor();
|
|
193
|
+
assert.equal(await page.locator('#requests').isVisible(), false, 'after reading the grouped focus replies, the sole background source opens directly');
|
|
194
|
+
assert.equal(await page.locator('#reader-text').innerText(), '后台会话已经完成,这是它的最终回复。');
|
|
195
195
|
assert.equal(await page.locator('#chat-session-name').innerText(), '演示会话', 'reading a single background reply keeps the chat target fixed');
|
|
196
196
|
await page.keyboard.press('Escape');
|
|
197
197
|
await page.locator('[data-demo=happy]').click(); await speechDone(page); await page.screenshot({ path: 'artifacts/desktop-pet.png' });
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
function qt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ye=qt();function er(t){ye=t}var Ae={exec:()=>null};function ze(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),i=e[s];return i||(i=t(s),e[s]=i),i}}function x(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(N.caret,"$1"),n=n.replace(i,a),s},getRegex:()=>new RegExp(n,e)};return s}var ui=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),N={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:ze(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:ze(t=>new RegExp(`^ {0,${t}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:ze(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:ze(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:ze(t=>new RegExp(`^ {0,${t}}(?:</?(?:${Ze})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,"i")),blockquoteBeginRegex:ze(t=>new RegExp(`^ {0,${t}}>`))},pi=/^(?:[ \t]*(?:\n|$))+/,hi=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fi=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,je=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gi=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,tr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,nr=x(tr).replace(/bull/g,jt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),di=x(tr).replace(/bull/g,jt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Zt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,mi=/^[^\n]+/,Yt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ki=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Yt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bi=x(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jt).getRegex(),Ze="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Xt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xi=x("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Xt).replace("tag",Ze).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rr=t=>x(Zt).replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ze).getRegex(),Ti=rr(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),_i=rr(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Ai=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",_i).getRegex(),Vt={blockquote:Ai,code:hi,def:ki,fences:fi,heading:gi,hr:je,html:xi,lheading:nr,list:bi,newline:pi,paragraph:Ti,table:Ae,text:mi},Wn=x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ze).getRegex(),wi={...Vt,lheading:di,table:Wn,paragraph:x(Zt).replace("hr",je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Wn).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html"," {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)").replace("tag",Ze).getRegex()},yi={...Vt,html:x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Xt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ae,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:x(Zt).replace("hr",je).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",nr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Si=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ei=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ir=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Ri=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,re=/[\p{P}\p{S}]/u,Ne=/[\s\p{P}\p{S}]/u,Ye=/[^\s\p{P}\p{S}]/u,Oi=x(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ne).getRegex(),Li=/[\p{Pi}\p{Ps}"']/u,sr=/(?!~)[\p{P}\p{S}]/u,Pi=/(?!~)[\s\p{P}\p{S}]/u,Di=/(?:[^\s\p{P}\p{S}]|~)/u,Ii=x(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ui?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),or=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ci=x(or,"u").replace(/punct/g,re).getRegex(),vi=x(or,"u").replace(/punct/g,sr).getRegex(),zi=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Ni=x(zi,"u").replace(/openQuote/g,Li).replace(/punct/g,re).getRegex(),lr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$i=x(lr,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ne).replace(/punct/g,re).getRegex(),Mi=x(lr,"gu").replace(/notPunctSpace/g,Di).replace(/punctSpace/g,Pi).replace(/punct/g,sr).getRegex(),Ui="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Fi=x(Ui,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ne).replace(/punct/g,re).getRegex(),Bi=x("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ne).replace(/punct/g,re).getRegex(),Hi="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Gi=x(Hi,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ne).replace(/punct/g,re).getRegex(),Wi=x(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,re).getRegex(),qi="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ji=x(qi,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Ne).replace(/punct/g,re).getRegex(),Zi=x(/\\(punct)/,"gu").replace(/punct/g,re).getRegex(),Yi=x(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,"gu").replace(/punct/g,re).getRegex(),Xi=x(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Vi=x(Xt).replace("(?:-->|$)","-->").getRegex(),Qi=x("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Vi).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ar=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,pt=x(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets",ar).getRegex(),Ki=x(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace("label",pt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ji=x(/^!?\[(label)\]\[(ref)\]/).replace("label",pt).replace("ref",Yt).getRegex(),es=x(/^!?\[(ref)\](?:\[\])?/).replace("ref",Yt).getRegex(),qn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,ts=x(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets",ar).getRegex(),ns=x("reflink|nolink(?!\\()","g").replace("reflink",x(/^!?\[(label)\]\[(ref)\]/).replace("label",ts).replace("ref",qn).getRegex()).replace("nolink",x(/^!?\[(ref)\](?:\[\])?/).replace("ref",qn).getRegex()).getRegex(),jn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,rs=/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/,is=x(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,rs).getRegex(),Qt={_backpedal:Ae,anyPunctuation:Zi,anyPunctuationOutsideCode:Yi,autolink:Xi,blockSkip:Ii,br:ir,code:Ei,del:Ae,delLDelim:Ae,delRDelim:Ae,emStrongLDelim:Ci,emStrongRDelimAst:$i,emStrongRDelimUnd:Bi,escape:Si,link:Ki,nolink:es,punctuation:Oi,reflink:Ji,reflinkSearch:ns,tag:Qi,text:Ri,url:Ae},ss={...Qt,emStrongLDelim:Ni,emStrongRDelimAst:Fi,emStrongRDelimUnd:Gi,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",pt).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pt).getRegex()},Ht={...Qt,emStrongRDelimAst:Mi,emStrongLDelim:vi,delLDelim:Wi,delRDelim:ji,url:x(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol",is).replace("protocol",jn).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:x(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol",jn).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},os={...Ht,br:x(ir).replace("{2,}","*").getRegex(),text:x(Ht.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ut={normal:Vt,gfm:wi,pedantic:yi},We={normal:Qt,gfm:Ht,breaks:os,pedantic:ss},ls={"&":"&","<":"<",">":">",'"':""","'":"'"},Zn=t=>ls[t];function Z(t,e){if(e){if(N.escapeTest.test(t))return t.replace(N.escapeReplace,Zn)}else if(N.escapeTestNoEncode.test(t))return t.replace(N.escapeReplaceNoEncode,Zn);return t}function as(t){return N.numericCharacterReference.test(t)?t.replace(N.numericCharacterReferenceOrAmpersand,(e,n,s)=>{if(n===void 0&&s===void 0)return"&";let i=n===void 0?Number.parseInt(s,16):Number.parseInt(n,10);return i===0||i>1114111||i>=55296&&i<=57343?"\uFFFD":i===38?"&":String.fromCodePoint(i)}):t}function Yn(t){try{t=encodeURI(t).replace(N.percentDecode,"%")}catch{return null}return t}function Xn(t,e){let n=t.replace(N.findPipe,(o,a,c)=>{let d=!1,g=a;for(;--g>=0&&c[g]==="\\";)d=!d;return d?"|":" |"}),s=n.split(N.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(N.slashPipe,"|");return s}function fe(t,e,n){let s=t.length;if(s===0)return"";let i=0;for(;i<s;){let o=t.charAt(s-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,s-i)}function Vn(t){let e=t.split(`
|
|
3
|
+
`),n=e.length-1;for(;n>=0&&N.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
4
|
+
`)}function ht(t){return t.trim().toLowerCase().toUpperCase().toLowerCase()}function Qn(t,e){if(t.indexOf(e[0])===-1&&t.indexOf(e[1])===-1)return-1;let n=0;for(let s=0;s<t.length;s++)if(t[s]==="\\")s++;else if(t[s]===e[0])n++;else if(t[s]===e[1]&&(n--,n<0))return s;return n>0?-2:-1}function Bt(t,e=0){let n=e,s="";for(let i of t)if(i===" "){let o=4-n%4;s+=" ".repeat(o),n+=o}else s+=i,n++;return s}function Kn(t,e,n,s,i){let o=e.href,a=e.title||null,c=t[1].replace(i.other.outputLinkReplace,"$1"),d=t[0].charAt(0)==="!",g=s.state.inLink,f=s.state.linkEmitted,m=s.state.inRawBlock;s.state.inLink=!0,s.state.linkEmitted=!1;let S=s.inlineTokens(c),T=s.state.linkEmitted;if(s.state.linkEmitted=f,s.state.inLink=g,!d){if(T){s.state.inRawBlock=m;return}s.state.linkEmitted=!0}return{type:d?"image":"link",raw:n,href:o,title:a,text:c,tokens:S}}function cs(t,e,n){let s=t.match(n.other.indentCodeCompensation);if(s===null)return e;let i=s[1];return e.split(`
|
|
5
|
+
`).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[c]=a;return o.slice(Math.min(c.length,i.length))}).join(`
|
|
6
|
+
`)}function Jn(t,e,n,s){if(!e.includes("<"))return!1;for(let i=0;i<e.length;i++){if(e[i]==="\\"){i++;continue}if(e[i]==="`"){let c=s.inline.code.exec(e.slice(i));if(c){i+=c[0].length-1;continue}}if(e[i]!=="<")continue;let o=t.slice(n+i),a=s.inline.tag.exec(o)||s.inline.autolink.exec(o);if(a){if(a[0].length>e.length-i)return!0;i+=a[0].length-1}}return!1}var ft=class{options;rules;lexer;constructor(t){this.options=t||ye}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Vn(e[0]),s=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:s}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],s=cs(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let s=fe(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceTabChar.test(s))&&(n=s.trim())}return{type:"heading",raw:fe(e[0],`
|
|
7
|
+
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:fe(e[0],`
|
|
8
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=fe(e[0],`
|
|
9
|
+
`).split(`
|
|
10
|
+
`),s="",i="",o=[];for(;n.length>0;){let a=!1,c=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))c.push(n[d]),a=!0;else if(!a)c.push(n[d]);else break;n=n.slice(d);let g=c.join(`
|
|
11
|
+
`),f=g.replace(this.rules.other.blockquoteSetextReplace,`
|
|
12
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
13
|
+
${g}`:g,i=i?`${i}
|
|
14
|
+
${f}`:f;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=m,n.length===0)break;let S=o.at(-1);if(S?.type==="code"||S?.type==="heading"||S?.type==="hr"||S?.type==="html")break;if(S?.type==="blockquote"){let T=S,F=n.join(`
|
|
15
|
+
`),D=T.raw+`
|
|
16
|
+
`+F.replace(this.rules.other.blockquoteSetextReplace2,""),y=this.blockquote(D);o[o.length-1]=y;let G=D.substring(y.raw.length).replace(/^\n/,""),R=G?G.split(`
|
|
17
|
+
`).length:0,ie=R?n.slice(0,-R):n;ie.length>0&&(s=`${s}
|
|
18
|
+
${ie.join(`
|
|
19
|
+
`)}`),i=i.substring(0,i.length-T.text.length)+y.text;break}else if(S?.type==="list"){let T=S,F=T.raw+`
|
|
20
|
+
`+n.join(`
|
|
21
|
+
`),D=this.list(F);o[o.length-1]=D,s=s.substring(0,s.length-S.raw.length)+D.raw,i=i.substring(0,i.length-T.raw.length)+D.raw,n=F.substring(o.at(-1).raw.length).split(`
|
|
22
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=t,s=()=>n.length-t.length,i=e[1].trim(),o=i.length>1,a={type:"list",raw:"",ordered:o,start:o?+i.slice(0,-1):"",loose:!1,items:[]};i=o?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=o?i:"[*+-]");let c=this.rules.other.listItemRegex(i),d=!1;for(;t;){let f=!1,m="";if(!(e=c.exec(t))||this.rules.block.hr.test(t))break;let S=s();t=t.substring(e[0].length);let T=e[2].split(`
|
|
23
|
+
`,1)[0],F=e[1].length,D=this.options.pedantic?Bt(T,F):T.replace(this.rules.other.leadingSpaceTab,V=>Bt(V,F)),y=t.split(`
|
|
24
|
+
`,1)[0],G=!D.trim(),R=0;if(this.options.pedantic?(R=2,m=D.trimStart()):G?R=F+1:(R=D.search(this.rules.other.nonSpaceChar),R=R>4?1:R,m=D.slice(R),R+=F),G&&this.rules.other.blankLine.test(y)&&(t=t.substring(y.length+1),f=!0),!f){let V=this.rules.other.nextBulletRegex(R),se=this.rules.other.hrRegex(R),de=this.rules.other.fencesBeginRegex(R),B=this.rules.other.headingBeginRegex(R),me=this.rules.other.htmlBeginRegex(R),Je=this.rules.other.blockquoteBeginRegex(R);for(;t;){let Ee=t.split(`
|
|
25
|
+
`,1)[0],C;if(y=Ee,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),C=y):C=y.replace(this.rules.other.leadingSpaceTab,oe=>Bt(oe)),de.test(y)||B.test(y)||me.test(y)||Je.test(y)||V.test(y)||se.test(y))break;if(C.search(this.rules.other.nonSpaceChar)>=R||!y.trim())m+=`
|
|
26
|
+
`+C.slice(R);else{if(G||D.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||de.test(D)||B.test(D)||se.test(D))break;m+=`
|
|
27
|
+
`+y}G=!y.trim(),t=t.substring(Ee.length+1),D=C.slice(R)}}let ie=n.slice(S,s());a.loose||(d?a.loose=!0:this.rules.other.doubleBlankLine.test(ie)&&(d=!0)),a.items.push({type:"list_item",raw:ie,task:!!this.options.gfm&&this.rules.other.listIsTask.test(m),loose:!1,text:m,tokens:[]})}let g=a.items.at(-1);if(g)g.raw=g.raw.trimEnd(),g.text=g.text.trimEnd();else return;a.raw=n.slice(0,s()).trimEnd();for(let f of a.items)if(this.lexer.state.top=!1,f.tokens=this.lexer.blockTokens(f.text,[]),!a.loose){let m=f.tokens.filter(T=>T.type==="space"),S=m.length>0&&m.some(T=>this.rules.other.anyLine.test(T.raw));a.loose=S}for(let f of a.items){let m=f.tokens[0];if(f.task&&(m?.type==="text"||m?.type==="paragraph")){f.text=f.text.replace(this.rules.other.listReplaceTask,""),m.raw=m.raw.replace(this.rules.other.listReplaceTask,""),m.text=m.text.replace(this.rules.other.listReplaceTask,"");for(let T=this.lexer.inlineQueue.length-1;T>=0;T--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[T].src)){this.lexer.inlineQueue[T].src=this.lexer.inlineQueue[T].src.replace(this.rules.other.listReplaceTask,"");break}let S=this.rules.other.listTaskCheckbox.exec(f.raw);if(S){let T={type:"checkbox",raw:S[0]+" ",checked:S[0]!=="[ ]"};f.checked=T.checked,a.loose?f.tokens[0]&&["paragraph","text"].includes(f.tokens[0].type)&&"tokens"in f.tokens[0]&&f.tokens[0].tokens?(f.tokens[0].raw=T.raw+f.tokens[0].raw,f.tokens[0].text=T.raw+f.tokens[0].text,f.tokens[0].tokens.unshift(T)):f.tokens.unshift({type:"paragraph",raw:T.raw,text:T.raw,tokens:[T]}):f.tokens.unshift(T)}}else f.task&&(f.task=!1)}if(a.loose)for(let f of a.items){f.loose=!0;for(let m of f.tokens)m.type==="text"&&(m.type="paragraph")}return a}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Vn(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){if(!this.rules.other.startAngleBracket.test(e[2])&&Qn(e[2],"()")!==-1)return;let n=ht(e[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:fe(e[0],`
|
|
28
|
+
`),href:s,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Xn(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],o={type:"table",raw:fe(e[0],`
|
|
30
|
+
`),header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(Xn(a,o.header.length).map((c,d)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:o.align[d]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:fe(e[0],`
|
|
31
|
+
`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
32
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){if(this.lexer.state.linkParenPossible===!1)return;let e=this.rules.inline.link.exec(t);if(e){let n=e[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Jn(t,e[1],n,this.rules))return;let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let a=fe(s.slice(0,-1),"\\");if((s.length-a.length)%2===0)return}else{let a=Qn(e[2],"()");if(a===-2)return;if(a>-1){let c=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,c).trim(),e[3]=""}}let i=e[2],o="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],o=a[3])}else o=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?i=i.slice(1):i=i.slice(1,-1)),Kn(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let s=n[0].charAt(0)==="!"?2:1;if(!this.options.pedantic&&Jn(t,n[1],s,this.rules))return;let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[ht(i)];if(!o){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return Kn(n,o,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,o,a,c=i,d=0,g=s[0][0],f=n===g,m=g==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,e=e.slice(-1*t.length+i);(s=m.exec(e))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){c+=a;continue}else if(s[5]||s[6]){if(i%3&&!((i+a)%3)){d+=a;continue}if(f)break}if(c-=a,c>0)continue;a=Math.min(a,a+c+d);let S=[...s[0]][0].length,T=t.slice(0,i+s.index+S+a);if(Math.min(i,a)%2){let D=T.slice(1,-1);return{type:"em",raw:T,text:D,tokens:this.lexer.inlineTokens(D)}}let F=T.slice(2,-2);return{type:"strong",raw:T,text:F,tokens:this.lexer.inlineTokens(F)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let s=this.rules.inline.delLDelim.exec(t);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,o,a,c=i,d=this.rules.inline.delRDelim;for(d.lastIndex=0,e=e.slice(-1*t.length+i);(s=d.exec(e))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(a=[...o].length,a!==i))continue;if(s[3]||s[4]){c+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c);let g=[...s[0]][0].length,f=t.slice(0,i+s.index+g+a),m=f.slice(i,-i);return{type:"del",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=e[1],s="mailto:"+n):(n=e[1],s=n),{type:"link",raw:e[0],text:n,href:s,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,s;if(e[2]==="@")n=e[0],s="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:n,href:s,autolink:!0,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:n?e[0]:as(e[0]),escaped:n}}}},K=class Gt{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ye,this.options.tokenizer=this.options.tokenizer||new ft,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0};let n={other:N,block:ut.normal,inline:We.normal};this.options.pedantic?(n.block=ut.pedantic,n.inline=We.pedantic):this.options.gfm&&(n.block=ut.gfm,this.options.breaks?n.inline=We.breaks:n.inline=We.gfm),this.tokenizer.rules=n}static get rules(){return{block:ut,inline:We}}static lex(e,n){return new Gt(n).lex(e)}static lexInline(e,n){return new Gt(n).inlineTokens(e)}lex(e){e=e.replace(N.carriageReturn,`
|
|
33
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(N.tabCharGlobal," ").replace(N.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(c=>(o=c.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let c=n.at(-1);o.raw.length===1&&c!==void 0?c.raw+=`
|
|
34
|
+
`:n.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let c=n.at(-1);c?.type==="paragraph"||c?.type==="text"?(c.raw+=(c.raw.endsWith(`
|
|
35
|
+
`)?"":`
|
|
36
|
+
`)+o.raw,c.text+=`
|
|
37
|
+
`+o.text,this.inlineQueue.at(-1).src=c.text):n.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);let c=n.at(-1);c?.type==="paragraph"||c?.type==="text"?(c.raw+=(c.raw.endsWith(`
|
|
38
|
+
`)?"":`
|
|
39
|
+
`)+o.raw,c.text+=`
|
|
40
|
+
`+o.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),n.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let c=1/0,d=e.slice(1),g;this.options.extensions.startBlock.forEach(f=>{g=f.call({lexer:this},d),typeof g=="number"&&g>=0&&(c=Math.min(c,g))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let c=n.at(-1);s&&c?.type==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
41
|
+
`)?"":`
|
|
42
|
+
`)+o.raw,c.text+=`
|
|
43
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(o),s=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let c=n.at(-1);c?.type==="text"?(c.raw+=(c.raw.endsWith(`
|
|
44
|
+
`)?"":`
|
|
45
|
+
`)+o.raw,c.text+=`
|
|
46
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}linkInText(e){if(!e.includes("["))return!1;let n=this.tokenizer.rules.inline.link;for(let s of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(n.test(s[0])&&e.charAt(s.index-1)!=="!")return!0;for(let s of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let i=s[0],o=i.lastIndexOf("[");if(!(i.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,ht(i.slice(o+1,-1))))&&!(o>1&&this.linkInText(i.slice(1,o-1))))return!0}return!1}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let s=this.state.linkParenPossible;this.state.linkParenPossible=s&&e.includes(")");try{return this.#e(e,n)}finally{this.state.linkParenPossible=s}}#e(e,n){let s=e;if(this.tokens.links&&e.includes("[")){let c=this.tokenizer.rules.inline.reflinkSearch,d=g=>{let f=g.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,ht(g.slice(f+1,-1))))return g;if(f>1&&g.charAt(0)!=="!"){let m=g.slice(1,f-1);if(this.linkInText(m))return"["+m.replace(c,d)+"]["+"a".repeat(g.length-f-2)+"]"}return"["+"a".repeat(g.length-2)+"]"};s=s.replace(c,d)}s=s.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(c,d,g)=>g?"+".repeat(c.length):d?d+c.slice(d.length,-d.length).replace(/`/g,"+")+d:c),s=s.replace(this.tokenizer.rules.inline.blockSkip,(c,d,g)=>{let f=g?g.length:0;return c.slice(0,f)+"["+"a".repeat(c.length-f-2)+"]"}),s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let c;if(this.options.extensions?.inline?.some(g=>(c=g.call({lexer:this},e,n))?(e=e.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.escape(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.tag(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.link(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(c.raw.length);let g=n.at(-1);c.type==="text"&&g?.type==="text"?(g.raw+=c.raw,g.text+=c.text):n.push(c);continue}if(c=this.tokenizer.emStrong(e,s,o)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.codespan(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.br(e)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.del(e,s,o)){e=e.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.autolink(e)){e=e.substring(c.raw.length),n.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(e))){e=e.substring(c.raw.length),n.push(c);continue}let d=e;if(this.options.extensions?.startInline){let g=1/0,f=e.slice(1),m;this.options.extensions.startInline.forEach(S=>{m=S.call({lexer:this},f),typeof m=="number"&&m>=0&&(g=Math.min(g,m))}),g<1/0&&g>=0&&(d=e.substring(0,g+1))}if(c=this.tokenizer.inlineText(d)){e=e.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(o=c.raw.slice(-1)),i=!0;let g=n.at(-1);g?.type==="text"?(g.raw+=c.raw,g.text+=c.text):n.push(c);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},gt=class{options;parser;constructor(t){this.options=t||ye}space(t){return""}code({text:t,lang:e,escaped:n}){let s=(e||"").match(N.notSpaceStart)?.[0],i=t?t.replace(N.endingNewline,"")+`
|
|
47
|
+
`:"";return s?'<pre><code class="language-'+Z(s)+'">'+(n?i:Z(i,!0))+`</code></pre>
|
|
48
|
+
`:"<pre><code>"+(n?i:Z(i,!0))+`</code></pre>
|
|
49
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
50
|
+
${this.parser.parse(t)}</blockquote>
|
|
51
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
52
|
+
`}hr(t){return`<hr>
|
|
53
|
+
`}list(t){let e=t.ordered,n=t.start,s="";for(let a=0;a<t.items.length;a++){let c=t.items[a];s+=this.listitem(c)}let i=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
|
|
54
|
+
`+s+"</"+i+`>
|
|
55
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
56
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
57
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let s="";for(let i=0;i<t.rows.length;i++){let o=t.rows[i];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
58
|
+
<thead>
|
|
59
|
+
`+e+`</thead>
|
|
60
|
+
`+s+`</table>
|
|
61
|
+
`}tablerow({text:t}){return`<tr>
|
|
62
|
+
${t}</tr>
|
|
63
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
64
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Z(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,text:n,tokens:s,autolink:i}){let o=i?Z(n,!0):this.parser.parseInline(s),a=Yn(t);if(a===null)return o;t=Z(a,i);let c='<a href="'+t+'"';return e&&(c+=' title="'+Z(e)+'"'),c+=">"+o+"</a>",c}image({href:t,title:e,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=Yn(t);if(i===null)return Z(n);t=i;let o=`<img src="${Z(t)}" alt="${Z(n)}"`;return e&&(o+=` title="${Z(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Z(t.text)}},Kt=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},J=class Wt{options;renderer;textRenderer;constructor(e){this.options=e||ye,this.options.renderer=this.options.renderer||new gt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Kt}static parse(e,n){return new Wt(n).parse(e)}static parseInline(e,n){return new Wt(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let a=i,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=c||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let s="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){s+=c||"";continue}}let a=o;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},qe=class{options;block;constructor(t){this.options=t||ye}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?K.lex:K.lexInline}provideParser(t=this.block){return t?J.parse:J.parseInline}};function _e(t,e){if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(e[n]);else t.push(e)}var Jt=class{defaults=qt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=J;Renderer=gt;TextRenderer=Kt;Lexer=K;Tokenizer=ft;Hooks=qe;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let s of t)switch(_e(n,e.call(this,s)),s.type){case"table":{let i=s;for(let o of i.header)_e(n,this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)_e(n,this.walkTokens(a.tokens,e));break}case"list":{let i=s;_e(n,this.walkTokens(i.items,e));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);_e(n,this.walkTokens(a,e))}):i.tokens&&_e(n,this.walkTokens(i.tokens,e))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let c=i.renderer.apply(this,a);return c===!1&&(c=o.apply(this,a)),c}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),s.extensions=e),n.renderer){let i=this.defaults.renderer||new gt(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,c=n.renderer[a],d=i[a];i[a]=(...g)=>{let f=c.apply(i,g);return f===!1&&(f=d.apply(i,g)),f||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new ft(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,c=n.tokenizer[a],d=i[a];i[a]=(...g)=>{let f=c.apply(i,g);return f===!1&&(f=d.apply(i,g)),f}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new qe;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,c=n.hooks[a],d=i[a];qe.passThroughHooks.has(o)?i[a]=g=>{if(this.defaults.async&&qe.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await c.call(i,g);return d.call(i,m)})();let f=c.call(i,g);return d.call(i,f)}:i[a]=(...g)=>{if(this.defaults.async)return(async()=>{let m=await c.apply(i,g);return m===!1&&(m=await d.apply(i,g)),m})();let f=c.apply(i,g);return f===!1&&(f=d.apply(i,g)),f}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(a){let c=[];return c.push(o.call(this,a)),i&&_e(c,i.call(this,a)),c}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return K.lex(t,e??this.defaults)}parser(t,e){return J.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let s={...n},i={...this.defaults,...s},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,c=await(i.hooks?await i.hooks.provideLexer(t):t?K.lex:K.lexInline)(a,i),d=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(d,i.walkTokens));let g=await(i.hooks?await i.hooks.provideParser(t):t?J.parse:J.parseInline)(d,i);return i.hooks?await i.hooks.postprocess(g):g})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?K.lex:K.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let c=(i.hooks?i.hooks.provideParser(t):t?J.parse:J.parseInline)(a,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
|
|
65
|
+
Please report this to https://github.com/markedjs/marked.`,t){let s="<p>An error occurred:</p><pre>"+Z(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}},we=new Jt;function w(t,e){return we.parse(t,e)}w.options=w.setOptions=function(t){return we.setOptions(t),w.defaults=we.defaults,er(w.defaults),w};w.getDefaults=qt;w.defaults=ye;function us(...t){return we.use(...t),w.defaults=we.defaults,er(w.defaults),w}w.use=us;w.walkTokens=function(t,e){return we.walkTokens(t,e)};w.parseInline=we.parseInline;w.Parser=J;w.parser=J.parse;w.Renderer=gt;w.TextRenderer=Kt;w.Lexer=K;w.lexer=K.lex;w.Tokenizer=ft;w.Hooks=qe;w.parse=w;var qs=w.options,js=w.setOptions,Zs=w.walkTokens,Ys=w.parseInline;var Xs=J.parse,Vs=K.lex;function ps(t,e){this.v=t,this.k=e}function cr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,s=Array(e);n<e;n++)s[n]=t[n];return s}function hs(t){if(Array.isArray(t))return t}function fs(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,i,o,a,c=[],d=!0,g=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;d=!1}else for(;!(d=(s=o.call(n)).done)&&(c.push(s.value),c.length!==e);d=!0);}catch(f){g=!0,i=f}finally{try{if(!d&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(g)throw i}}return c}}function gs(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
66
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ds(t,e){return hs(t)||fs(t,e)||ms(t,e)||gs()}function ms(t,e){if(t){if(typeof t=="string")return cr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cr(t,e):void 0}}function dt(t){var e,n;function s(o,a){try{var c=t[o](a),d=c.value,g=d instanceof ps;Promise.resolve(g?d.v:d).then(function(f){if(g){var m=o==="return"&&d.k?o:"next";if(!d.k||f.done)return s(m,f);f=t[m](f).value}i(!!c.done,f)},function(f){s("throw",f)})}catch(f){i(2,f)}}function i(o,a){o===2?e.reject(a):e.resolve({value:a,done:o}),(e=e.next)?s(e.key,e.arg):n=null}this._invoke=function(o,a){return new Promise(function(c,d){var g={key:o,arg:a,resolve:c,reject:d,next:null};n?n=n.next=g:(e=n=g,s(o,a))})},typeof t.return!="function"&&(this.return=void 0)}dt.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},dt.prototype.next=function(t){return this._invoke("next",t)},dt.prototype.throw=function(t){return this._invoke("throw",t)},dt.prototype.return=function(t){return this._invoke("return",t)};var yr=Object.entries,ur=Object.setPrototypeOf,ks=Object.isFrozen,Sr=Object.getPrototypeOf,Er=Object.getOwnPropertyDescriptor,$=Object.freeze,U=Object.seal,$e=Object.create,Rr=typeof Reflect<"u"&&Reflect,un=Rr.apply,pn=Rr.construct;$||($=function(e){return e});U||(U=function(e){return e});un||(un=function(e,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),o=2;o<s;o++)i[o-2]=arguments[o];return e.apply(n,i)});pn||(pn=function(e){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new e(...s)});var ae=P(Array.prototype.forEach);Array.prototype.indexOf;var bs=P(Array.prototype.lastIndexOf),pr=P(Array.prototype.pop),Xe=P(Array.prototype.push),xs=P(Array.prototype.slice),Ts=P(Array.prototype.splice),Me=Array.isArray,en=Or(Set),tn=P(Set.prototype.add),Ve=P(Set.prototype.has),Se=P(String.prototype.toLowerCase),nn=P(String.prototype.toString),hr=P(String.prototype.match),Qe=P(String.prototype.replace),fr=P(String.prototype.indexOf),_s=P(String.prototype.trim),As=P(Number.prototype.toString),ws=P(Boolean.prototype.toString),gr=typeof BigInt>"u"?null:P(BigInt.prototype.toString),dr=typeof Symbol>"u"?null:P(Symbol.prototype.toString),j=P(Object.prototype.hasOwnProperty),Ke=P(Object.prototype.toString),M=P(RegExp.prototype.test),ce=Or(TypeError);function P(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return un(t,e,s)}}function Or(t){return function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return pn(t,n)}}function A(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Se;if(ur&&ur(t,null),!Me(e))return t;let s=e.length;for(;s--;){let i=e[s];if(typeof i=="string"){let o=n(i);o!==i&&(ks(e)||(e[s]=o),i=o)}t[i]=!0}return t}function ys(t){for(let e=0;e<t.length;e++)j(t,e)||(t[e]=null);return t}function Y(t){let e=$e(null);for(let s of yr(t)){var n=ds(s,2);let i=n[0],o=n[1];j(t,i)&&(Me(o)?e[i]=ys(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Y(o):e[i]=o)}return e}function Ss(t){switch(typeof t){case"string":return t;case"number":return As(t);case"boolean":return ws(t);case"bigint":return gr?gr(t):"0";case"symbol":return dr?dr(t):"Symbol()";case"undefined":return Ke(t);case"function":case"object":{if(t===null)return Ke(t);let e=t,n=X(e,"toString");if(typeof n=="function"){let s=n(e);return typeof s=="string"?s:Ke(s)}return Ke(t)}default:return Ke(t)}}function X(t,e){for(;t!==null;){let s=Er(t,e);if(s){if(s.get)return P(s.get);if(typeof s.value=="function")return P(s.value)}t=Sr(t)}function n(){return null}return n}function Es(t,e){for(;t!==null;){let n=Er(t,e);if(n)return n.get?P(n.get):null;t=Sr(t)}return null}function Rs(t){try{return M(t,""),!0}catch{return!1}}var mr=$(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),rn=$(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),sn=$(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Os=$(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),on=$(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ls=$(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),kr=$(["#text"]),br=$(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ln=$(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),xr=$(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),mt=$(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ps=U(/{{[\w\W]*|^[\w\W]*}}/g),Ds=U(/<%[\w\W]*|^[\w\W]*%>/g),Is=U(/\${[\w\W]*/g),Cs=U(/^data-[\-\w.\u00B7-\uFFFF]+$/),vs=U(/^aria-[\-\w]+$/),Tr=U(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zs=U(/^(?:\w+script|data):/i),Ns=U(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$s=U(/^html$/i),Ms=U(/^[a-z][.\w]*(-[.\w]+)+$/i),an=U(/<[/\w!]/g),_r=U(/<[/\w]/g),Us=U(/<\/no(script|embed|frames)/i),Ar=U(/\/>/i),v={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Fs=$(A({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),Bs=function(){return typeof window>"u"?null:window},Hs=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));let o="dompurify"+(s?"#"+s:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},wr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ge=function(e,n,s,i){return j(e,n)&&Me(e[n])?A(i.base?Y(i.base):{},e[n],i.transform):s},cn=function(e,n,s){let i=j(e,n)?e[n]:void 0;return i&&typeof i=="object"?Y(i):s()};function Lr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Bs(),e=h=>Lr(h);if(e.version="3.4.17",e.removed=[],!t||!t.document||t.document.nodeType!==v.document||!t.Element)return e.isSupported=!1,e;let n=t.document,s=n,i=s.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,c=t.Element,d=t.NodeFilter;t.NamedNodeMap===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let g=t.DOMParser,f=t.trustedTypes,m=c.prototype,S=X(m,"cloneNode"),T=X(m,"remove"),F=X(m,"removeAttributeNode"),D=X(m,"nextSibling"),y=X(m,"childNodes"),G=X(m,"parentNode"),R=X(m,"shadowRoot"),ie=X(m,"attributes"),V=a&&a.prototype?X(a.prototype,"nodeType"):null,se=a&&a.prototype?X(a.prototype,"nodeName"):null,de=a&&a.prototype?X(a.prototype,"ownerDocument"):null,B=function(r){return V?V(r):r.nodeType},me=function(r){return se?se(r):r.nodeName},Je=Es(m,"namespaceURI"),Ee=function(r){return Je?Je(r):r.namespaceURI};if(typeof o=="function"){let h=n.createElement("template");h.content&&h.content.ownerDocument&&(n=h.content.ownerDocument)}let C,oe="",kt,hn=!1,Ue=0,fn=function(){if(Ue>0)throw ce('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Re=function(r){fn(),Ue++;try{return C.createHTML(r)}finally{Ue--}},Ir=function(r){fn(),Ue++;try{return C.createScriptURL(r)}finally{Ue--}},Cr=function(){return hn||(kt=Hs(f,i),hn=!0),kt},et=n,bt=et.implementation,gn=et.createNodeIterator,vr=et.createDocumentFragment,zr=et.getElementsByTagName,Nr=s.importNode,E=wr();e.isSupported=typeof yr=="function"&&typeof G=="function"&&bt&&bt.createHTMLDocument!==void 0;let $r=Ps,Mr=Ds,Ur=Is,Fr=Cs,Br=vs,Hr=zs,dn=Ns,Gr=Ms,mn=Tr,O=null,xt=A({},[...mr,...rn,...sn,...on,...kr]),L=null,Tt=A({},[...br,...ln,...xr,...mt]),ee=Object.seal($e(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Fe=null,kn=null,ue=Object.seal($e(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),bn=!0,_t=!0,xn=!1,At=!0,le=!1,ke=!0,be=!1,wt=!1,tt=null,nt=null,yt=!1,Oe=!1,rt=!1,it=!1,Tn=!0,_n=!1,An="user-content-",St=!0,Et=!1,xe=null,Le={},Te=null,wn=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),yn=null,Sn=A({},["audio","video","img","source","image","track"]),En=null,Rn=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),st="http://www.w3.org/1998/Math/MathML",ot="http://www.w3.org/2000/svg",te="http://www.w3.org/1999/xhtml",Pe=te,Rt=!1,Ot=null,Wr=A({},[st,ot,te],nn),On=$(["mi","mo","mn","ms","mtext"]),Lt=A({},On),Ln=$(["annotation-xml"]),Pt=A({},Ln),qr=A({},["title","style","font","a","script"]),Be=null,jr=["application/xhtml+xml","text/html"],Zr="text/html",I=null,De=null,Yr=n.createElement("form"),Pn=function(r){return r instanceof RegExp||r instanceof Function},Dt=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(De&&De===r)return;(!r||typeof r!="object")&&(r={}),r=Y(r),Be=jr.indexOf(r.PARSER_MEDIA_TYPE)===-1?Zr:r.PARSER_MEDIA_TYPE,I=Be==="application/xhtml+xml"?nn:Se,O=ge(r,"ALLOWED_TAGS",xt,{transform:I}),L=ge(r,"ALLOWED_ATTR",Tt,{transform:I}),Ot=ge(r,"ALLOWED_NAMESPACES",Wr,{transform:nn}),En=ge(r,"ADD_URI_SAFE_ATTR",Rn,{transform:I,base:Rn}),yn=ge(r,"ADD_DATA_URI_TAGS",Sn,{transform:I,base:Sn}),Te=ge(r,"FORBID_CONTENTS",wn,{transform:I}),Fe=ge(r,"FORBID_TAGS",Y({}),{transform:I}),kn=ge(r,"FORBID_ATTR",Y({}),{transform:I}),Le=j(r,"USE_PROFILES")?r.USE_PROFILES&&typeof r.USE_PROFILES=="object"?Y(r.USE_PROFILES):r.USE_PROFILES:!1,bn=r.ALLOW_ARIA_ATTR!==!1,_t=r.ALLOW_DATA_ATTR!==!1,xn=r.ALLOW_UNKNOWN_PROTOCOLS||!1,At=r.ALLOW_SELF_CLOSE_IN_ATTR!==!1,le=r.SAFE_FOR_TEMPLATES||!1,ke=r.SAFE_FOR_XML!==!1,be=r.WHOLE_DOCUMENT||!1,Oe=r.RETURN_DOM||!1,rt=r.RETURN_DOM_FRAGMENT||!1,it=r.RETURN_TRUSTED_TYPE||!1,yt=r.FORCE_BODY||!1,Tn=r.SANITIZE_DOM!==!1,_n=r.SANITIZE_NAMED_PROPS||!1,St=r.KEEP_CONTENT!==!1,Et=r.IN_PLACE||!1,mn=Rs(r.ALLOWED_URI_REGEXP)?r.ALLOWED_URI_REGEXP:Tr,Pe=typeof r.NAMESPACE=="string"?r.NAMESPACE:te,Lt=cn(r,"MATHML_TEXT_INTEGRATION_POINTS",()=>A({},On)),Pt=cn(r,"HTML_INTEGRATION_POINTS",()=>A({},Ln));let l=cn(r,"CUSTOM_ELEMENT_HANDLING",()=>$e(null));if(ee=$e(null),j(l,"tagNameCheck")&&Pn(l.tagNameCheck)&&(ee.tagNameCheck=l.tagNameCheck),j(l,"attributeNameCheck")&&Pn(l.attributeNameCheck)&&(ee.attributeNameCheck=l.attributeNameCheck),j(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(ee.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),U(ee),le&&(_t=!1),rt&&(Oe=!0),Le&&(O=A({},kr),L=$e(null),Le.html===!0&&(A(O,mr),A(L,br)),Le.svg===!0&&(A(O,rn),A(L,ln),A(L,mt)),Le.svgFilters===!0&&(A(O,sn),A(L,ln),A(L,mt)),Le.mathMl===!0&&(A(O,on),A(L,xr),A(L,mt))),ue.tagCheck=null,ue.attributeCheck=null,j(r,"ADD_TAGS")&&(typeof r.ADD_TAGS=="function"?ue.tagCheck=r.ADD_TAGS:Me(r.ADD_TAGS)&&(O===xt&&(O=Y(O)),A(O,r.ADD_TAGS,I))),j(r,"ADD_ATTR")&&(typeof r.ADD_ATTR=="function"?ue.attributeCheck=r.ADD_ATTR:Me(r.ADD_ATTR)&&(L===Tt&&(L=Y(L)),A(L,r.ADD_ATTR,I))),j(r,"ADD_FORBID_CONTENTS")&&Me(r.ADD_FORBID_CONTENTS)&&(Te===wn&&(Te=Y(Te)),A(Te,r.ADD_FORBID_CONTENTS,I)),St&&(O["#text"]=!0),be&&A(O,["html","head","body"]),O.table&&(A(O,["tbody"]),delete Fe.tbody),r.TRUSTED_TYPES_POLICY){if(typeof r.TRUSTED_TYPES_POLICY.createHTML!="function")throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof r.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ce('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let u=C;C=r.TRUSTED_TYPES_POLICY;try{oe=Re("")}catch(p){throw C=u,p}}else r.TRUSTED_TYPES_POLICY===null?(C=void 0,oe=""):(C===void 0&&(C=Cr()),C&&typeof oe=="string"&&(oe=Re("")));$&&$(r),De=r},Dn=A({},[...rn,...sn,...Os]),In=A({},[...on,...Ls]),Xr=function(r,l,u){return l.namespaceURI===te?r==="svg":l.namespaceURI===st?r==="svg"&&(u==="annotation-xml"||Lt[u]):!!Dn[r]},Vr=function(r,l,u){return l.namespaceURI===te?r==="math":l.namespaceURI===ot?r==="math"&&Pt[u]:!!In[r]},Qr=function(r,l,u){return l.namespaceURI===ot&&!Pt[u]||l.namespaceURI===st&&!Lt[u]?!1:!In[r]&&(qr[r]||!Dn[r])},Kr=function(r){let l=Ee(r),u=Se(me(r)),p=G(r),k,b;return p&&B(p)===v.element?(k={namespaceURI:Ee(p)},b=Se(me(p))):(k={namespaceURI:Pe},b="template"),Ot[l]?l===ot?Xr(u,k,b):l===st?Vr(u,k,b):l===te?Qr(u,k,b):!!(Be==="application/xhtml+xml"&&Ot[l]):!1},pe=function(r){Xe(e.removed,{element:r});try{G(r).removeChild(r)}catch{if(T(r),!G(r))throw ce("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Cn=function(r,l,u){try{F(r,l)}catch{try{r.removeAttribute(u)}catch{}}},It=function(r){vt(r);let l=y(r);l&&ae(xs(l),p=>{try{T(p)}catch{}});let u=B(r)===v.element?ie(r):null;if(u)for(let p=u.length-1;p>=0;--p){let k=u[p],b=k&&k.name;typeof b=="string"&&Cn(r,k,b)}},Ie=function(r,l,u){if(!u)try{u=l.getAttributeNode(r)}catch{u=null}Xe(e.removed,{attribute:u||null,from:l});try{u?F(l,u):l.removeAttribute(r)}catch{try{l.removeAttribute(r)}catch{}}if(r==="is")if(Oe||rt)try{pe(l)}catch{}else try{l.setAttribute(r,"")}catch{}},vn=function(r){let l=ie(r);if(l)for(let u=l.length-1;u>=0;--u){let p=l[u],k=p&&p.name;typeof k!="string"||L[I(k)]||Cn(r,p,k)}},Ct=function(r,l){let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,p=[r];for(;p.length>0;){let k=p.pop();if(l(k)===!1)continue;if(u&&B(k)===v.element){let _=R(k);he(_)&&p.push(_)}let b=y(k);if(b)for(let _=b.length-1;_>=0;--_)p.push(b[_])}},vt=function(r){Ct(r,l=>{B(l)===v.element&&vn(l)})},zt=function(r){let l=[];return Ct(r,u=>{l.push(u)},!0),l},Jr=function(r,l){let u=en();ae(zt(r),p=>{B(p)===v.element&&tn(u,p)}),ae(l,p=>{B(p)===v.element&&!Ve(u,p)&&vn(p)})},zn=function(r,l){let u=!1;return ae(e.removed,p=>{p.element&&(u=u||p.element===r,vt(p.element))}),Jr(r,l),u},ei=8,ti=function(r,l){let u=xe,p=null,k=()=>(p||(p=en(),ae(l,b=>{tn(p,b)})),p);for(let b=0;;b++){let _=zt(r),z=[r],ne=!1;if(ae(_,H=>{B(H)===v.documentFragment?Xe(z,H):!ne&&!Ve(u,H)&&(ne=Ve(k(),H))}),!ne)return;if(b>=ei)throw ce("the tree kept changing during in-place sanitization; refusing to return it");ae(z,(H,W)=>{ni(H,W>0,r,k())})}},ni=function(r,l,u,p){let k=Nt(r),b;for(;b=k.nextNode();)!Ve(p,b)||Ve(xe,b)||(l&&Q(E.uponSanitizeShadowNode,b,null),Mt(b,u),Ut(b,u),he(b.content)&&Ge(b.content))},ri=function(r){xe&&tn(xe,r)},Nn=function(r,l){return ke?r==="patchsrc"?!0:r==="for"&&l!=="label"&&l!=="output":!1},ii=function(r){ke&&Ct(r,l=>{let u=B(l);if(u===v.processingInstruction||u===v.comment&&M(_r,l.data)){try{T(l)}catch{}return!1}if(u===v.element){let p=l,k=I(me(l));try{p.hasAttribute&&p.hasAttribute("patchsrc")&&p.removeAttribute("patchsrc"),p.hasAttribute&&p.hasAttribute("for")&&Nn("for",k)&&p.removeAttribute("for")}catch{}}return!0})},$n=function(r){let l=null,u=null;if(yt)r="<remove></remove>"+r;else{let b=hr(r,/^[\r\n\t ]+/);u=b&&b[0]}Be==="application/xhtml+xml"&&Pe===te&&(r='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+r+"</body></html>");let p=C?Re(r):r;if(Pe===te)try{l=new g().parseFromString(p,Be)}catch{}if(!l||!l.documentElement){l=bt.createDocument(Pe,"template",null);try{l.documentElement.innerHTML=Rt?oe:p}catch{}}let k=l.body||l.documentElement;return r&&u&&k.insertBefore(n.createTextNode(u),k.childNodes[0]||null),Pe===te?zr.call(l,be?"html":"body")[0]:be?l.documentElement:k},Nt=function(r){let l=de?de(r):r.ownerDocument;return gn.call(l||r,r,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},lt=function(r){return r=Qe(r,$r," "),r=Qe(r,Mr," "),r=Qe(r,Ur," "),r},$t=function(r){var l;Mn(r);let u=(l=r.querySelectorAll)===null||l===void 0?void 0:l.call(r,"template");u&&ae(u,p=>{he(p.content)&&$t(p.content)})},Mn=function(r){r.normalize();let l=de?de(r):r.ownerDocument,u=gn.call(l||r,r,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null),p=u.nextNode();for(;p;)p.data=lt(p.data),p=u.nextNode()},at=function(r){let l=se?se(r):null;return typeof l!="string"||I(l)!=="form"?!1:typeof r.nodeName!="string"||typeof r.textContent!="string"||typeof r.removeChild!="function"||r.attributes!==ie(r)||typeof r.removeAttribute!="function"||typeof r.removeAttributeNode!="function"||typeof r.getAttributeNode!="function"||typeof r.setAttribute!="function"||typeof r.namespaceURI!="string"||typeof r.insertBefore!="function"||typeof r.hasChildNodes!="function"||r.nodeType!==V(r)||r.childNodes!==y(r)},he=function(r){if(!V||typeof r!="object"||r===null)return!1;try{return V(r)===v.documentFragment}catch{return!1}},He=function(r){if(!V||typeof r!="object"||r===null)return!1;try{return typeof V(r)=="number"}catch{return!1}};function Q(h,r,l){h.length!==0&&ae(h,u=>{u.call(e,r,l,De)})}let si=function(r,l){return!!(ke&&r.hasChildNodes()&&!He(r.firstElementChild)&&M(an,r.textContent)&&M(an,r.innerHTML)||ke&&Fs[l]&&B(r)===v.element&&Ee(r)===te&&(He(r.firstElementChild)||typeof r.textContent=="string"&&M(an,r.textContent))||r.nodeType===v.processingInstruction||ke&&r.nodeType===v.comment&&M(_r,r.data))},ct=function(r,l){if(r instanceof RegExp)return M(r,l);if(r instanceof Function){for(var u=arguments.length,p=new Array(u>2?u-2:0),k=2;k<u;k++)p[k-2]=arguments[k];return!!r(l,...p)}return!1},oi=function(r,l,u){if(!Fe[l]&&Bn(l)&&ct(ee.tagNameCheck,l))return!1;if(St&&!Te[l]&&!Te[Se(l)]){let p=G(r),k=y(r);if(k&&p){let b=k.length;for(let _=b-1;_>=0;--_){let z=r===u?S(k[_],!0):k[_];p.insertBefore(z,D(r))}}}return pe(r),!0},Un=function(r,l,u,p){return r.length===0?l:l===u||l===p?Y(l):l},Ce=function(r,l){return r===l||G(r)!==null?!1:(Et&&vt(r),!0)},Mt=function(r,l){if(ri(r),Q(E.beforeSanitizeElements,r,null),Ce(r,l))return!0;if(at(r))return pe(r),!0;let u=I(me(r));if(O=Un(E.uponSanitizeElement,O,xt,tt),Q(E.uponSanitizeElement,r,{tagName:u,allowedTags:O}),Ce(r,l))return!0;if(si(r,u))return pe(r),!0;if(Fe[u]||!(ue.tagCheck instanceof Function&&ue.tagCheck(u))&&!O[u]){let p=oi(r,u,l);return p===!1&&(Q(E.afterSanitizeElements,r,null),Ce(r,l))?!0:p}if(B(r)===v.element&&!Kr(r)||(u==="noscript"||u==="noembed"||u==="noframes")&&M(Us,r.innerHTML))return pe(r),!0;if(le&&r.nodeType===v.text){let p=lt(r.textContent);r.textContent!==p&&(Xe(e.removed,{element:r.cloneNode()}),r.textContent=p)}return Q(E.afterSanitizeElements,r,null),Ce(r,l)},Fn=function(r,l,u){if(kn[l]||Nn(l,r)||Tn&&(l==="id"||l==="name")&&(u in n||u in Yr))return!1;let p=L[l]||ue.attributeCheck instanceof Function&&ue.attributeCheck(l,r);return _t&&M(Fr,l)||bn&&M(Br,l)?!0:p?En[l]||M(mn,Qe(u,dn,""))||(l==="src"||l==="xlink:href"||l==="href")&&r!=="script"&&fr(u,"data:")===0&&yn[r]||xn&&!M(Hr,Qe(u,dn,""))?!0:!u:Bn(r)&&ct(ee.tagNameCheck,r)&&ct(ee.attributeNameCheck,l,r)||l==="is"&&ee.allowCustomizedBuiltInElements&&ct(ee.tagNameCheck,u)},li=A({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bn=function(r){return!li[Se(r)]&&M(Gr,r)},ai=function(r,l,u,p){if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!u)switch(f.getAttributeType(r,l)){case"TrustedHTML":return Re(p);case"TrustedScriptURL":return Ir(p)}return p},ci=function(r,l,u,p){try{return u?r.setAttributeNS(u,l,p):r.setAttribute(l,p),at(r)?(pe(r),!1):!0}catch{return Ie(l,r),!1}},Hn=function(r,l){return ke&&M(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,l)?!0:Se(r)==="attributename"&&hr(l,"href")!==null},Ut=function(r,l){if(Q(E.beforeSanitizeAttributes,r,null),Ce(r,l))return;let u=r.attributes;if(!u||at(r))return;L=Un(E.uponSanitizeAttribute,L,Tt,nt);let p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0},k=u.length,b=I(r.nodeName);for(;k--;){let _=u[k],z=_.name,ne=_.namespaceURI,H=_.value,W=I(z),ve=H,q=z==="value"?ve:_s(ve),Gn=!1;if(p.attrName=W,p.attrValue=q,p.keepAttr=!0,p.forceKeepAttr=void 0,Q(E.uponSanitizeAttribute,r,p),q=p.attrValue,_n&&(W==="id"||W==="name")&&fr(q,An)!==0&&(Ie(z,r,_),q=An+q,Gn=!0),Hn(z,q)){Ie(z,r,_);continue}if(!p.forceKeepAttr){if(!p.keepAttr){Ie(z,r,_);continue}if(!At&&M(Ar,q)){Ie(z,r,_);continue}if(le&&(q=lt(q)),!Fn(b,W,q)){Ie(z,r,_);continue}q=ai(b,W,ne,q),q!==ve&&ci(r,z,ne,q)&&Gn&&pr(e.removed)}}Q(E.afterSanitizeAttributes,r,null),Ce(r,l)},Ge=function(r){let l=null,u=Nt(r);for(Q(E.beforeSanitizeShadowDOM,r,null);l=u.nextNode();)if(Q(E.uponSanitizeShadowNode,l,null),Mt(l,r),Ut(l,r),he(l.content)&&Ge(l.content),B(l)===v.element){let p=R(l);he(p)&&(Ft(p),Ge(p))}le&&Mn(r),Q(E.afterSanitizeShadowDOM,r,null)},Ft=function(r){let l=[{node:r,shadow:null}];for(;l.length>0;){let u=l.pop();if(u.shadow){Ge(u.shadow);continue}let p=u.node,k=B(p)===v.element,b=y(p);if(b)for(let _=b.length-1;_>=0;--_)l.push({node:b[_],shadow:null});if(k){let _=se?se(p):null;if(typeof _=="string"&&I(_)==="template"){let z=p.content;he(z)&&l.push({node:z,shadow:null})}}if(k){let _=R(p);he(_)&&l.push({node:null,shadow:_},{node:_,shadow:null})}}};return e.sanitize=function(h){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,u=null,p=null,k=null;if(Rt=!h,Rt&&(h="<!-->"),typeof h!="string"&&!He(h)&&(h=Ss(h),typeof h!="string"))throw ce("dirty is not a string, aborting");if(!e.isSupported)return h;wt?(O=tt,L=nt):Dt(r),(E.uponSanitizeElement.length>0||E.uponSanitizeAttribute.length>0)&&(O=Y(O)),E.uponSanitizeAttribute.length>0&&(L=Y(L)),e.removed=[];let b=Et&&typeof h!="string"&&He(h),_=[],z=xe;if(b){ii(h);let W=me(h);if(typeof W=="string"){let ve=I(W);if(!O[ve]||Fe[ve])throw It(h),ce("root node is forbidden and cannot be sanitized in-place")}if(at(h))throw It(h),ce("root node is clobbered and cannot be sanitized in-place");_=zt(h),xe=en()}else if(He(h))l=$n("<!---->"),u=l.ownerDocument.importNode(h,!0),u.nodeType===v.element&&u.nodeName==="BODY"||u.nodeName==="HTML"?l=u:l.appendChild(u),Ft(l);else{if(!Oe&&!le&&!be&&h.indexOf("<")===-1)return C&&it?Re(h):h;if(l=$n(h),!l)return Oe?null:it?oe:""}l&&yt&&pe(l.firstChild);let ne=b?h:l;try{b&&Ft(h);let W=Nt(ne);for(;p=W.nextNode();)Mt(p,ne),Ut(p,ne),he(p.content)&&Ge(p.content);b&&ti(h,_)}catch(W){throw b&&(It(h),zn(h,_)),W}finally{xe=z}if(b){if(zn(h,_))throw ce("a node selected for removal could not be safely returned; refusing to sanitize in place");return le&&$t(h),h}if(Oe){if(le&&$t(l),rt)for(k=vr.call(l.ownerDocument);l.firstChild;)k.appendChild(l.firstChild);else k=l;return(L.shadowroot||L.shadowrootmode)&&(k=Nr.call(s,k,!0)),k}let H=be?l.outerHTML:l.innerHTML;return be&&O["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&M($s,l.ownerDocument.doctype.name)&&(H="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
|
|
67
|
+
`+H),le&&(H=lt(H)),C&&it?Re(H):H},e.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Dt(h),wt=!0,tt=O,nt=L},e.clearConfig=function(){De=null,wt=!1,tt=null,nt=null,C=kt,oe=""},e.isValidAttribute=function(h,r,l){De||Dt({});let u=I(h),p=I(r);return typeof l=="string"&&(Hn(r,l)||!At&&M(Ar,l))?!1:Fn(u,p,l)},e.addHook=function(h,r){typeof r=="function"&&j(E,h)&&Xe(E[h],r)},e.removeHook=function(h,r){if(j(E,h)){if(r!==void 0){let l=bs(E[h],r);return l===-1?void 0:Ts(E[h],l,1)[0]}return pr(E[h])}},e.removeHooks=function(h){j(E,h)&&(E[h]=[])},e.removeAllHooks=function(){E=wr()},e}var Pr=Lr();var Dr=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Gs=new Jt({gfm:!0,breaks:!0,renderer:{html:({text:t})=>Dr(t),image:({text:t})=>Dr(t)}}),Ws=["p","br","em","strong","del","blockquote","ul","ol","li","hr","h1","h2","h3","h4","h5","h6","pre","code","table","thead","tbody","tr","th","td","a","input"];function oo(t,e){let n=Pr.sanitize(Gs.parse(e),{ALLOWED_TAGS:Ws,ALLOWED_ATTR:["href","title","class","start","align","type","checked","disabled"],ALLOW_DATA_ATTR:!1,RETURN_DOM_FRAGMENT:!0});for(let s of n.querySelectorAll("a"))/^(https?:|mailto:)/i.test(s.getAttribute("href")??"")||s.removeAttribute("href"),s.target="_blank",s.rel="noopener noreferrer";for(let s of[...n.childNodes])s.nodeType===Node.TEXT_NODE&&!s.textContent.trim()&&s.remove();t.replaceChildren(n)}export{oo as renderReplyMarkdown};
|
|
68
|
+
/*! Bundled license information:
|
|
69
|
+
|
|
70
|
+
dompurify/dist/purify.es.mjs:
|
|
71
|
+
(*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE *)
|
|
72
|
+
(*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE *)
|
|
73
|
+
*/
|
package/web/pet.js
CHANGED
|
@@ -2,7 +2,8 @@ import { loadBody, knownScheme } from './upstream/body-host.js';
|
|
|
2
2
|
import { createSfx } from './upstream/sound.js';
|
|
3
3
|
import { createSpeech, replyPreview } from './speech.js';
|
|
4
4
|
import { createNoticeQueue, pendingInteractions, notificationPresentation, notificationCopy } from './notification-ui.js';
|
|
5
|
-
import { shortSessionIds, sessionTime, sessionActivity, inboxContents } from './session-ui.js';
|
|
5
|
+
import { shortSessionIds, sessionTime, sessionActivity, inboxContents, unreadReplies } from './session-ui.js';
|
|
6
|
+
import { renderReplyMarkdown } from './markdown-runtime.js';
|
|
6
7
|
const PACK_LIMIT = 128 * 1024 * 1024;
|
|
7
8
|
import { browserCharacters } from './character-library.js';
|
|
8
9
|
const BUILTIN_ID = 'whale';
|
|
@@ -111,7 +112,7 @@ function speak(result) {
|
|
|
111
112
|
}
|
|
112
113
|
function showNextReply() {
|
|
113
114
|
if (!bubble.hidden || !interaction.hidden || panels.some(p => !p.hidden) || pressing || dragging) return;
|
|
114
|
-
const result = snapshot.
|
|
115
|
+
const result = unreadReplies(snapshot, acknowledgedResults).find(r => r.sessionId === snapshot.sessionId && !shownResults.has(r.id));
|
|
115
116
|
if (result) speak(result);
|
|
116
117
|
}
|
|
117
118
|
function completionHasReply(notice) {
|
|
@@ -119,8 +120,13 @@ function completionHasReply(notice) {
|
|
|
119
120
|
snapshot.results?.some(result => result.id === `${notice.sessionId}:${notice.turn}:${notice.seq}`);
|
|
120
121
|
}
|
|
121
122
|
function acknowledge(result) {
|
|
122
|
-
if (!result || result.read
|
|
123
|
-
|
|
123
|
+
if (!result || result.read) return;
|
|
124
|
+
// Use the identities captured when this reply was shown. A new turn arriving
|
|
125
|
+
// during reading remains unread, even if it belongs to the same session.
|
|
126
|
+
for (const id of result.unreadIds ?? [result.id]) {
|
|
127
|
+
if (acknowledgedResults.has(id)) continue;
|
|
128
|
+
acknowledgedResults.add(id); send({ type: 'read', resultId: id });
|
|
129
|
+
}
|
|
124
130
|
}
|
|
125
131
|
function openReader(result, queue) {
|
|
126
132
|
if (!result) return;
|
|
@@ -131,7 +137,7 @@ function openReader(result, queue) {
|
|
|
131
137
|
const source = snapshot.sessions.find(s => s.id === result.sessionId);
|
|
132
138
|
$('reader-title').textContent = source?.label ?? '会话回复';
|
|
133
139
|
$('reader-detail').textContent = `${source?.project ?? ''} · ${sessionTime({ updatedAt: result.time })}`;
|
|
134
|
-
$('reader-text')
|
|
140
|
+
renderReplyMarkdown($('reader-text'), result.text); $('reader-text').scrollTop = 0;
|
|
135
141
|
updateReaderNavigation(); acknowledge(result); updateMood(); position(); $('reader-text').focus();
|
|
136
142
|
}
|
|
137
143
|
function updateReaderNavigation() {
|
|
@@ -180,22 +186,24 @@ function render() {
|
|
|
180
186
|
const previous = renderedSessionId;
|
|
181
187
|
const selected = snapshot.sessions.find(session => session.id === snapshot.sessionId);
|
|
182
188
|
const shortIds = shortSessionIds(snapshot.sessions);
|
|
189
|
+
const unreadSources = new Set(unreadReplies(snapshot, acknowledgedResults).map(result => result.sessionId));
|
|
190
|
+
const hasUnread = session => snapshot.results ? unreadSources.has(session.id) : !!session.unread;
|
|
183
191
|
const list = $('conversation-list');
|
|
184
192
|
const query = $('conversation-search').value.trim().toLocaleLowerCase();
|
|
185
193
|
const needsYou = s => ['waiting', 'error'].includes(s.mood) || pendingRequests().some(item => item.sessionId === s.id);
|
|
186
|
-
const matches = snapshot.sessions.filter(session => (!pendingOnly || session
|
|
187
|
-
matches.sort((a, b) => Number(needsYou(b)) - Number(needsYou(a)) || Number(
|
|
188
|
-
const listKey = JSON.stringify([query, pendingOnly, matches.map(session => [session.id, session.label, session.prompt, session.cwd, session.updatedAt, session.mood, session
|
|
194
|
+
const matches = snapshot.sessions.filter(session => (!pendingOnly || hasUnread(session) || needsYou(session)) && [session.label, session.project, session.cwd, session.prompt, session.id].join(' ').toLocaleLowerCase().includes(query));
|
|
195
|
+
matches.sort((a, b) => Number(needsYou(b)) - Number(needsYou(a)) || Number(hasUnread(b)) - Number(hasUnread(a)) || Number(b.id === snapshot.sessionId) - Number(a.id === snapshot.sessionId) || (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
|
|
196
|
+
const listKey = JSON.stringify([query, pendingOnly, matches.map(session => [session.id, session.label, session.prompt, session.cwd, session.updatedAt, session.mood, hasUnread(session), session.chatAvailable, session.id === snapshot.sessionId])]);
|
|
189
197
|
if (list.dataset.key !== listKey) {
|
|
190
198
|
const activeId = document.activeElement?.dataset?.sessionId;
|
|
191
199
|
const entries = matches.map(session => {
|
|
192
200
|
const card = document.createElement('button'); card.type = 'button'; card.className = 'conversation-card';
|
|
193
201
|
card.dataset.sessionId = session.id; card.dataset.mood = session.mood; card.setAttribute('role', 'option'); card.setAttribute('aria-selected', String(session.id === snapshot.sessionId));
|
|
194
|
-
card.dataset.unread = String(
|
|
202
|
+
card.dataset.unread = String(hasUnread(session));
|
|
195
203
|
card.tabIndex = session.id === snapshot.sessionId ? 0 : -1;
|
|
196
204
|
card.title = `${session.label}\n${session.prompt ?? ''}\n${session.cwd ?? session.project ?? ''}\n${session.id}`;
|
|
197
205
|
const copy = document.createElement('span'), meta = document.createElement('small'), status = document.createElement('em'), time = document.createElement('span'), name = document.createElement('strong'), detail = document.createElement('small'), prompt = document.createElement('small'), mark = document.createElement('b');
|
|
198
|
-
meta.className = 'session-meta'; status.textContent = `${session.id === snapshot.sessionId ? '关注 · ' : ''}${labels[session.mood] ?? labels.idle}${session
|
|
206
|
+
meta.className = 'session-meta'; status.textContent = `${session.id === snapshot.sessionId ? '关注 · ' : ''}${labels[session.mood] ?? labels.idle}${hasUnread(session) ? ' · 1 份未读' : ''}${session.chatAvailable === false ? ' · 未打开' : ''}`;
|
|
199
207
|
time.textContent = sessionTime(session); meta.append(status, time);
|
|
200
208
|
name.textContent = session.label; detail.className = 'session-detail'; detail.textContent = `${session.cwd || session.project || '会话'} · #${shortIds.get(session.id)}`;
|
|
201
209
|
prompt.className = 'session-prompt'; prompt.textContent = session.prompt && session.prompt !== session.label ? `最近:${session.prompt}` : ''; prompt.hidden = !prompt.textContent;
|
|
@@ -209,7 +217,7 @@ function render() {
|
|
|
209
217
|
if (activeId) list.querySelector(`[data-session-id="${CSS.escape(activeId)}"]`)?.focus();
|
|
210
218
|
}
|
|
211
219
|
const activity = sessionActivity(snapshot);
|
|
212
|
-
$('conversation-count').textContent = `${activity.busy} 段进行中 · ${activity.unread} 份未读回复`;
|
|
220
|
+
$('conversation-count').textContent = `${activity.busy} 段进行中 · ${snapshot.results ? unreadSources.size : activity.unread} 份未读回复`;
|
|
213
221
|
$('sessions-all').setAttribute('aria-pressed', String(!pendingOnly)); $('sessions-pending').setAttribute('aria-pressed', String(pendingOnly));
|
|
214
222
|
inboxState = inboxContents(snapshot, pendingRequests(), acknowledgedResults);
|
|
215
223
|
const pendingCount = inboxState.requests.length + inboxState.issues.length;
|
|
@@ -464,7 +472,7 @@ $('chat-close').onclick = closePanels;
|
|
|
464
472
|
$('dismiss').onclick = () => { bubble.hidden = true; acknowledge(bubbleResult); showNextReply(); };
|
|
465
473
|
$('bubble-reveal').onclick = () => { speech?.finish(); };
|
|
466
474
|
$('bubble-expand').onclick = () => openReader(bubbleResult);
|
|
467
|
-
$('chat-read').onclick = () => openReader((snapshot
|
|
475
|
+
$('chat-read').onclick = () => openReader(unreadReplies(snapshot, acknowledgedResults).find(r => r.sessionId === snapshot.sessionId) ?? (snapshot.results ?? []).find(r => r.id === snapshot.sessions.find(s => s.id === snapshot.sessionId)?.replyId));
|
|
468
476
|
$('reader-close').onclick = closePanels;
|
|
469
477
|
for (const [id, offset] of [['reader-prev', -1], ['reader-next', 1]]) $(id).onclick = () => {
|
|
470
478
|
const history = readerQueue ?? (snapshot.results ?? []).filter(r => r.sessionId === readerResult?.sessionId);
|
|
@@ -478,7 +486,7 @@ $('conversation-list').onclick = event => {
|
|
|
478
486
|
if (!session) return;
|
|
479
487
|
conversations.hidden = true;
|
|
480
488
|
if (session.id !== snapshot.sessionId) send({ type: 'select', sessionId: session.id });
|
|
481
|
-
const result = snapshot.
|
|
489
|
+
const result = unreadReplies(snapshot, acknowledgedResults).find(r => r.sessionId === session.id);
|
|
482
490
|
if (result) openReader(result); else render();
|
|
483
491
|
};
|
|
484
492
|
function openSession(id) { if (id) { send({ type: 'open-session', sessionId: id }); closePanels(); bubble.hidden = true; } }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Marked } from 'marked';
|
|
2
|
+
import DOMPurify from 'dompurify';
|
|
3
|
+
|
|
4
|
+
const escapeHtml = text => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
5
|
+
const markdown = new Marked({ gfm: true, breaks: true, renderer: {
|
|
6
|
+
// Assistant text is content, never page markup or an automatic network fetch.
|
|
7
|
+
html: ({ text }) => escapeHtml(text),
|
|
8
|
+
image: ({ text }) => escapeHtml(text),
|
|
9
|
+
} });
|
|
10
|
+
const tags = ['p', 'br', 'em', 'strong', 'del', 'blockquote', 'ul', 'ol', 'li', 'hr', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'code', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'a', 'input'];
|
|
11
|
+
|
|
12
|
+
/** Render once on an explicit read action; live snapshots never replace the open body. */
|
|
13
|
+
export function renderReplyMarkdown(node, text) {
|
|
14
|
+
const content = DOMPurify.sanitize(markdown.parse(text), {
|
|
15
|
+
ALLOWED_TAGS: tags,
|
|
16
|
+
ALLOWED_ATTR: ['href', 'title', 'class', 'start', 'align', 'type', 'checked', 'disabled'],
|
|
17
|
+
ALLOW_DATA_ATTR: false,
|
|
18
|
+
RETURN_DOM_FRAGMENT: true,
|
|
19
|
+
});
|
|
20
|
+
for (const link of content.querySelectorAll('a')) {
|
|
21
|
+
if (!/^(https?:|mailto:)/i.test(link.getAttribute('href') ?? '')) link.removeAttribute('href');
|
|
22
|
+
link.target = '_blank'; link.rel = 'noopener noreferrer';
|
|
23
|
+
}
|
|
24
|
+
// Parser formatting between blocks does not belong to the reply's text.
|
|
25
|
+
for (const child of [...content.childNodes]) if (child.nodeType === Node.TEXT_NODE && !child.textContent.trim()) child.remove();
|
|
26
|
+
node.replaceChildren(content);
|
|
27
|
+
}
|
package/web/session-ui.js
CHANGED
|
@@ -18,16 +18,30 @@ export function inboxContents(snapshot, interactions = [], acknowledged = new Se
|
|
|
18
18
|
const requests = interactions.filter(item => item.state !== 'settled');
|
|
19
19
|
const requested = new Set(requests.map(item => item.sessionId));
|
|
20
20
|
const issues = (snapshot.sessions ?? []).filter(session => session.mood === 'error' || session.mood === 'waiting' && !requested.has(session.id));
|
|
21
|
-
const replies = (snapshot
|
|
21
|
+
const replies = unreadReplies(snapshot, acknowledged);
|
|
22
22
|
return { requests, issues, replies, total: requests.length + issues.length + replies.length };
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** Keep one latest reply per source, with the exact unread identities it represents. */
|
|
26
|
+
export function unreadReplies(snapshot, acknowledged = new Set()) {
|
|
27
|
+
const sources = new Map();
|
|
28
|
+
for (const result of snapshot.results ?? []) {
|
|
29
|
+
if (result.read || acknowledged.has(result.id)) continue;
|
|
30
|
+
const current = sources.get(result.sessionId);
|
|
31
|
+
const unreadIds = current?.unreadIds ?? [];
|
|
32
|
+
unreadIds.push(result.id);
|
|
33
|
+
// Results are retained in completion order; the later entry wins a timestamp tie.
|
|
34
|
+
sources.set(result.sessionId, { ...(current && current.time > result.time ? current : result), unreadIds });
|
|
35
|
+
}
|
|
36
|
+
return [...sources.values()].sort((a, b) => b.time - a.time);
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
/** One focus for chat, one aggregate signal for work happening elsewhere. */
|
|
26
40
|
export function sessionActivity(snapshot) {
|
|
27
41
|
const sessions = snapshot.sessions ?? [];
|
|
28
42
|
const waiting = sessions.filter(s => s.mood === 'waiting');
|
|
29
43
|
const errors = sessions.filter(s => s.mood === 'error');
|
|
30
|
-
const unread =
|
|
44
|
+
const unread = snapshot.results ? new Set(snapshot.results.filter(result => !result.read).map(result => result.sessionId)).size : sessions.filter(s => s.unread).length;
|
|
31
45
|
const busy = sessions.filter(s => s.active ?? ['thinking', 'talking', 'working'].includes(s.mood));
|
|
32
46
|
const focusedActive = snapshot.active ?? ['thinking', 'talking', 'working'].includes(snapshot.mood);
|
|
33
47
|
const background = sessions.filter(s => s.id !== snapshot.sessionId);
|
package/web/style.css
CHANGED
|
@@ -36,7 +36,24 @@ svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width:
|
|
|
36
36
|
.reader .conversation-heading { min-width: 0; }
|
|
37
37
|
.reader .conversation-heading strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
38
38
|
.reader-detail { display: block; color: var(--muted); margin: 8px 0 14px; font-size: 10px; }
|
|
39
|
-
.reader-text { max-height: min(420px, calc(100vh - 310px)); overflow
|
|
39
|
+
.reader-text { max-height: min(420px, calc(100vh - 310px)); overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; font-size: 14px; line-height: 1.85; user-select: text; padding: 3px 10px 10px 2px; }
|
|
40
|
+
.reader-text>:first-child { margin-top: 0; }
|
|
41
|
+
.reader-text>:last-child { margin-bottom: 0; }
|
|
42
|
+
.reader-text p, .reader-text ul, .reader-text ol, .reader-text blockquote, .reader-text pre, .reader-text table { margin: 0 0 1em; }
|
|
43
|
+
.reader-text h1, .reader-text h2, .reader-text h3, .reader-text h4, .reader-text h5, .reader-text h6 { margin: 1.2em 0 .5em; line-height: 1.4; font-size: 1.05em; }
|
|
44
|
+
.reader-text h1 { font-size: 1.4em; }.reader-text h2 { font-size: 1.25em; }.reader-text h3 { font-size: 1.1em; }
|
|
45
|
+
.reader-text strong { font-size: inherit; }
|
|
46
|
+
.reader-text ul, .reader-text ol { padding-left: 1.5em; }
|
|
47
|
+
.reader-text li>p { margin-bottom: .4em; }
|
|
48
|
+
.reader-text blockquote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
|
|
49
|
+
.reader-text code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; background: var(--tint); padding: 2px 4px; border-radius: 4px; }
|
|
50
|
+
.reader-text pre { max-width: 100%; overflow-x: auto; white-space: pre; background: var(--tint); padding: 10px; border-radius: 10px; line-height: 1.6; }
|
|
51
|
+
.reader-text pre code { background: transparent; padding: 0; }
|
|
52
|
+
.reader-text table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .9em; }
|
|
53
|
+
.reader-text th, .reader-text td { border: 1px solid var(--line); padding: 6px 10px; min-width: 80px; }
|
|
54
|
+
.reader-text th { background: var(--tint); text-align: left; }
|
|
55
|
+
.reader-text a { color: var(--accent); text-underline-offset: 3px; }
|
|
56
|
+
.reader-text hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
|
|
40
57
|
.reader-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 9px; }
|
|
41
58
|
.reader-footer>button:not(.session-link) { width: 25px; height: 25px; border-radius: 8px; color: var(--accent); background: var(--tint); font-size: 20px; }
|
|
42
59
|
#reader-count { font-size: 10px; color: var(--muted); }
|