@lemoncat7/dsh-knowledge 2.3.1 → 2.3.3
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 +4 -3
- package/docs/architecture.md +1 -1
- package/lib/activity-control.d.ts +6 -0
- package/lib/activity-control.d.ts.map +1 -0
- package/lib/activity-control.js +118 -0
- package/lib/activity-control.js.map +1 -0
- package/lib/api.d.ts +2 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +2 -2
- package/lib/api.js.map +1 -1
- package/lib/client.d.ts +17 -0
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +3825 -142
- package/lib/client.js.map +4 -4
- package/lib/config.d.ts +2 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +26 -0
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -1
- package/lib/index.js.map +1 -1
- package/lib/knowledge-activity-api.d.ts +35 -0
- package/lib/knowledge-activity-api.d.ts.map +1 -0
- package/lib/knowledge-activity-api.js +115 -0
- package/lib/knowledge-activity-api.js.map +1 -0
- package/lib/knowledge-activity-controller.d.ts +25 -0
- package/lib/knowledge-activity-controller.d.ts.map +1 -0
- package/lib/knowledge-activity-controller.js +126 -0
- package/lib/knowledge-activity-controller.js.map +1 -0
- package/lib/knowledge-activity-notes.d.ts +9 -0
- package/lib/knowledge-activity-notes.d.ts.map +1 -0
- package/lib/knowledge-activity-notes.js +141 -0
- package/lib/knowledge-activity-notes.js.map +1 -0
- package/lib/knowledge-activity-panel.d.ts +8 -0
- package/lib/knowledge-activity-panel.d.ts.map +1 -0
- package/lib/knowledge-activity-panel.js +233 -0
- package/lib/knowledge-activity-panel.js.map +1 -0
- package/lib/notes/share-import.d.ts +16 -2
- package/lib/notes/share-import.d.ts.map +1 -1
- package/lib/notes/share-import.js +32 -13
- package/lib/notes/share-import.js.map +1 -1
- package/lib/notes/share-markdown.d.ts +12 -0
- package/lib/notes/share-markdown.d.ts.map +1 -0
- package/lib/notes/share-markdown.js +79 -0
- package/lib/notes/share-markdown.js.map +1 -0
- package/lib/notes/share-page.d.ts.map +1 -1
- package/lib/notes/share-page.js +116 -21
- package/lib/notes/share-page.js.map +1 -1
- package/lib/web-note-editor-outline.js +2 -2
- package/lib/web-note-editor-outline.js.map +1 -1
- package/lib/web-note-editor-selection.js +1 -1
- package/lib/web-note-editor-selection.js.map +1 -1
- package/package.json +5 -2
- package/web/app.js +33 -15
- package/web/note-editor.js +1 -1
- package/web/styles.css +69 -18
package/lib/client.js
CHANGED
|
@@ -21,33 +21,3657 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/client.tsx
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
|
-
apply: () =>
|
|
24
|
+
apply: () => apply2,
|
|
25
25
|
inject: () => inject
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(client_exports);
|
|
28
|
+
var import_react3 = require("react");
|
|
29
|
+
|
|
30
|
+
// src/workspace-ownership.ts
|
|
31
|
+
var WORKSPACE_ACTIVATE_EVENT = "@lemoncat7/dsh-plugin-ui/workspace-activate";
|
|
32
|
+
function activatePluginWorkspace(pluginId) {
|
|
33
|
+
window.dispatchEvent(new CustomEvent(WORKSPACE_ACTIVATE_EVENT, {
|
|
34
|
+
detail: { pluginId }
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function observePluginWorkspace(pluginId, close) {
|
|
38
|
+
const onActivate = (event) => {
|
|
39
|
+
const detail = event.detail;
|
|
40
|
+
if (detail?.pluginId !== pluginId) close();
|
|
41
|
+
};
|
|
42
|
+
window.addEventListener(WORKSPACE_ACTIVATE_EVENT, onActivate);
|
|
43
|
+
return () => window.removeEventListener(WORKSPACE_ACTIVATE_EVENT, onActivate);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/client.tsx
|
|
47
|
+
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
48
|
+
|
|
49
|
+
// src/client.css
|
|
50
|
+
var client_default = '.dsh-knowledge-trigger,\n.dsh-knowledge-activity-panel,\n.dsh-knowledge-workspace,\n.dsh-knowledge-settings-card,\n.dsh-knowledge-writeback-status {\n color-scheme: light;\n --knowledge-canvas: transparent;\n --knowledge-accent: #3a3a3c;\n --knowledge-on-accent: #fff;\n --knowledge-danger: #d70015;\n --knowledge-success: #248a3d;\n --knowledge-pane: rgba(255, 255, 255, 0.16);\n --knowledge-raised: rgba(255, 255, 255, 0.38);\n --knowledge-control: rgba(255, 255, 255, 0.27);\n --knowledge-border: rgb(60 60 67 / 14%);\n --knowledge-text: #1d1d1f;\n --knowledge-text-secondary: #515154;\n --knowledge-text-tertiary: #747478;\n --knowledge-hover: rgba(118, 118, 128, .1);\n --knowledge-glare-light: rgb(255 255 255 / 70%);\n --knowledge-glare-rim: rgb(60 60 67 / 11%);\n --knowledge-glass-filter: saturate(1.22) contrast(1.03) blur(32px);\n --knowledge-host-glass-filter: saturate(.18) contrast(1.015) blur(24px);\n --knowledge-glass-shadow: inset 0 1px 0 rgb(255 255 255 / 70%), inset 0 -1px 0 rgb(60 60 67 / 11%), 0 10px 28px rgb(31 31 35 / 8.5%);\n --knowledge-activity-surface: rgb(250 249 246 / 58%);\n --knowledge-font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;\n color: var(--knowledge-text);\n font-family: var(--knowledge-font-family);\n font-size: 13px;\n line-height: 1.5;\n}\n\nbody[data-ds-dark-theme] :is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-activity-panel,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) {\n color-scheme: dark;\n --knowledge-canvas: transparent;\n --knowledge-accent: #69b6ba;\n --knowledge-on-accent: #101819;\n --knowledge-danger: #ff453a;\n --knowledge-success: #30d158;\n --knowledge-pane: rgb(25 33 35 / 90%);\n --knowledge-raised: rgb(32 41 43 / 94%);\n --knowledge-control: rgb(39 50 53 / 92%);\n --knowledge-border: rgb(184 204 205 / 11%);\n --knowledge-text: #e3eaeb;\n --knowledge-text-secondary: #bbc9cc;\n --knowledge-text-tertiary: #95a7ab;\n --knowledge-hover: rgb(105 182 186 / 9%);\n --knowledge-glare-light: rgb(255 255 255 / 16%);\n --knowledge-glare-rim: rgb(0 0 0 / 30%);\n --knowledge-host-glass-filter: saturate(.45) contrast(1.02) blur(24px);\n --knowledge-glass-shadow: inset 0 1px 0 rgb(255 255 255 / 16%), inset 0 -1px 0 rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 30%);\n --knowledge-activity-surface: rgb(18 20 20 / 72%);\n}\n\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-activity-panel,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n),\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-activity-panel,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) * {\n box-sizing: border-box;\n}\n\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-activity-panel,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) :where(button, input, textarea, select) {\n margin: 0;\n color: inherit;\n font-family: var(--knowledge-font-family);\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n}\n\n.dsh-knowledge-trigger,\n.dsh-knowledge-activity-panel button,\n.dsh-knowledge-activity-panel input,\n.dsh-knowledge-panel-state button,\n.dsh-knowledge-settings-card button,\n.dsh-knowledge-writeback-status button {\n -webkit-appearance: none;\n appearance: none;\n margin: 0;\n}\n\n.dsh-knowledge-trigger {\n position: relative;\n flex: none;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 8px;\n width: calc(100% + 4px);\n height: 42px;\n margin: 4px -2px;\n padding: 0 10px 0 8px;\n box-sizing: border-box;\n border: 0;\n border-radius: 8px;\n overflow: hidden;\n background: transparent;\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n white-space: nowrap;\n isolation: isolate;\n transition:\n color 120ms ease,\n background-color 120ms ease,\n box-shadow 160ms ease;\n}\n\n.dsh-knowledge-trigger:hover {\n background: var(--knowledge-hover);\n}\n\n.dsh-knowledge-trigger:focus-visible,\n.dsh-knowledge-writeback-status button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-trigger.is-active {\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n box-shadow: 0 1px 2px rgb(0 0 0 / 7%), inset 0 1px 0 rgb(255 255 255 / 28%);\n}\n\n.dsh-knowledge-trigger--rail {\n width: 36px;\n height: 36px;\n margin: 8px 0 4px;\n padding: 0;\n justify-content: center;\n gap: 0;\n border-radius: 50%;\n}\n\n/* Rail (collapsed) mode: the host footer seat is a horizontal row sized for a\n single 36px circle per entry; with several entries it overflows the 56px\n rail and the circles drift off the settings axis. Stack the entries\n vertically, centered on the same axis as the settings circle. The --rail\n class on the knowledge trigger is the collapsed-mode signal, so wide mode\n is untouched. */\ndiv:has(> div[data-slot="sidebar.footer.action"] .dsh-knowledge-trigger--rail) {\n flex-direction: column;\n align-items: center;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-knowledge-trigger { transition: none; }\n}\n\n.dsh-knowledge-workspace {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background: var(--knowledge-canvas);\n}\n\n.dsh-knowledge-workspace-header {\n position: relative;\n z-index: 2;\n flex: none;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 52px;\n margin: 8px 10px 0;\n padding: 7px 14px;\n box-sizing: border-box;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px 14px 11px 11px;\n background: transparent;\n box-shadow: var(--knowledge-glass-shadow);\n -webkit-backdrop-filter: var(--knowledge-host-glass-filter);\n backdrop-filter: var(--knowledge-host-glass-filter);\n}\n\n.dsh-knowledge-workspace-header > div {\n display: flex;\n align-items: center;\n gap: 10px;\n min-width: 0;\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close] {\n -webkit-appearance: none;\n appearance: none;\n display: grid;\n place-items: center;\n box-sizing: border-box;\n flex: none;\n width: 30px;\n height: 30px;\n margin: 0;\n padding: 0;\n border: 1px solid transparent;\n border-radius: 9px;\n color: var(--knowledge-text-secondary);\n background: transparent;\n font: inherit;\n line-height: 1;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms ease;\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:hover {\n border-color: var(--knowledge-border);\n color: var(--knowledge-text);\n background: var(--knowledge-control);\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:active { transform: scale(.96); }\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close] > svg {\n display: block;\n pointer-events: none;\n}\n\n.dsh-knowledge-workspace-header > div > span {\n display: grid;\n min-width: 0;\n gap: 2px;\n}\n\n.dsh-knowledge-workspace-header h2,\n.dsh-knowledge-workspace-header p {\n margin: 0;\n}\n\n.dsh-knowledge-workspace-header h2 {\n color: var(--knowledge-text);\n font-size: 15px;\n line-height: 22px;\n font-weight: 600;\n}\n\n.dsh-knowledge-workspace-header p {\n color: var(--knowledge-text-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n\n.dsh-knowledge-frame {\n flex: 1;\n display: block;\n width: 100%;\n min-height: 0;\n margin: 0;\n border: 0;\n border-radius: 0;\n background: transparent;\n box-shadow: none;\n -webkit-backdrop-filter: none;\n backdrop-filter: none;\n}\n\n.dsh-knowledge-panel-state {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n min-height: 0;\n margin: 8px 10px 10px;\n padding: 32px;\n box-sizing: border-box;\n border: 1px solid var(--knowledge-border);\n border-radius: 15px;\n background: var(--knowledge-pane);\n box-shadow: var(--knowledge-glass-shadow);\n -webkit-backdrop-filter: var(--knowledge-host-glass-filter);\n backdrop-filter: var(--knowledge-host-glass-filter);\n color: var(--knowledge-text);\n}\n\n.dsh-knowledge-panel-state-icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 12px;\n background: var(--knowledge-hover);\n color: var(--knowledge-text-secondary);\n font-size: 18px;\n font-weight: 600;\n}\n\n.dsh-knowledge-panel-state > div { max-width: 560px; }\n.dsh-knowledge-panel-state h3 { margin: 0 0 6px; font-size: 17px; line-height: 24px; font-weight: 600; }\n.dsh-knowledge-panel-state p { margin: 0; color: var(--knowledge-text-secondary); font-size: 13px; line-height: 20px; }\n.dsh-knowledge-panel-state button {\n min-width: 72px;\n min-height: 32px;\n margin-top: 16px;\n padding: 6px 14px;\n border: 0;\n border-radius: 10px;\n background: var(--knowledge-accent);\n color: var(--knowledge-on-accent);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-panel-state button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-settings-card {\n list-style: none;\n overflow: hidden;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px;\n background:\n linear-gradient(145deg, color-mix(in srgb, var(--knowledge-glare-light) 16%, transparent), transparent 58%),\n var(--knowledge-pane);\n color: var(--knowledge-text);\n box-shadow: var(--knowledge-glass-shadow), 0 8px 24px rgb(0 0 0 / 5%);\n -webkit-backdrop-filter: var(--knowledge-glass-filter);\n backdrop-filter: var(--knowledge-glass-filter);\n transition: border-color .16s, background .16s, box-shadow .2s, transform .2s cubic-bezier(.22, 1, .36, 1);\n}\n.dsh-knowledge-settings-card:hover {\n border-color: color-mix(in srgb, var(--knowledge-border) 68%, var(--knowledge-text-secondary));\n box-shadow: var(--knowledge-glass-shadow), 0 12px 30px rgb(0 0 0 / 8%);\n transform: translateY(-1px);\n}\n.dsh-knowledge-settings-card--open {\n border-color: color-mix(in srgb, var(--knowledge-border) 68%, var(--knowledge-text-secondary));\n background: var(--knowledge-pane);\n}\n.dsh-knowledge-settings-header { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-radius: 12px; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; }\n.dsh-knowledge-settings-header:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: -2px;\n}\n.dsh-knowledge-settings-actions button:focus-visible,\n.dsh-knowledge-settings-load-error button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-settings-header > span:first-child { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }\n.dsh-knowledge-settings-header strong { font-size: 15px; font-weight: 600; line-height: 1.4; }\n.dsh-knowledge-settings-header small { color: var(--knowledge-text-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-knowledge-source-picker small,\n.dsh-knowledge-remote-fields small { color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-settings-summary { display: flex; flex: none; align-items: center; gap: 10px; color: var(--knowledge-text-tertiary); font-size: 12px; }\n.dsh-knowledge-settings-summary i { width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 160ms ease; }\n.dsh-knowledge-settings-card--open .dsh-knowledge-settings-summary i { transform: rotate(225deg); }\n\n.dsh-knowledge-settings-body {\n display: grid;\n gap: 18px;\n margin: 0 16px;\n padding-bottom: 8px;\n border-top: 1px solid var(--knowledge-border);\n}\n\n.dsh-knowledge-source-picker {\n min-width: 0;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 10px;\n margin: 18px 0 0;\n padding: 0;\n border: 0;\n}\n\n.dsh-knowledge-source-picker legend { margin-bottom: 8px; padding: 0; color: inherit; font-size: 13px; font-weight: 600; }\n.dsh-knowledge-source-picker label {\n display: flex;\n gap: 10px;\n padding: 13px;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px;\n cursor: pointer;\n}\n.dsh-knowledge-source-picker label.is-selected {\n border-color: var(--knowledge-accent);\n background: color-mix(in srgb, var(--knowledge-accent) 7%, transparent);\n}\n.dsh-knowledge-source-picker label.is-disabled {\n cursor: default;\n opacity: .55;\n}\n.dsh-knowledge-source-picker label:focus-within {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-source-picker input {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n display: inline-grid;\n place-content: center;\n flex: none;\n margin: 2px 0 0;\n border: 1px solid var(--knowledge-border);\n border-radius: 50%;\n background: var(--knowledge-control);\n color: var(--knowledge-on-accent);\n cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.dsh-knowledge-source-picker input::before {\n content: "";\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n opacity: 0;\n transform: scale(.55);\n transition: opacity .12s ease, transform .15s cubic-bezier(.2, .8, .2, 1);\n}\n.dsh-knowledge-source-picker input:checked { border-color: var(--knowledge-accent); background: var(--knowledge-accent); }\n.dsh-knowledge-source-picker input:checked::before { opacity: 1; transform: scale(1); }\n.dsh-knowledge-source-picker input:disabled { cursor: default; }\n.dsh-knowledge-source-picker span { display: grid; gap: 3px; }\n\n.dsh-knowledge-remote-fields { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }\n.dsh-knowledge-remote-fields label,\n.dsh-knowledge-timeout-field { display: grid; gap: 6px; color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-remote-fields input,\n.dsh-knowledge-timeout-field input {\n -webkit-appearance: none;\n appearance: none;\n min-height: 38px;\n box-sizing: border-box;\n padding: 8px 11px;\n border: 1px solid var(--knowledge-border);\n border-radius: 10px;\n outline: none;\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n font: inherit;\n}\n.dsh-knowledge-remote-fields input:focus,\n.dsh-knowledge-timeout-field input:focus { border-color: var(--knowledge-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--knowledge-accent) 16%, transparent); }\n.dsh-knowledge-remote-fields input:-webkit-autofill,\n.dsh-knowledge-remote-fields input:-webkit-autofill:hover,\n.dsh-knowledge-remote-fields input:-webkit-autofill:focus {\n -webkit-text-fill-color: var(--knowledge-text);\n box-shadow: 0 0 0 1000px var(--knowledge-control) inset;\n caret-color: var(--knowledge-text);\n}\n.dsh-knowledge-timeout-field input::-webkit-inner-spin-button,\n.dsh-knowledge-timeout-field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }\n.dsh-knowledge-timeout-field { max-width: 240px; }\n.dsh-knowledge-field-error { color: var(--knowledge-danger) !important; }\n\n.dsh-knowledge-settings-message,\n.dsh-knowledge-settings-note { margin: 0; color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-settings-message.is-success { color: var(--knowledge-success); }\n.dsh-knowledge-settings-message.is-error { color: var(--knowledge-danger); }\n.dsh-knowledge-settings-load-error {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-top: 18px;\n padding: 12px 14px;\n border-radius: 12px;\n background: color-mix(in srgb, var(--knowledge-danger) 8%, transparent);\n color: var(--knowledge-danger);\n font-size: 13px;\n}\n.dsh-knowledge-settings-load-error p { margin: 0; }\n.dsh-knowledge-settings-load-error button {\n flex: none;\n min-height: 30px;\n padding: 5px 10px;\n border: 0;\n border-radius: 9px;\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-settings-actions { display: flex; justify-content: flex-end; gap: 8px; }\n.dsh-knowledge-settings-actions button {\n min-height: 34px;\n padding: 7px 13px;\n border: 0;\n border-radius: 10px;\n background: var(--knowledge-hover);\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n font-size: 13px;\n}\n.dsh-knowledge-settings-actions button.is-primary { background: var(--knowledge-accent); color: var(--knowledge-on-accent); }\n.dsh-knowledge-settings-actions button:disabled { cursor: default; opacity: .45; }\n\n@media (max-width: 720px) {\n .dsh-knowledge-source-picker,\n .dsh-knowledge-remote-fields { grid-template-columns: 1fr; }\n .dsh-knowledge-settings-summary { font-size: 0; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-knowledge-settings-card,\n .dsh-knowledge-settings-header,\n .dsh-knowledge-settings-summary i { transition: none; }\n}\n\n.dsh-knowledge-writeback-status {\n display: grid;\n gap: 5px;\n min-width: 0;\n color: var(--knowledge-text-tertiary);\n font-size: 12px;\n line-height: 1.5;\n}\n.dsh-knowledge-writeback-summary {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n min-width: 0;\n}\n.dsh-knowledge-writeback-status strong {\n color: var(--knowledge-text-secondary);\n font-weight: 600;\n}\n.dsh-knowledge-writeback-status button {\n min-height: 24px;\n padding: 0 9px;\n border: 1px solid var(--knowledge-border);\n border-radius: 7px;\n color: var(--knowledge-text-secondary);\n background: var(--knowledge-control);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-writeback-status button:disabled { cursor: default; opacity: .5; }\n.dsh-knowledge-writeback-destinations {\n display: flex;\n flex-wrap: wrap;\n gap: 2px 12px;\n min-width: 0;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.dsh-knowledge-writeback-destinations li {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n min-width: 0;\n max-width: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n}\n.dsh-knowledge-writeback-base,\n.dsh-knowledge-writeback-separator {\n flex: none;\n}\n.dsh-knowledge-writeback-separator {\n color: var(--knowledge-text-tertiary);\n}\n.dsh-knowledge-writeback-destinations strong {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.dsh-knowledge-writeback-status .dsh-knowledge-writeback-document {\n display: inline-flex;\n align-items: center;\n min-width: 0;\n min-height: 24px;\n padding: 0 3px;\n border: 0;\n border-radius: 4px;\n background: transparent;\n color: var(--knowledge-text-secondary);\n text-decoration: underline;\n text-decoration-color: transparent;\n text-underline-offset: 3px;\n transition: color 120ms ease, background-color 120ms ease, text-decoration-color 120ms ease;\n}\n.dsh-knowledge-writeback-status .dsh-knowledge-writeback-document:hover {\n background: var(--knowledge-hover);\n color: var(--knowledge-text);\n text-decoration-color: currentColor;\n}\n.dsh-knowledge-writeback-document strong { color: inherit; }\n.dsh-knowledge-writeback-destinations small {\n flex: none;\n color: var(--knowledge-text-secondary);\n font: inherit;\n white-space: nowrap;\n}\n.dsh-knowledge-writeback-destinations small[data-disposition="written"] { color: var(--knowledge-success); }\n.dsh-knowledge-writeback-error {\n max-width: min(720px, 100%);\n margin: 0;\n color: var(--knowledge-danger);\n overflow-wrap: anywhere;\n}\n';
|
|
51
|
+
|
|
52
|
+
// src/knowledge-activity.css
|
|
53
|
+
var knowledge_activity_default = '.dsh-knowledge-activity-panel {\n display: flex;\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n flex-direction: column;\n overflow: hidden;\n color: var(--knowledge-text);\n background: var(--knowledge-activity-surface);\n -webkit-backdrop-filter: var(--knowledge-host-glass-filter);\n backdrop-filter: var(--knowledge-host-glass-filter);\n box-shadow: inset 1px 0 0 var(--knowledge-border);\n font-family: var(--knowledge-font-family);\n font-size: 13px;\n line-height: 1.5;\n animation: dsh-knowledge-activity-enter 180ms cubic-bezier(.2, .8, .2, 1) both;\n}\n\n.dsh-knowledge-activity-panel *,\n.dsh-knowledge-activity-panel *::before,\n.dsh-knowledge-activity-panel *::after { box-sizing: border-box; }\n\n.dsh-knowledge-activity-panel :where(button, input) {\n -webkit-appearance: none;\n appearance: none;\n margin: 0;\n color: inherit;\n font: inherit;\n letter-spacing: inherit;\n}\n\n.dsh-knowledge-activity-header {\n display: flex;\n min-height: 58px;\n padding: 0 12px 0 15px;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n border-bottom: 1px solid var(--knowledge-border);\n background: color-mix(in srgb, var(--knowledge-raised) 54%, transparent);\n}\n\n.dsh-knowledge-activity-tabs {\n display: grid;\n min-height: 43px;\n flex: none;\n grid-template-columns: 1fr 1fr;\n gap: 4px;\n padding: 5px 10px;\n border-bottom: 1px solid var(--knowledge-border);\n background: color-mix(in srgb, var(--knowledge-raised) 30%, transparent);\n}\n.dsh-knowledge-activity-tabs button {\n display: inline-flex;\n min-width: 0;\n min-height: 32px;\n align-items: center;\n justify-content: center;\n gap: 6px;\n padding: 0 10px;\n border: 1px solid transparent;\n border-radius: 9px;\n color: var(--knowledge-text-tertiary);\n background: transparent;\n cursor: pointer;\n font-size: 12px;\n font-weight: 580;\n}\n.dsh-knowledge-activity-tabs button:hover { color: var(--knowledge-text); background: var(--knowledge-hover); }\n.dsh-knowledge-activity-tabs button.is-active {\n border-color: var(--knowledge-border);\n color: var(--knowledge-text);\n background: var(--knowledge-control);\n box-shadow: inset 0 1px 0 var(--knowledge-glare-light);\n}\n\n.dsh-knowledge-activity-title,\n.dsh-knowledge-activity-header-actions { display: flex; min-width: 0; align-items: center; gap: 9px; }\n.dsh-knowledge-activity-title > span:last-child { display: grid; min-width: 0; gap: 1px; }\n.dsh-knowledge-activity-title strong { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-title small { overflow: hidden; color: var(--knowledge-text-tertiary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }\n\n.dsh-knowledge-activity-mark,\n.dsh-knowledge-activity-document-icon,\n.dsh-knowledge-activity-row-icon {\n display: grid;\n flex: none;\n place-items: center;\n border: 1px solid color-mix(in srgb, var(--knowledge-accent) 18%, transparent);\n color: var(--knowledge-accent);\n background: color-mix(in srgb, var(--knowledge-accent) 6%, transparent);\n}\n\n.dsh-knowledge-activity-mark { width: 27px; height: 27px; border: 0; border-radius: 8px; background: transparent; }\n.dsh-knowledge-activity-icon-button {\n display: grid;\n width: 32px;\n height: 32px;\n flex: none;\n place-items: center;\n padding: 0;\n border: 1px solid transparent;\n border-radius: 9px;\n color: var(--knowledge-text-secondary);\n background: transparent;\n cursor: pointer;\n}\n.dsh-knowledge-activity-icon-button:hover { border-color: var(--knowledge-border); color: var(--knowledge-text); background: var(--knowledge-hover); }\n.dsh-knowledge-activity-icon-button:focus-visible,\n.dsh-knowledge-activity-panel button:focus-visible,\n.dsh-knowledge-activity-panel input:focus-visible { outline: 2px solid var(--knowledge-accent); outline-offset: 2px; }\n\n.dsh-knowledge-activity-browser,\n.dsh-knowledge-activity-reader {\n display: flex;\n min-height: 0;\n flex: 1;\n flex-direction: column;\n overflow: hidden;\n padding: 14px 14px 16px;\n}\n\n.dsh-knowledge-activity-search {\n display: flex;\n min-height: 40px;\n flex: none;\n align-items: center;\n gap: 8px;\n padding: 0 10px;\n border: 1px solid var(--knowledge-border);\n border-radius: 10px;\n color: var(--knowledge-text-tertiary);\n background: var(--knowledge-control);\n}\n.dsh-knowledge-activity-search:focus-within { border-color: color-mix(in srgb, var(--knowledge-accent) 50%, var(--knowledge-border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--knowledge-accent) 10%, transparent); }\n.dsh-knowledge-activity-search input { min-width: 0; height: 38px; flex: 1; padding: 0; border: 0; outline: 0 !important; color: var(--knowledge-text); background: transparent; box-shadow: none; }\n.dsh-knowledge-activity-search input::placeholder { color: var(--knowledge-text-tertiary); opacity: 1; }\n.dsh-knowledge-activity-search > button { display: grid; width: 28px; height: 28px; place-items: center; padding: 0; border: 0; border-radius: 8px; color: var(--knowledge-text-tertiary); background: transparent; cursor: pointer; }\n.dsh-knowledge-activity-search > button:hover { color: var(--knowledge-text); background: var(--knowledge-hover); }\n\n.dsh-knowledge-activity-scope { position: relative; z-index: 3; flex: none; margin-top: 10px; }\n.dsh-knowledge-activity-breadcrumbs {\n display: flex;\n min-height: 37px;\n flex: none;\n align-items: center;\n gap: 1px;\n overflow-x: auto;\n padding: 5px 1px 2px;\n color: var(--knowledge-text-tertiary);\n scrollbar-width: none;\n}\n.dsh-knowledge-activity-breadcrumbs::-webkit-scrollbar { display: none; }\n.dsh-knowledge-activity-breadcrumbs span { display: inline-flex; flex: none; align-items: center; gap: 1px; }\n.dsh-knowledge-activity-breadcrumbs button {\n max-width: 130px;\n min-height: 28px;\n overflow: hidden;\n padding: 0 7px;\n border: 0;\n border-radius: 7px;\n color: inherit;\n text-overflow: ellipsis;\n white-space: nowrap;\n background: transparent;\n cursor: pointer;\n font-size: 11px;\n}\n.dsh-knowledge-activity-breadcrumbs button:hover { color: var(--knowledge-text); background: var(--knowledge-hover); }\n.dsh-knowledge-activity-breadcrumbs button[aria-current="location"] { color: var(--knowledge-text-secondary); font-weight: 620; }\n.dsh-knowledge-activity-scope-trigger {\n display: grid;\n width: 100%;\n min-height: 48px;\n grid-template-columns: 30px minmax(0, 1fr) 20px;\n align-items: center;\n gap: 8px;\n padding: 5px 9px;\n border: 1px solid var(--knowledge-border);\n border-radius: 10px;\n text-align: left;\n background: color-mix(in srgb, var(--knowledge-control) 72%, transparent);\n cursor: pointer;\n}\n.dsh-knowledge-activity-scope-trigger:hover { background: var(--knowledge-control); }\n.dsh-knowledge-activity-scope-trigger > span:nth-child(2) { display: grid; min-width: 0; gap: 1px; }\n.dsh-knowledge-activity-scope-trigger small { color: var(--knowledge-text-tertiary); font-size: 10px; }\n.dsh-knowledge-activity-scope-trigger strong { overflow: hidden; font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-scope-trigger > svg { color: var(--knowledge-text-tertiary); transition: transform 140ms ease; }\n.dsh-knowledge-activity-scope-trigger > svg.is-open { transform: rotate(180deg); }\n.dsh-knowledge-activity-scope-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 8px; color: var(--knowledge-accent); background: color-mix(in srgb, var(--knowledge-accent) 8%, transparent); }\n.dsh-knowledge-activity-scope-menu {\n position: absolute;\n z-index: 6;\n top: calc(100% + 6px);\n right: 0;\n left: 0;\n max-height: min(320px, 44vh);\n overflow-y: auto;\n padding: 5px;\n border: 1px solid var(--knowledge-border);\n border-radius: 12px;\n background: var(--knowledge-activity-surface);\n box-shadow: 0 16px 38px rgb(24 30 32 / 18%), inset 0 1px 0 var(--knowledge-glare-light);\n -webkit-backdrop-filter: var(--knowledge-glass-filter);\n backdrop-filter: var(--knowledge-glass-filter);\n}\n.dsh-knowledge-activity-scope-menu button { display: flex; width: 100%; min-height: 46px; align-items: center; gap: 9px; padding: 6px 9px; border: 0; border-radius: 8px; text-align: left; background: transparent; cursor: pointer; }\n.dsh-knowledge-activity-scope-menu button:hover { background: var(--knowledge-hover); }\n.dsh-knowledge-activity-scope-menu button.is-active { background: var(--knowledge-control); }\n.dsh-knowledge-activity-scope-menu button > svg { flex: none; color: var(--knowledge-text-secondary); }\n.dsh-knowledge-activity-scope-menu button > span { display: grid; min-width: 0; gap: 1px; }\n.dsh-knowledge-activity-scope-menu button strong { overflow: hidden; font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-scope-menu button small { color: var(--knowledge-text-tertiary); font-size: 10px; }\n\n.dsh-knowledge-activity-list-heading {\n display: flex;\n min-height: 46px;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 8px 2px 6px;\n border-bottom: 1px solid var(--knowledge-border);\n}\n.dsh-knowledge-activity-list-heading > span { display: grid; min-width: 0; }\n.dsh-knowledge-activity-list-heading strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-list-heading small { color: var(--knowledge-text-tertiary); font-size: 11px; }\n\n.dsh-knowledge-activity-list {\n min-height: 0;\n flex: 1;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 0 0 20px;\n scrollbar-color: color-mix(in srgb, var(--knowledge-text-tertiary) 35%, transparent) transparent;\n scrollbar-width: thin;\n}\n.dsh-knowledge-activity-row {\n display: flex;\n width: 100%;\n min-height: 61px;\n align-items: center;\n gap: 9px;\n padding: 8px 6px;\n border: 0;\n border-bottom: 1px solid color-mix(in srgb, var(--knowledge-border) 72%, transparent);\n border-radius: 0;\n text-align: left;\n background: transparent;\n cursor: pointer;\n}\n.dsh-knowledge-activity-row:hover { border-radius: 8px; background: var(--knowledge-hover); }\n.dsh-knowledge-activity-row:disabled { cursor: default; opacity: .58; }\n.dsh-knowledge-activity-row:disabled:hover { border-radius: 0; background: transparent; }\n.dsh-knowledge-activity-row-icon { width: 27px; height: 27px; border: 0; border-radius: 0; background: transparent; }\n.dsh-knowledge-activity-row-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }\n.dsh-knowledge-activity-row-copy strong,\n.dsh-knowledge-activity-row-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-row-copy strong { color: var(--knowledge-text); font-size: 13px; font-weight: 600; }\n.dsh-knowledge-activity-row-copy small { color: var(--knowledge-text-tertiary); font-size: 10px; }\n.dsh-knowledge-activity-row-meta { display: grid; flex: none; justify-items: end; align-items: center; gap: 3px; color: var(--knowledge-text-tertiary); font-size: 10px; }\n.dsh-knowledge-activity-row-meta em { padding: 1px 5px; border-radius: 999px; color: var(--knowledge-text-secondary); background: var(--knowledge-control); font-style: normal; }\n.dsh-knowledge-activity-load-more { display: block; min-height: 36px; margin: 8px auto 0; padding: 0 14px; border: 1px solid var(--knowledge-border); border-radius: 10px; color: var(--knowledge-text-secondary); background: var(--knowledge-control); cursor: pointer; }\n.dsh-knowledge-activity-load-more:hover:not(:disabled) { color: var(--knowledge-text); background: var(--knowledge-hover); }\n\n.dsh-knowledge-activity-reader-bar {\n display: flex;\n min-height: 38px;\n flex: none;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n border-bottom: 1px solid var(--knowledge-border);\n color: var(--knowledge-text-tertiary);\n font-size: 11px;\n}\n.dsh-knowledge-activity-back { display: inline-flex; min-height: 32px; align-items: center; gap: 4px; padding: 0 7px 0 4px; border: 0; border-radius: 8px; color: var(--knowledge-text-secondary); background: transparent; cursor: pointer; font-size: 12px !important; }\n.dsh-knowledge-activity-back:hover { color: var(--knowledge-text); background: var(--knowledge-hover); }\n.dsh-knowledge-activity-document-heading { display: flex; flex: none; align-items: center; gap: 10px; padding: 16px 4px 13px; }\n.dsh-knowledge-activity-document-icon { width: 36px; height: 36px; border-radius: 11px; }\n.dsh-knowledge-activity-document-heading > div { min-width: 0; }\n.dsh-knowledge-activity-document-heading h2 { overflow: hidden; margin: 0; font-size: 16px; line-height: 22px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }\n.dsh-knowledge-activity-document-heading p { overflow: hidden; margin: 1px 0 0; color: var(--knowledge-text-tertiary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }\n\n.dsh-knowledge-activity-markdown {\n min-height: 0;\n flex: 1;\n overflow-y: auto;\n padding: 0 5px 44px;\n color: var(--knowledge-text);\n font-size: 13px;\n line-height: 1.75;\n overflow-wrap: anywhere;\n scrollbar-color: color-mix(in srgb, var(--knowledge-text-tertiary) 35%, transparent) transparent;\n scrollbar-width: thin;\n}\n.dsh-knowledge-activity-markdown :where(h1, h2, h3, h4) { margin: 1.35em 0 .55em; color: var(--knowledge-text); line-height: 1.35; font-weight: 680; }\n.dsh-knowledge-activity-markdown h1 { font-size: 18px; }\n.dsh-knowledge-activity-markdown h2 { padding-bottom: .35em; border-bottom: 1px solid var(--knowledge-border); font-size: 16px; }\n.dsh-knowledge-activity-markdown h3 { font-size: 14px; }\n.dsh-knowledge-activity-markdown :where(p, ul, ol, blockquote, pre, table) { margin: .7em 0; }\n.dsh-knowledge-activity-markdown :where(ul, ol) { padding-left: 1.5em; }\n.dsh-knowledge-activity-markdown a { color: var(--knowledge-accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }\n.dsh-knowledge-activity-markdown blockquote { margin-left: 0; padding: .15em 0 .15em 12px; border-left: 3px solid color-mix(in srgb, var(--knowledge-accent) 40%, transparent); color: var(--knowledge-text-secondary); }\n.dsh-knowledge-activity-markdown :where(code, pre) { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }\n.dsh-knowledge-activity-markdown code { padding: .14em .32em; border-radius: 5px; background: var(--knowledge-control); font-size: .92em; }\n.dsh-knowledge-activity-markdown pre { overflow-x: auto; padding: 11px 12px; border: 1px solid var(--knowledge-border); border-radius: 10px; background: var(--knowledge-control); }\n.dsh-knowledge-activity-markdown pre code { padding: 0; background: transparent; }\n.dsh-knowledge-activity-markdown table { width: 100%; border-collapse: collapse; font-size: 12px; }\n.dsh-knowledge-activity-markdown :where(th, td) { padding: 6px 7px; border: 1px solid var(--knowledge-border); text-align: left; }\n.dsh-knowledge-activity-markdown img { display: block; max-width: 100%; height: auto; border-radius: 10px; }\n\n.dsh-knowledge-activity-state,\n.dsh-knowledge-activity-error,\n.dsh-knowledge-activity-empty { margin: auto; text-align: center; }\n.dsh-knowledge-activity-state { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 10px; color: var(--knowledge-text-tertiary); }\n.dsh-knowledge-activity-state > span { width: 8px; height: 8px; border: 2px solid var(--knowledge-border); border-top-color: var(--knowledge-accent); border-radius: 50%; animation: dsh-knowledge-activity-spin .8s linear infinite; }\n.dsh-knowledge-activity-error,\n.dsh-knowledge-activity-empty { display: grid; max-width: 260px; justify-items: center; gap: 6px; padding: 32px 12px; }\n.dsh-knowledge-activity-error strong,\n.dsh-knowledge-activity-empty strong { font-size: 13px; font-weight: 650; }\n.dsh-knowledge-activity-error p,\n.dsh-knowledge-activity-empty p { margin: 0; color: var(--knowledge-text-tertiary); font-size: 11px; line-height: 1.65; }\n.dsh-knowledge-activity-empty > span { display: grid; width: 40px; height: 40px; margin-bottom: 3px; place-items: center; border-radius: 13px; color: var(--knowledge-text-secondary); background: var(--knowledge-control); }\n.dsh-knowledge-activity-error > button { min-height: 34px; margin-top: 6px; padding: 0 13px; border: 1px solid var(--knowledge-border); border-radius: 9px; background: var(--knowledge-control); cursor: pointer; }\n.dsh-knowledge-activity-error > button:hover { background: var(--knowledge-hover); }\n\n@keyframes dsh-knowledge-activity-enter { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }\n@keyframes dsh-knowledge-activity-spin { to { transform: rotate(360deg); } }\n\n@media (max-width: 460px) {\n .dsh-knowledge-activity-header { padding-inline: 10px; }\n .dsh-knowledge-activity-browser,\n .dsh-knowledge-activity-reader { padding: 10px 10px max(14px, env(safe-area-inset-bottom)); }\n .dsh-knowledge-activity-search input { font-size: 16px; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-knowledge-activity-panel,\n .dsh-knowledge-activity-state > span { animation: none; transition: none; }\n}\n';
|
|
54
|
+
|
|
55
|
+
// src/knowledge-activity-panel.tsx
|
|
56
|
+
var import_react2 = require("react");
|
|
57
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
58
|
+
|
|
59
|
+
// src/knowledge-activity-api.ts
|
|
60
|
+
var API_PREFIX = "/knowledge-control/v1/activity";
|
|
61
|
+
var CLIENT_HEADER = "conversation-web";
|
|
62
|
+
async function loadMountedKnowledge(sessionId, projectId, signal) {
|
|
63
|
+
const params = new URLSearchParams({ sessionId });
|
|
64
|
+
if (projectId !== void 0) params.set("projectId", projectId);
|
|
65
|
+
const value = await request(`mounts?${params}`, signal);
|
|
66
|
+
if (!Array.isArray(value)) throw new Error("\u77E5\u8BC6\u5E93\u6302\u8F7D\u63A5\u53E3\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
67
|
+
return value.filter(isResolvedMount);
|
|
68
|
+
}
|
|
69
|
+
async function loadKnowledgeDocumentIndex(input) {
|
|
70
|
+
const params = new URLSearchParams({ sessionId: input.sessionId, limit: "60" });
|
|
71
|
+
if (input.projectId !== void 0) params.set("projectId", input.projectId);
|
|
72
|
+
for (const id of input.knowledgeBaseIds) params.append("knowledgeBaseId", id);
|
|
73
|
+
if (input.query?.trim()) params.set("q", input.query.trim());
|
|
74
|
+
if (input.cursor !== void 0) params.set("cursor", input.cursor);
|
|
75
|
+
const value = await request(`documents?${params}`, input.signal);
|
|
76
|
+
if (!isDocumentIndex(value)) throw new Error("\u77E5\u8BC6\u6587\u6863\u76EE\u5F55\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
async function loadNoteIndex(input) {
|
|
80
|
+
const params = new URLSearchParams({ sessionId: input.sessionId, limit: "200" });
|
|
81
|
+
if (input.projectId !== void 0) params.set("projectId", input.projectId);
|
|
82
|
+
if (input.query?.trim()) params.set("q", input.query.trim());
|
|
83
|
+
else if (input.parentId !== void 0 && input.parentId !== null) params.set("parentId", input.parentId);
|
|
84
|
+
const value = await request(`notes?${params}`, input.signal);
|
|
85
|
+
if (!Array.isArray(value) || !value.every(isNoteNode)) throw new Error("\u7B14\u8BB0\u76EE\u5F55\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
async function loadNoteContent(input) {
|
|
89
|
+
const params = new URLSearchParams({ sessionId: input.sessionId });
|
|
90
|
+
if (input.projectId !== void 0) params.set("projectId", input.projectId);
|
|
91
|
+
const value = await request(`notes/${encodeURIComponent(input.id)}/content?${params}`, input.signal);
|
|
92
|
+
if (!isRecord(value) || !isNoteNode(value.node) || typeof value.content !== "string") {
|
|
93
|
+
throw new Error("\u7B14\u8BB0\u6B63\u6587\u63A5\u53E3\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
async function loadKnowledgeDocument(input) {
|
|
98
|
+
const params = new URLSearchParams({ sessionId: input.sessionId });
|
|
99
|
+
if (input.projectId !== void 0) params.set("projectId", input.projectId);
|
|
100
|
+
const value = await request(`documents/${encodeURIComponent(input.id)}?${params}`, input.signal);
|
|
101
|
+
if (!isDocument(value)) throw new Error("\u77E5\u8BC6\u6587\u6863\u63A5\u53E3\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
async function request(path, signal) {
|
|
105
|
+
const response = await fetch(`${API_PREFIX}/${path}`, {
|
|
106
|
+
headers: { accept: "application/json", "x-dsh-knowledge-client": CLIENT_HEADER },
|
|
107
|
+
...signal === void 0 ? {} : { signal }
|
|
108
|
+
});
|
|
109
|
+
const body = await response.json().catch(() => void 0);
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
const message3 = isRecord(body) && typeof body.error === "string" ? body.error : `\u77E5\u8BC6\u5E93\u63A5\u53E3\u8FD4\u56DE HTTP ${response.status}`;
|
|
112
|
+
throw new Error(message3);
|
|
113
|
+
}
|
|
114
|
+
return body;
|
|
115
|
+
}
|
|
116
|
+
function isResolvedMount(value) {
|
|
117
|
+
return isRecord(value) && typeof value.knowledgeBaseId === "string" && typeof value.enabled === "boolean" && isRecord(value.base) && typeof value.base.id === "string" && typeof value.base.name === "string";
|
|
118
|
+
}
|
|
119
|
+
function isDocumentIndex(value) {
|
|
120
|
+
return isRecord(value) && Array.isArray(value.items) && value.items.every(isDocumentSummary) && Number.isInteger(value.total) && (value.nextCursor === void 0 || typeof value.nextCursor === "string");
|
|
121
|
+
}
|
|
122
|
+
function isDocumentSummary(value) {
|
|
123
|
+
return isRecord(value) && typeof value.id === "string" && typeof value.knowledgeBaseId === "string" && typeof value.relPath === "string" && typeof value.title === "string" && typeof value.updatedAt === "string" && (value.documentState === "open" || value.documentState === "resolved" || value.documentState === "complete");
|
|
124
|
+
}
|
|
125
|
+
function isDocument(value) {
|
|
126
|
+
return isDocumentSummary(value) && isRecord(value) && typeof value.content === "string";
|
|
127
|
+
}
|
|
128
|
+
function isNoteNode(value) {
|
|
129
|
+
return isRecord(value) && typeof value.id === "string" && (value.parentId === null || typeof value.parentId === "string") && (value.kind === "folder" || value.kind === "document" || value.kind === "file") && typeof value.name === "string" && (value.mediaType === null || typeof value.mediaType === "string") && typeof value.editable === "boolean" && typeof value.size === "number" && typeof value.version === "number" && typeof value.updatedAt === "string";
|
|
130
|
+
}
|
|
131
|
+
function isRecord(value) {
|
|
132
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/knowledge-activity-notes.tsx
|
|
28
136
|
var import_react = require("react");
|
|
137
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
138
|
+
|
|
139
|
+
// node_modules/dompurify/dist/purify.es.mjs
|
|
140
|
+
function _arrayLikeToArray(r, a) {
|
|
141
|
+
(null == a || a > r.length) && (a = r.length);
|
|
142
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
143
|
+
return n;
|
|
144
|
+
}
|
|
145
|
+
function _arrayWithHoles(r) {
|
|
146
|
+
if (Array.isArray(r)) return r;
|
|
147
|
+
}
|
|
148
|
+
function _iterableToArrayLimit(r, l3) {
|
|
149
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
150
|
+
if (null != t) {
|
|
151
|
+
var e, n, i, u, a = [], f2 = true, o = false;
|
|
152
|
+
try {
|
|
153
|
+
if (i = (t = t.call(r)).next, 0 === l3) ;
|
|
154
|
+
else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !== l3); f2 = true) ;
|
|
155
|
+
} catch (r2) {
|
|
156
|
+
o = true, n = r2;
|
|
157
|
+
} finally {
|
|
158
|
+
try {
|
|
159
|
+
if (!f2 && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
160
|
+
} finally {
|
|
161
|
+
if (o) throw n;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return a;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function _nonIterableRest() {
|
|
168
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
169
|
+
}
|
|
170
|
+
function _slicedToArray(r, e) {
|
|
171
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
172
|
+
}
|
|
173
|
+
function _unsupportedIterableToArray(r, a) {
|
|
174
|
+
if (r) {
|
|
175
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
176
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
177
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var entries = Object.entries;
|
|
181
|
+
var setPrototypeOf = Object.setPrototypeOf;
|
|
182
|
+
var isFrozen = Object.isFrozen;
|
|
183
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
184
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
185
|
+
var freeze = Object.freeze;
|
|
186
|
+
var seal = Object.seal;
|
|
187
|
+
var create = Object.create;
|
|
188
|
+
var _ref = typeof Reflect !== "undefined" && Reflect;
|
|
189
|
+
var apply = _ref.apply;
|
|
190
|
+
var construct = _ref.construct;
|
|
191
|
+
if (!freeze) {
|
|
192
|
+
freeze = function freeze2(x2) {
|
|
193
|
+
return x2;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (!seal) {
|
|
197
|
+
seal = function seal2(x2) {
|
|
198
|
+
return x2;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
if (!apply) {
|
|
202
|
+
apply = function apply3(func, thisArg) {
|
|
203
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
204
|
+
args[_key - 2] = arguments[_key];
|
|
205
|
+
}
|
|
206
|
+
return func.apply(thisArg, args);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (!construct) {
|
|
210
|
+
construct = function construct2(Func) {
|
|
211
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
212
|
+
args[_key2 - 1] = arguments[_key2];
|
|
213
|
+
}
|
|
214
|
+
return new Func(...args);
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
var arrayForEach = unapply(Array.prototype.forEach);
|
|
218
|
+
var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
|
219
|
+
var arrayPop = unapply(Array.prototype.pop);
|
|
220
|
+
var arrayPush = unapply(Array.prototype.push);
|
|
221
|
+
var arraySplice = unapply(Array.prototype.splice);
|
|
222
|
+
var arrayIsArray = Array.isArray;
|
|
223
|
+
var stringToLowerCase = unapply(String.prototype.toLowerCase);
|
|
224
|
+
var stringToString = unapply(String.prototype.toString);
|
|
225
|
+
var stringMatch = unapply(String.prototype.match);
|
|
226
|
+
var stringReplace = unapply(String.prototype.replace);
|
|
227
|
+
var stringIndexOf = unapply(String.prototype.indexOf);
|
|
228
|
+
var stringTrim = unapply(String.prototype.trim);
|
|
229
|
+
var numberToString = unapply(Number.prototype.toString);
|
|
230
|
+
var booleanToString = unapply(Boolean.prototype.toString);
|
|
231
|
+
var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
|
|
232
|
+
var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
|
|
233
|
+
var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
|
234
|
+
var objectToString = unapply(Object.prototype.toString);
|
|
235
|
+
var regExpTest = unapply(RegExp.prototype.test);
|
|
236
|
+
var typeErrorCreate = unconstruct(TypeError);
|
|
237
|
+
function unapply(func) {
|
|
238
|
+
return function(thisArg) {
|
|
239
|
+
if (thisArg instanceof RegExp) {
|
|
240
|
+
thisArg.lastIndex = 0;
|
|
241
|
+
}
|
|
242
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
243
|
+
args[_key3 - 1] = arguments[_key3];
|
|
244
|
+
}
|
|
245
|
+
return apply(func, thisArg, args);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function unconstruct(Func) {
|
|
249
|
+
return function() {
|
|
250
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
251
|
+
args[_key4] = arguments[_key4];
|
|
252
|
+
}
|
|
253
|
+
return construct(Func, args);
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function addToSet(set, array) {
|
|
257
|
+
let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
|
|
258
|
+
if (setPrototypeOf) {
|
|
259
|
+
setPrototypeOf(set, null);
|
|
260
|
+
}
|
|
261
|
+
if (!arrayIsArray(array)) {
|
|
262
|
+
return set;
|
|
263
|
+
}
|
|
264
|
+
let l3 = array.length;
|
|
265
|
+
while (l3--) {
|
|
266
|
+
let element = array[l3];
|
|
267
|
+
if (typeof element === "string") {
|
|
268
|
+
const lcElement = transformCaseFunc(element);
|
|
269
|
+
if (lcElement !== element) {
|
|
270
|
+
if (!isFrozen(array)) {
|
|
271
|
+
array[l3] = lcElement;
|
|
272
|
+
}
|
|
273
|
+
element = lcElement;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
set[element] = true;
|
|
277
|
+
}
|
|
278
|
+
return set;
|
|
279
|
+
}
|
|
280
|
+
function cleanArray(array) {
|
|
281
|
+
for (let index = 0; index < array.length; index++) {
|
|
282
|
+
const isPropertyExist = objectHasOwnProperty(array, index);
|
|
283
|
+
if (!isPropertyExist) {
|
|
284
|
+
array[index] = null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return array;
|
|
288
|
+
}
|
|
289
|
+
function clone(object) {
|
|
290
|
+
const newObject = create(null);
|
|
291
|
+
for (const _ref2 of entries(object)) {
|
|
292
|
+
var _ref3 = _slicedToArray(_ref2, 2);
|
|
293
|
+
const property = _ref3[0];
|
|
294
|
+
const value = _ref3[1];
|
|
295
|
+
const isPropertyExist = objectHasOwnProperty(object, property);
|
|
296
|
+
if (isPropertyExist) {
|
|
297
|
+
if (arrayIsArray(value)) {
|
|
298
|
+
newObject[property] = cleanArray(value);
|
|
299
|
+
} else if (value && typeof value === "object" && value.constructor === Object) {
|
|
300
|
+
newObject[property] = clone(value);
|
|
301
|
+
} else {
|
|
302
|
+
newObject[property] = value;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return newObject;
|
|
307
|
+
}
|
|
308
|
+
function stringifyValue(value) {
|
|
309
|
+
switch (typeof value) {
|
|
310
|
+
case "string": {
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
313
|
+
case "number": {
|
|
314
|
+
return numberToString(value);
|
|
315
|
+
}
|
|
316
|
+
case "boolean": {
|
|
317
|
+
return booleanToString(value);
|
|
318
|
+
}
|
|
319
|
+
case "bigint": {
|
|
320
|
+
return bigintToString ? bigintToString(value) : "0";
|
|
321
|
+
}
|
|
322
|
+
case "symbol": {
|
|
323
|
+
return symbolToString ? symbolToString(value) : "Symbol()";
|
|
324
|
+
}
|
|
325
|
+
case "undefined": {
|
|
326
|
+
return objectToString(value);
|
|
327
|
+
}
|
|
328
|
+
case "function":
|
|
329
|
+
case "object": {
|
|
330
|
+
if (value === null) {
|
|
331
|
+
return objectToString(value);
|
|
332
|
+
}
|
|
333
|
+
const valueAsRecord = value;
|
|
334
|
+
const valueToString = lookupGetter(valueAsRecord, "toString");
|
|
335
|
+
if (typeof valueToString === "function") {
|
|
336
|
+
const stringified = valueToString(valueAsRecord);
|
|
337
|
+
return typeof stringified === "string" ? stringified : objectToString(stringified);
|
|
338
|
+
}
|
|
339
|
+
return objectToString(value);
|
|
340
|
+
}
|
|
341
|
+
default: {
|
|
342
|
+
return objectToString(value);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function lookupGetter(object, prop) {
|
|
347
|
+
while (object !== null) {
|
|
348
|
+
const desc = getOwnPropertyDescriptor(object, prop);
|
|
349
|
+
if (desc) {
|
|
350
|
+
if (desc.get) {
|
|
351
|
+
return unapply(desc.get);
|
|
352
|
+
}
|
|
353
|
+
if (typeof desc.value === "function") {
|
|
354
|
+
return unapply(desc.value);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
object = getPrototypeOf(object);
|
|
358
|
+
}
|
|
359
|
+
function fallbackValue() {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return fallbackValue;
|
|
363
|
+
}
|
|
364
|
+
function isRegex(value) {
|
|
365
|
+
try {
|
|
366
|
+
regExpTest(value, "");
|
|
367
|
+
return true;
|
|
368
|
+
} catch (_unused) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
var html$1 = freeze(["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"]);
|
|
373
|
+
var svg$1 = freeze(["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"]);
|
|
374
|
+
var svgFilters = freeze(["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"]);
|
|
375
|
+
var svgDisallowed = freeze(["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"]);
|
|
376
|
+
var mathMl$1 = freeze(["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"]);
|
|
377
|
+
var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
|
|
378
|
+
var text = freeze(["#text"]);
|
|
379
|
+
var html = freeze(["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"]);
|
|
380
|
+
var svg = freeze(["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"]);
|
|
381
|
+
var mathMl = freeze(["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"]);
|
|
382
|
+
var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
|
|
383
|
+
var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
|
|
384
|
+
var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
|
|
385
|
+
var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
|
|
386
|
+
var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
|
|
387
|
+
var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
|
388
|
+
var IS_ALLOWED_URI = seal(
|
|
389
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
390
|
+
// eslint-disable-line no-useless-escape
|
|
391
|
+
);
|
|
392
|
+
var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
|
393
|
+
var ATTR_WHITESPACE = seal(
|
|
394
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
395
|
+
// eslint-disable-line no-control-regex
|
|
396
|
+
);
|
|
397
|
+
var DOCTYPE_NAME = seal(/^html$/i);
|
|
398
|
+
var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
399
|
+
var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
|
|
400
|
+
var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
|
|
401
|
+
var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
|
|
402
|
+
var SELF_CLOSING_TAG = seal(/\/>/i);
|
|
403
|
+
var NODE_TYPE = {
|
|
404
|
+
element: 1,
|
|
405
|
+
attribute: 2,
|
|
406
|
+
text: 3,
|
|
407
|
+
cdataSection: 4,
|
|
408
|
+
entityReference: 5,
|
|
409
|
+
// Deprecated
|
|
410
|
+
entityNode: 6,
|
|
411
|
+
// Deprecated
|
|
412
|
+
processingInstruction: 7,
|
|
413
|
+
comment: 8,
|
|
414
|
+
document: 9,
|
|
415
|
+
documentType: 10,
|
|
416
|
+
documentFragment: 11,
|
|
417
|
+
notation: 12
|
|
418
|
+
// Deprecated
|
|
419
|
+
};
|
|
420
|
+
var LITERAL_TEXT_ELEMENT_NAMES = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"];
|
|
421
|
+
var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
|
|
422
|
+
var LITERAL_TEXT_CLOSE = (function() {
|
|
423
|
+
const map = {};
|
|
424
|
+
arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, (name) => {
|
|
425
|
+
map[name] = seal(new RegExp("</" + name + "(?=[\\t\\n\\f\\r />])", "i"));
|
|
426
|
+
});
|
|
427
|
+
return freeze(map);
|
|
428
|
+
})();
|
|
429
|
+
var getGlobal = function getGlobal2() {
|
|
430
|
+
return typeof window === "undefined" ? null : window;
|
|
431
|
+
};
|
|
432
|
+
var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
|
|
433
|
+
if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
let suffix = null;
|
|
437
|
+
const ATTR_NAME = "data-tt-policy-suffix";
|
|
438
|
+
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
|
439
|
+
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
|
440
|
+
}
|
|
441
|
+
const policyName = "dompurify" + (suffix ? "#" + suffix : "");
|
|
442
|
+
try {
|
|
443
|
+
return trustedTypes.createPolicy(policyName, {
|
|
444
|
+
createHTML(html2) {
|
|
445
|
+
return html2;
|
|
446
|
+
},
|
|
447
|
+
createScriptURL(scriptUrl) {
|
|
448
|
+
return scriptUrl;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
} catch (_2) {
|
|
452
|
+
console.warn("TrustedTypes policy " + policyName + " could not be created.");
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
var _createHooksMap = function _createHooksMap2() {
|
|
457
|
+
return {
|
|
458
|
+
afterSanitizeAttributes: [],
|
|
459
|
+
afterSanitizeElements: [],
|
|
460
|
+
afterSanitizeShadowDOM: [],
|
|
461
|
+
beforeSanitizeAttributes: [],
|
|
462
|
+
beforeSanitizeElements: [],
|
|
463
|
+
beforeSanitizeShadowDOM: [],
|
|
464
|
+
uponSanitizeAttribute: [],
|
|
465
|
+
uponSanitizeElement: [],
|
|
466
|
+
uponSanitizeShadowNode: []
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
var _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
|
|
470
|
+
return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
|
|
471
|
+
};
|
|
472
|
+
var _resolveObjectOption = function _resolveObjectOption2(cfg, key, makeFallback) {
|
|
473
|
+
const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
|
|
474
|
+
return value && typeof value === "object" ? clone(value) : makeFallback();
|
|
475
|
+
};
|
|
476
|
+
function createDOMPurify() {
|
|
477
|
+
let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
|
|
478
|
+
const DOMPurify = (root) => createDOMPurify(root);
|
|
479
|
+
DOMPurify.version = "3.4.14";
|
|
480
|
+
DOMPurify.removed = [];
|
|
481
|
+
if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
|
|
482
|
+
DOMPurify.isSupported = false;
|
|
483
|
+
return DOMPurify;
|
|
484
|
+
}
|
|
485
|
+
let document2 = window2.document;
|
|
486
|
+
const originalDocument = document2;
|
|
487
|
+
const currentScript = originalDocument.currentScript;
|
|
488
|
+
window2.DocumentFragment;
|
|
489
|
+
const HTMLTemplateElement = window2.HTMLTemplateElement, Node = window2.Node, Element = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap;
|
|
490
|
+
_window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap;
|
|
491
|
+
window2.HTMLFormElement;
|
|
492
|
+
const DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
|
|
493
|
+
const ElementPrototype = Element.prototype;
|
|
494
|
+
const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
|
|
495
|
+
const remove = lookupGetter(ElementPrototype, "remove");
|
|
496
|
+
const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
|
|
497
|
+
const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
|
|
498
|
+
const getParentNode = lookupGetter(ElementPrototype, "parentNode");
|
|
499
|
+
const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
|
|
500
|
+
const getAttributes = lookupGetter(ElementPrototype, "attributes");
|
|
501
|
+
const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
|
|
502
|
+
const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
|
|
503
|
+
const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
|
|
504
|
+
const _readNodeType = function _readNodeType2(node) {
|
|
505
|
+
return getNodeType ? getNodeType(node) : node.nodeType;
|
|
506
|
+
};
|
|
507
|
+
const _readNodeName = function _readNodeName2(node) {
|
|
508
|
+
return getNodeName ? getNodeName(node) : node.nodeName;
|
|
509
|
+
};
|
|
510
|
+
if (typeof HTMLTemplateElement === "function") {
|
|
511
|
+
const template = document2.createElement("template");
|
|
512
|
+
if (template.content && template.content.ownerDocument) {
|
|
513
|
+
document2 = template.content.ownerDocument;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
let trustedTypesPolicy;
|
|
517
|
+
let emptyHTML = "";
|
|
518
|
+
let defaultTrustedTypesPolicy;
|
|
519
|
+
let defaultTrustedTypesPolicyResolved = false;
|
|
520
|
+
let IN_TRUSTED_TYPES_POLICY = 0;
|
|
521
|
+
const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
|
|
522
|
+
if (IN_TRUSTED_TYPES_POLICY > 0) {
|
|
523
|
+
throw typeErrorCreate('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.');
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const _createTrustedHTML = function _createTrustedHTML2(html2) {
|
|
527
|
+
_assertNotInTrustedTypesPolicy();
|
|
528
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
529
|
+
try {
|
|
530
|
+
return trustedTypesPolicy.createHTML(html2);
|
|
531
|
+
} finally {
|
|
532
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
const _createTrustedScriptURL = function _createTrustedScriptURL2(scriptUrl) {
|
|
536
|
+
_assertNotInTrustedTypesPolicy();
|
|
537
|
+
IN_TRUSTED_TYPES_POLICY++;
|
|
538
|
+
try {
|
|
539
|
+
return trustedTypesPolicy.createScriptURL(scriptUrl);
|
|
540
|
+
} finally {
|
|
541
|
+
IN_TRUSTED_TYPES_POLICY--;
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy2() {
|
|
545
|
+
if (!defaultTrustedTypesPolicyResolved) {
|
|
546
|
+
defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
|
547
|
+
defaultTrustedTypesPolicyResolved = true;
|
|
548
|
+
}
|
|
549
|
+
return defaultTrustedTypesPolicy;
|
|
550
|
+
};
|
|
551
|
+
const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
|
|
552
|
+
const importNode = originalDocument.importNode;
|
|
553
|
+
let hooks = _createHooksMap();
|
|
554
|
+
DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
|
|
555
|
+
const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
|
|
556
|
+
let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
|
|
557
|
+
let ALLOWED_TAGS = null;
|
|
558
|
+
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
|
559
|
+
let ALLOWED_ATTR = null;
|
|
560
|
+
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
|
561
|
+
let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
562
|
+
tagNameCheck: {
|
|
563
|
+
writable: true,
|
|
564
|
+
configurable: false,
|
|
565
|
+
enumerable: true,
|
|
566
|
+
value: null
|
|
567
|
+
},
|
|
568
|
+
attributeNameCheck: {
|
|
569
|
+
writable: true,
|
|
570
|
+
configurable: false,
|
|
571
|
+
enumerable: true,
|
|
572
|
+
value: null
|
|
573
|
+
},
|
|
574
|
+
allowCustomizedBuiltInElements: {
|
|
575
|
+
writable: true,
|
|
576
|
+
configurable: false,
|
|
577
|
+
enumerable: true,
|
|
578
|
+
value: false
|
|
579
|
+
}
|
|
580
|
+
}));
|
|
581
|
+
let FORBID_TAGS = null;
|
|
582
|
+
let FORBID_ATTR = null;
|
|
583
|
+
const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
|
|
584
|
+
tagCheck: {
|
|
585
|
+
writable: true,
|
|
586
|
+
configurable: false,
|
|
587
|
+
enumerable: true,
|
|
588
|
+
value: null
|
|
589
|
+
},
|
|
590
|
+
attributeCheck: {
|
|
591
|
+
writable: true,
|
|
592
|
+
configurable: false,
|
|
593
|
+
enumerable: true,
|
|
594
|
+
value: null
|
|
595
|
+
}
|
|
596
|
+
}));
|
|
597
|
+
let ALLOW_ARIA_ATTR = true;
|
|
598
|
+
let ALLOW_DATA_ATTR = true;
|
|
599
|
+
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
|
600
|
+
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
|
601
|
+
let SAFE_FOR_TEMPLATES = false;
|
|
602
|
+
let SAFE_FOR_XML = true;
|
|
603
|
+
let WHOLE_DOCUMENT = false;
|
|
604
|
+
let SET_CONFIG = false;
|
|
605
|
+
let SET_CONFIG_ALLOWED_TAGS = null;
|
|
606
|
+
let SET_CONFIG_ALLOWED_ATTR = null;
|
|
607
|
+
let FORCE_BODY = false;
|
|
608
|
+
let RETURN_DOM = false;
|
|
609
|
+
let RETURN_DOM_FRAGMENT = false;
|
|
610
|
+
let RETURN_TRUSTED_TYPE = false;
|
|
611
|
+
let SANITIZE_DOM = true;
|
|
612
|
+
let SANITIZE_NAMED_PROPS = false;
|
|
613
|
+
const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
|
|
614
|
+
let KEEP_CONTENT = true;
|
|
615
|
+
let IN_PLACE = false;
|
|
616
|
+
let USE_PROFILES = {};
|
|
617
|
+
let FORBID_CONTENTS = null;
|
|
618
|
+
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
|
619
|
+
"annotation-xml",
|
|
620
|
+
"audio",
|
|
621
|
+
"colgroup",
|
|
622
|
+
"desc",
|
|
623
|
+
"foreignobject",
|
|
624
|
+
"head",
|
|
625
|
+
"iframe",
|
|
626
|
+
"math",
|
|
627
|
+
"mi",
|
|
628
|
+
"mn",
|
|
629
|
+
"mo",
|
|
630
|
+
"ms",
|
|
631
|
+
"mtext",
|
|
632
|
+
"noembed",
|
|
633
|
+
"noframes",
|
|
634
|
+
"noscript",
|
|
635
|
+
"plaintext",
|
|
636
|
+
"script",
|
|
637
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
638
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
639
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
640
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
641
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
642
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
643
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
644
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
645
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
646
|
+
"selectedcontent",
|
|
647
|
+
"style",
|
|
648
|
+
"svg",
|
|
649
|
+
"template",
|
|
650
|
+
"thead",
|
|
651
|
+
"title",
|
|
652
|
+
"video",
|
|
653
|
+
"xmp"
|
|
654
|
+
]);
|
|
655
|
+
let DATA_URI_TAGS = null;
|
|
656
|
+
const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
657
|
+
let URI_SAFE_ATTRIBUTES = null;
|
|
658
|
+
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
|
|
659
|
+
const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
660
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
661
|
+
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
662
|
+
let NAMESPACE = HTML_NAMESPACE;
|
|
663
|
+
let IS_EMPTY_INPUT = false;
|
|
664
|
+
let ALLOWED_NAMESPACES = null;
|
|
665
|
+
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
|
666
|
+
const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
|
|
667
|
+
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
|
|
668
|
+
const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
|
|
669
|
+
let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
|
|
670
|
+
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
|
|
671
|
+
let PARSER_MEDIA_TYPE = null;
|
|
672
|
+
const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
|
|
673
|
+
const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
|
|
674
|
+
let transformCaseFunc = null;
|
|
675
|
+
let CONFIG = null;
|
|
676
|
+
const formElement = document2.createElement("form");
|
|
677
|
+
const isRegexOrFunction = function isRegexOrFunction2(testValue) {
|
|
678
|
+
return testValue instanceof RegExp || testValue instanceof Function;
|
|
679
|
+
};
|
|
680
|
+
const _parseConfig = function _parseConfig2() {
|
|
681
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
682
|
+
if (CONFIG && CONFIG === cfg) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
if (!cfg || typeof cfg !== "object") {
|
|
686
|
+
cfg = {};
|
|
687
|
+
}
|
|
688
|
+
cfg = clone(cfg);
|
|
689
|
+
PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
|
|
690
|
+
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
|
691
|
+
transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
|
|
692
|
+
ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
|
|
693
|
+
transform: transformCaseFunc
|
|
694
|
+
});
|
|
695
|
+
ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
|
|
696
|
+
transform: transformCaseFunc
|
|
697
|
+
});
|
|
698
|
+
ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
|
|
699
|
+
transform: stringToString
|
|
700
|
+
});
|
|
701
|
+
URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
|
|
702
|
+
transform: transformCaseFunc,
|
|
703
|
+
base: DEFAULT_URI_SAFE_ATTRIBUTES
|
|
704
|
+
});
|
|
705
|
+
DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
|
|
706
|
+
transform: transformCaseFunc,
|
|
707
|
+
base: DEFAULT_DATA_URI_TAGS
|
|
708
|
+
});
|
|
709
|
+
FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
|
|
710
|
+
transform: transformCaseFunc
|
|
711
|
+
});
|
|
712
|
+
FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
|
|
713
|
+
transform: transformCaseFunc
|
|
714
|
+
});
|
|
715
|
+
FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
|
|
716
|
+
transform: transformCaseFunc
|
|
717
|
+
});
|
|
718
|
+
USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
|
|
719
|
+
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
|
720
|
+
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
|
721
|
+
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
|
722
|
+
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
|
723
|
+
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
|
724
|
+
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
|
|
725
|
+
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
|
726
|
+
RETURN_DOM = cfg.RETURN_DOM || false;
|
|
727
|
+
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
|
728
|
+
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
|
729
|
+
FORCE_BODY = cfg.FORCE_BODY || false;
|
|
730
|
+
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
|
731
|
+
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
|
732
|
+
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
|
733
|
+
IN_PLACE = cfg.IN_PLACE || false;
|
|
734
|
+
IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
|
|
735
|
+
NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
|
|
736
|
+
MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(
|
|
737
|
+
cfg,
|
|
738
|
+
"MATHML_TEXT_INTEGRATION_POINTS",
|
|
739
|
+
() => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS)
|
|
740
|
+
// Default built-in map
|
|
741
|
+
);
|
|
742
|
+
HTML_INTEGRATION_POINTS = _resolveObjectOption(
|
|
743
|
+
cfg,
|
|
744
|
+
"HTML_INTEGRATION_POINTS",
|
|
745
|
+
() => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS)
|
|
746
|
+
// Default built-in map
|
|
747
|
+
);
|
|
748
|
+
const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
|
|
749
|
+
CUSTOM_ELEMENT_HANDLING = create(null);
|
|
750
|
+
if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
|
|
751
|
+
CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
|
|
752
|
+
}
|
|
753
|
+
if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
|
|
754
|
+
CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
|
|
755
|
+
}
|
|
756
|
+
if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
|
|
757
|
+
CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
|
|
758
|
+
}
|
|
759
|
+
seal(CUSTOM_ELEMENT_HANDLING);
|
|
760
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
761
|
+
ALLOW_DATA_ATTR = false;
|
|
762
|
+
}
|
|
763
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
764
|
+
RETURN_DOM = true;
|
|
765
|
+
}
|
|
766
|
+
if (USE_PROFILES) {
|
|
767
|
+
ALLOWED_TAGS = addToSet({}, text);
|
|
768
|
+
ALLOWED_ATTR = create(null);
|
|
769
|
+
if (USE_PROFILES.html === true) {
|
|
770
|
+
addToSet(ALLOWED_TAGS, html$1);
|
|
771
|
+
addToSet(ALLOWED_ATTR, html);
|
|
772
|
+
}
|
|
773
|
+
if (USE_PROFILES.svg === true) {
|
|
774
|
+
addToSet(ALLOWED_TAGS, svg$1);
|
|
775
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
776
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
777
|
+
}
|
|
778
|
+
if (USE_PROFILES.svgFilters === true) {
|
|
779
|
+
addToSet(ALLOWED_TAGS, svgFilters);
|
|
780
|
+
addToSet(ALLOWED_ATTR, svg);
|
|
781
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
782
|
+
}
|
|
783
|
+
if (USE_PROFILES.mathMl === true) {
|
|
784
|
+
addToSet(ALLOWED_TAGS, mathMl$1);
|
|
785
|
+
addToSet(ALLOWED_ATTR, mathMl);
|
|
786
|
+
addToSet(ALLOWED_ATTR, xml);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
790
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
791
|
+
if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
|
|
792
|
+
if (typeof cfg.ADD_TAGS === "function") {
|
|
793
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
|
|
794
|
+
} else if (arrayIsArray(cfg.ADD_TAGS)) {
|
|
795
|
+
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
|
796
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
797
|
+
}
|
|
798
|
+
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
|
|
802
|
+
if (typeof cfg.ADD_ATTR === "function") {
|
|
803
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
|
|
804
|
+
} else if (arrayIsArray(cfg.ADD_ATTR)) {
|
|
805
|
+
if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
|
|
806
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
807
|
+
}
|
|
808
|
+
addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
|
|
812
|
+
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
|
813
|
+
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
|
814
|
+
}
|
|
815
|
+
addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
|
|
816
|
+
}
|
|
817
|
+
if (KEEP_CONTENT) {
|
|
818
|
+
ALLOWED_TAGS["#text"] = true;
|
|
819
|
+
}
|
|
820
|
+
if (WHOLE_DOCUMENT) {
|
|
821
|
+
addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
|
|
822
|
+
}
|
|
823
|
+
if (ALLOWED_TAGS.table) {
|
|
824
|
+
addToSet(ALLOWED_TAGS, ["tbody"]);
|
|
825
|
+
delete FORBID_TAGS.tbody;
|
|
826
|
+
}
|
|
827
|
+
if (cfg.TRUSTED_TYPES_POLICY) {
|
|
828
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
|
|
829
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
830
|
+
}
|
|
831
|
+
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
|
|
832
|
+
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
833
|
+
}
|
|
834
|
+
const previousTrustedTypesPolicy = trustedTypesPolicy;
|
|
835
|
+
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
|
836
|
+
try {
|
|
837
|
+
emptyHTML = _createTrustedHTML("");
|
|
838
|
+
} catch (error) {
|
|
839
|
+
trustedTypesPolicy = previousTrustedTypesPolicy;
|
|
840
|
+
throw error;
|
|
841
|
+
}
|
|
842
|
+
} else if (cfg.TRUSTED_TYPES_POLICY === null) {
|
|
843
|
+
trustedTypesPolicy = void 0;
|
|
844
|
+
emptyHTML = "";
|
|
845
|
+
} else {
|
|
846
|
+
if (trustedTypesPolicy === void 0) {
|
|
847
|
+
trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
|
|
848
|
+
}
|
|
849
|
+
if (trustedTypesPolicy && typeof emptyHTML === "string") {
|
|
850
|
+
emptyHTML = _createTrustedHTML("");
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
if (freeze) {
|
|
854
|
+
freeze(cfg);
|
|
855
|
+
}
|
|
856
|
+
CONFIG = cfg;
|
|
857
|
+
};
|
|
858
|
+
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
|
859
|
+
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
|
860
|
+
const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
|
|
861
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
862
|
+
return tagName === "svg";
|
|
863
|
+
}
|
|
864
|
+
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
|
865
|
+
return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
|
866
|
+
}
|
|
867
|
+
return Boolean(ALL_SVG_TAGS[tagName]);
|
|
868
|
+
};
|
|
869
|
+
const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
|
|
870
|
+
if (parent.namespaceURI === HTML_NAMESPACE) {
|
|
871
|
+
return tagName === "math";
|
|
872
|
+
}
|
|
873
|
+
if (parent.namespaceURI === SVG_NAMESPACE) {
|
|
874
|
+
return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
|
|
875
|
+
}
|
|
876
|
+
return Boolean(ALL_MATHML_TAGS[tagName]);
|
|
877
|
+
};
|
|
878
|
+
const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
|
|
879
|
+
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
|
880
|
+
return false;
|
|
881
|
+
}
|
|
882
|
+
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
|
883
|
+
return false;
|
|
884
|
+
}
|
|
885
|
+
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
|
886
|
+
};
|
|
887
|
+
const _checkValidNamespace = function _checkValidNamespace2(element) {
|
|
888
|
+
let parent = getParentNode(element);
|
|
889
|
+
if (!parent || !parent.tagName) {
|
|
890
|
+
parent = {
|
|
891
|
+
namespaceURI: NAMESPACE,
|
|
892
|
+
tagName: "template"
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
const tagName = stringToLowerCase(element.tagName);
|
|
896
|
+
const parentTagName = stringToLowerCase(parent.tagName);
|
|
897
|
+
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
if (element.namespaceURI === SVG_NAMESPACE) {
|
|
901
|
+
return _checkSvgNamespace(tagName, parent, parentTagName);
|
|
902
|
+
}
|
|
903
|
+
if (element.namespaceURI === MATHML_NAMESPACE) {
|
|
904
|
+
return _checkMathMlNamespace(tagName, parent, parentTagName);
|
|
905
|
+
}
|
|
906
|
+
if (element.namespaceURI === HTML_NAMESPACE) {
|
|
907
|
+
return _checkHtmlNamespace(tagName, parent, parentTagName);
|
|
908
|
+
}
|
|
909
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
return false;
|
|
913
|
+
};
|
|
914
|
+
const _forceRemove = function _forceRemove2(node) {
|
|
915
|
+
arrayPush(DOMPurify.removed, {
|
|
916
|
+
element: node
|
|
917
|
+
});
|
|
918
|
+
try {
|
|
919
|
+
getParentNode(node).removeChild(node);
|
|
920
|
+
} catch (_2) {
|
|
921
|
+
remove(node);
|
|
922
|
+
if (!getParentNode(node)) {
|
|
923
|
+
throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const _stripAttributeNode = function _stripAttributeNode2(element, attribute, name) {
|
|
928
|
+
try {
|
|
929
|
+
element.removeAttributeNode(attribute);
|
|
930
|
+
} catch (_2) {
|
|
931
|
+
try {
|
|
932
|
+
element.removeAttribute(name);
|
|
933
|
+
} catch (_3) {
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
const _neutralizeRoot = function _neutralizeRoot2(root) {
|
|
938
|
+
_neutralizeSubtree(root);
|
|
939
|
+
const childNodes = getChildNodes(root);
|
|
940
|
+
if (childNodes) {
|
|
941
|
+
const snapshot = [];
|
|
942
|
+
arrayForEach(childNodes, (child) => {
|
|
943
|
+
arrayPush(snapshot, child);
|
|
944
|
+
});
|
|
945
|
+
arrayForEach(snapshot, (child) => {
|
|
946
|
+
try {
|
|
947
|
+
remove(child);
|
|
948
|
+
} catch (_2) {
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
const attributes = getAttributes(root);
|
|
953
|
+
if (attributes) {
|
|
954
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
955
|
+
const attribute = attributes[i];
|
|
956
|
+
const name = attribute && attribute.name;
|
|
957
|
+
if (typeof name === "string") {
|
|
958
|
+
_stripAttributeNode(root, attribute, name);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
const _removeAttribute = function _removeAttribute2(name, element, attr) {
|
|
964
|
+
if (!attr) {
|
|
965
|
+
try {
|
|
966
|
+
attr = element.getAttributeNode(name);
|
|
967
|
+
} catch (_2) {
|
|
968
|
+
attr = null;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
arrayPush(DOMPurify.removed, {
|
|
972
|
+
attribute: attr || null,
|
|
973
|
+
from: element
|
|
974
|
+
});
|
|
975
|
+
try {
|
|
976
|
+
if (attr) {
|
|
977
|
+
element.removeAttributeNode(attr);
|
|
978
|
+
} else {
|
|
979
|
+
element.removeAttribute(name);
|
|
980
|
+
}
|
|
981
|
+
} catch (_2) {
|
|
982
|
+
try {
|
|
983
|
+
element.removeAttribute(name);
|
|
984
|
+
} catch (_3) {
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (name === "is") {
|
|
988
|
+
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
|
989
|
+
try {
|
|
990
|
+
_forceRemove(element);
|
|
991
|
+
} catch (_2) {
|
|
992
|
+
}
|
|
993
|
+
} else {
|
|
994
|
+
try {
|
|
995
|
+
element.setAttribute(name, "");
|
|
996
|
+
} catch (_2) {
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
|
|
1002
|
+
const attributes = getAttributes(element);
|
|
1003
|
+
if (!attributes) {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
for (let i = attributes.length - 1; i >= 0; --i) {
|
|
1007
|
+
const attribute = attributes[i];
|
|
1008
|
+
const name = attribute && attribute.name;
|
|
1009
|
+
if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) {
|
|
1010
|
+
continue;
|
|
1011
|
+
}
|
|
1012
|
+
_stripAttributeNode(element, attribute, name);
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
const _neutralizeSubtree = function _neutralizeSubtree2(root) {
|
|
1016
|
+
const stack = [root];
|
|
1017
|
+
while (stack.length > 0) {
|
|
1018
|
+
const node = stack.pop();
|
|
1019
|
+
const nodeType = _readNodeType(node);
|
|
1020
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1021
|
+
_stripDisallowedAttributes(node);
|
|
1022
|
+
}
|
|
1023
|
+
const childNodes = getChildNodes(node);
|
|
1024
|
+
if (childNodes) {
|
|
1025
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1026
|
+
stack.push(childNodes[i]);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
const _isPatchLinkageAttribute = function _isPatchLinkageAttribute2(lcName, lcTag) {
|
|
1032
|
+
if (!SAFE_FOR_XML) {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
if (lcName === "patchsrc") {
|
|
1036
|
+
return true;
|
|
1037
|
+
}
|
|
1038
|
+
return lcName === "for" && lcTag !== "label" && lcTag !== "output";
|
|
1039
|
+
};
|
|
1040
|
+
const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
|
|
1041
|
+
if (!SAFE_FOR_XML) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const stack = [root];
|
|
1045
|
+
while (stack.length > 0) {
|
|
1046
|
+
const node = stack.pop();
|
|
1047
|
+
const nodeType = _readNodeType(node);
|
|
1048
|
+
if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
|
|
1049
|
+
try {
|
|
1050
|
+
remove(node);
|
|
1051
|
+
} catch (_2) {
|
|
1052
|
+
}
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
if (nodeType === NODE_TYPE.element) {
|
|
1056
|
+
const element = node;
|
|
1057
|
+
const lcTag = transformCaseFunc(_readNodeName(node));
|
|
1058
|
+
try {
|
|
1059
|
+
if (element.hasAttribute && element.hasAttribute("patchsrc")) {
|
|
1060
|
+
element.removeAttribute("patchsrc");
|
|
1061
|
+
}
|
|
1062
|
+
if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) {
|
|
1063
|
+
element.removeAttribute("for");
|
|
1064
|
+
}
|
|
1065
|
+
} catch (_2) {
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
const childNodes = getChildNodes(node);
|
|
1069
|
+
if (childNodes) {
|
|
1070
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1071
|
+
stack.push(childNodes[i]);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
const _initDocument = function _initDocument2(dirty) {
|
|
1077
|
+
let doc = null;
|
|
1078
|
+
let leadingWhitespace = null;
|
|
1079
|
+
if (FORCE_BODY) {
|
|
1080
|
+
dirty = "<remove></remove>" + dirty;
|
|
1081
|
+
} else {
|
|
1082
|
+
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
|
1083
|
+
leadingWhitespace = matches && matches[0];
|
|
1084
|
+
}
|
|
1085
|
+
if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
|
|
1086
|
+
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
|
|
1087
|
+
}
|
|
1088
|
+
const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
|
|
1089
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
1090
|
+
try {
|
|
1091
|
+
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
|
1092
|
+
} catch (_2) {
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
if (!doc || !doc.documentElement) {
|
|
1096
|
+
doc = implementation.createDocument(NAMESPACE, "template", null);
|
|
1097
|
+
try {
|
|
1098
|
+
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
|
1099
|
+
} catch (_2) {
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
const body = doc.body || doc.documentElement;
|
|
1103
|
+
if (dirty && leadingWhitespace) {
|
|
1104
|
+
body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
|
1105
|
+
}
|
|
1106
|
+
if (NAMESPACE === HTML_NAMESPACE) {
|
|
1107
|
+
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
|
|
1108
|
+
}
|
|
1109
|
+
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
|
1110
|
+
};
|
|
1111
|
+
const _createNodeIterator = function _createNodeIterator2(root) {
|
|
1112
|
+
const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
|
|
1113
|
+
return createNodeIterator.call(
|
|
1114
|
+
doc || root,
|
|
1115
|
+
root,
|
|
1116
|
+
// eslint-disable-next-line no-bitwise
|
|
1117
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
|
|
1118
|
+
null
|
|
1119
|
+
);
|
|
1120
|
+
};
|
|
1121
|
+
const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
|
|
1122
|
+
value = stringReplace(value, MUSTACHE_EXPR$1, " ");
|
|
1123
|
+
value = stringReplace(value, ERB_EXPR$1, " ");
|
|
1124
|
+
value = stringReplace(value, TMPLIT_EXPR$1, " ");
|
|
1125
|
+
return value;
|
|
1126
|
+
};
|
|
1127
|
+
const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
|
|
1128
|
+
var _node$querySelectorAl;
|
|
1129
|
+
node.normalize();
|
|
1130
|
+
const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
|
|
1131
|
+
const walker = createNodeIterator.call(
|
|
1132
|
+
doc || node,
|
|
1133
|
+
node,
|
|
1134
|
+
// eslint-disable-next-line no-bitwise
|
|
1135
|
+
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION,
|
|
1136
|
+
null
|
|
1137
|
+
);
|
|
1138
|
+
let currentNode = walker.nextNode();
|
|
1139
|
+
while (currentNode) {
|
|
1140
|
+
currentNode.data = _stripTemplateExpressions(currentNode.data);
|
|
1141
|
+
currentNode = walker.nextNode();
|
|
1142
|
+
}
|
|
1143
|
+
const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
|
|
1144
|
+
if (templates) {
|
|
1145
|
+
arrayForEach(templates, (tmpl) => {
|
|
1146
|
+
if (_isDocumentFragment(tmpl.content)) {
|
|
1147
|
+
_scrubTemplateExpressions2(tmpl.content);
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
const _isClobbered = function _isClobbered2(element) {
|
|
1153
|
+
const realTagName = getNodeName ? getNodeName(element) : null;
|
|
1154
|
+
if (typeof realTagName !== "string") {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
if (transformCaseFunc(realTagName) !== "form") {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || // Realm-safe NamedNodeMap detection: equality against the cached
|
|
1161
|
+
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
|
|
1162
|
+
// makes the direct read diverge from the cached read; a clean form
|
|
1163
|
+
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
1164
|
+
// canonical NamedNodeMap.
|
|
1165
|
+
element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
1166
|
+
// returns the integer 1 for any Element regardless of realm; direct
|
|
1167
|
+
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
1168
|
+
// the named child element. Cheap addition — nodeType is read from
|
|
1169
|
+
// an internal slot, no serialization cost — and removes a residual
|
|
1170
|
+
// clobbering surface used by several mXSS / PI / comment branches
|
|
1171
|
+
// in _sanitizeElements that compare currentNode.nodeType directly.
|
|
1172
|
+
element.nodeType !== getNodeType(element) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
|
|
1173
|
+
// "childNodes" shadows the prototype getter. Direct reads of
|
|
1174
|
+
// form.childNodes from a clobbered form return the named child
|
|
1175
|
+
// instead of the real NodeList, so any walk that reads it directly
|
|
1176
|
+
// skips the form's real children. Compare the direct read to the
|
|
1177
|
+
// cached Node.prototype getter — when the form's named-property
|
|
1178
|
+
// getter intercepts the read, the two values differ and we flag
|
|
1179
|
+
// the form. This catches every clobbering child type (input,
|
|
1180
|
+
// select, etc.) regardless of whether the named child happens to
|
|
1181
|
+
// carry a numeric .length, which a typeof-based probe would miss
|
|
1182
|
+
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
|
|
1183
|
+
element.childNodes !== getChildNodes(element);
|
|
1184
|
+
};
|
|
1185
|
+
const _isDocumentFragment = function _isDocumentFragment2(value) {
|
|
1186
|
+
if (!getNodeType || typeof value !== "object" || value === null) {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
try {
|
|
1190
|
+
return getNodeType(value) === NODE_TYPE.documentFragment;
|
|
1191
|
+
} catch (_2) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
const _isNode = function _isNode2(value) {
|
|
1196
|
+
if (!getNodeType || typeof value !== "object" || value === null) {
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
try {
|
|
1200
|
+
return typeof getNodeType(value) === "number";
|
|
1201
|
+
} catch (_2) {
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
function _executeHooks(hooks2, currentNode, data) {
|
|
1206
|
+
if (hooks2.length === 0) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
arrayForEach(hooks2, (hook) => {
|
|
1210
|
+
hook.call(DOMPurify, currentNode, data, CONFIG);
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
|
|
1214
|
+
if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
|
|
1215
|
+
return true;
|
|
1216
|
+
}
|
|
1217
|
+
if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) {
|
|
1218
|
+
return true;
|
|
1219
|
+
}
|
|
1220
|
+
if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
|
|
1221
|
+
return true;
|
|
1222
|
+
}
|
|
1223
|
+
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
|
|
1224
|
+
return true;
|
|
1225
|
+
}
|
|
1226
|
+
return false;
|
|
1227
|
+
};
|
|
1228
|
+
const _matchesNameCheck = function _matchesNameCheck2(check, name) {
|
|
1229
|
+
if (check instanceof RegExp) {
|
|
1230
|
+
return regExpTest(check, name);
|
|
1231
|
+
}
|
|
1232
|
+
if (check instanceof Function) {
|
|
1233
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1234
|
+
args[_key - 2] = arguments[_key];
|
|
1235
|
+
}
|
|
1236
|
+
return Boolean(check(name, ...args));
|
|
1237
|
+
}
|
|
1238
|
+
return false;
|
|
1239
|
+
};
|
|
1240
|
+
const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
|
|
1241
|
+
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
|
1245
|
+
const parentNode = getParentNode(currentNode);
|
|
1246
|
+
const childNodes = getChildNodes(currentNode);
|
|
1247
|
+
if (childNodes && parentNode) {
|
|
1248
|
+
const childCount = childNodes.length;
|
|
1249
|
+
for (let i = childCount - 1; i >= 0; --i) {
|
|
1250
|
+
const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
|
|
1251
|
+
parentNode.insertBefore(hoisted, getNextSibling(currentNode));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
_forceRemove(currentNode);
|
|
1256
|
+
return true;
|
|
1257
|
+
};
|
|
1258
|
+
const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
|
|
1259
|
+
if (hookList.length === 0) {
|
|
1260
|
+
return set;
|
|
1261
|
+
}
|
|
1262
|
+
return set === defaultSet || set === setConfigSet ? clone(set) : set;
|
|
1263
|
+
};
|
|
1264
|
+
const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
|
|
1265
|
+
if (currentNode === root || getParentNode(currentNode) !== null) {
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
if (IN_PLACE) {
|
|
1269
|
+
_neutralizeSubtree(currentNode);
|
|
1270
|
+
}
|
|
1271
|
+
return true;
|
|
1272
|
+
};
|
|
1273
|
+
const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
|
|
1274
|
+
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
|
1275
|
+
if (_handleHookDetachedNode(currentNode, root)) {
|
|
1276
|
+
return true;
|
|
1277
|
+
}
|
|
1278
|
+
if (_isClobbered(currentNode)) {
|
|
1279
|
+
_forceRemove(currentNode);
|
|
1280
|
+
return true;
|
|
1281
|
+
}
|
|
1282
|
+
const tagName = transformCaseFunc(_readNodeName(currentNode));
|
|
1283
|
+
ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
|
|
1284
|
+
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
|
1285
|
+
tagName,
|
|
1286
|
+
allowedTags: ALLOWED_TAGS
|
|
1287
|
+
});
|
|
1288
|
+
if (_handleHookDetachedNode(currentNode, root)) {
|
|
1289
|
+
return true;
|
|
1290
|
+
}
|
|
1291
|
+
if (_isUnsafeNode(currentNode, tagName)) {
|
|
1292
|
+
_forceRemove(currentNode);
|
|
1293
|
+
return true;
|
|
1294
|
+
}
|
|
1295
|
+
if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
|
|
1296
|
+
const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
|
|
1297
|
+
if (removed === false) {
|
|
1298
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1299
|
+
}
|
|
1300
|
+
return removed;
|
|
1301
|
+
}
|
|
1302
|
+
const nt2 = _readNodeType(currentNode);
|
|
1303
|
+
if (nt2 === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
|
|
1304
|
+
_forceRemove(currentNode);
|
|
1305
|
+
return true;
|
|
1306
|
+
}
|
|
1307
|
+
if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
|
|
1308
|
+
_forceRemove(currentNode);
|
|
1309
|
+
return true;
|
|
1310
|
+
}
|
|
1311
|
+
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
|
1312
|
+
const content = _stripTemplateExpressions(currentNode.textContent);
|
|
1313
|
+
if (currentNode.textContent !== content) {
|
|
1314
|
+
arrayPush(DOMPurify.removed, {
|
|
1315
|
+
element: currentNode.cloneNode()
|
|
1316
|
+
});
|
|
1317
|
+
currentNode.textContent = content;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
|
1321
|
+
return false;
|
|
1322
|
+
};
|
|
1323
|
+
const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
|
|
1324
|
+
if (FORBID_ATTR[lcName]) {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
if (_isPatchLinkageAttribute(lcName, lcTag)) {
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1330
|
+
if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
|
|
1331
|
+
return false;
|
|
1332
|
+
}
|
|
1333
|
+
const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
|
|
1334
|
+
if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {
|
|
1338
|
+
return true;
|
|
1339
|
+
}
|
|
1340
|
+
if (!nameIsPermitted) {
|
|
1341
|
+
return (
|
|
1342
|
+
// Condition a) covers a basically valid custom element tag name whose
|
|
1343
|
+
// tag passes the configured tagNameCheck and whose attribute name
|
|
1344
|
+
// passes the configured attributeNameCheck ...
|
|
1345
|
+
_isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || // Condition b) covers an `is` attribute whose value passes the
|
|
1346
|
+
// configured tagNameCheck while customized built-in elements are
|
|
1347
|
+
// allowed.
|
|
1348
|
+
lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
if (URI_SAFE_ATTRIBUTES[lcName]) {
|
|
1352
|
+
return true;
|
|
1353
|
+
}
|
|
1354
|
+
if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
|
|
1355
|
+
return true;
|
|
1356
|
+
}
|
|
1357
|
+
if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) {
|
|
1358
|
+
return true;
|
|
1359
|
+
}
|
|
1360
|
+
if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
return !value;
|
|
1364
|
+
};
|
|
1365
|
+
const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
|
|
1366
|
+
const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
|
|
1367
|
+
return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
|
|
1368
|
+
};
|
|
1369
|
+
const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
|
|
1370
|
+
if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
|
|
1371
|
+
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
|
1372
|
+
case "TrustedHTML": {
|
|
1373
|
+
return _createTrustedHTML(value);
|
|
1374
|
+
}
|
|
1375
|
+
case "TrustedScriptURL": {
|
|
1376
|
+
return _createTrustedScriptURL(value);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return value;
|
|
1381
|
+
};
|
|
1382
|
+
const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
|
|
1383
|
+
try {
|
|
1384
|
+
if (namespaceURI) {
|
|
1385
|
+
currentNode.setAttributeNS(namespaceURI, name, value);
|
|
1386
|
+
} else {
|
|
1387
|
+
currentNode.setAttribute(name, value);
|
|
1388
|
+
}
|
|
1389
|
+
if (_isClobbered(currentNode)) {
|
|
1390
|
+
_forceRemove(currentNode);
|
|
1391
|
+
} else {
|
|
1392
|
+
arrayPop(DOMPurify.removed);
|
|
1393
|
+
}
|
|
1394
|
+
} catch (_2) {
|
|
1395
|
+
_removeAttribute(name, currentNode);
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
|
|
1399
|
+
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
|
1400
|
+
const attributes = currentNode.attributes;
|
|
1401
|
+
if (!attributes || _isClobbered(currentNode)) {
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
|
|
1405
|
+
const hookEvent = {
|
|
1406
|
+
attrName: "",
|
|
1407
|
+
attrValue: "",
|
|
1408
|
+
keepAttr: true,
|
|
1409
|
+
allowedAttributes: ALLOWED_ATTR,
|
|
1410
|
+
forceKeepAttr: void 0
|
|
1411
|
+
};
|
|
1412
|
+
let l3 = attributes.length;
|
|
1413
|
+
const lcTag = transformCaseFunc(currentNode.nodeName);
|
|
1414
|
+
while (l3--) {
|
|
1415
|
+
const attr = attributes[l3];
|
|
1416
|
+
const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
|
|
1417
|
+
const lcName = transformCaseFunc(name);
|
|
1418
|
+
const initValue = attrValue;
|
|
1419
|
+
let value = name === "value" ? initValue : stringTrim(initValue);
|
|
1420
|
+
hookEvent.attrName = lcName;
|
|
1421
|
+
hookEvent.attrValue = value;
|
|
1422
|
+
hookEvent.keepAttr = true;
|
|
1423
|
+
hookEvent.forceKeepAttr = void 0;
|
|
1424
|
+
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
|
1425
|
+
value = hookEvent.attrValue;
|
|
1426
|
+
if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
|
|
1427
|
+
_removeAttribute(name, currentNode, attr);
|
|
1428
|
+
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1429
|
+
}
|
|
1430
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
1431
|
+
_removeAttribute(name, currentNode, attr);
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
if (lcName === "attributename" && stringMatch(value, "href")) {
|
|
1435
|
+
_removeAttribute(name, currentNode, attr);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (hookEvent.forceKeepAttr) {
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
if (!hookEvent.keepAttr) {
|
|
1442
|
+
_removeAttribute(name, currentNode, attr);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
|
|
1446
|
+
_removeAttribute(name, currentNode, attr);
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1450
|
+
value = _stripTemplateExpressions(value);
|
|
1451
|
+
}
|
|
1452
|
+
if (!_isValidAttribute(lcTag, lcName, value)) {
|
|
1453
|
+
_removeAttribute(name, currentNode, attr);
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
|
|
1457
|
+
if (value !== initValue) {
|
|
1458
|
+
_setAttributeValue(currentNode, name, namespaceURI, value);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
|
1462
|
+
};
|
|
1463
|
+
const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
|
|
1464
|
+
let shadowNode = null;
|
|
1465
|
+
const shadowIterator = _createNodeIterator(fragment);
|
|
1466
|
+
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
|
1467
|
+
while (shadowNode = shadowIterator.nextNode()) {
|
|
1468
|
+
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
|
1469
|
+
_sanitizeElements(shadowNode, fragment);
|
|
1470
|
+
_sanitizeAttributes(shadowNode);
|
|
1471
|
+
if (_isDocumentFragment(shadowNode.content)) {
|
|
1472
|
+
_sanitizeShadowDOM2(shadowNode.content);
|
|
1473
|
+
}
|
|
1474
|
+
if (_readNodeType(shadowNode) === NODE_TYPE.element) {
|
|
1475
|
+
const innerSr = getShadowRoot(shadowNode);
|
|
1476
|
+
if (_isDocumentFragment(innerSr)) {
|
|
1477
|
+
_sanitizeAttachedShadowRoots(innerSr);
|
|
1478
|
+
_sanitizeShadowDOM2(innerSr);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
|
1483
|
+
};
|
|
1484
|
+
const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
|
|
1485
|
+
const stack = [{
|
|
1486
|
+
node: root,
|
|
1487
|
+
shadow: null
|
|
1488
|
+
}];
|
|
1489
|
+
while (stack.length > 0) {
|
|
1490
|
+
const item = stack.pop();
|
|
1491
|
+
if (item.shadow) {
|
|
1492
|
+
_sanitizeShadowDOM2(item.shadow);
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
const node = item.node;
|
|
1496
|
+
const nodeType = _readNodeType(node);
|
|
1497
|
+
const isElement = nodeType === NODE_TYPE.element;
|
|
1498
|
+
const childNodes = getChildNodes(node);
|
|
1499
|
+
if (childNodes) {
|
|
1500
|
+
for (let i = childNodes.length - 1; i >= 0; --i) {
|
|
1501
|
+
stack.push({
|
|
1502
|
+
node: childNodes[i],
|
|
1503
|
+
shadow: null
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
if (isElement) {
|
|
1508
|
+
const rootName = getNodeName ? getNodeName(node) : null;
|
|
1509
|
+
if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
|
|
1510
|
+
const content = node.content;
|
|
1511
|
+
if (_isDocumentFragment(content)) {
|
|
1512
|
+
stack.push({
|
|
1513
|
+
node: content,
|
|
1514
|
+
shadow: null
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (isElement) {
|
|
1520
|
+
const sr = getShadowRoot(node);
|
|
1521
|
+
if (_isDocumentFragment(sr)) {
|
|
1522
|
+
stack.push({
|
|
1523
|
+
node: null,
|
|
1524
|
+
shadow: sr
|
|
1525
|
+
}, {
|
|
1526
|
+
node: sr,
|
|
1527
|
+
shadow: null
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
DOMPurify.sanitize = function(dirty) {
|
|
1534
|
+
let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1535
|
+
let body = null;
|
|
1536
|
+
let importedNode = null;
|
|
1537
|
+
let currentNode = null;
|
|
1538
|
+
let returnNode = null;
|
|
1539
|
+
IS_EMPTY_INPUT = !dirty;
|
|
1540
|
+
if (IS_EMPTY_INPUT) {
|
|
1541
|
+
dirty = "<!-->";
|
|
1542
|
+
}
|
|
1543
|
+
if (typeof dirty !== "string" && !_isNode(dirty)) {
|
|
1544
|
+
dirty = stringifyValue(dirty);
|
|
1545
|
+
if (typeof dirty !== "string") {
|
|
1546
|
+
throw typeErrorCreate("dirty is not a string, aborting");
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
if (!DOMPurify.isSupported) {
|
|
1550
|
+
return dirty;
|
|
1551
|
+
}
|
|
1552
|
+
if (SET_CONFIG) {
|
|
1553
|
+
ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
|
|
1554
|
+
ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
|
|
1555
|
+
} else {
|
|
1556
|
+
_parseConfig(cfg);
|
|
1557
|
+
}
|
|
1558
|
+
if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
|
|
1559
|
+
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
|
1560
|
+
}
|
|
1561
|
+
if (hooks.uponSanitizeAttribute.length > 0) {
|
|
1562
|
+
ALLOWED_ATTR = clone(ALLOWED_ATTR);
|
|
1563
|
+
}
|
|
1564
|
+
DOMPurify.removed = [];
|
|
1565
|
+
const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
|
|
1566
|
+
if (inPlace) {
|
|
1567
|
+
_neutralizePatchLinkage(dirty);
|
|
1568
|
+
const nn2 = _readNodeName(dirty);
|
|
1569
|
+
if (typeof nn2 === "string") {
|
|
1570
|
+
const tagName = transformCaseFunc(nn2);
|
|
1571
|
+
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
|
1572
|
+
_neutralizeRoot(dirty);
|
|
1573
|
+
throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
if (_isClobbered(dirty)) {
|
|
1577
|
+
_neutralizeRoot(dirty);
|
|
1578
|
+
throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
|
|
1579
|
+
}
|
|
1580
|
+
try {
|
|
1581
|
+
_sanitizeAttachedShadowRoots(dirty);
|
|
1582
|
+
} catch (error) {
|
|
1583
|
+
_neutralizeRoot(dirty);
|
|
1584
|
+
throw error;
|
|
1585
|
+
}
|
|
1586
|
+
} else if (_isNode(dirty)) {
|
|
1587
|
+
body = _initDocument("<!---->");
|
|
1588
|
+
importedNode = body.ownerDocument.importNode(dirty, true);
|
|
1589
|
+
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
|
|
1590
|
+
body = importedNode;
|
|
1591
|
+
} else if (importedNode.nodeName === "HTML") {
|
|
1592
|
+
body = importedNode;
|
|
1593
|
+
} else {
|
|
1594
|
+
body.appendChild(importedNode);
|
|
1595
|
+
}
|
|
1596
|
+
_sanitizeAttachedShadowRoots(importedNode);
|
|
1597
|
+
} else {
|
|
1598
|
+
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
|
|
1599
|
+
dirty.indexOf("<") === -1) {
|
|
1600
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
|
|
1601
|
+
}
|
|
1602
|
+
body = _initDocument(dirty);
|
|
1603
|
+
if (!body) {
|
|
1604
|
+
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (body && FORCE_BODY) {
|
|
1608
|
+
_forceRemove(body.firstChild);
|
|
1609
|
+
}
|
|
1610
|
+
const walkRoot = inPlace ? dirty : body;
|
|
1611
|
+
try {
|
|
1612
|
+
const nodeIterator = _createNodeIterator(walkRoot);
|
|
1613
|
+
while (currentNode = nodeIterator.nextNode()) {
|
|
1614
|
+
_sanitizeElements(currentNode, walkRoot);
|
|
1615
|
+
_sanitizeAttributes(currentNode);
|
|
1616
|
+
if (_isDocumentFragment(currentNode.content)) {
|
|
1617
|
+
_sanitizeShadowDOM2(currentNode.content);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
} catch (error) {
|
|
1621
|
+
if (inPlace) {
|
|
1622
|
+
_neutralizeRoot(dirty);
|
|
1623
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1624
|
+
if (entry.element) {
|
|
1625
|
+
_neutralizeSubtree(entry.element);
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
throw error;
|
|
1630
|
+
}
|
|
1631
|
+
if (inPlace) {
|
|
1632
|
+
arrayForEach(DOMPurify.removed, (entry) => {
|
|
1633
|
+
if (entry.element) {
|
|
1634
|
+
_neutralizeSubtree(entry.element);
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1638
|
+
_scrubTemplateExpressions2(dirty);
|
|
1639
|
+
}
|
|
1640
|
+
return dirty;
|
|
1641
|
+
}
|
|
1642
|
+
if (RETURN_DOM) {
|
|
1643
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1644
|
+
_scrubTemplateExpressions2(body);
|
|
1645
|
+
}
|
|
1646
|
+
if (RETURN_DOM_FRAGMENT) {
|
|
1647
|
+
returnNode = createDocumentFragment.call(body.ownerDocument);
|
|
1648
|
+
while (body.firstChild) {
|
|
1649
|
+
returnNode.appendChild(body.firstChild);
|
|
1650
|
+
}
|
|
1651
|
+
} else {
|
|
1652
|
+
returnNode = body;
|
|
1653
|
+
}
|
|
1654
|
+
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
|
1655
|
+
returnNode = importNode.call(originalDocument, returnNode, true);
|
|
1656
|
+
}
|
|
1657
|
+
return returnNode;
|
|
1658
|
+
}
|
|
1659
|
+
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
|
1660
|
+
if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
|
1661
|
+
serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
|
|
1662
|
+
}
|
|
1663
|
+
if (SAFE_FOR_TEMPLATES) {
|
|
1664
|
+
serializedHTML = _stripTemplateExpressions(serializedHTML);
|
|
1665
|
+
}
|
|
1666
|
+
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
|
|
1667
|
+
};
|
|
1668
|
+
DOMPurify.setConfig = function() {
|
|
1669
|
+
let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1670
|
+
_parseConfig(cfg);
|
|
1671
|
+
SET_CONFIG = true;
|
|
1672
|
+
SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
|
|
1673
|
+
SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
|
|
1674
|
+
};
|
|
1675
|
+
DOMPurify.clearConfig = function() {
|
|
1676
|
+
CONFIG = null;
|
|
1677
|
+
SET_CONFIG = false;
|
|
1678
|
+
SET_CONFIG_ALLOWED_TAGS = null;
|
|
1679
|
+
SET_CONFIG_ALLOWED_ATTR = null;
|
|
1680
|
+
trustedTypesPolicy = defaultTrustedTypesPolicy;
|
|
1681
|
+
emptyHTML = "";
|
|
1682
|
+
};
|
|
1683
|
+
DOMPurify.isValidAttribute = function(tag, attr, value) {
|
|
1684
|
+
if (!CONFIG) {
|
|
1685
|
+
_parseConfig({});
|
|
1686
|
+
}
|
|
1687
|
+
const lcTag = transformCaseFunc(tag);
|
|
1688
|
+
const lcName = transformCaseFunc(attr);
|
|
1689
|
+
return _isValidAttribute(lcTag, lcName, value);
|
|
1690
|
+
};
|
|
1691
|
+
DOMPurify.addHook = function(entryPoint, hookFunction) {
|
|
1692
|
+
if (typeof hookFunction !== "function") {
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
arrayPush(hooks[entryPoint], hookFunction);
|
|
1699
|
+
};
|
|
1700
|
+
DOMPurify.removeHook = function(entryPoint, hookFunction) {
|
|
1701
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1702
|
+
return void 0;
|
|
1703
|
+
}
|
|
1704
|
+
if (hookFunction !== void 0) {
|
|
1705
|
+
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
|
1706
|
+
return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
|
|
1707
|
+
}
|
|
1708
|
+
return arrayPop(hooks[entryPoint]);
|
|
1709
|
+
};
|
|
1710
|
+
DOMPurify.removeHooks = function(entryPoint) {
|
|
1711
|
+
if (!objectHasOwnProperty(hooks, entryPoint)) {
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
hooks[entryPoint] = [];
|
|
1715
|
+
};
|
|
1716
|
+
DOMPurify.removeAllHooks = function() {
|
|
1717
|
+
hooks = _createHooksMap();
|
|
1718
|
+
};
|
|
1719
|
+
return DOMPurify;
|
|
1720
|
+
}
|
|
1721
|
+
var purify = createDOMPurify();
|
|
1722
|
+
|
|
1723
|
+
// node_modules/marked/lib/marked.esm.js
|
|
1724
|
+
function C() {
|
|
1725
|
+
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
1726
|
+
}
|
|
1727
|
+
var R = C();
|
|
1728
|
+
function j(l3) {
|
|
1729
|
+
R = l3;
|
|
1730
|
+
}
|
|
1731
|
+
var z = { exec: () => null };
|
|
1732
|
+
function A(l3) {
|
|
1733
|
+
let e = [];
|
|
1734
|
+
return (t) => {
|
|
1735
|
+
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
1736
|
+
return s || (s = l3(n), e[n] = s), s;
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
function d(l3, e = "") {
|
|
1740
|
+
let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
|
|
1741
|
+
let i = typeof r == "string" ? r : r.source;
|
|
1742
|
+
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
1743
|
+
}, getRegex: () => new RegExp(t, e) };
|
|
1744
|
+
return n;
|
|
1745
|
+
}
|
|
1746
|
+
var Te = ((l3 = "") => {
|
|
1747
|
+
try {
|
|
1748
|
+
return !!new RegExp("(?<=1)(?<!1)" + l3);
|
|
1749
|
+
} catch {
|
|
1750
|
+
return false;
|
|
1751
|
+
}
|
|
1752
|
+
})();
|
|
1753
|
+
var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, 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, 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: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: A((l3) => new RegExp(`^ {0,${l3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: A((l3) => new RegExp(`^ {0,${l3}}>`)) };
|
|
1754
|
+
var Oe = /^(?:[ \t]*(?:\n|$))+/;
|
|
1755
|
+
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
1756
|
+
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
1757
|
+
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
1758
|
+
var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
1759
|
+
var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
1760
|
+
var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
1761
|
+
var ae = d(oe).replace(/bull/g, U).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(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
|
|
1762
|
+
var Se = d(oe).replace(/bull/g, U).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(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
|
|
1763
|
+
var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
1764
|
+
var _e = /^[^\n]+/;
|
|
1765
|
+
var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
1766
|
+
var $e = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
1767
|
+
var Le = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
1768
|
+
var Q = "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";
|
|
1769
|
+
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
1770
|
+
var Me = d("^ {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-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
1771
|
+
var le = (l3) => d(K).replace("hr", q).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", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
1772
|
+
var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
1773
|
+
var Ee = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
1774
|
+
var Ce = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Ee).getRegex();
|
|
1775
|
+
var J = { blockquote: Ce, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Me, lheading: ae, list: Le, newline: Oe, paragraph: ze, table: z, text: _e };
|
|
1776
|
+
var se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).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", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
1777
|
+
var Ae = { ...J, lheading: Se, table: se, paragraph: d(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
|
|
1778
|
+
var Ie = { ...J, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).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: z, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
1779
|
+
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
1780
|
+
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
1781
|
+
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
1782
|
+
var pe = /^( {2,}|\\)\n(?!\s*$)/;
|
|
1783
|
+
var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
1784
|
+
var _ = /[\p{P}\p{S}]/u;
|
|
1785
|
+
var I = /[\s\p{P}\p{S}]/u;
|
|
1786
|
+
var v = /[^\s\p{P}\p{S}]/u;
|
|
1787
|
+
var ve = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, I).getRegex();
|
|
1788
|
+
var He = /[\p{Pi}\p{Ps}"']/u;
|
|
1789
|
+
var ue = /(?!~)[\p{P}\p{S}]/u;
|
|
1790
|
+
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
1791
|
+
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
1792
|
+
var Qe = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
1793
|
+
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
1794
|
+
var Ne = d(ce, "u").replace(/punct/g, _).getRegex();
|
|
1795
|
+
var je = d(ce, "u").replace(/punct/g, ue).getRegex();
|
|
1796
|
+
var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
1797
|
+
var Ue = d(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
|
|
1798
|
+
var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
1799
|
+
var Ke = d(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
1800
|
+
var We = d(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, ue).getRegex();
|
|
1801
|
+
var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
1802
|
+
var Je = d(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
1803
|
+
var Ve = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
1804
|
+
var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
1805
|
+
var et = d(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
1806
|
+
var tt = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
|
|
1807
|
+
var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
1808
|
+
var rt = d(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, I).replace(/punct/g, _).getRegex();
|
|
1809
|
+
var st = d(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
1810
|
+
var it = d(/^<(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();
|
|
1811
|
+
var ot = d(X).replace("(?:-->|$)", "-->").getRegex();
|
|
1812
|
+
var at = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
|
|
1813
|
+
var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
1814
|
+
var lt = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
1815
|
+
var de = d(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
1816
|
+
var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
1817
|
+
var pt = d("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
|
|
1818
|
+
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
1819
|
+
var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: pe, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: ke, punctuation: ve, reflink: de, reflinkSearch: pt, tag: at, text: qe, url: z };
|
|
1820
|
+
var ut = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
1821
|
+
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
|
|
1822
|
+
var ct = { ...F, br: d(pe).replace("{2,}", "*").getRegex(), text: d(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
1823
|
+
var H = { normal: J, gfm: Ae, pedantic: Ie };
|
|
1824
|
+
var B = { normal: V, gfm: F, breaks: ct, pedantic: ut };
|
|
1825
|
+
var ht = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
1826
|
+
var ge = (l3) => ht[l3];
|
|
1827
|
+
function O(l3, e) {
|
|
1828
|
+
if (e) {
|
|
1829
|
+
if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, ge);
|
|
1830
|
+
} else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, ge);
|
|
1831
|
+
return l3;
|
|
1832
|
+
}
|
|
1833
|
+
function Y(l3) {
|
|
1834
|
+
try {
|
|
1835
|
+
l3 = encodeURI(l3).replace(m.percentDecode, "%");
|
|
1836
|
+
} catch {
|
|
1837
|
+
return null;
|
|
1838
|
+
}
|
|
1839
|
+
return l3;
|
|
1840
|
+
}
|
|
1841
|
+
function ee(l3, e) {
|
|
1842
|
+
let t = l3.replace(m.findPipe, (r, i, o) => {
|
|
1843
|
+
let p = false, a = i;
|
|
1844
|
+
for (; --a >= 0 && o[a] === "\\"; ) p = !p;
|
|
1845
|
+
return p ? "|" : " |";
|
|
1846
|
+
}), n = t.split(m.splitPipe), s = 0;
|
|
1847
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
|
|
1848
|
+
else for (; n.length < e; ) n.push("");
|
|
1849
|
+
for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
1850
|
+
return n;
|
|
1851
|
+
}
|
|
1852
|
+
function $(l3, e, t) {
|
|
1853
|
+
let n = l3.length;
|
|
1854
|
+
if (n === 0) return "";
|
|
1855
|
+
let s = 0;
|
|
1856
|
+
for (; s < n; ) {
|
|
1857
|
+
let r = l3.charAt(n - s - 1);
|
|
1858
|
+
if (r === e && !t) s++;
|
|
1859
|
+
else if (r !== e && t) s++;
|
|
1860
|
+
else break;
|
|
1861
|
+
}
|
|
1862
|
+
return l3.slice(0, n - s);
|
|
1863
|
+
}
|
|
1864
|
+
function te(l3) {
|
|
1865
|
+
let e = l3.split(`
|
|
1866
|
+
`), t = e.length - 1;
|
|
1867
|
+
for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
|
|
1868
|
+
return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
|
|
1869
|
+
`);
|
|
1870
|
+
}
|
|
1871
|
+
function fe(l3, e) {
|
|
1872
|
+
if (l3.indexOf(e[1]) === -1) return -1;
|
|
1873
|
+
let t = 0;
|
|
1874
|
+
for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
|
|
1875
|
+
else if (l3[n] === e[0]) t++;
|
|
1876
|
+
else if (l3[n] === e[1] && (t--, t < 0)) return n;
|
|
1877
|
+
return t > 0 ? -2 : -1;
|
|
1878
|
+
}
|
|
1879
|
+
function me(l3, e = 0) {
|
|
1880
|
+
let t = e, n = "";
|
|
1881
|
+
for (let s of l3) if (s === " ") {
|
|
1882
|
+
let r = 4 - t % 4;
|
|
1883
|
+
n += " ".repeat(r), t += r;
|
|
1884
|
+
} else n += s, t++;
|
|
1885
|
+
return n;
|
|
1886
|
+
}
|
|
1887
|
+
function xe(l3, e, t, n, s) {
|
|
1888
|
+
let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
|
|
1889
|
+
n.state.inLink = true;
|
|
1890
|
+
let p = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
|
|
1891
|
+
return n.state.inLink = false, p;
|
|
1892
|
+
}
|
|
1893
|
+
function dt(l3, e, t) {
|
|
1894
|
+
let n = l3.match(t.other.indentCodeCompensation);
|
|
1895
|
+
if (n === null) return e;
|
|
1896
|
+
let s = n[1];
|
|
1897
|
+
return e.split(`
|
|
1898
|
+
`).map((r) => {
|
|
1899
|
+
let i = r.match(t.other.beginningSpace);
|
|
1900
|
+
if (i === null) return r;
|
|
1901
|
+
let [o] = i;
|
|
1902
|
+
return o.length >= s.length ? r.slice(s.length) : r;
|
|
1903
|
+
}).join(`
|
|
1904
|
+
`);
|
|
1905
|
+
}
|
|
1906
|
+
var y = class {
|
|
1907
|
+
options;
|
|
1908
|
+
rules;
|
|
1909
|
+
lexer;
|
|
1910
|
+
constructor(e) {
|
|
1911
|
+
this.options = e || R;
|
|
1912
|
+
}
|
|
1913
|
+
space(e) {
|
|
1914
|
+
let t = this.rules.block.newline.exec(e);
|
|
1915
|
+
if (t && t[0].length > 0) return { type: "space", raw: t[0] };
|
|
1916
|
+
}
|
|
1917
|
+
code(e) {
|
|
1918
|
+
let t = this.rules.block.code.exec(e);
|
|
1919
|
+
if (t) {
|
|
1920
|
+
let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
1921
|
+
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
fences(e) {
|
|
1925
|
+
let t = this.rules.block.fences.exec(e);
|
|
1926
|
+
if (t) {
|
|
1927
|
+
let n = t[0], s = dt(n, t[3] || "", this.rules);
|
|
1928
|
+
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
heading(e) {
|
|
1932
|
+
let t = this.rules.block.heading.exec(e);
|
|
1933
|
+
if (t) {
|
|
1934
|
+
let n = t[2].trim();
|
|
1935
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
1936
|
+
let s = $(n, "#");
|
|
1937
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
1938
|
+
}
|
|
1939
|
+
return { type: "heading", raw: $(t[0], `
|
|
1940
|
+
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
hr(e) {
|
|
1944
|
+
let t = this.rules.block.hr.exec(e);
|
|
1945
|
+
if (t) return { type: "hr", raw: $(t[0], `
|
|
1946
|
+
`) };
|
|
1947
|
+
}
|
|
1948
|
+
blockquote(e) {
|
|
1949
|
+
let t = this.rules.block.blockquote.exec(e);
|
|
1950
|
+
if (t) {
|
|
1951
|
+
let n = $(t[0], `
|
|
1952
|
+
`).split(`
|
|
1953
|
+
`), s = "", r = "", i = [];
|
|
1954
|
+
for (; n.length > 0; ) {
|
|
1955
|
+
let o = false, p = [], a;
|
|
1956
|
+
for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) p.push(n[a]), o = true;
|
|
1957
|
+
else if (!o) p.push(n[a]);
|
|
1958
|
+
else break;
|
|
1959
|
+
n = n.slice(a);
|
|
1960
|
+
let u = p.join(`
|
|
1961
|
+
`), c = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
1962
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
1963
|
+
s = s ? `${s}
|
|
1964
|
+
${u}` : u, r = r ? `${r}
|
|
1965
|
+
${c}` : c;
|
|
1966
|
+
let h = this.lexer.state.top;
|
|
1967
|
+
if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0) break;
|
|
1968
|
+
let k = i.at(-1);
|
|
1969
|
+
if (k?.type === "code") break;
|
|
1970
|
+
if (k?.type === "blockquote") {
|
|
1971
|
+
let T = k, g = n.join(`
|
|
1972
|
+
`), w = T.raw + `
|
|
1973
|
+
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), M = this.blockquote(w);
|
|
1974
|
+
i[i.length - 1] = M, s = `${s}
|
|
1975
|
+
${g}`, r = r.substring(0, r.length - T.text.length) + M.text;
|
|
1976
|
+
break;
|
|
1977
|
+
} else if (k?.type === "list") {
|
|
1978
|
+
let T = k, g = T.raw + `
|
|
1979
|
+
` + n.join(`
|
|
1980
|
+
`), w = this.list(g);
|
|
1981
|
+
i[i.length - 1] = w, s = s.substring(0, s.length - k.raw.length) + w.raw, r = r.substring(0, r.length - T.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
|
|
1982
|
+
`);
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
list(e) {
|
|
1990
|
+
let t = this.rules.block.list.exec(e);
|
|
1991
|
+
if (t) {
|
|
1992
|
+
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
1993
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
1994
|
+
let i = this.rules.other.listItemRegex(n), o = false;
|
|
1995
|
+
for (; e; ) {
|
|
1996
|
+
let a = false, u = "", c = "";
|
|
1997
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
|
|
1998
|
+
u = t[0], e = e.substring(u.length);
|
|
1999
|
+
let h = me(t[2].split(`
|
|
2000
|
+
`, 1)[0], t[1].length), k = e.split(`
|
|
2001
|
+
`, 1)[0], T = !h.trim(), g = 0;
|
|
2002
|
+
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : T ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), T && this.rules.other.blankLine.test(k) && (u += k + `
|
|
2003
|
+
`, e = e.substring(k.length + 1), a = true), !a) {
|
|
2004
|
+
let w = this.rules.other.nextBulletRegex(g), M = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
|
|
2005
|
+
for (; e; ) {
|
|
2006
|
+
let N = e.split(`
|
|
2007
|
+
`, 1)[0], D;
|
|
2008
|
+
if (k = N, this.options.pedantic ? (k = k.replace(this.rules.other.listReplaceNesting, " "), D = k) : D = k.replace(this.rules.other.tabCharGlobal, " "), ne.test(k) || re.test(k) || be.test(k) || Re.test(k) || w.test(k) || M.test(k)) break;
|
|
2009
|
+
if (D.search(this.rules.other.nonSpaceChar) >= g || !k.trim()) c += `
|
|
2010
|
+
` + D.slice(g);
|
|
2011
|
+
else {
|
|
2012
|
+
if (T || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || M.test(h)) break;
|
|
2013
|
+
c += `
|
|
2014
|
+
` + k;
|
|
2015
|
+
}
|
|
2016
|
+
T = !k.trim(), u += N + `
|
|
2017
|
+
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(u) && (o = true)), r.items.push({ type: "list_item", raw: u, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += u;
|
|
2021
|
+
}
|
|
2022
|
+
let p = r.items.at(-1);
|
|
2023
|
+
if (p) p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
|
|
2024
|
+
else return;
|
|
2025
|
+
r.raw = r.raw.trimEnd();
|
|
2026
|
+
for (let a of r.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r.loose) {
|
|
2027
|
+
let u = a.tokens.filter((h) => h.type === "space"), c = u.length > 0 && u.some((h) => this.rules.other.anyLine.test(h.raw));
|
|
2028
|
+
r.loose = c;
|
|
2029
|
+
}
|
|
2030
|
+
for (let a of r.items) {
|
|
2031
|
+
let u = a.tokens[0];
|
|
2032
|
+
if (a.task && (u?.type === "text" || u?.type === "paragraph")) {
|
|
2033
|
+
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), u.raw = u.raw.replace(this.rules.other.listReplaceTask, ""), u.text = u.text.replace(this.rules.other.listReplaceTask, "");
|
|
2034
|
+
for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
|
|
2035
|
+
this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
|
|
2036
|
+
break;
|
|
2037
|
+
}
|
|
2038
|
+
let c = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
2039
|
+
if (c) {
|
|
2040
|
+
let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
|
|
2041
|
+
a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
|
|
2042
|
+
}
|
|
2043
|
+
} else a.task && (a.task = false);
|
|
2044
|
+
}
|
|
2045
|
+
if (r.loose) for (let a of r.items) {
|
|
2046
|
+
a.loose = true;
|
|
2047
|
+
for (let u of a.tokens) u.type === "text" && (u.type = "paragraph");
|
|
2048
|
+
}
|
|
2049
|
+
return r;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
html(e) {
|
|
2053
|
+
let t = this.rules.block.html.exec(e);
|
|
2054
|
+
if (t) {
|
|
2055
|
+
let n = te(t[0]);
|
|
2056
|
+
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
def(e) {
|
|
2060
|
+
let t = this.rules.block.def.exec(e);
|
|
2061
|
+
if (t) {
|
|
2062
|
+
let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
2063
|
+
return { type: "def", tag: n, raw: $(t[0], `
|
|
2064
|
+
`), href: s, title: r };
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
table(e) {
|
|
2068
|
+
let t = this.rules.block.table.exec(e);
|
|
2069
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
|
|
2070
|
+
let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
2071
|
+
`) : [], i = { type: "table", raw: $(t[0], `
|
|
2072
|
+
`), header: [], align: [], rows: [] };
|
|
2073
|
+
if (n.length === s.length) {
|
|
2074
|
+
for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
|
|
2075
|
+
for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
2076
|
+
for (let o of r) i.rows.push(ee(o, i.header.length).map((p, a) => ({ text: p, tokens: this.lexer.inline(p), header: false, align: i.align[a] })));
|
|
2077
|
+
return i;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
lheading(e) {
|
|
2081
|
+
let t = this.rules.block.lheading.exec(e);
|
|
2082
|
+
if (t) {
|
|
2083
|
+
let n = t[1].trim();
|
|
2084
|
+
return { type: "heading", raw: $(t[0], `
|
|
2085
|
+
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
paragraph(e) {
|
|
2089
|
+
let t = this.rules.block.paragraph.exec(e);
|
|
2090
|
+
if (t) {
|
|
2091
|
+
let n = t[1].charAt(t[1].length - 1) === `
|
|
2092
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
2093
|
+
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
text(e) {
|
|
2097
|
+
let t = this.rules.block.text.exec(e);
|
|
2098
|
+
if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
2099
|
+
}
|
|
2100
|
+
escape(e) {
|
|
2101
|
+
let t = this.rules.inline.escape.exec(e);
|
|
2102
|
+
if (t) return { type: "escape", raw: t[0], text: t[1] };
|
|
2103
|
+
}
|
|
2104
|
+
tag(e) {
|
|
2105
|
+
let t = this.rules.inline.tag.exec(e);
|
|
2106
|
+
if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
|
|
2107
|
+
}
|
|
2108
|
+
link(e) {
|
|
2109
|
+
let t = this.rules.inline.link.exec(e);
|
|
2110
|
+
if (t) {
|
|
2111
|
+
let n = t[2].trim();
|
|
2112
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
2113
|
+
if (!this.rules.other.endAngleBracket.test(n)) return;
|
|
2114
|
+
let i = $(n.slice(0, -1), "\\");
|
|
2115
|
+
if ((n.length - i.length) % 2 === 0) return;
|
|
2116
|
+
} else {
|
|
2117
|
+
let i = fe(t[2], "()");
|
|
2118
|
+
if (i === -2) return;
|
|
2119
|
+
if (i > -1) {
|
|
2120
|
+
let p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
2121
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, p).trim(), t[3] = "";
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
let s = t[2], r = "";
|
|
2125
|
+
if (this.options.pedantic) {
|
|
2126
|
+
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
2127
|
+
i && (s = i[1], r = i[3]);
|
|
2128
|
+
} else r = t[3] ? t[3].slice(1, -1) : "";
|
|
2129
|
+
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
reflink(e, t) {
|
|
2133
|
+
let n;
|
|
2134
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
2135
|
+
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
2136
|
+
if (!r) {
|
|
2137
|
+
let i = n[0].charAt(0);
|
|
2138
|
+
return { type: "text", raw: i, text: i };
|
|
2139
|
+
}
|
|
2140
|
+
return xe(n, r, n[0], this.lexer, this.rules);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
emStrong(e, t, n = "") {
|
|
2144
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
2145
|
+
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
|
|
2146
|
+
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2147
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = 0, c = s[0][0], h = n === c, k = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
2148
|
+
for (k.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = k.exec(t)) !== null; ) {
|
|
2149
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
|
|
2150
|
+
if (p = [...o].length, s[3] || s[4]) {
|
|
2151
|
+
a += p;
|
|
2152
|
+
continue;
|
|
2153
|
+
} else if (s[5] || s[6]) {
|
|
2154
|
+
if (i % 3 && !((i + p) % 3)) {
|
|
2155
|
+
u += p;
|
|
2156
|
+
continue;
|
|
2157
|
+
}
|
|
2158
|
+
if (h) break;
|
|
2159
|
+
}
|
|
2160
|
+
if (a -= p, a > 0) continue;
|
|
2161
|
+
p = Math.min(p, p + a + u);
|
|
2162
|
+
let T = [...s[0]][0].length, g = e.slice(0, i + s.index + T + p);
|
|
2163
|
+
if (Math.min(i, p) % 2) {
|
|
2164
|
+
let M = g.slice(1, -1);
|
|
2165
|
+
return { type: "em", raw: g, text: M, tokens: this.lexer.inlineTokens(M) };
|
|
2166
|
+
}
|
|
2167
|
+
let w = g.slice(2, -2);
|
|
2168
|
+
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
codespan(e) {
|
|
2173
|
+
let t = this.rules.inline.code.exec(e);
|
|
2174
|
+
if (t) {
|
|
2175
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
2176
|
+
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
br(e) {
|
|
2180
|
+
let t = this.rules.inline.br.exec(e);
|
|
2181
|
+
if (t) return { type: "br", raw: t[0] };
|
|
2182
|
+
}
|
|
2183
|
+
del(e, t, n = "") {
|
|
2184
|
+
let s = this.rules.inline.delLDelim.exec(e);
|
|
2185
|
+
if (!s) return;
|
|
2186
|
+
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
2187
|
+
let i = [...s[0]].length - 1, o, p, a = i, u = this.rules.inline.delRDelim;
|
|
2188
|
+
for (u.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = u.exec(t)) !== null; ) {
|
|
2189
|
+
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (p = [...o].length, p !== i)) continue;
|
|
2190
|
+
if (s[3] || s[4]) {
|
|
2191
|
+
a += p;
|
|
2192
|
+
continue;
|
|
2193
|
+
}
|
|
2194
|
+
if (a -= p, a > 0) continue;
|
|
2195
|
+
p = Math.min(p, p + a);
|
|
2196
|
+
let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + p), k = h.slice(i, -i);
|
|
2197
|
+
return { type: "del", raw: h, text: k, tokens: this.lexer.inlineTokens(k) };
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
autolink(e) {
|
|
2202
|
+
let t = this.rules.inline.autolink.exec(e);
|
|
2203
|
+
if (t) {
|
|
2204
|
+
let n, s;
|
|
2205
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
url(e) {
|
|
2209
|
+
let t;
|
|
2210
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
2211
|
+
let n, s;
|
|
2212
|
+
if (t[2] === "@") n = t[0], s = "mailto:" + n;
|
|
2213
|
+
else {
|
|
2214
|
+
let r;
|
|
2215
|
+
do
|
|
2216
|
+
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
2217
|
+
while (r !== t[0]);
|
|
2218
|
+
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
2219
|
+
}
|
|
2220
|
+
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
inlineText(e) {
|
|
2224
|
+
let t = this.rules.inline.text.exec(e);
|
|
2225
|
+
if (t) {
|
|
2226
|
+
let n = this.lexer.state.inRawBlock;
|
|
2227
|
+
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
var x = class l {
|
|
2232
|
+
tokens;
|
|
2233
|
+
options;
|
|
2234
|
+
state;
|
|
2235
|
+
inlineQueue;
|
|
2236
|
+
tokenizer;
|
|
2237
|
+
constructor(e) {
|
|
2238
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || R, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
|
|
2239
|
+
let t = { other: m, block: H.normal, inline: B.normal };
|
|
2240
|
+
this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
|
|
2241
|
+
}
|
|
2242
|
+
static get rules() {
|
|
2243
|
+
return { block: H, inline: B };
|
|
2244
|
+
}
|
|
2245
|
+
static lex(e, t) {
|
|
2246
|
+
return new l(t).lex(e);
|
|
2247
|
+
}
|
|
2248
|
+
static lexInline(e, t) {
|
|
2249
|
+
return new l(t).inlineTokens(e);
|
|
2250
|
+
}
|
|
2251
|
+
lex(e) {
|
|
2252
|
+
e = e.replace(m.carriageReturn, `
|
|
2253
|
+
`), this.blockTokens(e, this.tokens);
|
|
2254
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
2255
|
+
let n = this.inlineQueue[t];
|
|
2256
|
+
this.inlineTokens(n.src, n.tokens);
|
|
2257
|
+
}
|
|
2258
|
+
return this.inlineQueue = [], this.tokens;
|
|
2259
|
+
}
|
|
2260
|
+
blockTokens(e, t = [], n = false) {
|
|
2261
|
+
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
2262
|
+
let s = 1 / 0;
|
|
2263
|
+
for (; e; ) {
|
|
2264
|
+
if (e.length < s) s = e.length;
|
|
2265
|
+
else {
|
|
2266
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
2267
|
+
break;
|
|
2268
|
+
}
|
|
2269
|
+
let r;
|
|
2270
|
+
if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
|
|
2271
|
+
if (r = this.tokenizer.space(e)) {
|
|
2272
|
+
e = e.substring(r.raw.length);
|
|
2273
|
+
let o = t.at(-1);
|
|
2274
|
+
r.raw.length === 1 && o !== void 0 ? o.raw += `
|
|
2275
|
+
` : t.push(r);
|
|
2276
|
+
continue;
|
|
2277
|
+
}
|
|
2278
|
+
if (r = this.tokenizer.code(e)) {
|
|
2279
|
+
e = e.substring(r.raw.length);
|
|
2280
|
+
let o = t.at(-1);
|
|
2281
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
2282
|
+
`) ? "" : `
|
|
2283
|
+
`) + r.raw, o.text += `
|
|
2284
|
+
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
2285
|
+
continue;
|
|
2286
|
+
}
|
|
2287
|
+
if (r = this.tokenizer.fences(e)) {
|
|
2288
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2289
|
+
continue;
|
|
2290
|
+
}
|
|
2291
|
+
if (r = this.tokenizer.heading(e)) {
|
|
2292
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
if (r = this.tokenizer.hr(e)) {
|
|
2296
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
if (r = this.tokenizer.blockquote(e)) {
|
|
2300
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2301
|
+
continue;
|
|
2302
|
+
}
|
|
2303
|
+
if (r = this.tokenizer.list(e)) {
|
|
2304
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
if (r = this.tokenizer.html(e)) {
|
|
2308
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2309
|
+
continue;
|
|
2310
|
+
}
|
|
2311
|
+
if (r = this.tokenizer.def(e)) {
|
|
2312
|
+
e = e.substring(r.raw.length);
|
|
2313
|
+
let o = t.at(-1);
|
|
2314
|
+
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
2315
|
+
`) ? "" : `
|
|
2316
|
+
`) + r.raw, o.text += `
|
|
2317
|
+
` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
|
|
2318
|
+
continue;
|
|
2319
|
+
}
|
|
2320
|
+
if (r = this.tokenizer.table(e)) {
|
|
2321
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2322
|
+
continue;
|
|
2323
|
+
}
|
|
2324
|
+
if (r = this.tokenizer.lheading(e)) {
|
|
2325
|
+
e = e.substring(r.raw.length), t.push(r);
|
|
2326
|
+
continue;
|
|
2327
|
+
}
|
|
2328
|
+
let i = e;
|
|
2329
|
+
if (this.options.extensions?.startBlock) {
|
|
2330
|
+
let o = 1 / 0, p = e.slice(1), a;
|
|
2331
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
2332
|
+
a = u.call({ lexer: this }, p), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
2333
|
+
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
2334
|
+
}
|
|
2335
|
+
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
2336
|
+
let o = t.at(-1);
|
|
2337
|
+
n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
2338
|
+
`) ? "" : `
|
|
2339
|
+
`) + r.raw, o.text += `
|
|
2340
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
if (r = this.tokenizer.text(e)) {
|
|
2344
|
+
e = e.substring(r.raw.length);
|
|
2345
|
+
let o = t.at(-1);
|
|
2346
|
+
o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
2347
|
+
`) ? "" : `
|
|
2348
|
+
`) + r.raw, o.text += `
|
|
2349
|
+
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
2350
|
+
continue;
|
|
2351
|
+
}
|
|
2352
|
+
if (e) {
|
|
2353
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
2354
|
+
break;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
return this.state.top = true, t;
|
|
2358
|
+
}
|
|
2359
|
+
inline(e, t = []) {
|
|
2360
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
2361
|
+
}
|
|
2362
|
+
inlineTokens(e, t = []) {
|
|
2363
|
+
this.tokenizer.lexer = this;
|
|
2364
|
+
let n = e;
|
|
2365
|
+
if (this.tokens.links) {
|
|
2366
|
+
let o = Object.keys(this.tokens.links);
|
|
2367
|
+
o.length > 0 && (n = n.replace(this.tokenizer.rules.inline.reflinkSearch, (p) => o.includes(p.slice(p.lastIndexOf("[") + 1, -1)) ? "[" + "a".repeat(p.length - 2) + "]" : p));
|
|
2368
|
+
}
|
|
2369
|
+
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (o) => "+".repeat(o.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, p, a) => {
|
|
2370
|
+
let u = a ? a.length : 0;
|
|
2371
|
+
return o.slice(0, u) + "[" + "a".repeat(o.length - u - 2) + "]";
|
|
2372
|
+
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
2373
|
+
let s = false, r = "", i = 1 / 0;
|
|
2374
|
+
for (; e; ) {
|
|
2375
|
+
if (e.length < i) i = e.length;
|
|
2376
|
+
else {
|
|
2377
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
2378
|
+
break;
|
|
2379
|
+
}
|
|
2380
|
+
s || (r = ""), s = false;
|
|
2381
|
+
let o;
|
|
2382
|
+
if (this.options.extensions?.inline?.some((a) => (o = a.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false)) continue;
|
|
2383
|
+
if (o = this.tokenizer.escape(e)) {
|
|
2384
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2385
|
+
continue;
|
|
2386
|
+
}
|
|
2387
|
+
if (o = this.tokenizer.tag(e)) {
|
|
2388
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2389
|
+
continue;
|
|
2390
|
+
}
|
|
2391
|
+
if (o = this.tokenizer.link(e)) {
|
|
2392
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2393
|
+
continue;
|
|
2394
|
+
}
|
|
2395
|
+
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
2396
|
+
e = e.substring(o.raw.length);
|
|
2397
|
+
let a = t.at(-1);
|
|
2398
|
+
o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
2399
|
+
continue;
|
|
2400
|
+
}
|
|
2401
|
+
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
2402
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2403
|
+
continue;
|
|
2404
|
+
}
|
|
2405
|
+
if (o = this.tokenizer.codespan(e)) {
|
|
2406
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
if (o = this.tokenizer.br(e)) {
|
|
2410
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2411
|
+
continue;
|
|
2412
|
+
}
|
|
2413
|
+
if (o = this.tokenizer.del(e, n, r)) {
|
|
2414
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2415
|
+
continue;
|
|
2416
|
+
}
|
|
2417
|
+
if (o = this.tokenizer.autolink(e)) {
|
|
2418
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2419
|
+
continue;
|
|
2420
|
+
}
|
|
2421
|
+
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
2422
|
+
e = e.substring(o.raw.length), t.push(o);
|
|
2423
|
+
continue;
|
|
2424
|
+
}
|
|
2425
|
+
let p = e;
|
|
2426
|
+
if (this.options.extensions?.startInline) {
|
|
2427
|
+
let a = 1 / 0, u = e.slice(1), c;
|
|
2428
|
+
this.options.extensions.startInline.forEach((h) => {
|
|
2429
|
+
c = h.call({ lexer: this }, u), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
2430
|
+
}), a < 1 / 0 && a >= 0 && (p = e.substring(0, a + 1));
|
|
2431
|
+
}
|
|
2432
|
+
if (o = this.tokenizer.inlineText(p)) {
|
|
2433
|
+
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
|
|
2434
|
+
let a = t.at(-1);
|
|
2435
|
+
a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
2436
|
+
continue;
|
|
2437
|
+
}
|
|
2438
|
+
if (e) {
|
|
2439
|
+
this.infiniteLoopError(e.charCodeAt(0));
|
|
2440
|
+
break;
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
return t;
|
|
2444
|
+
}
|
|
2445
|
+
infiniteLoopError(e) {
|
|
2446
|
+
let t = "Infinite loop on byte: " + e;
|
|
2447
|
+
if (this.options.silent) console.error(t);
|
|
2448
|
+
else throw new Error(t);
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
var P = class {
|
|
2452
|
+
options;
|
|
2453
|
+
parser;
|
|
2454
|
+
constructor(e) {
|
|
2455
|
+
this.options = e || R;
|
|
2456
|
+
}
|
|
2457
|
+
space(e) {
|
|
2458
|
+
return "";
|
|
2459
|
+
}
|
|
2460
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
2461
|
+
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
2462
|
+
`;
|
|
2463
|
+
return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
|
|
2464
|
+
` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
|
|
2465
|
+
`;
|
|
2466
|
+
}
|
|
2467
|
+
blockquote({ tokens: e }) {
|
|
2468
|
+
return `<blockquote>
|
|
2469
|
+
${this.parser.parse(e)}</blockquote>
|
|
2470
|
+
`;
|
|
2471
|
+
}
|
|
2472
|
+
html({ text: e }) {
|
|
2473
|
+
return e;
|
|
2474
|
+
}
|
|
2475
|
+
def(e) {
|
|
2476
|
+
return "";
|
|
2477
|
+
}
|
|
2478
|
+
heading({ tokens: e, depth: t }) {
|
|
2479
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
2480
|
+
`;
|
|
2481
|
+
}
|
|
2482
|
+
hr(e) {
|
|
2483
|
+
return `<hr>
|
|
2484
|
+
`;
|
|
2485
|
+
}
|
|
2486
|
+
list(e) {
|
|
2487
|
+
let t = e.ordered, n = e.start, s = "";
|
|
2488
|
+
for (let o = 0; o < e.items.length; o++) {
|
|
2489
|
+
let p = e.items[o];
|
|
2490
|
+
s += this.listitem(p);
|
|
2491
|
+
}
|
|
2492
|
+
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
2493
|
+
return "<" + r + i + `>
|
|
2494
|
+
` + s + "</" + r + `>
|
|
2495
|
+
`;
|
|
2496
|
+
}
|
|
2497
|
+
listitem(e) {
|
|
2498
|
+
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
2499
|
+
`;
|
|
2500
|
+
}
|
|
2501
|
+
checkbox({ checked: e }) {
|
|
2502
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
2503
|
+
}
|
|
2504
|
+
paragraph({ tokens: e }) {
|
|
2505
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
2506
|
+
`;
|
|
2507
|
+
}
|
|
2508
|
+
table(e) {
|
|
2509
|
+
let t = "", n = "";
|
|
2510
|
+
for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
|
|
2511
|
+
t += this.tablerow({ text: n });
|
|
2512
|
+
let s = "";
|
|
2513
|
+
for (let r = 0; r < e.rows.length; r++) {
|
|
2514
|
+
let i = e.rows[r];
|
|
2515
|
+
n = "";
|
|
2516
|
+
for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
|
|
2517
|
+
s += this.tablerow({ text: n });
|
|
2518
|
+
}
|
|
2519
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
2520
|
+
<thead>
|
|
2521
|
+
` + t + `</thead>
|
|
2522
|
+
` + s + `</table>
|
|
2523
|
+
`;
|
|
2524
|
+
}
|
|
2525
|
+
tablerow({ text: e }) {
|
|
2526
|
+
return `<tr>
|
|
2527
|
+
${e}</tr>
|
|
2528
|
+
`;
|
|
2529
|
+
}
|
|
2530
|
+
tablecell(e) {
|
|
2531
|
+
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
2532
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
2533
|
+
`;
|
|
2534
|
+
}
|
|
2535
|
+
strong({ tokens: e }) {
|
|
2536
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
2537
|
+
}
|
|
2538
|
+
em({ tokens: e }) {
|
|
2539
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
2540
|
+
}
|
|
2541
|
+
codespan({ text: e }) {
|
|
2542
|
+
return `<code>${O(e, true)}</code>`;
|
|
2543
|
+
}
|
|
2544
|
+
br(e) {
|
|
2545
|
+
return "<br>";
|
|
2546
|
+
}
|
|
2547
|
+
del({ tokens: e }) {
|
|
2548
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
2549
|
+
}
|
|
2550
|
+
link({ href: e, title: t, tokens: n }) {
|
|
2551
|
+
let s = this.parser.parseInline(n), r = Y(e);
|
|
2552
|
+
if (r === null) return s;
|
|
2553
|
+
e = r;
|
|
2554
|
+
let i = '<a href="' + e + '"';
|
|
2555
|
+
return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
|
|
2556
|
+
}
|
|
2557
|
+
image({ href: e, title: t, text: n, tokens: s }) {
|
|
2558
|
+
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
2559
|
+
let r = Y(e);
|
|
2560
|
+
if (r === null) return O(n);
|
|
2561
|
+
e = r;
|
|
2562
|
+
let i = `<img src="${e}" alt="${O(n)}"`;
|
|
2563
|
+
return t && (i += ` title="${O(t)}"`), i += ">", i;
|
|
2564
|
+
}
|
|
2565
|
+
text(e) {
|
|
2566
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2569
|
+
var L = class {
|
|
2570
|
+
strong({ text: e }) {
|
|
2571
|
+
return e;
|
|
2572
|
+
}
|
|
2573
|
+
em({ text: e }) {
|
|
2574
|
+
return e;
|
|
2575
|
+
}
|
|
2576
|
+
codespan({ text: e }) {
|
|
2577
|
+
return e;
|
|
2578
|
+
}
|
|
2579
|
+
del({ text: e }) {
|
|
2580
|
+
return e;
|
|
2581
|
+
}
|
|
2582
|
+
html({ text: e }) {
|
|
2583
|
+
return e;
|
|
2584
|
+
}
|
|
2585
|
+
text({ text: e }) {
|
|
2586
|
+
return e;
|
|
2587
|
+
}
|
|
2588
|
+
link({ text: e }) {
|
|
2589
|
+
return "" + e;
|
|
2590
|
+
}
|
|
2591
|
+
image({ text: e }) {
|
|
2592
|
+
return "" + e;
|
|
2593
|
+
}
|
|
2594
|
+
br() {
|
|
2595
|
+
return "";
|
|
2596
|
+
}
|
|
2597
|
+
checkbox({ raw: e }) {
|
|
2598
|
+
return e;
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
var b = class l2 {
|
|
2602
|
+
options;
|
|
2603
|
+
renderer;
|
|
2604
|
+
textRenderer;
|
|
2605
|
+
constructor(e) {
|
|
2606
|
+
this.options = e || R, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
|
|
2607
|
+
}
|
|
2608
|
+
static parse(e, t) {
|
|
2609
|
+
return new l2(t).parse(e);
|
|
2610
|
+
}
|
|
2611
|
+
static parseInline(e, t) {
|
|
2612
|
+
return new l2(t).parseInline(e);
|
|
2613
|
+
}
|
|
2614
|
+
parse(e) {
|
|
2615
|
+
this.renderer.parser = this;
|
|
2616
|
+
let t = "";
|
|
2617
|
+
for (let n = 0; n < e.length; n++) {
|
|
2618
|
+
let s = e[n];
|
|
2619
|
+
if (this.options.extensions?.renderers?.[s.type]) {
|
|
2620
|
+
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
2621
|
+
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
2622
|
+
t += o || "";
|
|
2623
|
+
continue;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
let r = s;
|
|
2627
|
+
switch (r.type) {
|
|
2628
|
+
case "space": {
|
|
2629
|
+
t += this.renderer.space(r);
|
|
2630
|
+
break;
|
|
2631
|
+
}
|
|
2632
|
+
case "hr": {
|
|
2633
|
+
t += this.renderer.hr(r);
|
|
2634
|
+
break;
|
|
2635
|
+
}
|
|
2636
|
+
case "heading": {
|
|
2637
|
+
t += this.renderer.heading(r);
|
|
2638
|
+
break;
|
|
2639
|
+
}
|
|
2640
|
+
case "code": {
|
|
2641
|
+
t += this.renderer.code(r);
|
|
2642
|
+
break;
|
|
2643
|
+
}
|
|
2644
|
+
case "table": {
|
|
2645
|
+
t += this.renderer.table(r);
|
|
2646
|
+
break;
|
|
2647
|
+
}
|
|
2648
|
+
case "blockquote": {
|
|
2649
|
+
t += this.renderer.blockquote(r);
|
|
2650
|
+
break;
|
|
2651
|
+
}
|
|
2652
|
+
case "list": {
|
|
2653
|
+
t += this.renderer.list(r);
|
|
2654
|
+
break;
|
|
2655
|
+
}
|
|
2656
|
+
case "checkbox": {
|
|
2657
|
+
t += this.renderer.checkbox(r);
|
|
2658
|
+
break;
|
|
2659
|
+
}
|
|
2660
|
+
case "html": {
|
|
2661
|
+
t += this.renderer.html(r);
|
|
2662
|
+
break;
|
|
2663
|
+
}
|
|
2664
|
+
case "def": {
|
|
2665
|
+
t += this.renderer.def(r);
|
|
2666
|
+
break;
|
|
2667
|
+
}
|
|
2668
|
+
case "paragraph": {
|
|
2669
|
+
t += this.renderer.paragraph(r);
|
|
2670
|
+
break;
|
|
2671
|
+
}
|
|
2672
|
+
case "text": {
|
|
2673
|
+
t += this.renderer.text(r);
|
|
2674
|
+
break;
|
|
2675
|
+
}
|
|
2676
|
+
default: {
|
|
2677
|
+
let i = 'Token with "' + r.type + '" type was not found.';
|
|
2678
|
+
if (this.options.silent) return console.error(i), "";
|
|
2679
|
+
throw new Error(i);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
return t;
|
|
2684
|
+
}
|
|
2685
|
+
parseInline(e, t = this.renderer) {
|
|
2686
|
+
this.renderer.parser = this;
|
|
2687
|
+
let n = "";
|
|
2688
|
+
for (let s = 0; s < e.length; s++) {
|
|
2689
|
+
let r = e[s];
|
|
2690
|
+
if (this.options.extensions?.renderers?.[r.type]) {
|
|
2691
|
+
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
2692
|
+
if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
2693
|
+
n += o || "";
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
let i = r;
|
|
2698
|
+
switch (i.type) {
|
|
2699
|
+
case "escape": {
|
|
2700
|
+
n += t.text(i);
|
|
2701
|
+
break;
|
|
2702
|
+
}
|
|
2703
|
+
case "html": {
|
|
2704
|
+
n += t.html(i);
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
case "link": {
|
|
2708
|
+
n += t.link(i);
|
|
2709
|
+
break;
|
|
2710
|
+
}
|
|
2711
|
+
case "image": {
|
|
2712
|
+
n += t.image(i);
|
|
2713
|
+
break;
|
|
2714
|
+
}
|
|
2715
|
+
case "checkbox": {
|
|
2716
|
+
n += t.checkbox(i);
|
|
2717
|
+
break;
|
|
2718
|
+
}
|
|
2719
|
+
case "strong": {
|
|
2720
|
+
n += t.strong(i);
|
|
2721
|
+
break;
|
|
2722
|
+
}
|
|
2723
|
+
case "em": {
|
|
2724
|
+
n += t.em(i);
|
|
2725
|
+
break;
|
|
2726
|
+
}
|
|
2727
|
+
case "codespan": {
|
|
2728
|
+
n += t.codespan(i);
|
|
2729
|
+
break;
|
|
2730
|
+
}
|
|
2731
|
+
case "br": {
|
|
2732
|
+
n += t.br(i);
|
|
2733
|
+
break;
|
|
2734
|
+
}
|
|
2735
|
+
case "del": {
|
|
2736
|
+
n += t.del(i);
|
|
2737
|
+
break;
|
|
2738
|
+
}
|
|
2739
|
+
case "text": {
|
|
2740
|
+
n += t.text(i);
|
|
2741
|
+
break;
|
|
2742
|
+
}
|
|
2743
|
+
default: {
|
|
2744
|
+
let o = 'Token with "' + i.type + '" type was not found.';
|
|
2745
|
+
if (this.options.silent) return console.error(o), "";
|
|
2746
|
+
throw new Error(o);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
return n;
|
|
2751
|
+
}
|
|
2752
|
+
};
|
|
2753
|
+
var S = class {
|
|
2754
|
+
options;
|
|
2755
|
+
block;
|
|
2756
|
+
constructor(e) {
|
|
2757
|
+
this.options = e || R;
|
|
2758
|
+
}
|
|
2759
|
+
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
2760
|
+
static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
2761
|
+
preprocess(e) {
|
|
2762
|
+
return e;
|
|
2763
|
+
}
|
|
2764
|
+
postprocess(e) {
|
|
2765
|
+
return e;
|
|
2766
|
+
}
|
|
2767
|
+
processAllTokens(e) {
|
|
2768
|
+
return e;
|
|
2769
|
+
}
|
|
2770
|
+
emStrongMask(e) {
|
|
2771
|
+
return e;
|
|
2772
|
+
}
|
|
2773
|
+
provideLexer(e = this.block) {
|
|
2774
|
+
return e ? x.lex : x.lexInline;
|
|
2775
|
+
}
|
|
2776
|
+
provideParser(e = this.block) {
|
|
2777
|
+
return e ? b.parse : b.parseInline;
|
|
2778
|
+
}
|
|
2779
|
+
};
|
|
2780
|
+
var Z = class {
|
|
2781
|
+
defaults = C();
|
|
2782
|
+
options = this.setOptions;
|
|
2783
|
+
parse = this.parseMarkdown(true);
|
|
2784
|
+
parseInline = this.parseMarkdown(false);
|
|
2785
|
+
Parser = b;
|
|
2786
|
+
Renderer = P;
|
|
2787
|
+
TextRenderer = L;
|
|
2788
|
+
Lexer = x;
|
|
2789
|
+
Tokenizer = y;
|
|
2790
|
+
Hooks = S;
|
|
2791
|
+
constructor(...e) {
|
|
2792
|
+
this.use(...e);
|
|
2793
|
+
}
|
|
2794
|
+
walkTokens(e, t) {
|
|
2795
|
+
let n = [];
|
|
2796
|
+
for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
|
|
2797
|
+
case "table": {
|
|
2798
|
+
let r = s;
|
|
2799
|
+
for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
|
|
2800
|
+
for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
|
|
2801
|
+
break;
|
|
2802
|
+
}
|
|
2803
|
+
case "list": {
|
|
2804
|
+
let r = s;
|
|
2805
|
+
n = n.concat(this.walkTokens(r.items, t));
|
|
2806
|
+
break;
|
|
2807
|
+
}
|
|
2808
|
+
default: {
|
|
2809
|
+
let r = s;
|
|
2810
|
+
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
2811
|
+
let o = r[i].flat(1 / 0);
|
|
2812
|
+
n = n.concat(this.walkTokens(o, t));
|
|
2813
|
+
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return n;
|
|
2817
|
+
}
|
|
2818
|
+
use(...e) {
|
|
2819
|
+
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
2820
|
+
return e.forEach((n) => {
|
|
2821
|
+
let s = { ...n };
|
|
2822
|
+
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
2823
|
+
if (!r.name) throw new Error("extension name required");
|
|
2824
|
+
if ("renderer" in r) {
|
|
2825
|
+
let i = t.renderers[r.name];
|
|
2826
|
+
i ? t.renderers[r.name] = function(...o) {
|
|
2827
|
+
let p = r.renderer.apply(this, o);
|
|
2828
|
+
return p === false && (p = i.apply(this, o)), p;
|
|
2829
|
+
} : t.renderers[r.name] = r.renderer;
|
|
2830
|
+
}
|
|
2831
|
+
if ("tokenizer" in r) {
|
|
2832
|
+
if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
|
|
2833
|
+
let i = t[r.level];
|
|
2834
|
+
i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
2835
|
+
}
|
|
2836
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
2837
|
+
}), s.extensions = t), n.renderer) {
|
|
2838
|
+
let r = this.defaults.renderer || new P(this.defaults);
|
|
2839
|
+
for (let i in n.renderer) {
|
|
2840
|
+
if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
|
|
2841
|
+
if (["options", "parser"].includes(i)) continue;
|
|
2842
|
+
let o = i, p = n.renderer[o], a = r[o];
|
|
2843
|
+
r[o] = (...u) => {
|
|
2844
|
+
let c = p.apply(r, u);
|
|
2845
|
+
return c === false && (c = a.apply(r, u)), c || "";
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
s.renderer = r;
|
|
2849
|
+
}
|
|
2850
|
+
if (n.tokenizer) {
|
|
2851
|
+
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
2852
|
+
for (let i in n.tokenizer) {
|
|
2853
|
+
if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
|
|
2854
|
+
if (["options", "rules", "lexer"].includes(i)) continue;
|
|
2855
|
+
let o = i, p = n.tokenizer[o], a = r[o];
|
|
2856
|
+
r[o] = (...u) => {
|
|
2857
|
+
let c = p.apply(r, u);
|
|
2858
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
s.tokenizer = r;
|
|
2862
|
+
}
|
|
2863
|
+
if (n.hooks) {
|
|
2864
|
+
let r = this.defaults.hooks || new S();
|
|
2865
|
+
for (let i in n.hooks) {
|
|
2866
|
+
if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
|
|
2867
|
+
if (["options", "block"].includes(i)) continue;
|
|
2868
|
+
let o = i, p = n.hooks[o], a = r[o];
|
|
2869
|
+
S.passThroughHooks.has(i) ? r[o] = (u) => {
|
|
2870
|
+
if (this.defaults.async && S.passThroughHooksRespectAsync.has(i)) return (async () => {
|
|
2871
|
+
let h = await p.call(r, u);
|
|
2872
|
+
return a.call(r, h);
|
|
2873
|
+
})();
|
|
2874
|
+
let c = p.call(r, u);
|
|
2875
|
+
return a.call(r, c);
|
|
2876
|
+
} : r[o] = (...u) => {
|
|
2877
|
+
if (this.defaults.async) return (async () => {
|
|
2878
|
+
let h = await p.apply(r, u);
|
|
2879
|
+
return h === false && (h = await a.apply(r, u)), h;
|
|
2880
|
+
})();
|
|
2881
|
+
let c = p.apply(r, u);
|
|
2882
|
+
return c === false && (c = a.apply(r, u)), c;
|
|
2883
|
+
};
|
|
2884
|
+
}
|
|
2885
|
+
s.hooks = r;
|
|
2886
|
+
}
|
|
2887
|
+
if (n.walkTokens) {
|
|
2888
|
+
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
2889
|
+
s.walkTokens = function(o) {
|
|
2890
|
+
let p = [];
|
|
2891
|
+
return p.push(i.call(this, o)), r && (p = p.concat(r.call(this, o))), p;
|
|
2892
|
+
};
|
|
2893
|
+
}
|
|
2894
|
+
this.defaults = { ...this.defaults, ...s };
|
|
2895
|
+
}), this;
|
|
2896
|
+
}
|
|
2897
|
+
setOptions(e) {
|
|
2898
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
2899
|
+
}
|
|
2900
|
+
lexer(e, t) {
|
|
2901
|
+
return x.lex(e, t ?? this.defaults);
|
|
2902
|
+
}
|
|
2903
|
+
parser(e, t) {
|
|
2904
|
+
return b.parse(e, t ?? this.defaults);
|
|
2905
|
+
}
|
|
2906
|
+
parseMarkdown(e) {
|
|
2907
|
+
return (n, s) => {
|
|
2908
|
+
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
2909
|
+
if (this.defaults.async === true && r.async === false) 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."));
|
|
2910
|
+
if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
|
|
2911
|
+
if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2912
|
+
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
|
|
2913
|
+
let p = i.hooks ? await i.hooks.preprocess(n) : n, u = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(p, i), c = i.hooks ? await i.hooks.processAllTokens(u) : u;
|
|
2914
|
+
i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
|
|
2915
|
+
let k = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
|
|
2916
|
+
return i.hooks ? await i.hooks.postprocess(k) : k;
|
|
2917
|
+
})().catch(o);
|
|
2918
|
+
try {
|
|
2919
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
2920
|
+
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
2921
|
+
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
2922
|
+
let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
2923
|
+
return i.hooks && (c = i.hooks.postprocess(c)), c;
|
|
2924
|
+
} catch (p) {
|
|
2925
|
+
return o(p);
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
}
|
|
2929
|
+
onError(e, t) {
|
|
2930
|
+
return (n) => {
|
|
2931
|
+
if (n.message += `
|
|
2932
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2933
|
+
let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
|
|
2934
|
+
return t ? Promise.resolve(s) : s;
|
|
2935
|
+
}
|
|
2936
|
+
if (t) return Promise.reject(n);
|
|
2937
|
+
throw n;
|
|
2938
|
+
};
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
var E = new Z();
|
|
2942
|
+
function f(l3, e) {
|
|
2943
|
+
return E.parse(l3, e);
|
|
2944
|
+
}
|
|
2945
|
+
f.options = f.setOptions = function(l3) {
|
|
2946
|
+
return E.setOptions(l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
2947
|
+
};
|
|
2948
|
+
f.getDefaults = C;
|
|
2949
|
+
f.defaults = R;
|
|
2950
|
+
function kt(...l3) {
|
|
2951
|
+
return E.use(...l3), f.defaults = E.defaults, j(f.defaults), f;
|
|
2952
|
+
}
|
|
2953
|
+
f.use = kt;
|
|
2954
|
+
f.walkTokens = function(l3, e) {
|
|
2955
|
+
return E.walkTokens(l3, e);
|
|
2956
|
+
};
|
|
2957
|
+
f.parseInline = E.parseInline;
|
|
2958
|
+
f.Parser = b;
|
|
2959
|
+
f.parser = b.parse;
|
|
2960
|
+
f.Renderer = P;
|
|
2961
|
+
f.TextRenderer = L;
|
|
2962
|
+
f.Lexer = x;
|
|
2963
|
+
f.lexer = x.lex;
|
|
2964
|
+
f.Tokenizer = y;
|
|
2965
|
+
f.Hooks = S;
|
|
2966
|
+
f.parse = f;
|
|
2967
|
+
var nn = f.options;
|
|
2968
|
+
var rn = f.setOptions;
|
|
2969
|
+
var sn = f.walkTokens;
|
|
2970
|
+
var on = f.parseInline;
|
|
2971
|
+
var ln = b.parse;
|
|
2972
|
+
var pn = x.lex;
|
|
29
2973
|
|
|
30
|
-
// src/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2974
|
+
// src/web-markdown-preview.ts
|
|
2975
|
+
f.use({
|
|
2976
|
+
gfm: true,
|
|
2977
|
+
breaks: false
|
|
2978
|
+
});
|
|
2979
|
+
var SAFE_LINK_PATTERN = /^(?:(?:https?|mailto|tel):|note:\/\/note_[a-f0-9]{32}$|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i;
|
|
2980
|
+
var NOTE_LINK_PATTERN = /^note:\/\/(note_[a-f0-9]{32})$/;
|
|
2981
|
+
function renderMarkdown(markdown) {
|
|
2982
|
+
const rendered = f.parse(markdown, { async: false });
|
|
2983
|
+
const sanitized = purify.sanitize(rendered, {
|
|
2984
|
+
FORBID_TAGS: ["style", "form", "input", "button", "textarea", "select", "option", "iframe", "object", "embed", "svg", "math", "video", "audio"],
|
|
2985
|
+
FORBID_ATTR: ["style"],
|
|
2986
|
+
RETURN_TRUSTED_TYPE: false,
|
|
2987
|
+
USE_PROFILES: { html: true },
|
|
2988
|
+
ALLOWED_URI_REGEXP: SAFE_LINK_PATTERN
|
|
2989
|
+
});
|
|
2990
|
+
const template = document.createElement("template");
|
|
2991
|
+
template.innerHTML = sanitized;
|
|
2992
|
+
for (const link of template.content.querySelectorAll("a")) {
|
|
2993
|
+
const note = NOTE_LINK_PATTERN.exec(link.getAttribute("href") ?? "");
|
|
2994
|
+
if (note?.[1]) {
|
|
2995
|
+
link.removeAttribute("href");
|
|
2996
|
+
link.dataset.noteId = note[1];
|
|
2997
|
+
link.classList.add("note-reference");
|
|
2998
|
+
continue;
|
|
2999
|
+
}
|
|
3000
|
+
link.target = "_blank";
|
|
3001
|
+
link.rel = "noopener noreferrer";
|
|
3002
|
+
}
|
|
3003
|
+
return template.innerHTML;
|
|
36
3004
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
3005
|
+
|
|
3006
|
+
// src/knowledge-activity-notes.tsx
|
|
3007
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3008
|
+
function KnowledgeActivityNotes({ sessionId, projectId, controller }) {
|
|
3009
|
+
const initial = controller.selection(sessionId);
|
|
3010
|
+
const [folderId, setFolderId] = (0, import_react.useState)(initial.noteFolderId ?? null);
|
|
3011
|
+
const [crumbs, setCrumbs] = (0, import_react.useState)([{ id: null, name: "\u5168\u90E8\u7B14\u8BB0" }]);
|
|
3012
|
+
const [selectedId, setSelectedId] = (0, import_react.useState)(initial.noteDocumentId);
|
|
3013
|
+
const [nodes, setNodes] = (0, import_react.useState)([]);
|
|
3014
|
+
const [content, setContent] = (0, import_react.useState)();
|
|
3015
|
+
const [queryInput, setQueryInput] = (0, import_react.useState)("");
|
|
3016
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
3017
|
+
const [listState, setListState] = (0, import_react.useState)("loading");
|
|
3018
|
+
const [contentState, setContentState] = (0, import_react.useState)("idle");
|
|
3019
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
3020
|
+
const [refresh, setRefresh] = (0, import_react.useState)(0);
|
|
3021
|
+
const loadNodes = (0, import_react.useCallback)(async (signal) => {
|
|
3022
|
+
setListState("loading");
|
|
3023
|
+
setError("");
|
|
3024
|
+
try {
|
|
3025
|
+
const value = await loadNoteIndex({
|
|
3026
|
+
sessionId,
|
|
3027
|
+
...projectId === void 0 ? {} : { projectId },
|
|
3028
|
+
parentId: folderId,
|
|
3029
|
+
query,
|
|
3030
|
+
...signal === void 0 ? {} : { signal }
|
|
3031
|
+
});
|
|
3032
|
+
setNodes(value);
|
|
3033
|
+
setListState("ready");
|
|
3034
|
+
} catch (reason) {
|
|
3035
|
+
if (signal?.aborted) return;
|
|
3036
|
+
setListState("error");
|
|
3037
|
+
setError(message(reason));
|
|
3038
|
+
}
|
|
3039
|
+
}, [folderId, projectId, query, sessionId]);
|
|
3040
|
+
(0, import_react.useEffect)(() => {
|
|
3041
|
+
const abort = new AbortController();
|
|
3042
|
+
void loadNodes(abort.signal);
|
|
3043
|
+
return () => {
|
|
3044
|
+
abort.abort();
|
|
3045
|
+
};
|
|
3046
|
+
}, [loadNodes, refresh]);
|
|
3047
|
+
(0, import_react.useEffect)(() => {
|
|
3048
|
+
if (selectedId === void 0) {
|
|
3049
|
+
setContent(void 0);
|
|
3050
|
+
setContentState("idle");
|
|
3051
|
+
return;
|
|
3052
|
+
}
|
|
3053
|
+
const abort = new AbortController();
|
|
3054
|
+
setContentState("loading");
|
|
3055
|
+
setError("");
|
|
3056
|
+
void loadNoteContent({
|
|
3057
|
+
id: selectedId,
|
|
3058
|
+
sessionId,
|
|
3059
|
+
...projectId === void 0 ? {} : { projectId },
|
|
3060
|
+
signal: abort.signal
|
|
3061
|
+
}).then((value) => {
|
|
3062
|
+
setContent(value);
|
|
3063
|
+
setContentState("ready");
|
|
3064
|
+
}).catch((reason) => {
|
|
3065
|
+
if (abort.signal.aborted) return;
|
|
3066
|
+
setContentState("error");
|
|
3067
|
+
setError(message(reason));
|
|
3068
|
+
});
|
|
3069
|
+
return () => {
|
|
3070
|
+
abort.abort();
|
|
3071
|
+
};
|
|
3072
|
+
}, [projectId, refresh, selectedId, sessionId]);
|
|
3073
|
+
const openFolder = (node) => {
|
|
3074
|
+
setFolderId(node.id);
|
|
3075
|
+
setCrumbs((current) => [...current, { id: node.id, name: node.name }]);
|
|
3076
|
+
setQuery("");
|
|
3077
|
+
setQueryInput("");
|
|
3078
|
+
controller.select(sessionId, { ...controller.selection(sessionId), mode: "notes", noteFolderId: node.id, noteDocumentId: void 0 });
|
|
41
3079
|
};
|
|
42
|
-
|
|
43
|
-
|
|
3080
|
+
const openCrumb = (crumb, index) => {
|
|
3081
|
+
setFolderId(crumb.id);
|
|
3082
|
+
setCrumbs((current) => current.slice(0, index + 1));
|
|
3083
|
+
setSelectedId(void 0);
|
|
3084
|
+
controller.select(sessionId, { ...controller.selection(sessionId), mode: "notes", noteFolderId: crumb.id, noteDocumentId: void 0 });
|
|
3085
|
+
};
|
|
3086
|
+
const openNode = (node) => {
|
|
3087
|
+
if (node.kind === "folder") return openFolder(node);
|
|
3088
|
+
if (!node.editable) return;
|
|
3089
|
+
setSelectedId(node.id);
|
|
3090
|
+
controller.select(sessionId, { ...controller.selection(sessionId), mode: "notes", noteFolderId: folderId, noteDocumentId: node.id });
|
|
3091
|
+
};
|
|
3092
|
+
const closeDocument = () => {
|
|
3093
|
+
setSelectedId(void 0);
|
|
3094
|
+
setContent(void 0);
|
|
3095
|
+
controller.select(sessionId, { ...controller.selection(sessionId), mode: "notes", noteFolderId: folderId, noteDocumentId: void 0 });
|
|
3096
|
+
};
|
|
3097
|
+
const submitSearch = (event) => {
|
|
3098
|
+
event.preventDefault();
|
|
3099
|
+
setSelectedId(void 0);
|
|
3100
|
+
setContent(void 0);
|
|
3101
|
+
setQuery(queryInput.trim());
|
|
3102
|
+
};
|
|
3103
|
+
if (selectedId !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3104
|
+
NoteReader,
|
|
3105
|
+
{
|
|
3106
|
+
value: content,
|
|
3107
|
+
state: contentState,
|
|
3108
|
+
error,
|
|
3109
|
+
onBack: closeDocument,
|
|
3110
|
+
onRetry: () => setRefresh((value) => value + 1)
|
|
3111
|
+
}
|
|
3112
|
+
);
|
|
3113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-browser", children: [
|
|
3114
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "dsh-knowledge-activity-search", role: "search", onSubmit: submitSearch, children: [
|
|
3115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconSearchOutline16, { size: 16, "aria-hidden": "true" }),
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { "aria-label": "\u641C\u7D22\u7B14\u8BB0\u6587\u6863", value: queryInput, placeholder: "\u641C\u7D22\u7B14\u8BB0\u548C\u76EE\u5F55\u2026", onChange: (event) => setQueryInput(event.target.value) }),
|
|
3117
|
+
queryInput && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => {
|
|
3118
|
+
setQueryInput("");
|
|
3119
|
+
setQuery("");
|
|
3120
|
+
}, "aria-label": "\u6E05\u9664\u641C\u7D22", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCloseOutline16, { size: 14 }) })
|
|
3121
|
+
] }),
|
|
3122
|
+
!query && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: "dsh-knowledge-activity-breadcrumbs", "aria-label": "\u7B14\u8BB0\u76EE\u5F55\u8DEF\u5F84", children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
3123
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutline14, { size: 12 }),
|
|
3124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-current": index === crumbs.length - 1 ? "location" : void 0, onClick: () => openCrumb(crumb, index), children: crumb.name })
|
|
3125
|
+
] }, `${crumb.id ?? "root"}-${index}`)) }),
|
|
3126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-list-heading", children: [
|
|
3127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
3128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: query ? `\u201C${query}\u201D \u7684\u7ED3\u679C` : crumbs.at(-1)?.name ?? "\u7B14\u8BB0\u6587\u6863" }),
|
|
3129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: query ? "\u641C\u7D22\u5168\u90E8\u7B14\u8BB0" : `\u5F53\u524D\u663E\u793A ${nodes.length} \u9879` })
|
|
3130
|
+
] }),
|
|
3131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dsh-knowledge-activity-icon-button", "aria-label": "\u5237\u65B0\u7B14\u8BB0", title: "\u5237\u65B0", onClick: () => setRefresh((value) => value + 1), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconRefreshOutline14, { size: 14 }) })
|
|
3132
|
+
] }),
|
|
3133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-knowledge-activity-list", "aria-busy": listState === "loading", children: listState === "loading" && nodes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityState, { label: "\u6B63\u5728\u8BFB\u53D6\u7B14\u8BB0\u2026" }) : listState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityError, { error, onRetry: () => setRefresh((value) => value + 1) }) : nodes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityEmpty, { query }) : nodes.map((node) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-knowledge-activity-row", disabled: node.kind !== "folder" && !node.editable, onClick: () => openNode(node), children: [
|
|
3134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-knowledge-activity-row-icon", children: node.kind === "folder" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconFolderOpenOutline16, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 16 }) }),
|
|
3135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-knowledge-activity-row-copy", children: [
|
|
3136
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: node.name }),
|
|
3137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: node.kind === "folder" ? "\u76EE\u5F55" : node.editable ? formatSize(node.size) : "\u6682\u4E0D\u652F\u6301\u4FA7\u680F\u9884\u89C8" })
|
|
3138
|
+
] }),
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-knowledge-activity-row-meta", children: [
|
|
3140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("time", { dateTime: node.updatedAt, children: formatDate(node.updatedAt) }),
|
|
3141
|
+
node.kind === "folder" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronRightOutline14, { size: 13 })
|
|
3142
|
+
] })
|
|
3143
|
+
] }, node.id)) })
|
|
3144
|
+
] });
|
|
3145
|
+
}
|
|
3146
|
+
function NoteReader({ value, state, error, onBack, onRetry }) {
|
|
3147
|
+
const html2 = (0, import_react.useMemo)(() => value === void 0 ? "" : renderMarkdown(value.content), [value]);
|
|
3148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-reader", children: [
|
|
3149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-reader-bar", children: [
|
|
3150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-knowledge-activity-back", onClick: onBack, children: [
|
|
3151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronLeftOutline14, { size: 14 }),
|
|
3152
|
+
"\u7B14\u8BB0\u76EE\u5F55"
|
|
3153
|
+
] }),
|
|
3154
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
3155
|
+
formatDate(value.node.updatedAt),
|
|
3156
|
+
" \u66F4\u65B0"
|
|
3157
|
+
] })
|
|
3158
|
+
] }),
|
|
3159
|
+
state === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityState, { label: "\u6B63\u5728\u6253\u5F00\u7B14\u8BB0\u2026" }) : state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityError, { error, onRetry }) : value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityState, { label: "\u6B63\u5728\u51C6\u5907\u7B14\u8BB0\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-document-heading", children: [
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-knowledge-activity-document-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 18 }) }),
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
3163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: value.node.name }),
|
|
3164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
3165
|
+
"\u7B14\u8BB0\u6587\u6863 \xB7 ",
|
|
3166
|
+
formatSize(value.node.size)
|
|
3167
|
+
] })
|
|
3168
|
+
] })
|
|
3169
|
+
] }),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("article", { className: "dsh-knowledge-activity-markdown", dangerouslySetInnerHTML: { __html: html2 } })
|
|
3171
|
+
] })
|
|
3172
|
+
] });
|
|
3173
|
+
}
|
|
3174
|
+
function ActivityState({ label }) {
|
|
3175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsh-knowledge-activity-state", role: "status", children: [
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true" }),
|
|
3177
|
+
label
|
|
3178
|
+
] });
|
|
3179
|
+
}
|
|
3180
|
+
function ActivityError({ error, onRetry }) {
|
|
3181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-error", role: "alert", children: [
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6" }),
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: error }),
|
|
3184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: onRetry, children: "\u91CD\u8BD5" })
|
|
3185
|
+
] });
|
|
3186
|
+
}
|
|
3187
|
+
function ActivityEmpty({ query }) {
|
|
3188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-activity-empty", children: [
|
|
3189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 20 }) }),
|
|
3190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: query ? "\u6CA1\u6709\u627E\u5230\u76F8\u5173\u7B14\u8BB0" : "\u8FD9\u4E2A\u76EE\u5F55\u8FD8\u662F\u7A7A\u7684" }),
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: query ? "\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u6E05\u9664\u641C\u7D22\u540E\u6D4F\u89C8\u76EE\u5F55\u3002" : "\u53EF\u4EE5\u5728\u5B8C\u6574\u5DE5\u4F5C\u533A\u4E2D\u65B0\u5EFA\u6216\u5BFC\u5165\u7B14\u8BB0\u3002" })
|
|
3192
|
+
] });
|
|
3193
|
+
}
|
|
3194
|
+
function formatDate(value) {
|
|
3195
|
+
const date = new Date(value);
|
|
3196
|
+
if (Number.isNaN(date.getTime())) return "\u672A\u77E5\u65F6\u95F4";
|
|
3197
|
+
return new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit" }).format(date);
|
|
3198
|
+
}
|
|
3199
|
+
function formatSize(value) {
|
|
3200
|
+
if (value < 1024) return `${value} B`;
|
|
3201
|
+
if (value < 1024 * 1024) return `${(value / 1024).toFixed(value < 10 * 1024 ? 1 : 0)} KB`;
|
|
3202
|
+
return `${(value / 1024 / 1024).toFixed(1)} MB`;
|
|
3203
|
+
}
|
|
3204
|
+
function message(reason) {
|
|
3205
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
44
3206
|
}
|
|
45
3207
|
|
|
46
|
-
// src/
|
|
47
|
-
var
|
|
3208
|
+
// src/knowledge-activity-panel.tsx
|
|
3209
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
3210
|
+
function KnowledgeActivityPanel(props) {
|
|
3211
|
+
const sessionId = String(props.sessionId);
|
|
3212
|
+
const projectId = props.useSessions((state) => state.byId[sessionId]?.cwd);
|
|
3213
|
+
const initial = props.controller.selection(sessionId);
|
|
3214
|
+
const [mode, setMode] = (0, import_react2.useState)(initial.mode ?? "knowledge");
|
|
3215
|
+
const [mounts, setMounts] = (0, import_react2.useState)([]);
|
|
3216
|
+
const [selectedBaseId, setSelectedBaseId] = (0, import_react2.useState)(initial.knowledgeBaseId);
|
|
3217
|
+
const [selectedDocumentId, setSelectedDocumentId] = (0, import_react2.useState)(initial.documentId);
|
|
3218
|
+
const [documents, setDocuments] = (0, import_react2.useState)([]);
|
|
3219
|
+
const [documentValue, setDocumentValue] = (0, import_react2.useState)();
|
|
3220
|
+
const [queryInput, setQueryInput] = (0, import_react2.useState)("");
|
|
3221
|
+
const [query, setQuery] = (0, import_react2.useState)("");
|
|
3222
|
+
const [mountState, setMountState] = (0, import_react2.useState)("loading");
|
|
3223
|
+
const [listState, setListState] = (0, import_react2.useState)("idle");
|
|
3224
|
+
const [documentState, setDocumentState] = (0, import_react2.useState)("idle");
|
|
3225
|
+
const [documentRefresh, setDocumentRefresh] = (0, import_react2.useState)(0);
|
|
3226
|
+
const [error, setError] = (0, import_react2.useState)("");
|
|
3227
|
+
const [nextCursor, setNextCursor] = (0, import_react2.useState)();
|
|
3228
|
+
const [baseMenuOpen, setBaseMenuOpen] = (0, import_react2.useState)(false);
|
|
3229
|
+
const scopeRef = (0, import_react2.useRef)(null);
|
|
3230
|
+
(0, import_react2.useEffect)(() => {
|
|
3231
|
+
if (!baseMenuOpen) return;
|
|
3232
|
+
const closeOutside = (event) => {
|
|
3233
|
+
if (!scopeRef.current?.contains(event.target)) setBaseMenuOpen(false);
|
|
3234
|
+
};
|
|
3235
|
+
const closeOnEscape = (event) => {
|
|
3236
|
+
if (event.key === "Escape") setBaseMenuOpen(false);
|
|
3237
|
+
};
|
|
3238
|
+
document.addEventListener("pointerdown", closeOutside);
|
|
3239
|
+
document.addEventListener("keydown", closeOnEscape);
|
|
3240
|
+
return () => {
|
|
3241
|
+
document.removeEventListener("pointerdown", closeOutside);
|
|
3242
|
+
document.removeEventListener("keydown", closeOnEscape);
|
|
3243
|
+
};
|
|
3244
|
+
}, [baseMenuOpen]);
|
|
3245
|
+
const refreshMounts = (0, import_react2.useCallback)(async (signal) => {
|
|
3246
|
+
setMountState("loading");
|
|
3247
|
+
setError("");
|
|
3248
|
+
try {
|
|
3249
|
+
const next = await loadMountedKnowledge(sessionId, projectId, signal);
|
|
3250
|
+
setMounts(next);
|
|
3251
|
+
const current = props.controller.selection(sessionId);
|
|
3252
|
+
const selected = next.some((item) => item.knowledgeBaseId === current.knowledgeBaseId) ? current.knowledgeBaseId : next[0]?.knowledgeBaseId;
|
|
3253
|
+
props.controller.select(sessionId, {
|
|
3254
|
+
...selected === void 0 ? {} : { knowledgeBaseId: selected },
|
|
3255
|
+
...selected === current.knowledgeBaseId && current.documentId !== void 0 ? { documentId: current.documentId } : {}
|
|
3256
|
+
});
|
|
3257
|
+
setSelectedBaseId(selected);
|
|
3258
|
+
if (selected !== current.knowledgeBaseId) {
|
|
3259
|
+
setSelectedDocumentId(void 0);
|
|
3260
|
+
setDocumentValue(void 0);
|
|
3261
|
+
}
|
|
3262
|
+
setMountState("ready");
|
|
3263
|
+
} catch (reason) {
|
|
3264
|
+
if (signal?.aborted) return;
|
|
3265
|
+
setMountState("error");
|
|
3266
|
+
setError(message2(reason));
|
|
3267
|
+
}
|
|
3268
|
+
}, [projectId, props.controller, sessionId]);
|
|
3269
|
+
(0, import_react2.useEffect)(() => {
|
|
3270
|
+
const controller = new AbortController();
|
|
3271
|
+
void refreshMounts(controller.signal);
|
|
3272
|
+
return () => {
|
|
3273
|
+
controller.abort();
|
|
3274
|
+
};
|
|
3275
|
+
}, [refreshMounts]);
|
|
3276
|
+
const loadIndex = (0, import_react2.useCallback)(async (cursor, append = false, signal) => {
|
|
3277
|
+
if (mounts.length === 0 || query.length === 0 && selectedBaseId === void 0) {
|
|
3278
|
+
setDocuments([]);
|
|
3279
|
+
setNextCursor(void 0);
|
|
3280
|
+
setListState("ready");
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
setListState("loading");
|
|
3284
|
+
setError("");
|
|
3285
|
+
try {
|
|
3286
|
+
const result = await loadKnowledgeDocumentIndex({
|
|
3287
|
+
sessionId,
|
|
3288
|
+
...projectId === void 0 ? {} : { projectId },
|
|
3289
|
+
knowledgeBaseIds: query ? mounts.map((item) => item.knowledgeBaseId) : [selectedBaseId],
|
|
3290
|
+
...query ? { query } : {},
|
|
3291
|
+
...cursor === void 0 ? {} : { cursor },
|
|
3292
|
+
...signal === void 0 ? {} : { signal }
|
|
3293
|
+
});
|
|
3294
|
+
setDocuments((current) => append ? [...current, ...result.items] : result.items);
|
|
3295
|
+
setNextCursor(result.nextCursor);
|
|
3296
|
+
setListState("ready");
|
|
3297
|
+
} catch (reason) {
|
|
3298
|
+
if (signal?.aborted) return;
|
|
3299
|
+
setListState("error");
|
|
3300
|
+
setError(message2(reason));
|
|
3301
|
+
}
|
|
3302
|
+
}, [mounts, projectId, query, selectedBaseId, sessionId]);
|
|
3303
|
+
(0, import_react2.useEffect)(() => {
|
|
3304
|
+
const controller = new AbortController();
|
|
3305
|
+
void loadIndex(void 0, false, controller.signal);
|
|
3306
|
+
return () => {
|
|
3307
|
+
controller.abort();
|
|
3308
|
+
};
|
|
3309
|
+
}, [loadIndex]);
|
|
3310
|
+
(0, import_react2.useEffect)(() => {
|
|
3311
|
+
if (selectedDocumentId === void 0) {
|
|
3312
|
+
setDocumentValue(void 0);
|
|
3313
|
+
setDocumentState("idle");
|
|
3314
|
+
return;
|
|
3315
|
+
}
|
|
3316
|
+
const controller = new AbortController();
|
|
3317
|
+
setDocumentState("loading");
|
|
3318
|
+
setError("");
|
|
3319
|
+
void loadKnowledgeDocument({
|
|
3320
|
+
id: selectedDocumentId,
|
|
3321
|
+
sessionId,
|
|
3322
|
+
...projectId === void 0 ? {} : { projectId },
|
|
3323
|
+
signal: controller.signal
|
|
3324
|
+
}).then((value) => {
|
|
3325
|
+
setDocumentValue(value);
|
|
3326
|
+
setDocumentState("ready");
|
|
3327
|
+
}).catch((reason) => {
|
|
3328
|
+
if (controller.signal.aborted) return;
|
|
3329
|
+
setDocumentState("error");
|
|
3330
|
+
setError(message2(reason));
|
|
3331
|
+
});
|
|
3332
|
+
return () => {
|
|
3333
|
+
controller.abort();
|
|
3334
|
+
};
|
|
3335
|
+
}, [documentRefresh, projectId, selectedDocumentId, sessionId]);
|
|
3336
|
+
const selectBase = (knowledgeBaseId) => {
|
|
3337
|
+
setBaseMenuOpen(false);
|
|
3338
|
+
setSelectedBaseId(knowledgeBaseId);
|
|
3339
|
+
setSelectedDocumentId(void 0);
|
|
3340
|
+
setDocumentValue(void 0);
|
|
3341
|
+
setQueryInput("");
|
|
3342
|
+
setQuery("");
|
|
3343
|
+
props.controller.select(sessionId, { mode: "knowledge", knowledgeBaseId });
|
|
3344
|
+
};
|
|
3345
|
+
const selectDocument = (document2) => {
|
|
3346
|
+
setSelectedBaseId(document2.knowledgeBaseId);
|
|
3347
|
+
setSelectedDocumentId(document2.id);
|
|
3348
|
+
props.controller.select(sessionId, {
|
|
3349
|
+
mode: "knowledge",
|
|
3350
|
+
knowledgeBaseId: document2.knowledgeBaseId,
|
|
3351
|
+
documentId: document2.id
|
|
3352
|
+
});
|
|
3353
|
+
};
|
|
3354
|
+
const closeDocument = () => {
|
|
3355
|
+
setSelectedDocumentId(void 0);
|
|
3356
|
+
setDocumentValue(void 0);
|
|
3357
|
+
props.controller.select(sessionId, {
|
|
3358
|
+
mode: "knowledge",
|
|
3359
|
+
...selectedBaseId === void 0 ? {} : { knowledgeBaseId: selectedBaseId }
|
|
3360
|
+
});
|
|
3361
|
+
};
|
|
3362
|
+
const submitSearch = (event) => {
|
|
3363
|
+
event.preventDefault();
|
|
3364
|
+
setSelectedDocumentId(void 0);
|
|
3365
|
+
setDocumentValue(void 0);
|
|
3366
|
+
setQuery(queryInput.trim());
|
|
3367
|
+
};
|
|
3368
|
+
const clearSearch = () => {
|
|
3369
|
+
setQueryInput("");
|
|
3370
|
+
setQuery("");
|
|
3371
|
+
};
|
|
3372
|
+
const workspaceTarget = mode === "notes" ? { view: "notes" } : documentValue === void 0 ? void 0 : {
|
|
3373
|
+
knowledgeBaseId: documentValue.knowledgeBaseId,
|
|
3374
|
+
documentId: documentValue.id
|
|
3375
|
+
};
|
|
3376
|
+
const selectMode = (nextMode) => {
|
|
3377
|
+
setMode(nextMode);
|
|
3378
|
+
setBaseMenuOpen(false);
|
|
3379
|
+
props.controller.select(sessionId, { ...props.controller.selection(sessionId), mode: nextMode });
|
|
3380
|
+
};
|
|
3381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "dsh-knowledge-activity-panel", "data-xiaohei-surface": "plugin-workspace", "aria-label": "\u4F1A\u8BDD\u77E5\u8BC6\u5E93", children: [
|
|
3382
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "dsh-knowledge-activity-header", children: [
|
|
3383
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-title", children: [
|
|
3384
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-knowledge-activity-mark", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDatabaseOutline16, { size: 17 }) }),
|
|
3385
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
3386
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u77E5\u8BC6\u5E93" }),
|
|
3387
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("small", { children: [
|
|
3388
|
+
"\u5F53\u524D\u4F1A\u8BDD \xB7 ",
|
|
3389
|
+
shortId(sessionId)
|
|
3390
|
+
] })
|
|
3391
|
+
] })
|
|
3392
|
+
] }),
|
|
3393
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-header-actions", children: [
|
|
3394
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-knowledge-activity-icon-button", "aria-label": "\u5728\u5B8C\u6574\u5DE5\u4F5C\u533A\u4E2D\u6253\u5F00", title: "\u5B8C\u6574\u5DE5\u4F5C\u533A", onClick: () => props.controller.openWorkspace(workspaceTarget), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconFullscreenOutline16, { size: 16 }) }),
|
|
3395
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-knowledge-activity-icon-button", "aria-label": "\u5173\u95ED\u4F1A\u8BDD\u77E5\u8BC6\u5E93", title: "\u5173\u95ED", onClick: () => props.controller.close(sessionId), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconCloseOutline16, { size: 16 }) })
|
|
3396
|
+
] })
|
|
3397
|
+
] }),
|
|
3398
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("nav", { className: "dsh-knowledge-activity-tabs", "aria-label": "\u77E5\u8BC6\u5E93\u5185\u5BB9\u7C7B\u578B", children: [
|
|
3399
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: mode === "knowledge" ? "is-active" : "", "aria-pressed": mode === "knowledge", onClick: () => selectMode("knowledge"), children: [
|
|
3400
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDatabaseOutline16, { size: 15 }),
|
|
3401
|
+
"\u77E5\u8BC6\u6587\u6863"
|
|
3402
|
+
] }),
|
|
3403
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: mode === "notes" ? "is-active" : "", "aria-pressed": mode === "notes", onClick: () => selectMode("notes"), children: [
|
|
3404
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDataOutline16, { size: 15 }),
|
|
3405
|
+
"\u7B14\u8BB0\u6587\u6863"
|
|
3406
|
+
] })
|
|
3407
|
+
] }),
|
|
3408
|
+
mode === "notes" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(KnowledgeActivityNotes, { sessionId, projectId, controller: props.controller }) : selectedDocumentId === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-browser", children: [
|
|
3409
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { className: "dsh-knowledge-activity-search", role: "search", onSubmit: submitSearch, children: [
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconSearchOutline16, { size: 16, "aria-hidden": "true" }),
|
|
3411
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { "aria-label": "\u641C\u7D22\u5F53\u524D\u4F1A\u8BDD\u77E5\u8BC6\u6587\u6863", value: queryInput, placeholder: "\u641C\u7D22\u5DF2\u6302\u8F7D\u77E5\u8BC6\u2026", onChange: (event) => setQueryInput(event.target.value) }),
|
|
3412
|
+
queryInput && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: clearSearch, "aria-label": "\u6E05\u9664\u641C\u7D22", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconCloseOutline16, { size: 14 }) })
|
|
3413
|
+
] }),
|
|
3414
|
+
mountState === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityState2, { label: "\u6B63\u5728\u8BFB\u53D6\u4F1A\u8BDD\u6302\u8F7D\u2026" }) : mountState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityError2, { message: error, onRetry: () => {
|
|
3415
|
+
void refreshMounts();
|
|
3416
|
+
} }) : mounts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityEmpty2, { title: "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u6302\u8F7D\u77E5\u8BC6\u5E93", description: "\u5728\u5B8C\u6574\u5DE5\u4F5C\u533A\u4E2D\u6302\u8F7D\u540E\uFF0C\u5C31\u80FD\u5728\u8FD9\u91CC\u968F\u624B\u67E5\u9605\u6587\u6863\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3417
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: scopeRef, className: "dsh-knowledge-activity-scope", children: [
|
|
3418
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-knowledge-activity-scope-trigger", "aria-haspopup": "listbox", "aria-expanded": baseMenuOpen, onClick: () => setBaseMenuOpen((value) => !value), children: [
|
|
3419
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-knowledge-activity-scope-icon", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDatabaseOutline16, { size: 15 }) }),
|
|
3420
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
3421
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: "\u5F53\u524D\u77E5\u8BC6\u5E93" }),
|
|
3422
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: mounts.find((item) => item.knowledgeBaseId === selectedBaseId)?.base.name })
|
|
3423
|
+
] }),
|
|
3424
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconChevronDownOutline14, { size: 14, className: baseMenuOpen ? "is-open" : "" })
|
|
3425
|
+
] }),
|
|
3426
|
+
baseMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-knowledge-activity-scope-menu", role: "listbox", "aria-label": "\u5207\u6362\u77E5\u8BC6\u5E93", children: mounts.map((mount) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
3427
|
+
"button",
|
|
3428
|
+
{
|
|
3429
|
+
type: "button",
|
|
3430
|
+
role: "option",
|
|
3431
|
+
"aria-selected": selectedBaseId === mount.knowledgeBaseId,
|
|
3432
|
+
className: selectedBaseId === mount.knowledgeBaseId ? "is-active" : "",
|
|
3433
|
+
onClick: () => selectBase(mount.knowledgeBaseId),
|
|
3434
|
+
children: [
|
|
3435
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDataOutline16, { size: 15 }),
|
|
3436
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
3437
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: mount.base.name }),
|
|
3438
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: mount.inheritedFrom === "project" ? "\u9879\u76EE\u6302\u8F7D" : "\u4F1A\u8BDD\u6302\u8F7D" })
|
|
3439
|
+
] })
|
|
3440
|
+
]
|
|
3441
|
+
},
|
|
3442
|
+
mount.knowledgeBaseId
|
|
3443
|
+
)) })
|
|
3444
|
+
] }),
|
|
3445
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-list-heading", children: [
|
|
3446
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
3447
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: query ? `\u201C${query}\u201D \u7684\u7ED3\u679C` : "\u77E5\u8BC6\u6587\u6863" }),
|
|
3448
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: query ? "\u641C\u7D22\u5168\u90E8\u5DF2\u6302\u8F7D\u77E5\u8BC6\u5E93" : `\u5F53\u524D\u663E\u793A ${documents.length} \u9879` })
|
|
3449
|
+
] }),
|
|
3450
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-knowledge-activity-icon-button", "aria-label": "\u5237\u65B0\u6587\u6863", title: "\u5237\u65B0", onClick: () => {
|
|
3451
|
+
void loadIndex();
|
|
3452
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconRefreshOutline14, { size: 14 }) })
|
|
3453
|
+
] }),
|
|
3454
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-knowledge-activity-list", "aria-busy": listState === "loading", children: listState === "loading" && documents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityState2, { label: "\u6B63\u5728\u8BFB\u53D6\u6587\u6863\u2026" }) : listState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityError2, { message: error, onRetry: () => {
|
|
3455
|
+
void loadIndex();
|
|
3456
|
+
} }) : documents.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityEmpty2, { title: query ? "\u6CA1\u6709\u627E\u5230\u76F8\u5173\u6587\u6863" : "\u8FD9\u91CC\u8FD8\u6CA1\u6709\u77E5\u8BC6\u6587\u6863", description: query ? "\u6362\u4E2A\u5173\u952E\u8BCD\uFF0C\u6216\u6E05\u9664\u641C\u7D22\u540E\u6D4F\u89C8\u76EE\u5F55\u3002" : "\u5BA1\u6838\u901A\u8FC7\u6216\u76F4\u63A5\u56DE\u5199\u7684\u77E5\u8BC6\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3457
|
+
documents.map((document2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3458
|
+
DocumentRow,
|
|
3459
|
+
{
|
|
3460
|
+
document: document2,
|
|
3461
|
+
baseName: query ? mounts.find((item) => item.knowledgeBaseId === document2.knowledgeBaseId)?.base.name : void 0,
|
|
3462
|
+
onClick: () => selectDocument(document2)
|
|
3463
|
+
},
|
|
3464
|
+
document2.id
|
|
3465
|
+
)),
|
|
3466
|
+
nextCursor && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "dsh-knowledge-activity-load-more", disabled: listState === "loading", onClick: () => {
|
|
3467
|
+
void loadIndex(nextCursor, true);
|
|
3468
|
+
}, children: listState === "loading" ? "\u6B63\u5728\u52A0\u8F7D\u2026" : "\u52A0\u8F7D\u66F4\u591A" })
|
|
3469
|
+
] }) })
|
|
3470
|
+
] })
|
|
3471
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3472
|
+
DocumentReader,
|
|
3473
|
+
{
|
|
3474
|
+
value: documentValue,
|
|
3475
|
+
state: documentState,
|
|
3476
|
+
error,
|
|
3477
|
+
onBack: closeDocument,
|
|
3478
|
+
onRetry: () => setDocumentRefresh((value) => value + 1)
|
|
3479
|
+
}
|
|
3480
|
+
)
|
|
3481
|
+
] });
|
|
3482
|
+
}
|
|
3483
|
+
function DocumentRow({ document: document2, baseName, onClick }) {
|
|
3484
|
+
const stateLabel = document2.documentState === "resolved" ? "\u5DF2\u89E3\u51B3" : document2.documentState === "complete" ? "\u5DF2\u5B8C\u6210" : void 0;
|
|
3485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-knowledge-activity-row", onClick, children: [
|
|
3486
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-knowledge-activity-row-icon", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDataOutline16, { size: 16 }) }),
|
|
3487
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-knowledge-activity-row-copy", children: [
|
|
3488
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: document2.title }),
|
|
3489
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("small", { children: baseName ? `${baseName} \xB7 ${document2.relPath}` : document2.relPath })
|
|
3490
|
+
] }),
|
|
3491
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-knowledge-activity-row-meta", children: [
|
|
3492
|
+
stateLabel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: stateLabel }),
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("time", { dateTime: document2.updatedAt, children: formatDate2(document2.updatedAt) })
|
|
3494
|
+
] })
|
|
3495
|
+
] });
|
|
3496
|
+
}
|
|
3497
|
+
function DocumentReader({ value, state, error, onBack, onRetry }) {
|
|
3498
|
+
const html2 = (0, import_react2.useMemo)(() => value === void 0 ? "" : renderMarkdown(readableMarkdown(value.content)), [value]);
|
|
3499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-reader", children: [
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-reader-bar", children: [
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", className: "dsh-knowledge-activity-back", onClick: onBack, children: [
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconChevronLeftOutline14, { size: 14 }),
|
|
3503
|
+
"\u6587\u6863\u76EE\u5F55"
|
|
3504
|
+
] }),
|
|
3505
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
3506
|
+
formatDate2(value.updatedAt),
|
|
3507
|
+
" \u66F4\u65B0"
|
|
3508
|
+
] })
|
|
3509
|
+
] }),
|
|
3510
|
+
state === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityState2, { label: "\u6B63\u5728\u6253\u5F00\u6587\u6863\u2026" }) : state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityError2, { message: error, onRetry }) : value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActivityState2, { label: "\u6B63\u5728\u51C6\u5907\u6587\u6863\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
3511
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-document-heading", children: [
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-knowledge-activity-document-icon", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDataOutline16, { size: 18 }) }),
|
|
3513
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
3514
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: value.title }),
|
|
3515
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: value.relPath })
|
|
3516
|
+
] })
|
|
3517
|
+
] }),
|
|
3518
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("article", { className: "dsh-knowledge-activity-markdown", dangerouslySetInnerHTML: { __html: html2 } })
|
|
3519
|
+
] })
|
|
3520
|
+
] });
|
|
3521
|
+
}
|
|
3522
|
+
function ActivityState2({ label }) {
|
|
3523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "dsh-knowledge-activity-state", role: "status", children: [
|
|
3524
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": "true" }),
|
|
3525
|
+
label
|
|
3526
|
+
] });
|
|
3527
|
+
}
|
|
3528
|
+
function ActivityError2({ message: message3, onRetry }) {
|
|
3529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-error", role: "alert", children: [
|
|
3530
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6" }),
|
|
3531
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: message3 }),
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: onRetry, children: "\u91CD\u8BD5" })
|
|
3533
|
+
] });
|
|
3534
|
+
}
|
|
3535
|
+
function ActivityEmpty2({ title, description }) {
|
|
3536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-knowledge-activity-empty", children: [
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconDatabaseOutline16, { size: 20 }) }),
|
|
3538
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: title }),
|
|
3539
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description })
|
|
3540
|
+
] });
|
|
3541
|
+
}
|
|
3542
|
+
function readableMarkdown(value) {
|
|
3543
|
+
return value.replace(/^---\s*\n[\s\S]*?\n---\s*\n*/u, "").replace(/^#\s+[^\n]+\n*/u, "");
|
|
3544
|
+
}
|
|
3545
|
+
function shortId(value) {
|
|
3546
|
+
return value.length <= 12 ? value : `${value.slice(0, 7)}\u2026${value.slice(-5)}`;
|
|
3547
|
+
}
|
|
3548
|
+
function formatDate2(value) {
|
|
3549
|
+
const date = new Date(value);
|
|
3550
|
+
if (Number.isNaN(date.getTime())) return "\u672A\u77E5\u65F6\u95F4";
|
|
3551
|
+
return new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit" }).format(date);
|
|
3552
|
+
}
|
|
3553
|
+
function message2(reason) {
|
|
3554
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
3555
|
+
}
|
|
48
3556
|
|
|
49
|
-
// src/
|
|
50
|
-
var client_default = '.dsh-knowledge-trigger,\n.dsh-knowledge-workspace,\n.dsh-knowledge-settings-card,\n.dsh-knowledge-writeback-status {\n color-scheme: light;\n --knowledge-canvas: transparent;\n --knowledge-accent: #3a3a3c;\n --knowledge-on-accent: #fff;\n --knowledge-danger: #d70015;\n --knowledge-success: #248a3d;\n --knowledge-pane: rgba(255, 255, 255, 0.16);\n --knowledge-raised: rgba(255, 255, 255, 0.38);\n --knowledge-control: rgba(255, 255, 255, 0.27);\n --knowledge-border: rgb(60 60 67 / 14%);\n --knowledge-text: #1d1d1f;\n --knowledge-text-secondary: #515154;\n --knowledge-text-tertiary: #747478;\n --knowledge-hover: rgba(118, 118, 128, .1);\n --knowledge-glare-light: rgb(255 255 255 / 70%);\n --knowledge-glare-rim: rgb(60 60 67 / 11%);\n --knowledge-glass-filter: saturate(1.22) contrast(1.03) blur(32px);\n --knowledge-host-glass-filter: saturate(.18) contrast(1.015) blur(24px);\n --knowledge-glass-shadow: inset 0 1px 0 rgb(255 255 255 / 70%), inset 0 -1px 0 rgb(60 60 67 / 11%), 0 10px 28px rgb(31 31 35 / 8.5%);\n --knowledge-font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;\n color: var(--knowledge-text);\n font-family: var(--knowledge-font-family);\n font-size: 13px;\n line-height: 1.5;\n}\n\nbody[data-ds-dark-theme] :is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) {\n color-scheme: dark;\n --knowledge-canvas: transparent;\n --knowledge-accent: #69b6ba;\n --knowledge-on-accent: #101819;\n --knowledge-danger: #ff453a;\n --knowledge-success: #30d158;\n --knowledge-pane: rgb(25 33 35 / 90%);\n --knowledge-raised: rgb(32 41 43 / 94%);\n --knowledge-control: rgb(39 50 53 / 92%);\n --knowledge-border: rgb(184 204 205 / 11%);\n --knowledge-text: #e3eaeb;\n --knowledge-text-secondary: #bbc9cc;\n --knowledge-text-tertiary: #95a7ab;\n --knowledge-hover: rgb(105 182 186 / 9%);\n --knowledge-glare-light: rgb(255 255 255 / 16%);\n --knowledge-glare-rim: rgb(0 0 0 / 30%);\n --knowledge-host-glass-filter: saturate(.45) contrast(1.02) blur(24px);\n --knowledge-glass-shadow: inset 0 1px 0 rgb(255 255 255 / 16%), inset 0 -1px 0 rgb(0 0 0 / 30%), 0 12px 32px rgb(0 0 0 / 30%);\n}\n\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n),\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) * {\n box-sizing: border-box;\n}\n\n:is(\n .dsh-knowledge-trigger,\n .dsh-knowledge-workspace,\n .dsh-knowledge-settings-card,\n .dsh-knowledge-writeback-status\n) :where(button, input, textarea, select) {\n margin: 0;\n color: inherit;\n font-family: var(--knowledge-font-family);\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n}\n\n.dsh-knowledge-trigger,\n.dsh-knowledge-panel-state button,\n.dsh-knowledge-settings-card button,\n.dsh-knowledge-writeback-status button {\n -webkit-appearance: none;\n appearance: none;\n margin: 0;\n}\n\n.dsh-knowledge-trigger {\n position: relative;\n flex: none;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 8px;\n width: calc(100% + 4px);\n height: 42px;\n margin: 4px -2px;\n padding: 0 10px 0 8px;\n box-sizing: border-box;\n border: 0;\n border-radius: 8px;\n overflow: hidden;\n background: transparent;\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n white-space: nowrap;\n isolation: isolate;\n transition:\n color 120ms ease,\n background-color 120ms ease,\n box-shadow 160ms ease;\n}\n\n.dsh-knowledge-trigger:hover {\n background: var(--knowledge-hover);\n}\n\n.dsh-knowledge-trigger:focus-visible,\n.dsh-knowledge-writeback-status button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-trigger.is-active {\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n box-shadow: 0 1px 2px rgb(0 0 0 / 7%), inset 0 1px 0 rgb(255 255 255 / 28%);\n}\n\n.dsh-knowledge-trigger--rail {\n width: 36px;\n height: 36px;\n margin: 8px 0 4px;\n padding: 0;\n justify-content: center;\n gap: 0;\n border-radius: 50%;\n}\n\n/* Rail (collapsed) mode: the host footer seat is a horizontal row sized for a\n single 36px circle per entry; with several entries it overflows the 56px\n rail and the circles drift off the settings axis. Stack the entries\n vertically, centered on the same axis as the settings circle. The --rail\n class on the knowledge trigger is the collapsed-mode signal, so wide mode\n is untouched. */\ndiv:has(> div[data-slot="sidebar.footer.action"] .dsh-knowledge-trigger--rail) {\n flex-direction: column;\n align-items: center;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-knowledge-trigger { transition: none; }\n}\n\n.dsh-knowledge-workspace {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background: var(--knowledge-canvas);\n}\n\n.dsh-knowledge-workspace-header {\n position: relative;\n z-index: 2;\n flex: none;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 52px;\n margin: 8px 10px 0;\n padding: 7px 14px;\n box-sizing: border-box;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px 14px 11px 11px;\n background: transparent;\n box-shadow: var(--knowledge-glass-shadow);\n -webkit-backdrop-filter: var(--knowledge-host-glass-filter);\n backdrop-filter: var(--knowledge-host-glass-filter);\n}\n\n.dsh-knowledge-workspace-header > div {\n display: flex;\n align-items: center;\n gap: 10px;\n min-width: 0;\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close] {\n -webkit-appearance: none;\n appearance: none;\n display: grid;\n place-items: center;\n box-sizing: border-box;\n flex: none;\n width: 30px;\n height: 30px;\n margin: 0;\n padding: 0;\n border: 1px solid transparent;\n border-radius: 9px;\n color: var(--knowledge-text-secondary);\n background: transparent;\n font: inherit;\n line-height: 1;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms ease;\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:hover {\n border-color: var(--knowledge-border);\n color: var(--knowledge-text);\n background: var(--knowledge-control);\n}\n\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:active { transform: scale(.96); }\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close]:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-workspace-header [data-xiaohei-workspace-close] > svg {\n display: block;\n pointer-events: none;\n}\n\n.dsh-knowledge-workspace-header > div > span {\n display: grid;\n min-width: 0;\n gap: 2px;\n}\n\n.dsh-knowledge-workspace-header h2,\n.dsh-knowledge-workspace-header p {\n margin: 0;\n}\n\n.dsh-knowledge-workspace-header h2 {\n color: var(--knowledge-text);\n font-size: 15px;\n line-height: 22px;\n font-weight: 600;\n}\n\n.dsh-knowledge-workspace-header p {\n color: var(--knowledge-text-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n\n.dsh-knowledge-frame {\n flex: 1;\n display: block;\n width: 100%;\n min-height: 0;\n margin: 0;\n border: 0;\n border-radius: 0;\n background: transparent;\n box-shadow: none;\n -webkit-backdrop-filter: none;\n backdrop-filter: none;\n}\n\n.dsh-knowledge-panel-state {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n min-height: 0;\n margin: 8px 10px 10px;\n padding: 32px;\n box-sizing: border-box;\n border: 1px solid var(--knowledge-border);\n border-radius: 15px;\n background: var(--knowledge-pane);\n box-shadow: var(--knowledge-glass-shadow);\n -webkit-backdrop-filter: var(--knowledge-host-glass-filter);\n backdrop-filter: var(--knowledge-host-glass-filter);\n color: var(--knowledge-text);\n}\n\n.dsh-knowledge-panel-state-icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 12px;\n background: var(--knowledge-hover);\n color: var(--knowledge-text-secondary);\n font-size: 18px;\n font-weight: 600;\n}\n\n.dsh-knowledge-panel-state > div { max-width: 560px; }\n.dsh-knowledge-panel-state h3 { margin: 0 0 6px; font-size: 17px; line-height: 24px; font-weight: 600; }\n.dsh-knowledge-panel-state p { margin: 0; color: var(--knowledge-text-secondary); font-size: 13px; line-height: 20px; }\n.dsh-knowledge-panel-state button {\n min-width: 72px;\n min-height: 32px;\n margin-top: 16px;\n padding: 6px 14px;\n border: 0;\n border-radius: 10px;\n background: var(--knowledge-accent);\n color: var(--knowledge-on-accent);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-panel-state button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-settings-card {\n list-style: none;\n overflow: hidden;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px;\n background:\n linear-gradient(145deg, color-mix(in srgb, var(--knowledge-glare-light) 16%, transparent), transparent 58%),\n var(--knowledge-pane);\n color: var(--knowledge-text);\n box-shadow: var(--knowledge-glass-shadow), 0 8px 24px rgb(0 0 0 / 5%);\n -webkit-backdrop-filter: var(--knowledge-glass-filter);\n backdrop-filter: var(--knowledge-glass-filter);\n transition: border-color .16s, background .16s, box-shadow .2s, transform .2s cubic-bezier(.22, 1, .36, 1);\n}\n.dsh-knowledge-settings-card:hover {\n border-color: color-mix(in srgb, var(--knowledge-border) 68%, var(--knowledge-text-secondary));\n box-shadow: var(--knowledge-glass-shadow), 0 12px 30px rgb(0 0 0 / 8%);\n transform: translateY(-1px);\n}\n.dsh-knowledge-settings-card--open {\n border-color: color-mix(in srgb, var(--knowledge-border) 68%, var(--knowledge-text-secondary));\n background: var(--knowledge-pane);\n}\n.dsh-knowledge-settings-header { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-radius: 12px; background: transparent; color: inherit; text-align: left; cursor: pointer; font: inherit; }\n.dsh-knowledge-settings-header:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: -2px;\n}\n.dsh-knowledge-settings-actions button:focus-visible,\n.dsh-knowledge-settings-load-error button:focus-visible {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-settings-header > span:first-child { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }\n.dsh-knowledge-settings-header strong { font-size: 15px; font-weight: 600; line-height: 1.4; }\n.dsh-knowledge-settings-header small { color: var(--knowledge-text-tertiary); font-size: 13px; line-height: 1.5; }\n.dsh-knowledge-source-picker small,\n.dsh-knowledge-remote-fields small { color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-settings-summary { display: flex; flex: none; align-items: center; gap: 10px; color: var(--knowledge-text-tertiary); font-size: 12px; }\n.dsh-knowledge-settings-summary i { width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 160ms ease; }\n.dsh-knowledge-settings-card--open .dsh-knowledge-settings-summary i { transform: rotate(225deg); }\n\n.dsh-knowledge-settings-body {\n display: grid;\n gap: 18px;\n margin: 0 16px;\n padding-bottom: 8px;\n border-top: 1px solid var(--knowledge-border);\n}\n\n.dsh-knowledge-source-picker {\n min-width: 0;\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 10px;\n margin: 18px 0 0;\n padding: 0;\n border: 0;\n}\n\n.dsh-knowledge-source-picker legend { margin-bottom: 8px; padding: 0; color: inherit; font-size: 13px; font-weight: 600; }\n.dsh-knowledge-source-picker label {\n display: flex;\n gap: 10px;\n padding: 13px;\n border: 1px solid var(--knowledge-border);\n border-radius: 14px;\n cursor: pointer;\n}\n.dsh-knowledge-source-picker label.is-selected {\n border-color: var(--knowledge-accent);\n background: color-mix(in srgb, var(--knowledge-accent) 7%, transparent);\n}\n.dsh-knowledge-source-picker label.is-disabled {\n cursor: default;\n opacity: .55;\n}\n.dsh-knowledge-source-picker label:focus-within {\n outline: 2px solid var(--knowledge-accent);\n outline-offset: 2px;\n}\n.dsh-knowledge-source-picker input {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n display: inline-grid;\n place-content: center;\n flex: none;\n margin: 2px 0 0;\n border: 1px solid var(--knowledge-border);\n border-radius: 50%;\n background: var(--knowledge-control);\n color: var(--knowledge-on-accent);\n cursor: pointer;\n transition: border-color .15s ease, background-color .15s ease;\n}\n.dsh-knowledge-source-picker input::before {\n content: "";\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n opacity: 0;\n transform: scale(.55);\n transition: opacity .12s ease, transform .15s cubic-bezier(.2, .8, .2, 1);\n}\n.dsh-knowledge-source-picker input:checked { border-color: var(--knowledge-accent); background: var(--knowledge-accent); }\n.dsh-knowledge-source-picker input:checked::before { opacity: 1; transform: scale(1); }\n.dsh-knowledge-source-picker input:disabled { cursor: default; }\n.dsh-knowledge-source-picker span { display: grid; gap: 3px; }\n\n.dsh-knowledge-remote-fields { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }\n.dsh-knowledge-remote-fields label,\n.dsh-knowledge-timeout-field { display: grid; gap: 6px; color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-remote-fields input,\n.dsh-knowledge-timeout-field input {\n -webkit-appearance: none;\n appearance: none;\n min-height: 38px;\n box-sizing: border-box;\n padding: 8px 11px;\n border: 1px solid var(--knowledge-border);\n border-radius: 10px;\n outline: none;\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n font: inherit;\n}\n.dsh-knowledge-remote-fields input:focus,\n.dsh-knowledge-timeout-field input:focus { border-color: var(--knowledge-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--knowledge-accent) 16%, transparent); }\n.dsh-knowledge-remote-fields input:-webkit-autofill,\n.dsh-knowledge-remote-fields input:-webkit-autofill:hover,\n.dsh-knowledge-remote-fields input:-webkit-autofill:focus {\n -webkit-text-fill-color: var(--knowledge-text);\n box-shadow: 0 0 0 1000px var(--knowledge-control) inset;\n caret-color: var(--knowledge-text);\n}\n.dsh-knowledge-timeout-field input::-webkit-inner-spin-button,\n.dsh-knowledge-timeout-field input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }\n.dsh-knowledge-timeout-field { max-width: 240px; }\n.dsh-knowledge-field-error { color: var(--knowledge-danger) !important; }\n\n.dsh-knowledge-settings-message,\n.dsh-knowledge-settings-note { margin: 0; color: var(--knowledge-text-secondary); font-size: 12px; }\n.dsh-knowledge-settings-message.is-success { color: var(--knowledge-success); }\n.dsh-knowledge-settings-message.is-error { color: var(--knowledge-danger); }\n.dsh-knowledge-settings-load-error {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-top: 18px;\n padding: 12px 14px;\n border-radius: 12px;\n background: color-mix(in srgb, var(--knowledge-danger) 8%, transparent);\n color: var(--knowledge-danger);\n font-size: 13px;\n}\n.dsh-knowledge-settings-load-error p { margin: 0; }\n.dsh-knowledge-settings-load-error button {\n flex: none;\n min-height: 30px;\n padding: 5px 10px;\n border: 0;\n border-radius: 9px;\n background: var(--knowledge-control);\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-settings-actions { display: flex; justify-content: flex-end; gap: 8px; }\n.dsh-knowledge-settings-actions button {\n min-height: 34px;\n padding: 7px 13px;\n border: 0;\n border-radius: 10px;\n background: var(--knowledge-hover);\n color: var(--knowledge-text);\n cursor: pointer;\n font: inherit;\n font-size: 13px;\n}\n.dsh-knowledge-settings-actions button.is-primary { background: var(--knowledge-accent); color: var(--knowledge-on-accent); }\n.dsh-knowledge-settings-actions button:disabled { cursor: default; opacity: .45; }\n\n@media (max-width: 720px) {\n .dsh-knowledge-source-picker,\n .dsh-knowledge-remote-fields { grid-template-columns: 1fr; }\n .dsh-knowledge-settings-summary { font-size: 0; }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsh-knowledge-settings-card,\n .dsh-knowledge-settings-header,\n .dsh-knowledge-settings-summary i { transition: none; }\n}\n\n.dsh-knowledge-writeback-status {\n display: grid;\n gap: 5px;\n min-width: 0;\n color: var(--knowledge-text-tertiary);\n font-size: 12px;\n line-height: 1.5;\n}\n.dsh-knowledge-writeback-summary {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n min-width: 0;\n}\n.dsh-knowledge-writeback-status strong {\n color: var(--knowledge-text-secondary);\n font-weight: 600;\n}\n.dsh-knowledge-writeback-status button {\n min-height: 24px;\n padding: 0 9px;\n border: 1px solid var(--knowledge-border);\n border-radius: 7px;\n color: var(--knowledge-text-secondary);\n background: var(--knowledge-control);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-writeback-status button:disabled { cursor: default; opacity: .5; }\n.dsh-knowledge-writeback-destinations {\n display: flex;\n flex-wrap: wrap;\n gap: 2px 12px;\n min-width: 0;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.dsh-knowledge-writeback-destinations li {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n min-width: 0;\n max-width: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n}\n.dsh-knowledge-writeback-base,\n.dsh-knowledge-writeback-separator {\n flex: none;\n}\n.dsh-knowledge-writeback-separator {\n color: var(--knowledge-text-tertiary);\n}\n.dsh-knowledge-writeback-destinations strong {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.dsh-knowledge-writeback-status .dsh-knowledge-writeback-document {\n display: inline-flex;\n align-items: center;\n min-width: 0;\n min-height: 24px;\n padding: 0 3px;\n border: 0;\n border-radius: 4px;\n background: transparent;\n color: var(--knowledge-text-secondary);\n text-decoration: underline;\n text-decoration-color: transparent;\n text-underline-offset: 3px;\n transition: color 120ms ease, background-color 120ms ease, text-decoration-color 120ms ease;\n}\n.dsh-knowledge-writeback-status .dsh-knowledge-writeback-document:hover {\n background: var(--knowledge-hover);\n color: var(--knowledge-text);\n text-decoration-color: currentColor;\n}\n.dsh-knowledge-writeback-document strong { color: inherit; }\n.dsh-knowledge-writeback-destinations small {\n flex: none;\n color: var(--knowledge-text-secondary);\n font: inherit;\n white-space: nowrap;\n}\n.dsh-knowledge-writeback-destinations small[data-disposition="written"] { color: var(--knowledge-success); }\n.dsh-knowledge-writeback-error {\n max-width: min(720px, 100%);\n margin: 0;\n color: var(--knowledge-danger);\n overflow-wrap: anywhere;\n}\n';
|
|
3557
|
+
// src/knowledge-activity-controller.tsx
|
|
3558
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
3559
|
+
function createKnowledgeActivityController(ctx, options) {
|
|
3560
|
+
const runtime = ctx;
|
|
3561
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3562
|
+
const states = /* @__PURE__ */ new Map();
|
|
3563
|
+
let currentSessionId = normalizeSessionId(runtime.sessions.list.getSnapshot().current);
|
|
3564
|
+
let mountedSessionId;
|
|
3565
|
+
let restoreFrame;
|
|
3566
|
+
let disposePanel;
|
|
3567
|
+
const notify = () => {
|
|
3568
|
+
for (const listener of listeners) listener();
|
|
3569
|
+
};
|
|
3570
|
+
const cancelRestore = () => {
|
|
3571
|
+
if (restoreFrame === void 0) return;
|
|
3572
|
+
window.cancelAnimationFrame(restoreFrame);
|
|
3573
|
+
restoreFrame = void 0;
|
|
3574
|
+
};
|
|
3575
|
+
const unmount = () => {
|
|
3576
|
+
if (disposePanel === void 0) return false;
|
|
3577
|
+
const dispose = disposePanel;
|
|
3578
|
+
disposePanel = void 0;
|
|
3579
|
+
mountedSessionId = void 0;
|
|
3580
|
+
dispose();
|
|
3581
|
+
return true;
|
|
3582
|
+
};
|
|
3583
|
+
const mount = (sessionId, openDetails = true) => {
|
|
3584
|
+
if (mountedSessionId === sessionId && disposePanel !== void 0) return;
|
|
3585
|
+
unmount();
|
|
3586
|
+
mountedSessionId = sessionId;
|
|
3587
|
+
disposePanel = ctx.slots.register({ name: "details", priority: -3 }, (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(KnowledgeActivityPanel, { ...props, controller }));
|
|
3588
|
+
if (openDetails) ctx.layout.openDetails();
|
|
3589
|
+
};
|
|
3590
|
+
const syncCurrentSession = () => {
|
|
3591
|
+
const nextSessionId = normalizeSessionId(runtime.sessions.list.getSnapshot().current);
|
|
3592
|
+
if (nextSessionId === currentSessionId) return;
|
|
3593
|
+
cancelRestore();
|
|
3594
|
+
const wasMounted = unmount();
|
|
3595
|
+
currentSessionId = nextSessionId;
|
|
3596
|
+
if (nextSessionId !== void 0 && states.get(nextSessionId)?.open === true) {
|
|
3597
|
+
mount(nextSessionId, false);
|
|
3598
|
+
restoreFrame = window.requestAnimationFrame(() => {
|
|
3599
|
+
restoreFrame = void 0;
|
|
3600
|
+
if (currentSessionId === nextSessionId && mountedSessionId === nextSessionId && states.get(nextSessionId)?.open === true) {
|
|
3601
|
+
ctx.layout.openDetails();
|
|
3602
|
+
}
|
|
3603
|
+
});
|
|
3604
|
+
} else if (wasMounted) {
|
|
3605
|
+
ctx.layout.closeDetails();
|
|
3606
|
+
}
|
|
3607
|
+
notify();
|
|
3608
|
+
};
|
|
3609
|
+
const controller = {
|
|
3610
|
+
open(sessionId, selection) {
|
|
3611
|
+
const previous = states.get(sessionId);
|
|
3612
|
+
states.set(sessionId, { ...previous, ...selection, open: true });
|
|
3613
|
+
options.beforeOpen();
|
|
3614
|
+
if (sessionId === currentSessionId) {
|
|
3615
|
+
cancelRestore();
|
|
3616
|
+
mount(sessionId);
|
|
3617
|
+
}
|
|
3618
|
+
notify();
|
|
3619
|
+
},
|
|
3620
|
+
toggle(sessionId) {
|
|
3621
|
+
if (states.get(sessionId)?.open === true) controller.close(sessionId);
|
|
3622
|
+
else controller.open(sessionId);
|
|
3623
|
+
},
|
|
3624
|
+
close(sessionId) {
|
|
3625
|
+
const target = sessionId ?? currentSessionId;
|
|
3626
|
+
if (target === void 0) return;
|
|
3627
|
+
const previous = states.get(target) ?? { open: false };
|
|
3628
|
+
states.set(target, { ...previous, open: false });
|
|
3629
|
+
if (target === currentSessionId) {
|
|
3630
|
+
cancelRestore();
|
|
3631
|
+
if (unmount()) ctx.layout.closeDetails();
|
|
3632
|
+
}
|
|
3633
|
+
notify();
|
|
3634
|
+
},
|
|
3635
|
+
isOpen: (sessionId) => states.get(sessionId)?.open === true,
|
|
3636
|
+
selection(sessionId) {
|
|
3637
|
+
const state = states.get(sessionId);
|
|
3638
|
+
return {
|
|
3639
|
+
...state?.mode === void 0 ? {} : { mode: state.mode },
|
|
3640
|
+
...state?.knowledgeBaseId === void 0 ? {} : { knowledgeBaseId: state.knowledgeBaseId },
|
|
3641
|
+
...state?.documentId === void 0 ? {} : { documentId: state.documentId },
|
|
3642
|
+
...state?.noteFolderId === void 0 ? {} : { noteFolderId: state.noteFolderId },
|
|
3643
|
+
...state?.noteDocumentId === void 0 ? {} : { noteDocumentId: state.noteDocumentId }
|
|
3644
|
+
};
|
|
3645
|
+
},
|
|
3646
|
+
select(sessionId, selection) {
|
|
3647
|
+
const previous = states.get(sessionId) ?? { open: true };
|
|
3648
|
+
states.set(sessionId, { ...previous, ...selection, open: previous.open });
|
|
3649
|
+
notify();
|
|
3650
|
+
},
|
|
3651
|
+
openWorkspace(target) {
|
|
3652
|
+
controller.close();
|
|
3653
|
+
options.openWorkspace(target);
|
|
3654
|
+
},
|
|
3655
|
+
subscribe(listener) {
|
|
3656
|
+
listeners.add(listener);
|
|
3657
|
+
return () => {
|
|
3658
|
+
listeners.delete(listener);
|
|
3659
|
+
};
|
|
3660
|
+
},
|
|
3661
|
+
dispose() {
|
|
3662
|
+
disposeSelection();
|
|
3663
|
+
cancelRestore();
|
|
3664
|
+
unmount();
|
|
3665
|
+
states.clear();
|
|
3666
|
+
listeners.clear();
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
const disposeSelection = runtime.sessions.list.subscribe(syncCurrentSession);
|
|
3670
|
+
return controller;
|
|
3671
|
+
}
|
|
3672
|
+
function normalizeSessionId(value) {
|
|
3673
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
3674
|
+
}
|
|
51
3675
|
|
|
52
3676
|
// src/constants.ts
|
|
53
3677
|
var KNOWLEDGE_SETTINGS_NAMESPACE = "dsh-knowledge-connection";
|
|
@@ -116,24 +3740,40 @@ function createKnowledgeHostTheme(_computed, snapshot) {
|
|
|
116
3740
|
}
|
|
117
3741
|
|
|
118
3742
|
// src/client.tsx
|
|
119
|
-
var
|
|
3743
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
120
3744
|
var PLUGIN_ID = "@lemoncat7/dsh-knowledge";
|
|
121
3745
|
var STYLE_ID = `${PLUGIN_ID}/client`;
|
|
3746
|
+
var COMPACT_KNOWLEDGE_VIEWPORT = "(max-width: 1120px), (hover: none) and (pointer: coarse) and (max-width: 1400px)";
|
|
122
3747
|
var CONNECTION_CONTROL_PATH = "/knowledge-control/v1/connection";
|
|
123
3748
|
var cachedConnectionView;
|
|
124
|
-
var inject = ["slots", "theme"];
|
|
125
|
-
function
|
|
3749
|
+
var inject = ["slots", "theme", "layout", "sessions"];
|
|
3750
|
+
function apply2(ctx) {
|
|
126
3751
|
ctx.effect(installStyles, "dsh-knowledge: client styles");
|
|
127
|
-
|
|
128
|
-
|
|
3752
|
+
let activity;
|
|
3753
|
+
const workspace = createKnowledgeWorkspaceController(ctx, () => activity?.close());
|
|
3754
|
+
activity = createKnowledgeActivityController(ctx, {
|
|
3755
|
+
beforeOpen: () => {
|
|
3756
|
+
workspace.close();
|
|
3757
|
+
activatePluginWorkspace(PLUGIN_ID);
|
|
3758
|
+
},
|
|
3759
|
+
openWorkspace: (target) => {
|
|
3760
|
+
if (target === void 0) workspace.open();
|
|
3761
|
+
else workspace.openDocument(target);
|
|
3762
|
+
}
|
|
3763
|
+
});
|
|
3764
|
+
ctx.effect(() => observePluginWorkspace(PLUGIN_ID, () => {
|
|
3765
|
+
workspace.close();
|
|
3766
|
+
activity?.close();
|
|
3767
|
+
}), "dsh-knowledge: exclusive workspace");
|
|
129
3768
|
ctx.effect(() => () => {
|
|
130
3769
|
workspace.close();
|
|
3770
|
+
activity?.dispose();
|
|
131
3771
|
}, "dsh-knowledge: workspace lifecycle");
|
|
132
3772
|
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
133
3773
|
name: "sidebar.footer.action",
|
|
134
3774
|
id: "knowledge",
|
|
135
3775
|
order: -10
|
|
136
|
-
}, (props) => /* @__PURE__ */ (0,
|
|
3776
|
+
}, (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(KnowledgeLauncher, { ...props, workspace, activity })));
|
|
137
3777
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
138
3778
|
name: "settings.plugin.item",
|
|
139
3779
|
key: KNOWLEDGE_SETTINGS_NAMESPACE
|
|
@@ -141,16 +3781,16 @@ function apply(ctx) {
|
|
|
141
3781
|
ctx.slots.inject("conversation.chat.turnTail", () => ctx.slots.register({
|
|
142
3782
|
name: "conversation.chat.turnTail",
|
|
143
3783
|
select: (owner) => ({ turn: owner.turn.turn })
|
|
144
|
-
}, (props) => /* @__PURE__ */ (0,
|
|
3784
|
+
}, (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(KnowledgeWritebackStatus, { sessionId: String(props.sessionId), turn: props.matched.turn, workspace })));
|
|
145
3785
|
}
|
|
146
3786
|
function KnowledgeWritebackStatus({
|
|
147
3787
|
sessionId,
|
|
148
3788
|
turn,
|
|
149
3789
|
workspace
|
|
150
3790
|
}) {
|
|
151
|
-
const [state, setState] = (0,
|
|
152
|
-
const [retrying, setRetrying] = (0,
|
|
153
|
-
(0,
|
|
3791
|
+
const [state, setState] = (0, import_react3.useState)();
|
|
3792
|
+
const [retrying, setRetrying] = (0, import_react3.useState)(false);
|
|
3793
|
+
(0, import_react3.useEffect)(() => {
|
|
154
3794
|
const controller = new AbortController();
|
|
155
3795
|
let timer;
|
|
156
3796
|
let missingAttempts = 0;
|
|
@@ -211,19 +3851,19 @@ function KnowledgeWritebackStatus({
|
|
|
211
3851
|
};
|
|
212
3852
|
const destinations = state.destinations ?? [];
|
|
213
3853
|
const summary = state.summary.replace(/^知识库回写\s*·\s*/u, "");
|
|
214
|
-
return /* @__PURE__ */ (0,
|
|
215
|
-
/* @__PURE__ */ (0,
|
|
216
|
-
/* @__PURE__ */ (0,
|
|
217
|
-
/* @__PURE__ */ (0,
|
|
218
|
-
/* @__PURE__ */ (0,
|
|
219
|
-
state.status === "failed" && state.retryable && /* @__PURE__ */ (0,
|
|
3854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-writeback-status", "data-status": state.status, children: [
|
|
3855
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-writeback-summary", role: state.status === "running" ? "status" : void 0, "aria-atomic": "true", children: [
|
|
3856
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u77E5\u8BC6\u5E93\u56DE\u5199" }),
|
|
3857
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "@lemoncat7/dsh-knowledge" }),
|
|
3858
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: state.error, children: summary }),
|
|
3859
|
+
state.status === "failed" && state.retryable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", disabled: retrying, onClick: () => {
|
|
220
3860
|
void retry();
|
|
221
3861
|
}, children: retrying ? "\u91CD\u8BD5\u4E2D\u2026" : "\u91CD\u8BD5" })
|
|
222
3862
|
] }),
|
|
223
|
-
destinations.length > 0 && /* @__PURE__ */ (0,
|
|
224
|
-
/* @__PURE__ */ (0,
|
|
225
|
-
/* @__PURE__ */ (0,
|
|
226
|
-
destination.documentId ? /* @__PURE__ */ (0,
|
|
3863
|
+
destinations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "dsh-knowledge-writeback-destinations", "aria-label": "\u56DE\u5199\u76EE\u6807", children: destinations.map((destination, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { children: [
|
|
3864
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-knowledge-writeback-base", children: destination.knowledgeBaseName }),
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-knowledge-writeback-separator", "aria-hidden": "true", children: "/" }),
|
|
3866
|
+
destination.documentId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
227
3867
|
"button",
|
|
228
3868
|
{
|
|
229
3869
|
type: "button",
|
|
@@ -233,15 +3873,15 @@ function KnowledgeWritebackStatus({
|
|
|
233
3873
|
onClick: () => {
|
|
234
3874
|
workspace.openDocument({ knowledgeBaseId: destination.knowledgeBaseId, documentId: destination.documentId });
|
|
235
3875
|
},
|
|
236
|
-
children: /* @__PURE__ */ (0,
|
|
3876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: destination.documentPath ?? destination.documentTitle })
|
|
237
3877
|
}
|
|
238
|
-
) : /* @__PURE__ */ (0,
|
|
239
|
-
/* @__PURE__ */ (0,
|
|
3878
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { title: destination.documentTitle, children: `\u62DF\u65B0\u5EFA\uFF1A${destination.documentTitle}` }),
|
|
3879
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { "data-disposition": destination.disposition, children: destination.disposition === "written" ? "\u5DF2\u5199\u5165" : "\u5F85\u5BA1\u6838" })
|
|
240
3880
|
] }, `${destination.knowledgeBaseId}:${destination.documentId ?? destination.documentTitle}:${index}`)) }),
|
|
241
|
-
state.status === "failed" && state.error && /* @__PURE__ */ (0,
|
|
3881
|
+
state.status === "failed" && state.error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-knowledge-writeback-error", role: "alert", children: state.error })
|
|
242
3882
|
] });
|
|
243
3883
|
}
|
|
244
|
-
function createKnowledgeWorkspaceController(client) {
|
|
3884
|
+
function createKnowledgeWorkspaceController(client, beforeOpen) {
|
|
245
3885
|
const listeners = /* @__PURE__ */ new Set();
|
|
246
3886
|
let disposeWorkspace;
|
|
247
3887
|
let target;
|
|
@@ -258,11 +3898,17 @@ function createKnowledgeWorkspaceController(client) {
|
|
|
258
3898
|
let controller;
|
|
259
3899
|
const open = () => {
|
|
260
3900
|
if (disposeWorkspace !== void 0) return;
|
|
3901
|
+
beforeOpen();
|
|
261
3902
|
activatePluginWorkspace(PLUGIN_ID);
|
|
262
|
-
disposeWorkspace = client.slots.register({ name: "conversation", priority: -1 }, (props) => /* @__PURE__ */ (0,
|
|
3903
|
+
disposeWorkspace = client.slots.register({ name: "conversation", priority: -1 }, (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(KnowledgeWorkspace, { ...props, client, workspace: controller }));
|
|
263
3904
|
};
|
|
264
3905
|
controller = {
|
|
265
3906
|
isOpen: () => disposeWorkspace !== void 0,
|
|
3907
|
+
open: () => {
|
|
3908
|
+
target = void 0;
|
|
3909
|
+
open();
|
|
3910
|
+
notify();
|
|
3911
|
+
},
|
|
266
3912
|
toggle: () => {
|
|
267
3913
|
if (disposeWorkspace !== void 0) return close();
|
|
268
3914
|
target = void 0;
|
|
@@ -286,18 +3932,18 @@ function createKnowledgeWorkspaceController(client) {
|
|
|
286
3932
|
return controller;
|
|
287
3933
|
}
|
|
288
3934
|
function KnowledgeConnectionCard() {
|
|
289
|
-
const [current, setCurrent] = (0,
|
|
290
|
-
const [loadState, setLoadState] = (0,
|
|
291
|
-
const [loadError, setLoadError] = (0,
|
|
292
|
-
const [open, setOpen] = (0,
|
|
293
|
-
const [backend, setBackend] = (0,
|
|
294
|
-
const [remoteUrl, setRemoteUrl] = (0,
|
|
295
|
-
const [remoteToken, setRemoteToken] = (0,
|
|
296
|
-
const [timeout, setTimeoutValue] = (0,
|
|
297
|
-
const [dirty, setDirty] = (0,
|
|
298
|
-
const [saving, setSaving] = (0,
|
|
299
|
-
const [
|
|
300
|
-
const load = (0,
|
|
3935
|
+
const [current, setCurrent] = (0, import_react3.useState)();
|
|
3936
|
+
const [loadState, setLoadState] = (0, import_react3.useState)("loading");
|
|
3937
|
+
const [loadError, setLoadError] = (0, import_react3.useState)("");
|
|
3938
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
3939
|
+
const [backend, setBackend] = (0, import_react3.useState)("local");
|
|
3940
|
+
const [remoteUrl, setRemoteUrl] = (0, import_react3.useState)("");
|
|
3941
|
+
const [remoteToken, setRemoteToken] = (0, import_react3.useState)("");
|
|
3942
|
+
const [timeout, setTimeoutValue] = (0, import_react3.useState)("10000");
|
|
3943
|
+
const [dirty, setDirty] = (0, import_react3.useState)(false);
|
|
3944
|
+
const [saving, setSaving] = (0, import_react3.useState)(false);
|
|
3945
|
+
const [message3, setMessage] = (0, import_react3.useState)();
|
|
3946
|
+
const load = (0, import_react3.useCallback)(async (signal) => {
|
|
301
3947
|
setLoadState("loading");
|
|
302
3948
|
setLoadError("");
|
|
303
3949
|
try {
|
|
@@ -310,14 +3956,14 @@ function KnowledgeConnectionCard() {
|
|
|
310
3956
|
setLoadState("error");
|
|
311
3957
|
}
|
|
312
3958
|
}, []);
|
|
313
|
-
(0,
|
|
3959
|
+
(0, import_react3.useEffect)(() => {
|
|
314
3960
|
const controller = new AbortController();
|
|
315
3961
|
void load(controller.signal);
|
|
316
3962
|
return () => {
|
|
317
3963
|
controller.abort();
|
|
318
3964
|
};
|
|
319
3965
|
}, [load]);
|
|
320
|
-
(0,
|
|
3966
|
+
(0, import_react3.useEffect)(() => {
|
|
321
3967
|
if (dirty || current === void 0) return;
|
|
322
3968
|
setBackend(current.backend);
|
|
323
3969
|
setRemoteUrl(current.remoteUrl ?? "");
|
|
@@ -365,75 +4011,75 @@ function KnowledgeConnectionCard() {
|
|
|
365
4011
|
setSaving(false);
|
|
366
4012
|
}
|
|
367
4013
|
};
|
|
368
|
-
return /* @__PURE__ */ (0,
|
|
369
|
-
/* @__PURE__ */ (0,
|
|
4014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { className: `dsh-knowledge-settings-card${open ? " dsh-knowledge-settings-card--open" : ""}`, children: [
|
|
4015
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("button", { type: "button", className: "dsh-knowledge-settings-header", "aria-expanded": open, onClick: () => {
|
|
370
4016
|
setOpen((value) => !value);
|
|
371
4017
|
}, children: [
|
|
372
|
-
/* @__PURE__ */ (0,
|
|
373
|
-
/* @__PURE__ */ (0,
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
4018
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
4019
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "\u77E5\u8BC6\u5E93\u8FDE\u63A5" }),
|
|
4020
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u9009\u62E9\u672C\u673A\u77E5\u8BC6\u5E93\uFF0C\u6216\u8FDE\u63A5\u4E00\u53F0\u4E2D\u592E DSH \u77E5\u8BC6\u5E93" })
|
|
375
4021
|
] }),
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
4022
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "dsh-knowledge-settings-summary", children: [
|
|
377
4023
|
loadState === "loading" ? "\u8BFB\u53D6\u4E2D" : loadState === "error" ? "\u8FDE\u63A5\u5165\u53E3" : current?.backend === "remote" ? "\u8FDC\u7A0B" : "\u672C\u5730",
|
|
378
|
-
/* @__PURE__ */ (0,
|
|
4024
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("i", { "aria-hidden": "true" })
|
|
379
4025
|
] })
|
|
380
4026
|
] }),
|
|
381
|
-
open && /* @__PURE__ */ (0,
|
|
382
|
-
/* @__PURE__ */ (0,
|
|
383
|
-
/* @__PURE__ */ (0,
|
|
4027
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsh-knowledge-settings-body", children: loadState === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-knowledge-settings-note", role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u8FDE\u63A5\u914D\u7F6E\u2026" }) : loadState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-settings-load-error", role: "alert", children: [
|
|
4028
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: loadError }),
|
|
4029
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => {
|
|
384
4030
|
void load();
|
|
385
4031
|
}, children: "\u91CD\u65B0\u8BFB\u53D6" })
|
|
386
|
-
] }) : /* @__PURE__ */ (0,
|
|
387
|
-
/* @__PURE__ */ (0,
|
|
388
|
-
/* @__PURE__ */ (0,
|
|
389
|
-
/* @__PURE__ */ (0,
|
|
390
|
-
/* @__PURE__ */ (0,
|
|
4032
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4033
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { className: "dsh-knowledge-source-picker", children: [
|
|
4034
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: "\u77E5\u8BC6\u5E93\u6765\u6E90" }),
|
|
4035
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: backend === "local" ? "is-selected" : "", children: [
|
|
4036
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "dsh-knowledge-backend", checked: backend === "local", onChange: () => edit(() => {
|
|
391
4037
|
setBackend("local");
|
|
392
4038
|
}) }),
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
394
|
-
/* @__PURE__ */ (0,
|
|
395
|
-
/* @__PURE__ */ (0,
|
|
4039
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
4040
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "\u672C\u5730" }),
|
|
4041
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u6570\u636E\u4FDD\u5B58\u5728\u5F53\u524D DSH \u7684 SQLite \u4E2D" })
|
|
396
4042
|
] })
|
|
397
4043
|
] }),
|
|
398
|
-
/* @__PURE__ */ (0,
|
|
399
|
-
/* @__PURE__ */ (0,
|
|
4044
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: `${backend === "remote" ? "is-selected" : ""}${!current?.canSwitchRemote ? " is-disabled" : ""}`, children: [
|
|
4045
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "radio", name: "dsh-knowledge-backend", checked: backend === "remote", disabled: !current?.canSwitchRemote, onChange: () => edit(() => {
|
|
400
4046
|
setBackend("remote");
|
|
401
4047
|
}) }),
|
|
402
|
-
/* @__PURE__ */ (0,
|
|
403
|
-
/* @__PURE__ */ (0,
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
4048
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
4049
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: "\u8FDC\u7A0B" }),
|
|
4050
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { children: "\u53EC\u56DE\u548C\u56DE\u5199\u7EDF\u4E00\u4F7F\u7528\u4E2D\u592E\u77E5\u8BC6\u5E93" })
|
|
405
4051
|
] })
|
|
406
4052
|
] })
|
|
407
4053
|
] }),
|
|
408
|
-
!current?.canSwitchRemote && /* @__PURE__ */ (0,
|
|
409
|
-
backend === "remote" && /* @__PURE__ */ (0,
|
|
410
|
-
/* @__PURE__ */ (0,
|
|
4054
|
+
!current?.canSwitchRemote && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-knowledge-settings-note", children: "\u5F53\u524D\u5B9E\u4F8B\u662F\u4E2D\u592E\u77E5\u8BC6\u5E93\u670D\u52A1\uFF0C\u4E0D\u80FD\u518D\u5207\u6362\u5230\u53E6\u4E00\u53F0\u8FDC\u7A0B\u670D\u52A1\u3002" }),
|
|
4055
|
+
backend === "remote" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-remote-fields", children: [
|
|
4056
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: "dsh-knowledge-remote-url", children: [
|
|
411
4057
|
"\u670D\u52A1\u5668\u5730\u5740",
|
|
412
|
-
/* @__PURE__ */ (0,
|
|
4058
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { id: "dsh-knowledge-remote-url", type: "url", value: remoteUrl, placeholder: "https://example.com/knowledge-api/v1", autoComplete: "url", onChange: (event) => edit(() => {
|
|
413
4059
|
setRemoteUrl(event.target.value);
|
|
414
4060
|
}), "aria-invalid": urlError !== void 0, "aria-describedby": urlError ? "dsh-knowledge-url-error" : void 0 }),
|
|
415
|
-
urlError && /* @__PURE__ */ (0,
|
|
4061
|
+
urlError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { id: "dsh-knowledge-url-error", className: "dsh-knowledge-field-error", children: urlError })
|
|
416
4062
|
] }),
|
|
417
|
-
/* @__PURE__ */ (0,
|
|
4063
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: "dsh-knowledge-remote-token", children: [
|
|
418
4064
|
"\u5BA2\u6237\u7AEF\u4EE4\u724C",
|
|
419
|
-
/* @__PURE__ */ (0,
|
|
4065
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { id: "dsh-knowledge-remote-token", type: "password", value: remoteToken, placeholder: current?.tokenConfigured ? "\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u5219\u4FDD\u6301\u4E0D\u53D8" : "\u7C98\u8D34\u5BA2\u6237\u7AEF\u4EE4\u724C", autoComplete: "new-password", onChange: (event) => edit(() => {
|
|
420
4066
|
setRemoteToken(event.target.value);
|
|
421
4067
|
}), "aria-invalid": tokenError !== void 0, "aria-describedby": "dsh-knowledge-token-help" }),
|
|
422
|
-
/* @__PURE__ */ (0,
|
|
4068
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { id: "dsh-knowledge-token-help", className: tokenError ? "dsh-knowledge-field-error" : void 0, children: tokenError ?? (current?.tokenConfigured ? "\u4EE4\u724C\u5DF2\u5B89\u5168\u4FDD\u5B58\uFF0C\u9875\u9762\u65E0\u6CD5\u8BFB\u53D6\uFF1B\u8F93\u5165\u65B0\u4EE4\u724C\u53EF\u8986\u76D6\u3002" : "\u4EE4\u724C\u4FDD\u5B58\u540E\u4E0D\u53EF\u8BFB\u53D6\uFF0C\u53EA\u80FD\u8986\u76D6\u3002") })
|
|
423
4069
|
] })
|
|
424
4070
|
] }),
|
|
425
|
-
/* @__PURE__ */ (0,
|
|
4071
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "dsh-knowledge-timeout-field", htmlFor: "dsh-knowledge-timeout", children: [
|
|
426
4072
|
"\u8BF7\u6C42\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
427
|
-
/* @__PURE__ */ (0,
|
|
4073
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { id: "dsh-knowledge-timeout", type: "number", min: "100", max: "120000", step: "100", value: timeout, onChange: (event) => edit(() => {
|
|
428
4074
|
setTimeoutValue(event.target.value);
|
|
429
4075
|
}), "aria-invalid": timeoutError !== void 0 }),
|
|
430
|
-
timeoutError && /* @__PURE__ */ (0,
|
|
4076
|
+
timeoutError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("small", { className: "dsh-knowledge-field-error", children: timeoutError })
|
|
431
4077
|
] }),
|
|
432
|
-
!current?.writable && /* @__PURE__ */ (0,
|
|
433
|
-
|
|
434
|
-
/* @__PURE__ */ (0,
|
|
435
|
-
/* @__PURE__ */ (0,
|
|
436
|
-
/* @__PURE__ */ (0,
|
|
4078
|
+
!current?.writable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsh-knowledge-settings-note", children: "\u5F53\u524D\u63D2\u4EF6\u6CA1\u6709\u914D\u7F6E\u6301\u4E45\u5316\u8DEF\u5F84\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8FDE\u63A5\u3002" }),
|
|
4079
|
+
message3 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: `dsh-knowledge-settings-message is-${message3.kind}`, role: message3.kind === "error" ? "alert" : "status", "aria-live": "polite", children: message3.text }),
|
|
4080
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-settings-actions", children: [
|
|
4081
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: reset, disabled: !dirty || saving, children: "\u653E\u5F03\u66F4\u6539" }),
|
|
4082
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "is-primary", onClick: () => {
|
|
437
4083
|
void save();
|
|
438
4084
|
}, disabled: !dirty || invalid || saving || !current?.writable, children: saving ? "\u6B63\u5728\u9A8C\u8BC1\u2026" : "\u9A8C\u8BC1\u5E76\u8FDE\u63A5" })
|
|
439
4085
|
] })
|
|
@@ -451,9 +4097,9 @@ function validateRemoteUrl(value) {
|
|
|
451
4097
|
}
|
|
452
4098
|
}
|
|
453
4099
|
function connectionErrorMessage(error) {
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
return
|
|
4100
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
4101
|
+
if (message3.includes("Failed to fetch")) return "\u65E0\u6CD5\u8BBF\u95EE\u63D2\u4EF6\u8FDE\u63A5\u63A5\u53E3\uFF0C\u8BF7\u786E\u8BA4\u63D2\u4EF6\u670D\u52A1\u5DF2\u52A0\u8F7D\u3002";
|
|
4102
|
+
return message3 || "\u8FDE\u63A5\u914D\u7F6E\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u5730\u5740\u3001\u4EE4\u724C\u548C DSH \u65E5\u5FD7\u3002";
|
|
457
4103
|
}
|
|
458
4104
|
async function requestConnection(method, body, signal) {
|
|
459
4105
|
const response = await fetch(CONNECTION_CONTROL_PATH, {
|
|
@@ -464,8 +4110,8 @@ async function requestConnection(method, body, signal) {
|
|
|
464
4110
|
});
|
|
465
4111
|
const payload = await response.json().catch(() => void 0);
|
|
466
4112
|
if (!response.ok) {
|
|
467
|
-
const
|
|
468
|
-
throw new Error(
|
|
4113
|
+
const message3 = payload !== null && typeof payload === "object" && typeof payload.error === "string" ? payload.error : `\u8FDE\u63A5\u63A5\u53E3\u8FD4\u56DE HTTP ${response.status}`;
|
|
4114
|
+
throw new Error(message3);
|
|
469
4115
|
}
|
|
470
4116
|
if (!isConnectionView(payload)) throw new Error("\u63D2\u4EF6\u8FDE\u63A5\u63A5\u53E3\u8FD4\u56DE\u4E86\u65E0\u6548\u6570\u636E\u3002");
|
|
471
4117
|
cachedConnectionView = payload;
|
|
@@ -479,25 +4125,51 @@ function isConnectionView(value) {
|
|
|
479
4125
|
function isManagementPath(value) {
|
|
480
4126
|
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//");
|
|
481
4127
|
}
|
|
482
|
-
function KnowledgeLauncher({ wide, workspace }) {
|
|
483
|
-
const [open, setOpen] = (0,
|
|
484
|
-
|
|
4128
|
+
function KnowledgeLauncher({ wide, useSessions, workspace, activity }) {
|
|
4129
|
+
const [open, setOpen] = (0, import_react3.useState)(workspace.isOpen());
|
|
4130
|
+
const sessionId = useSessions((state) => state.current);
|
|
4131
|
+
const currentSessionId = sessionId === void 0 ? void 0 : String(sessionId);
|
|
4132
|
+
const [activityOpen, setActivityOpen] = (0, import_react3.useState)(currentSessionId === void 0 ? false : activity.isOpen(currentSessionId));
|
|
4133
|
+
const [compactViewport, setCompactViewport] = (0, import_react3.useState)(() => window.matchMedia(COMPACT_KNOWLEDGE_VIEWPORT).matches);
|
|
4134
|
+
(0, import_react3.useEffect)(() => workspace.subscribe(() => {
|
|
485
4135
|
setOpen(workspace.isOpen());
|
|
486
4136
|
}), [workspace]);
|
|
487
|
-
|
|
4137
|
+
(0, import_react3.useEffect)(() => {
|
|
4138
|
+
const sync = () => {
|
|
4139
|
+
setActivityOpen(currentSessionId === void 0 ? false : activity.isOpen(currentSessionId));
|
|
4140
|
+
};
|
|
4141
|
+
sync();
|
|
4142
|
+
return activity.subscribe(sync);
|
|
4143
|
+
}, [activity, currentSessionId]);
|
|
4144
|
+
(0, import_react3.useEffect)(() => {
|
|
4145
|
+
const query = window.matchMedia(COMPACT_KNOWLEDGE_VIEWPORT);
|
|
4146
|
+
const sync = () => {
|
|
4147
|
+
setCompactViewport(query.matches);
|
|
4148
|
+
};
|
|
4149
|
+
sync();
|
|
4150
|
+
query.addEventListener("change", sync);
|
|
4151
|
+
return () => {
|
|
4152
|
+
query.removeEventListener("change", sync);
|
|
4153
|
+
};
|
|
4154
|
+
}, []);
|
|
4155
|
+
const active = open || activityOpen;
|
|
4156
|
+
const activate = () => {
|
|
4157
|
+
if (open) return workspace.close();
|
|
4158
|
+
if (compactViewport || currentSessionId === void 0) return workspace.open();
|
|
4159
|
+
if (currentSessionId !== void 0) activity.toggle(currentSessionId);
|
|
4160
|
+
};
|
|
4161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
488
4162
|
"button",
|
|
489
4163
|
{
|
|
490
4164
|
type: "button",
|
|
491
|
-
className: `dsh-knowledge-trigger${wide ? "" : " dsh-knowledge-trigger--rail"}${
|
|
492
|
-
"aria-label":
|
|
493
|
-
"aria-pressed":
|
|
494
|
-
title: wide ? void 0 :
|
|
495
|
-
onClick:
|
|
496
|
-
workspace.toggle();
|
|
497
|
-
},
|
|
4165
|
+
className: `dsh-knowledge-trigger${wide ? "" : " dsh-knowledge-trigger--rail"}${active ? " is-active" : ""}`,
|
|
4166
|
+
"aria-label": active ? "\u8FD4\u56DE\u5BF9\u8BDD" : compactViewport || currentSessionId === void 0 ? "\u6253\u5F00\u77E5\u8BC6\u5E93\u5DE5\u4F5C\u533A" : "\u5C55\u5F00\u4F1A\u8BDD\u77E5\u8BC6\u5E93",
|
|
4167
|
+
"aria-pressed": active,
|
|
4168
|
+
title: wide ? void 0 : active ? "\u8FD4\u56DE\u5BF9\u8BDD" : "\u77E5\u8BC6\u5E93",
|
|
4169
|
+
onClick: activate,
|
|
498
4170
|
children: [
|
|
499
|
-
/* @__PURE__ */ (0,
|
|
500
|
-
wide && /* @__PURE__ */ (0,
|
|
4171
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.IconDataOutline16, { size: wide ? 16 : 18 }),
|
|
4172
|
+
wide && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u77E5\u8BC6\u5E93" })
|
|
501
4173
|
]
|
|
502
4174
|
}
|
|
503
4175
|
);
|
|
@@ -509,15 +4181,15 @@ function KnowledgeWorkspace({
|
|
|
509
4181
|
workspace
|
|
510
4182
|
}) {
|
|
511
4183
|
const cachedManagementPath = cachedConnectionView?.managementAvailable ? cachedConnectionView.managementPath : void 0;
|
|
512
|
-
const [panelState, setPanelState] = (0,
|
|
513
|
-
const [managementPath, setManagementPath] = (0,
|
|
514
|
-
const [panelError, setPanelError] = (0,
|
|
515
|
-
const [target, setTarget] = (0,
|
|
4184
|
+
const [panelState, setPanelState] = (0, import_react3.useState)(cachedConnectionView === void 0 ? "loading" : cachedManagementPath === void 0 ? "unavailable" : "ready");
|
|
4185
|
+
const [managementPath, setManagementPath] = (0, import_react3.useState)(cachedManagementPath);
|
|
4186
|
+
const [panelError, setPanelError] = (0, import_react3.useState)("");
|
|
4187
|
+
const [target, setTarget] = (0, import_react3.useState)(workspace.currentTarget());
|
|
516
4188
|
const projectId = useSessions((state) => sessionId === void 0 ? void 0 : state.byId[sessionId]?.cwd);
|
|
517
4189
|
const knowledgeUrl = managementPath === void 0 ? void 0 : knowledgePanelUrl(managementPath, sessionId, projectId, target);
|
|
518
|
-
const frame = (0,
|
|
519
|
-
const themeFrame = (0,
|
|
520
|
-
const loadManagement = (0,
|
|
4190
|
+
const frame = (0, import_react3.useRef)(null);
|
|
4191
|
+
const themeFrame = (0, import_react3.useRef)(0);
|
|
4192
|
+
const loadManagement = (0, import_react3.useCallback)(async (background = false) => {
|
|
521
4193
|
if (!background) setPanelState("loading");
|
|
522
4194
|
setPanelError("");
|
|
523
4195
|
try {
|
|
@@ -535,13 +4207,13 @@ function KnowledgeWorkspace({
|
|
|
535
4207
|
setPanelState("error");
|
|
536
4208
|
}
|
|
537
4209
|
}, []);
|
|
538
|
-
(0,
|
|
4210
|
+
(0, import_react3.useEffect)(() => {
|
|
539
4211
|
void loadManagement(cachedConnectionView !== void 0);
|
|
540
4212
|
}, [loadManagement]);
|
|
541
|
-
(0,
|
|
4213
|
+
(0, import_react3.useEffect)(() => workspace.subscribe(() => {
|
|
542
4214
|
setTarget(workspace.currentTarget());
|
|
543
4215
|
}), [workspace]);
|
|
544
|
-
const sendTheme = (0,
|
|
4216
|
+
const sendTheme = (0, import_react3.useCallback)(() => {
|
|
545
4217
|
const currentFrame = frame.current;
|
|
546
4218
|
if (currentFrame === null) return;
|
|
547
4219
|
const target2 = currentFrame.contentWindow;
|
|
@@ -552,14 +4224,14 @@ function KnowledgeWorkspace({
|
|
|
552
4224
|
frameOrigin(currentFrame) ?? "*"
|
|
553
4225
|
);
|
|
554
4226
|
}, [client]);
|
|
555
|
-
const scheduleTheme = (0,
|
|
4227
|
+
const scheduleTheme = (0, import_react3.useCallback)(() => {
|
|
556
4228
|
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
557
4229
|
themeFrame.current = window.requestAnimationFrame(() => {
|
|
558
4230
|
themeFrame.current = 0;
|
|
559
4231
|
sendTheme();
|
|
560
4232
|
});
|
|
561
4233
|
}, [sendTheme]);
|
|
562
|
-
(0,
|
|
4234
|
+
(0, import_react3.useEffect)(() => {
|
|
563
4235
|
const off = client.on("theme/change", scheduleTheme);
|
|
564
4236
|
const onMessage = (event) => {
|
|
565
4237
|
const currentFrame = frame.current;
|
|
@@ -577,21 +4249,21 @@ function KnowledgeWorkspace({
|
|
|
577
4249
|
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
578
4250
|
};
|
|
579
4251
|
}, [client, scheduleTheme, sendTheme]);
|
|
580
|
-
return /* @__PURE__ */ (0,
|
|
581
|
-
/* @__PURE__ */ (0,
|
|
582
|
-
/* @__PURE__ */ (0,
|
|
583
|
-
/* @__PURE__ */ (0,
|
|
584
|
-
/* @__PURE__ */ (0,
|
|
585
|
-
/* @__PURE__ */ (0,
|
|
586
|
-
/* @__PURE__ */ (0,
|
|
4252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "dsh-knowledge-workspace", "data-xiaohei-surface": "plugin-workspace", "aria-labelledby": "dsh-knowledge-workspace-title", children: [
|
|
4253
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("header", { className: "dsh-knowledge-workspace-header", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
4254
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", "data-xiaohei-workspace-close": true, onClick: workspace.close, "aria-label": "\u8FD4\u56DE\u4F1A\u8BDD", title: "\u8FD4\u56DE\u4F1A\u8BDD", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.IconChevronLeftOutline14, { size: 15 }) }),
|
|
4255
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.IconDataOutline16, { size: 18 }),
|
|
4256
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
4257
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { id: "dsh-knowledge-workspace-title", children: "\u77E5\u8BC6\u5E93" }),
|
|
4258
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "\u6587\u6863\u3001\u5BA1\u6838\u3001\u6302\u8F7D\u4E0E\u8BBF\u95EE\u7BA1\u7406" })
|
|
587
4259
|
] })
|
|
588
4260
|
] }) }),
|
|
589
|
-
panelState === "ready" && knowledgeUrl !== void 0 ? /* @__PURE__ */ (0,
|
|
590
|
-
/* @__PURE__ */ (0,
|
|
591
|
-
/* @__PURE__ */ (0,
|
|
592
|
-
/* @__PURE__ */ (0,
|
|
593
|
-
/* @__PURE__ */ (0,
|
|
594
|
-
panelState === "error" && /* @__PURE__ */ (0,
|
|
4261
|
+
panelState === "ready" && knowledgeUrl !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("iframe", { ref: frame, className: "dsh-knowledge-frame", src: knowledgeUrl, title: "\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0", onLoad: sendTheme }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsh-knowledge-panel-state", role: panelState === "error" ? "alert" : "status", "aria-live": "polite", children: [
|
|
4262
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "dsh-knowledge-panel-state-icon", "aria-hidden": "true", children: panelState === "loading" ? "\xB7\xB7\xB7" : panelState === "error" ? "!" : "\u2014" }),
|
|
4263
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
4264
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: panelState === "loading" ? "\u6B63\u5728\u6253\u5F00\u77E5\u8BC6\u5E93\u2026" : panelState === "error" ? "\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u77E5\u8BC6\u5E93" : "\u8FD9\u53F0 DSH \u672A\u542F\u7528\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0" }),
|
|
4265
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: panelState === "loading" ? "\u6B63\u5728\u786E\u8BA4\u5F53\u524D\u5B9E\u4F8B\u662F\u5426\u63D0\u4F9B\u7BA1\u7406\u9875\u9762\u3002" : panelState === "error" ? panelError : "\u672C\u5730\u53EC\u56DE\u548C\u56DE\u5199\u4ECD\u53EF\u4F7F\u7528\u3002\u5F53\u524D profile \u5DF2\u663E\u5F0F\u5173\u95ED exposeWeb\uFF1B\u91CD\u65B0\u542F\u7528\u540E\u5373\u53EF\u5728\u8FD9\u91CC\u7BA1\u7406\u3002\u4F7F\u7528\u8FDC\u7A0B\u77E5\u8BC6\u5E93\u65F6\uFF0C\u8BF7\u524D\u5F80\u4E2D\u592E DSH \u7684\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0\u3002" }),
|
|
4266
|
+
panelState === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", onClick: () => {
|
|
595
4267
|
void loadManagement();
|
|
596
4268
|
}, children: "\u91CD\u8BD5" })
|
|
597
4269
|
] })
|
|
@@ -603,8 +4275,13 @@ function knowledgePanelUrl(managementPath, sessionId, projectId, target) {
|
|
|
603
4275
|
if (sessionId !== void 0) params.set("sessionId", sessionId);
|
|
604
4276
|
if (projectId !== void 0) params.set("projectId", projectId);
|
|
605
4277
|
if (target !== void 0) {
|
|
606
|
-
|
|
607
|
-
|
|
4278
|
+
if (target.view === "notes") {
|
|
4279
|
+
params.set("view", "notes");
|
|
4280
|
+
if (target.noteId !== void 0) params.set("noteId", target.noteId);
|
|
4281
|
+
} else {
|
|
4282
|
+
params.set("knowledgeBaseId", target.knowledgeBaseId);
|
|
4283
|
+
params.set("documentId", target.documentId);
|
|
4284
|
+
}
|
|
608
4285
|
}
|
|
609
4286
|
const query = params.toString();
|
|
610
4287
|
return query.length === 0 ? managementPath : `${managementPath}${managementPath.includes("?") ? "&" : "?"}${query}`;
|
|
@@ -623,11 +4300,17 @@ function installStyles() {
|
|
|
623
4300
|
const style = document.createElement("style");
|
|
624
4301
|
style.dataset.plugin = PLUGIN_ID;
|
|
625
4302
|
style.dataset.pluginCss = STYLE_ID;
|
|
626
|
-
style.textContent = client_default
|
|
4303
|
+
style.textContent = `${client_default}
|
|
4304
|
+
${knowledge_activity_default}`;
|
|
627
4305
|
document.head.appendChild(style);
|
|
628
4306
|
return () => {
|
|
629
4307
|
style.remove();
|
|
630
4308
|
};
|
|
631
4309
|
}
|
|
4310
|
+
/*! Bundled license information:
|
|
4311
|
+
|
|
4312
|
+
dompurify/dist/purify.es.mjs:
|
|
4313
|
+
(*! @license DOMPurify 3.4.14 | (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.14/LICENSE *)
|
|
4314
|
+
*/
|
|
632
4315
|
return module.exports; } });
|
|
633
4316
|
//# sourceMappingURL=client.js.map
|