@herbertgao/pi-extensions 2026.8.7 → 2026.8.8

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.
Files changed (99) hide show
  1. package/README.md +7 -5
  2. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
  4. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +63 -15
  5. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/message-display.ts +78 -16
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/hover.ts +13 -0
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +17 -6
  8. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
  9. package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +4 -4
  10. package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +154 -96
  11. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +3 -0
  12. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/keyboard.md +10 -2
  13. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/localization.md +7 -5
  14. package/node_modules/@juicesharp/rpiv-ask-user-question/docs/tool-schema.md +11 -5
  15. package/node_modules/@juicesharp/rpiv-ask-user-question/locales/en.json +3 -0
  16. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
  17. package/node_modules/@juicesharp/rpiv-ask-user-question/state/key-router.ts +137 -96
  18. package/node_modules/@juicesharp/rpiv-ask-user-question/state/questionnaire-session.ts +44 -32
  19. package/node_modules/@juicesharp/rpiv-ask-user-question/state/selectors/projections.ts +22 -15
  20. package/node_modules/@juicesharp/rpiv-ask-user-question/state/state-reducer.ts +11 -1
  21. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/response-envelope.ts +11 -0
  22. package/node_modules/@juicesharp/rpiv-ask-user-question/tool/types.ts +11 -0
  23. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/multi-select-view.ts +31 -17
  24. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/preview/preview-block-renderer.ts +15 -6
  25. package/node_modules/@juicesharp/rpiv-ask-user-question/view/components/wrapping-select.ts +15 -6
  26. package/node_modules/@juicesharp/rpiv-ask-user-question/view/dialog-builder.ts +56 -34
  27. package/node_modules/@juicesharp/rpiv-ask-user-question/view/tab-content-strategy.ts +50 -4
  28. package/node_modules/@narumitw/pi-btw/package.json +2 -2
  29. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +44 -1856
  30. package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -1
  31. package/node_modules/@pi-plugins/fast-mode/package.json +4 -6
  32. package/node_modules/pi-lens/CHANGELOG.md +90 -0
  33. package/node_modules/pi-lens/README.md +106 -0
  34. package/node_modules/pi-lens/dist/clients/bash-file-access.js +97 -6
  35. package/node_modules/pi-lens/dist/clients/blocker-past-eof.js +16 -6
  36. package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +14 -0
  37. package/node_modules/pi-lens/dist/clients/cache-observability.js +353 -76
  38. package/node_modules/pi-lens/dist/clients/degradation-ledger.js +22 -1
  39. package/node_modules/pi-lens/dist/clients/demoted-finding-render.js +155 -0
  40. package/node_modules/pi-lens/dist/clients/deps/pi-tui.js +8 -2
  41. package/node_modules/pi-lens/dist/clients/deps/typebox.js +8 -3
  42. package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +9 -6
  43. package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +9 -7
  44. package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +8 -6
  45. package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +8 -10
  46. package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +10 -10
  47. package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +20 -5
  48. package/node_modules/pi-lens/dist/clients/dispatch/runners/phpstan.js +44 -11
  49. package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +10 -15
  50. package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +19 -11
  51. package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +35 -13
  52. package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +8 -8
  53. package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +110 -23
  54. package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +12 -7
  55. package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +117 -1
  56. package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +16 -14
  57. package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +8 -9
  58. package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +22 -0
  59. package/node_modules/pi-lens/dist/clients/jscpd-client.js +5 -2
  60. package/node_modules/pi-lens/dist/clients/language-profile.js +7 -2
  61. package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +27 -2
  62. package/node_modules/pi-lens/dist/clients/lsp/client.js +144 -5
  63. package/node_modules/pi-lens/dist/clients/lsp/index.js +151 -6
  64. package/node_modules/pi-lens/dist/clients/module-report.js +14 -1
  65. package/node_modules/pi-lens/dist/clients/ndjson-logger.js +114 -23
  66. package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +18 -9
  67. package/node_modules/pi-lens/dist/clients/project-report.js +62 -27
  68. package/node_modules/pi-lens/dist/clients/read-guard-logger.js +7 -2
  69. package/node_modules/pi-lens/dist/clients/read-guard.js +88 -19
  70. package/node_modules/pi-lens/dist/clients/review-graph/builder.js +194 -31
  71. package/node_modules/pi-lens/dist/clients/review-graph/revision-drift.js +21 -0
  72. package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +6 -3
  73. package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +44 -0
  74. package/node_modules/pi-lens/dist/clients/runtime-session.js +41 -0
  75. package/node_modules/pi-lens/dist/clients/runtime-turn.js +47 -2
  76. package/node_modules/pi-lens/dist/clients/session-event-guard.js +184 -0
  77. package/node_modules/pi-lens/dist/clients/source-filter.js +6 -2
  78. package/node_modules/pi-lens/dist/clients/startup-scan.js +5 -2
  79. package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +1 -0
  80. package/node_modules/pi-lens/dist/index.js +1224 -393
  81. package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +10 -3
  82. package/node_modules/pi-lens/package.json +18 -5
  83. package/node_modules/pi-lens/scripts/install-selftest.mjs +99 -11
  84. package/node_modules/pi-lens/scripts/lib/host-provided-deps.mjs +75 -0
  85. package/node_modules/pi-lens/scripts/lib/warm-loader-cache.mjs +285 -0
  86. package/node_modules/pi-lens/scripts/warm-loader-cache.mjs +233 -0
  87. package/node_modules/pi-web-access/CHANGELOG.md +14 -0
  88. package/node_modules/pi-web-access/README.md +6 -5
  89. package/node_modules/pi-web-access/chrome-cookies.ts +86 -15
  90. package/node_modules/pi-web-access/data-uri-sanitize.ts +406 -0
  91. package/node_modules/pi-web-access/extract.ts +12 -2
  92. package/node_modules/pi-web-access/firecrawl.ts +18 -2
  93. package/node_modules/pi-web-access/github-extract.ts +65 -36
  94. package/node_modules/pi-web-access/index.ts +19 -4
  95. package/node_modules/pi-web-access/openai-search.ts +17 -6
  96. package/node_modules/pi-web-access/package.json +1 -1
  97. package/node_modules/pi-web-access/pdf-extract.ts +18 -5
  98. package/node_modules/pi-web-access/ssrf-protection.ts +12 -2
  99. package/package.json +9 -9
@@ -1,17 +1,45 @@
1
- import { createRequire } from "node:module";
2
- import * as NodeServices from "@effect/platform-node/NodeServices";
3
1
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
4
- import { Array as Array$1, Data, Effect, FileSystem, Match, Order, Path, Predicate, Record, Schema, String as String$1, pipe } from "effect";
2
+ import * as NodeServices from "@effect/platform-node/NodeServices";
3
+ import { Array, Cause, Data, Effect, Exit, FileSystem, Inspectable, Match, Order, Path, Predicate, Record, Schema, String, pipe } from "effect";
4
+ //#region ../../tooling/shared/src/run.ts
5
+ const ABORT_MESSAGE = "Operation aborted";
6
+ function causeMessage(cause) {
7
+ if (Cause.hasInterruptsOnly(cause)) return ABORT_MESSAGE;
8
+ if (Cause.hasDies(cause)) return Cause.pretty(cause);
9
+ return cause.reasons.filter(Cause.isFailReason).map(({ error }) => {
10
+ if (error instanceof Error) return error.message || error.name;
11
+ return typeof error === "string" ? error : Inspectable.toStringUnknown(error);
12
+ }).join("\n");
13
+ }
14
+ /**
15
+ * For boundaries where pi reports rejections but expected failures should
16
+ * degrade gracefully (event hooks, commands, background work). Expected
17
+ * failures and interrupts never reject. Without `onError` they vanish, while
18
+ * defects rethrow so pi's handler boundary reports the bug.
19
+ */
20
+ async function runHandler(effect, options) {
21
+ const exit = await Effect.runPromiseExit(effect);
22
+ if (Exit.isSuccess(exit)) return exit.value;
23
+ if (options?.onError) return options.onError(causeMessage(exit.cause));
24
+ const die = exit.cause.reasons.find(Cause.isDieReason);
25
+ if (die !== void 0) throw die.defect;
26
+ }
27
+ //#endregion
5
28
  //#region ../../tooling/shared/src/config.ts
6
29
  /**
7
- * Loads an extension's JSON config from `<agent-dir>/extensions/<name>.json` and
8
- * validates it with `schema`.
30
+ * A missing config file yields `defaults` silently. An unreadable or invalid
31
+ * one warns and yields `defaults`, so a typo downgrades the extension rather
32
+ * than breaking it.
9
33
  */
10
- const loadExtensionConfig = Effect.fnUntraced(function* (schema, name) {
34
+ const loadExtensionConfig = Effect.fnUntraced(function* (_ctx, schema, name, _defaults) {
11
35
  const fs = yield* FileSystem.FileSystem;
12
36
  const file = (yield* Path.Path).join(getAgentDir(), "extensions", `${name}.json`);
13
- return yield* fs.readFileString(file).pipe(Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(schema))), Effect.tapError((error) => error._tag === "PlatformError" && error.reason._tag === "NotFound" ? Effect.void : Effect.logWarning(`Could not load ${name} config. [${error._tag}]: ${error.message}`)));
14
- });
37
+ const contents = yield* fs.readFileString(file);
38
+ return yield* Schema.decodeEffect(Schema.fromJsonString(schema))(contents);
39
+ }, (load, ctx, _schema, name, defaults) => runHandler(load.pipe(Effect.catchIf((error) => error._tag === "PlatformError" && error.reason._tag === "NotFound", () => Effect.succeed(defaults)), Effect.provide(NodeServices.layer)), { onError: (message) => {
40
+ if (ctx.hasUI) ctx.ui.notify(`Ignoring invalid ${name} config: ${message}`, "warning");
41
+ return defaults;
42
+ } }));
15
43
  //#endregion
16
44
  //#region ../../tooling/shared/src/statusline.ts
17
45
  const WIDGET_KEY = "pi-plugins:statusline";
@@ -23,14 +51,14 @@ function registry() {
23
51
  }
24
52
  const byKey = Order.mapInput(Order.String, ([key]) => key);
25
53
  function side(segments, align) {
26
- return pipe(Array$1.fromIterable(segments), Array$1.filter(([, segment]) => segment.align === align), Array$1.sortBy(byKey), Array$1.map(([, segment]) => segment.text), Array$1.join(" · "));
54
+ return pipe(Array.fromIterable(segments), Array.filter(([, segment]) => segment.align === align), Array.sortBy(byKey), Array.map(([, segment]) => segment.text), Array.join(" · "));
27
55
  }
28
56
  /** Terminal columns of plain text (code points, no ANSI). */
29
57
  function textWidth(text) {
30
- return Array$1.fromIterable(text).length;
58
+ return Array.fromIterable(text).length;
31
59
  }
32
60
  function truncate(text, columns) {
33
- return pipe(Array$1.fromIterable(text), Array$1.take(columns), Array$1.join(""));
61
+ return pipe(Array.fromIterable(text), Array.take(columns), Array.join(""));
34
62
  }
35
63
  /**
36
64
  * Lays out `left ... right` across `width`: left indented one column to match
@@ -43,8 +71,8 @@ function renderLine(segments, width, theme) {
43
71
  const margin = Math.min(width, 1);
44
72
  const inner = width - margin;
45
73
  const gap = inner - textWidth(left) - textWidth(right);
46
- const minGap = String$1.isNonEmpty(left) && String$1.isNonEmpty(right) ? 2 : 0;
47
- const line = String$1.isNonEmpty(right) && gap >= minGap ? `${left}${" ".repeat(gap)}${right}` : truncate(pipe([left, right], Array$1.filter(String$1.isNonEmpty), Array$1.join(" · ")), Math.max(inner, 0));
74
+ const minGap = String.isNonEmpty(left) && String.isNonEmpty(right) ? 2 : 0;
75
+ const line = String.isNonEmpty(right) && gap >= minGap ? `${left}${" ".repeat(gap)}${right}` : truncate(pipe([left, right], Array.filter(String.isNonEmpty), Array.join(" · ")), Math.max(inner, 0));
48
76
  return " ".repeat(margin) + theme.fg("dim", line);
49
77
  }
50
78
  /**
@@ -66,1846 +94,6 @@ function setStatuslineSegment(ctx, key, segment) {
66
94
  invalidate: () => {}
67
95
  }));
68
96
  }
69
- new Intl.Segmenter(void 0, { granularity: "grapheme" });
70
- new Intl.Segmenter(void 0, { granularity: "word" });
71
- function parseOsc8Hyperlink(ansiCode) {
72
- if (!ansiCode.startsWith("\x1B]8;")) return;
73
- const terminator = ansiCode.endsWith("\x07") ? "\x07" : "\x1B\\";
74
- const body = ansiCode.slice(4, terminator === "\x07" ? -1 : -2);
75
- const separatorIndex = body.indexOf(";");
76
- if (separatorIndex === -1) return;
77
- const params = body.slice(0, separatorIndex);
78
- const url = body.slice(separatorIndex + 1);
79
- if (!url) return null;
80
- return {
81
- params,
82
- url,
83
- terminator
84
- };
85
- }
86
- function formatOsc8Hyperlink(hyperlink) {
87
- return `\x1b]8;${hyperlink.params};${hyperlink.url}${hyperlink.terminator}`;
88
- }
89
- function formatOsc8Close(terminator) {
90
- return `\x1b]8;;${terminator}`;
91
- }
92
- /**
93
- * Track active ANSI SGR codes to preserve styling across line breaks.
94
- */
95
- var AnsiCodeTracker = class {
96
- bold = false;
97
- dim = false;
98
- italic = false;
99
- underline = false;
100
- blink = false;
101
- inverse = false;
102
- hidden = false;
103
- strikethrough = false;
104
- fgColor = null;
105
- bgColor = null;
106
- activeHyperlink = null;
107
- process(ansiCode) {
108
- const hyperlink = parseOsc8Hyperlink(ansiCode);
109
- if (hyperlink !== void 0) {
110
- this.activeHyperlink = hyperlink;
111
- return;
112
- }
113
- if (!ansiCode.endsWith("m")) return;
114
- const match = ansiCode.match(/\x1b\[([\d;]*)m/);
115
- if (!match) return;
116
- const params = match[1];
117
- if (params === "" || params === "0") {
118
- this.reset();
119
- return;
120
- }
121
- const parts = params.split(";");
122
- let i = 0;
123
- while (i < parts.length) {
124
- const code = Number.parseInt(parts[i], 10);
125
- if (code === 38 || code === 48) {
126
- if (parts[i + 1] === "5" && parts[i + 2] !== void 0) {
127
- const colorCode = `${parts[i]};${parts[i + 1]};${parts[i + 2]}`;
128
- if (code === 38) this.fgColor = colorCode;
129
- else this.bgColor = colorCode;
130
- i += 3;
131
- continue;
132
- } else if (parts[i + 1] === "2" && parts[i + 4] !== void 0) {
133
- const colorCode = `${parts[i]};${parts[i + 1]};${parts[i + 2]};${parts[i + 3]};${parts[i + 4]}`;
134
- if (code === 38) this.fgColor = colorCode;
135
- else this.bgColor = colorCode;
136
- i += 5;
137
- continue;
138
- }
139
- }
140
- switch (code) {
141
- case 0:
142
- this.reset();
143
- break;
144
- case 1:
145
- this.bold = true;
146
- break;
147
- case 2:
148
- this.dim = true;
149
- break;
150
- case 3:
151
- this.italic = true;
152
- break;
153
- case 4:
154
- this.underline = true;
155
- break;
156
- case 5:
157
- this.blink = true;
158
- break;
159
- case 7:
160
- this.inverse = true;
161
- break;
162
- case 8:
163
- this.hidden = true;
164
- break;
165
- case 9:
166
- this.strikethrough = true;
167
- break;
168
- case 21:
169
- this.bold = false;
170
- break;
171
- case 22:
172
- this.bold = false;
173
- this.dim = false;
174
- break;
175
- case 23:
176
- this.italic = false;
177
- break;
178
- case 24:
179
- this.underline = false;
180
- break;
181
- case 25:
182
- this.blink = false;
183
- break;
184
- case 27:
185
- this.inverse = false;
186
- break;
187
- case 28:
188
- this.hidden = false;
189
- break;
190
- case 29:
191
- this.strikethrough = false;
192
- break;
193
- case 39:
194
- this.fgColor = null;
195
- break;
196
- case 49:
197
- this.bgColor = null;
198
- break;
199
- default:
200
- if (code >= 30 && code <= 37 || code >= 90 && code <= 97) this.fgColor = String(code);
201
- else if (code >= 40 && code <= 47 || code >= 100 && code <= 107) this.bgColor = String(code);
202
- break;
203
- }
204
- i++;
205
- }
206
- }
207
- reset() {
208
- this.bold = false;
209
- this.dim = false;
210
- this.italic = false;
211
- this.underline = false;
212
- this.blink = false;
213
- this.inverse = false;
214
- this.hidden = false;
215
- this.strikethrough = false;
216
- this.fgColor = null;
217
- this.bgColor = null;
218
- }
219
- /** Clear all state for reuse. */
220
- clear() {
221
- this.reset();
222
- this.activeHyperlink = null;
223
- }
224
- getActiveCodes() {
225
- const codes = [];
226
- if (this.bold) codes.push("1");
227
- if (this.dim) codes.push("2");
228
- if (this.italic) codes.push("3");
229
- if (this.underline) codes.push("4");
230
- if (this.blink) codes.push("5");
231
- if (this.inverse) codes.push("7");
232
- if (this.hidden) codes.push("8");
233
- if (this.strikethrough) codes.push("9");
234
- if (this.fgColor) codes.push(this.fgColor);
235
- if (this.bgColor) codes.push(this.bgColor);
236
- let result = codes.length > 0 ? `\x1b[${codes.join(";")}m` : "";
237
- if (this.activeHyperlink) result += formatOsc8Hyperlink(this.activeHyperlink);
238
- return result;
239
- }
240
- hasActiveCodes() {
241
- return this.bold || this.dim || this.italic || this.underline || this.blink || this.inverse || this.hidden || this.strikethrough || this.fgColor !== null || this.bgColor !== null || this.activeHyperlink !== null;
242
- }
243
- /**
244
- * Get reset codes for attributes that need to be turned off at line end.
245
- * Underline must be closed to prevent bleeding into padding.
246
- * Active OSC 8 hyperlinks must be closed and re-opened on the next line.
247
- * Returns empty string if no attributes need closing.
248
- */
249
- getLineEndReset() {
250
- let result = "";
251
- if (this.underline) result += "\x1B[24m";
252
- if (this.activeHyperlink) result += formatOsc8Close(this.activeHyperlink.terminator);
253
- return result;
254
- }
255
- };
256
- new AnsiCodeTracker();
257
- //#endregion
258
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.83.0/node_modules/@earendil-works/pi-tui/dist/keys.js
259
- const MODIFIERS = {
260
- shift: 1,
261
- alt: 2,
262
- ctrl: 4,
263
- super: 8
264
- };
265
- const LOCK_MASK = 192;
266
- const ARROW_CODEPOINTS = {
267
- up: -1,
268
- down: -2,
269
- right: -3,
270
- left: -4
271
- };
272
- const FUNCTIONAL_CODEPOINTS = {
273
- delete: -10,
274
- insert: -11,
275
- pageUp: -12,
276
- pageDown: -13,
277
- home: -14,
278
- end: -15
279
- };
280
- ARROW_CODEPOINTS.left, ARROW_CODEPOINTS.right, ARROW_CODEPOINTS.up, ARROW_CODEPOINTS.down, FUNCTIONAL_CODEPOINTS.pageUp, FUNCTIONAL_CODEPOINTS.pageDown, FUNCTIONAL_CODEPOINTS.home, FUNCTIONAL_CODEPOINTS.end, FUNCTIONAL_CODEPOINTS.insert, FUNCTIONAL_CODEPOINTS.delete;
281
- MODIFIERS.shift | LOCK_MASK;
282
- //#endregion
283
- //#region ../../node_modules/.pnpm/marked@18.0.5/node_modules/marked/lib/marked.esm.js
284
- /**
285
- * marked v18.0.5 - a markdown parser
286
- * Copyright (c) 2018-2026, MarkedJS. (MIT License)
287
- * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
288
- * https://github.com/markedjs/marked
289
- */
290
- /**
291
- * DO NOT EDIT THIS FILE
292
- * The code in this file is generated from files in ./src/
293
- */
294
- function M() {
295
- return {
296
- async: !1,
297
- breaks: !1,
298
- extensions: null,
299
- gfm: !0,
300
- hooks: null,
301
- pedantic: !1,
302
- renderer: null,
303
- silent: !1,
304
- tokenizer: null,
305
- walkTokens: null
306
- };
307
- }
308
- var T = M();
309
- function N(l) {
310
- T = l;
311
- }
312
- var _ = { exec: () => null };
313
- function E(l) {
314
- let e = [];
315
- return (t) => {
316
- let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
317
- return s || (s = l(n), e[n] = s), s;
318
- };
319
- }
320
- function d(l, e = "") {
321
- let t = typeof l == "string" ? l : l.source, n = {
322
- replace: (s, r) => {
323
- let i = typeof r == "string" ? r : r.source;
324
- return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
325
- },
326
- getRegex: () => new RegExp(t, e)
327
- };
328
- return n;
329
- }
330
- var Te = ((l = "") => {
331
- try {
332
- return !!new RegExp("(?<=1)(?<!1)" + l);
333
- } catch {
334
- return !1;
335
- }
336
- })();
337
- var m = {
338
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
339
- outputLinkReplace: /\\([\[\]])/g,
340
- indentCodeCompensation: /^(\s+)(?:```)/,
341
- beginningSpace: /^\s+/,
342
- endingHash: /#$/,
343
- startingSpaceChar: /^ /,
344
- endingSpaceChar: / $/,
345
- nonSpaceChar: /[^ ]/,
346
- newLineCharGlobal: /\n/g,
347
- tabCharGlobal: /\t/g,
348
- multipleSpaceGlobal: /\s+/g,
349
- blankLine: /^[ \t]*$/,
350
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
351
- blockquoteStart: /^ {0,3}>/,
352
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
353
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
354
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
355
- listIsTask: /^\[[ xX]\] +\S/,
356
- listReplaceTask: /^\[[ xX]\] +/,
357
- listTaskCheckbox: /\[[ xX]\]/,
358
- anyLine: /\n.*\n/,
359
- hrefBrackets: /^<(.*)>$/,
360
- tableDelimiter: /[:|]/,
361
- tableAlignChars: /^\||\| *$/g,
362
- tableRowBlankLine: /\n[ \t]*$/,
363
- tableAlignRight: /^ *-+: *$/,
364
- tableAlignCenter: /^ *:-+: *$/,
365
- tableAlignLeft: /^ *:-+ *$/,
366
- startATag: /^<a /i,
367
- endATag: /^<\/a>/i,
368
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
369
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
370
- startAngleBracket: /^</,
371
- endAngleBracket: />$/,
372
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
373
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
374
- escapeTest: /[&<>"']/,
375
- escapeReplace: /[&<>"']/g,
376
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
377
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
378
- caret: /(^|[^\[])\^/g,
379
- percentDecode: /%25/g,
380
- findPipe: /\|/g,
381
- splitPipe: / \|/,
382
- slashPipe: /\\\|/g,
383
- carriageReturn: /\r\n|\r/g,
384
- spaceLine: /^ +$/gm,
385
- notSpaceStart: /^\S*/,
386
- endingNewline: /\n$/,
387
- listItemRegex: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),
388
- nextBulletRegex: E((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),
389
- hrRegex: E((l) => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),
390
- fencesBeginRegex: E((l) => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)),
391
- headingBeginRegex: E((l) => new RegExp(`^ {0,${l}}#`)),
392
- htmlBeginRegex: E((l) => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")),
393
- blockquoteBeginRegex: E((l) => new RegExp(`^ {0,${l}}>`))
394
- };
395
- var Oe = /^(?:[ \t]*(?:\n|$))+/;
396
- var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
397
- var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
398
- var B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
399
- var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
400
- var j = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
401
- var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
402
- var ae = d(oe).replace(/bull/g, j).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
403
- var Se = d(oe).replace(/bull/g, j).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}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
404
- var F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
405
- var $e = /^[^\n]+/;
406
- var U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
407
- var Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
408
- var _e = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, j).getRegex();
409
- var H = "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";
410
- var K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
411
- var ze = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\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", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
412
- var le = d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
413
- var W = {
414
- blockquote: d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex(),
415
- code: we,
416
- def: Le,
417
- fences: ye,
418
- heading: Pe,
419
- hr: B,
420
- html: ze,
421
- lheading: ae,
422
- list: _e,
423
- newline: Oe,
424
- paragraph: le,
425
- table: _,
426
- text: $e
427
- };
428
- var se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
429
- var Ee = {
430
- ...W,
431
- lheading: Se,
432
- table: se,
433
- paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex()
434
- };
435
- var Ie = {
436
- ...W,
437
- html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).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(),
438
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
439
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
440
- fences: _,
441
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
442
- paragraph: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
443
- ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
444
- };
445
- var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
446
- var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
447
- var ue = /^( {2,}|\\)\n(?!\s*$)/;
448
- var Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
449
- var I = /[\p{P}\p{S}]/u;
450
- var Z = /[\s\p{P}\p{S}]/u;
451
- var X = /[^\s\p{P}\p{S}]/u;
452
- var De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex();
453
- var pe = /(?!~)[\p{P}\p{S}]/u;
454
- var qe = /(?!~)[\s\p{P}\p{S}]/u;
455
- var ve = /(?:[^\s\p{P}\p{S}]|~)/u;
456
- var He = 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();
457
- var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
458
- var Ze = d(ce, "u").replace(/punct/g, I).getRegex();
459
- var Ge = d(ce, "u").replace(/punct/g, pe).getRegex();
460
- var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
461
- var Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
462
- var Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex();
463
- var je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
464
- var Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex();
465
- var Ke = d("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
466
- var We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex();
467
- var Xe = 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();
468
- var Je = d(K).replace("(?:-->|$)", "-->").getRegex();
469
- var Ve = 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", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
470
- var v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
471
- var Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
472
- var ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex();
473
- var de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex();
474
- var et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
475
- var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
476
- var J = {
477
- _backpedal: _,
478
- anyPunctuation: We,
479
- autolink: Xe,
480
- blockSkip: He,
481
- br: ue,
482
- code: Ce,
483
- del: _,
484
- delLDelim: _,
485
- delRDelim: _,
486
- emStrongLDelim: Ze,
487
- emStrongRDelimAst: Ne,
488
- emStrongRDelimUnd: je,
489
- escape: Ae,
490
- link: Ye,
491
- nolink: de,
492
- punctuation: De,
493
- reflink: ke,
494
- reflinkSearch: et,
495
- tag: Ve,
496
- text: Be,
497
- url: _
498
- };
499
- var tt = {
500
- ...J,
501
- link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(),
502
- reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex()
503
- };
504
- var Q = {
505
- ...J,
506
- emStrongRDelimAst: Qe,
507
- emStrongLDelim: Ge,
508
- delLDelim: Fe,
509
- delRDelim: Ke,
510
- 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(),
511
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
512
- del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
513
- 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()
514
- };
515
- var nt = {
516
- ...Q,
517
- br: d(ue).replace("{2,}", "*").getRegex(),
518
- text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
519
- };
520
- var D = {
521
- normal: W,
522
- gfm: Ee,
523
- pedantic: Ie
524
- };
525
- var A = {
526
- normal: J,
527
- gfm: Q,
528
- breaks: nt,
529
- pedantic: tt
530
- };
531
- var rt = {
532
- "&": "&amp;",
533
- "<": "&lt;",
534
- ">": "&gt;",
535
- "\"": "&quot;",
536
- "'": "&#39;"
537
- };
538
- var ge = (l) => rt[l];
539
- function O(l, e) {
540
- if (e) {
541
- if (m.escapeTest.test(l)) return l.replace(m.escapeReplace, ge);
542
- } else if (m.escapeTestNoEncode.test(l)) return l.replace(m.escapeReplaceNoEncode, ge);
543
- return l;
544
- }
545
- function V(l) {
546
- try {
547
- l = encodeURI(l).replace(m.percentDecode, "%");
548
- } catch {
549
- return null;
550
- }
551
- return l;
552
- }
553
- function Y(l, e) {
554
- let n = l.replace(m.findPipe, (r, i, o) => {
555
- let u = !1, a = i;
556
- for (; --a >= 0 && o[a] === "\\";) u = !u;
557
- return u ? "|" : " |";
558
- }).split(m.splitPipe), s = 0;
559
- if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
560
- else for (; n.length < e;) n.push("");
561
- for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
562
- return n;
563
- }
564
- function $(l, e, t) {
565
- let n = l.length;
566
- if (n === 0) return "";
567
- let s = 0;
568
- for (; s < n;) {
569
- let r = l.charAt(n - s - 1);
570
- if (r === e && !t) s++;
571
- else if (r !== e && t) s++;
572
- else break;
573
- }
574
- return l.slice(0, n - s);
575
- }
576
- function ee(l) {
577
- let e = l.split(`
578
- `), t = e.length - 1;
579
- for (; t >= 0 && m.blankLine.test(e[t]);) t--;
580
- return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
581
- `);
582
- }
583
- function fe(l, e) {
584
- if (l.indexOf(e[1]) === -1) return -1;
585
- let t = 0;
586
- for (let n = 0; n < l.length; n++) if (l[n] === "\\") n++;
587
- else if (l[n] === e[0]) t++;
588
- else if (l[n] === e[1] && (t--, t < 0)) return n;
589
- return t > 0 ? -2 : -1;
590
- }
591
- function me(l, e = 0) {
592
- let t = e, n = "";
593
- for (let s of l) if (s === " ") {
594
- let r = 4 - t % 4;
595
- n += " ".repeat(r), t += r;
596
- } else n += s, t++;
597
- return n;
598
- }
599
- function xe(l, e, t, n, s) {
600
- let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
601
- n.state.inLink = !0;
602
- let u = {
603
- type: l[0].charAt(0) === "!" ? "image" : "link",
604
- raw: t,
605
- href: r,
606
- title: i,
607
- text: o,
608
- tokens: n.inlineTokens(o)
609
- };
610
- return n.state.inLink = !1, u;
611
- }
612
- function st(l, e, t) {
613
- let n = l.match(t.other.indentCodeCompensation);
614
- if (n === null) return e;
615
- let s = n[1];
616
- return e.split(`
617
- `).map((r) => {
618
- let i = r.match(t.other.beginningSpace);
619
- if (i === null) return r;
620
- let [o] = i;
621
- return o.length >= s.length ? r.slice(s.length) : r;
622
- }).join(`
623
- `);
624
- }
625
- var w = class {
626
- options;
627
- rules;
628
- lexer;
629
- constructor(e) {
630
- this.options = e || T;
631
- }
632
- space(e) {
633
- let t = this.rules.block.newline.exec(e);
634
- if (t && t[0].length > 0) return {
635
- type: "space",
636
- raw: t[0]
637
- };
638
- }
639
- code(e) {
640
- let t = this.rules.block.code.exec(e);
641
- if (t) {
642
- let n = this.options.pedantic ? t[0] : ee(t[0]);
643
- return {
644
- type: "code",
645
- raw: n,
646
- codeBlockStyle: "indented",
647
- text: n.replace(this.rules.other.codeRemoveIndent, "")
648
- };
649
- }
650
- }
651
- fences(e) {
652
- let t = this.rules.block.fences.exec(e);
653
- if (t) {
654
- let n = t[0], s = st(n, t[3] || "", this.rules);
655
- return {
656
- type: "code",
657
- raw: n,
658
- lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
659
- text: s
660
- };
661
- }
662
- }
663
- heading(e) {
664
- let t = this.rules.block.heading.exec(e);
665
- if (t) {
666
- let n = t[2].trim();
667
- if (this.rules.other.endingHash.test(n)) {
668
- let s = $(n, "#");
669
- (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
670
- }
671
- return {
672
- type: "heading",
673
- raw: $(t[0], `
674
- `),
675
- depth: t[1].length,
676
- text: n,
677
- tokens: this.lexer.inline(n)
678
- };
679
- }
680
- }
681
- hr(e) {
682
- let t = this.rules.block.hr.exec(e);
683
- if (t) return {
684
- type: "hr",
685
- raw: $(t[0], `
686
- `)
687
- };
688
- }
689
- blockquote(e) {
690
- let t = this.rules.block.blockquote.exec(e);
691
- if (t) {
692
- let n = $(t[0], `
693
- `).split(`
694
- `), s = "", r = "", i = [];
695
- for (; n.length > 0;) {
696
- let o = !1, u = [], a;
697
- for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), o = !0;
698
- else if (!o) u.push(n[a]);
699
- else break;
700
- n = n.slice(a);
701
- let c = u.join(`
702
- `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
703
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
704
- s = s ? `${s}
705
- ${c}` : c, r = r ? `${r}
706
- ${p}` : p;
707
- let k = this.lexer.state.top;
708
- if (this.lexer.state.top = !0, this.lexer.blockTokens(p, i, !0), this.lexer.state.top = k, n.length === 0) break;
709
- let h = i.at(-1);
710
- if (h?.type === "code") break;
711
- if (h?.type === "blockquote") {
712
- let R = h, f = R.raw + `
713
- ` + n.join(`
714
- `), S = this.blockquote(f);
715
- i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
716
- break;
717
- } else if (h?.type === "list") {
718
- let R = h, f = R.raw + `
719
- ` + n.join(`
720
- `), S = this.list(f);
721
- i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
722
- `);
723
- continue;
724
- }
725
- }
726
- return {
727
- type: "blockquote",
728
- raw: s,
729
- tokens: i,
730
- text: r
731
- };
732
- }
733
- }
734
- list(e) {
735
- let t = this.rules.block.list.exec(e);
736
- if (t) {
737
- let n = t[1].trim(), s = n.length > 1, r = {
738
- type: "list",
739
- raw: "",
740
- ordered: s,
741
- start: s ? +n.slice(0, -1) : "",
742
- loose: !1,
743
- items: []
744
- };
745
- n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
746
- let i = this.rules.other.listItemRegex(n), o = !1;
747
- for (; e;) {
748
- let a = !1, c = "", p = "";
749
- if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
750
- c = t[0], e = e.substring(c.length);
751
- let k = me(t[2].split(`
752
- `, 1)[0], t[1].length), h = e.split(`
753
- `, 1)[0], R = !k.trim(), f = 0;
754
- if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
755
- `, e = e.substring(h.length + 1), a = !0), !a) {
756
- let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
757
- for (; e;) {
758
- let G = e.split(`
759
- `, 1)[0], C;
760
- if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h)) break;
761
- if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) p += `
762
- ` + C.slice(f);
763
- else {
764
- if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k)) break;
765
- p += `
766
- ` + h;
767
- }
768
- R = !h.trim(), c += G + `
769
- `, e = e.substring(G.length + 1), k = C.slice(f);
770
- }
771
- }
772
- r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (o = !0)), r.items.push({
773
- type: "list_item",
774
- raw: c,
775
- task: !!this.options.gfm && this.rules.other.listIsTask.test(p),
776
- loose: !1,
777
- text: p,
778
- tokens: []
779
- }), r.raw += c;
780
- }
781
- let u = r.items.at(-1);
782
- if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
783
- else return;
784
- r.raw = r.raw.trimEnd();
785
- for (let a of r.items) {
786
- this.lexer.state.top = !1, a.tokens = this.lexer.blockTokens(a.text, []);
787
- let c = a.tokens[0];
788
- if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
789
- a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
790
- for (let k = this.lexer.inlineQueue.length - 1; k >= 0; k--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
791
- this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
792
- break;
793
- }
794
- let p = this.rules.other.listTaskCheckbox.exec(a.raw);
795
- if (p) {
796
- let k = {
797
- type: "checkbox",
798
- raw: p[0] + " ",
799
- checked: p[0] !== "[ ]"
800
- };
801
- a.checked = k.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 = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({
802
- type: "paragraph",
803
- raw: k.raw,
804
- text: k.raw,
805
- tokens: [k]
806
- }) : a.tokens.unshift(k);
807
- }
808
- } else a.task && (a.task = !1);
809
- if (!r.loose) {
810
- let p = a.tokens.filter((h) => h.type === "space");
811
- r.loose = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
812
- }
813
- }
814
- if (r.loose) for (let a of r.items) {
815
- a.loose = !0;
816
- for (let c of a.tokens) c.type === "text" && (c.type = "paragraph");
817
- }
818
- return r;
819
- }
820
- }
821
- html(e) {
822
- let t = this.rules.block.html.exec(e);
823
- if (t) {
824
- let n = ee(t[0]);
825
- return {
826
- type: "html",
827
- block: !0,
828
- raw: n,
829
- pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
830
- text: n
831
- };
832
- }
833
- }
834
- def(e) {
835
- let t = this.rules.block.def.exec(e);
836
- if (t) {
837
- 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];
838
- return {
839
- type: "def",
840
- tag: n,
841
- raw: $(t[0], `
842
- `),
843
- href: s,
844
- title: r
845
- };
846
- }
847
- }
848
- table(e) {
849
- let t = this.rules.block.table.exec(e);
850
- if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
851
- let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
852
- `) : [], i = {
853
- type: "table",
854
- raw: $(t[0], `
855
- `),
856
- header: [],
857
- align: [],
858
- rows: []
859
- };
860
- if (n.length === s.length) {
861
- 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);
862
- for (let o = 0; o < n.length; o++) i.header.push({
863
- text: n[o],
864
- tokens: this.lexer.inline(n[o]),
865
- header: !0,
866
- align: i.align[o]
867
- });
868
- for (let o of r) i.rows.push(Y(o, i.header.length).map((u, a) => ({
869
- text: u,
870
- tokens: this.lexer.inline(u),
871
- header: !1,
872
- align: i.align[a]
873
- })));
874
- return i;
875
- }
876
- }
877
- lheading(e) {
878
- let t = this.rules.block.lheading.exec(e);
879
- if (t) {
880
- let n = t[1].trim();
881
- return {
882
- type: "heading",
883
- raw: $(t[0], `
884
- `),
885
- depth: t[2].charAt(0) === "=" ? 1 : 2,
886
- text: n,
887
- tokens: this.lexer.inline(n)
888
- };
889
- }
890
- }
891
- paragraph(e) {
892
- let t = this.rules.block.paragraph.exec(e);
893
- if (t) {
894
- let n = t[1].charAt(t[1].length - 1) === `
895
- ` ? t[1].slice(0, -1) : t[1];
896
- return {
897
- type: "paragraph",
898
- raw: t[0],
899
- text: n,
900
- tokens: this.lexer.inline(n)
901
- };
902
- }
903
- }
904
- text(e) {
905
- let t = this.rules.block.text.exec(e);
906
- if (t) return {
907
- type: "text",
908
- raw: t[0],
909
- text: t[0],
910
- tokens: this.lexer.inline(t[0])
911
- };
912
- }
913
- escape(e) {
914
- let t = this.rules.inline.escape.exec(e);
915
- if (t) return {
916
- type: "escape",
917
- raw: t[0],
918
- text: t[1]
919
- };
920
- }
921
- tag(e) {
922
- let t = this.rules.inline.tag.exec(e);
923
- if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
924
- type: "html",
925
- raw: t[0],
926
- inLink: this.lexer.state.inLink,
927
- inRawBlock: this.lexer.state.inRawBlock,
928
- block: !1,
929
- text: t[0]
930
- };
931
- }
932
- link(e) {
933
- let t = this.rules.inline.link.exec(e);
934
- if (t) {
935
- let n = t[2].trim();
936
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
937
- if (!this.rules.other.endAngleBracket.test(n)) return;
938
- let i = $(n.slice(0, -1), "\\");
939
- if ((n.length - i.length) % 2 === 0) return;
940
- } else {
941
- let i = fe(t[2], "()");
942
- if (i === -2) return;
943
- if (i > -1) {
944
- let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
945
- t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
946
- }
947
- }
948
- let s = t[2], r = "";
949
- if (this.options.pedantic) {
950
- let i = this.rules.other.pedanticHrefTitle.exec(s);
951
- i && (s = i[1], r = i[3]);
952
- } else r = t[3] ? t[3].slice(1, -1) : "";
953
- 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, {
954
- href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
955
- title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
956
- }, t[0], this.lexer, this.rules);
957
- }
958
- }
959
- reflink(e, t) {
960
- let n;
961
- if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
962
- let r = t[(n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
963
- if (!r) {
964
- let i = n[0].charAt(0);
965
- return {
966
- type: "text",
967
- raw: i,
968
- text: i
969
- };
970
- }
971
- return xe(n, r, n[0], this.lexer, this.rules);
972
- }
973
- }
974
- emStrong(e, t, n = "") {
975
- let s = this.rules.inline.emStrongLDelim.exec(e);
976
- if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
977
- if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
978
- let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
979
- for (p.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p.exec(t)) !== null;) {
980
- if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
981
- if (u = [...o].length, s[3] || s[4]) {
982
- a += u;
983
- continue;
984
- } else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
985
- c += u;
986
- continue;
987
- }
988
- if (a -= u, a > 0) continue;
989
- u = Math.min(u, u + a + c);
990
- let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
991
- if (Math.min(i, u) % 2) {
992
- let f = h.slice(1, -1);
993
- return {
994
- type: "em",
995
- raw: h,
996
- text: f,
997
- tokens: this.lexer.inlineTokens(f)
998
- };
999
- }
1000
- let R = h.slice(2, -2);
1001
- return {
1002
- type: "strong",
1003
- raw: h,
1004
- text: R,
1005
- tokens: this.lexer.inlineTokens(R)
1006
- };
1007
- }
1008
- }
1009
- }
1010
- codespan(e) {
1011
- let t = this.rules.inline.code.exec(e);
1012
- if (t) {
1013
- 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);
1014
- return s && r && (n = n.substring(1, n.length - 1)), {
1015
- type: "codespan",
1016
- raw: t[0],
1017
- text: n
1018
- };
1019
- }
1020
- }
1021
- br(e) {
1022
- let t = this.rules.inline.br.exec(e);
1023
- if (t) return {
1024
- type: "br",
1025
- raw: t[0]
1026
- };
1027
- }
1028
- del(e, t, n = "") {
1029
- let s = this.rules.inline.delLDelim.exec(e);
1030
- if (!s) return;
1031
- if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
1032
- let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
1033
- for (c.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c.exec(t)) !== null;) {
1034
- if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i)) continue;
1035
- if (s[3] || s[4]) {
1036
- a += u;
1037
- continue;
1038
- }
1039
- if (a -= u, a > 0) continue;
1040
- u = Math.min(u, u + a);
1041
- let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
1042
- return {
1043
- type: "del",
1044
- raw: k,
1045
- text: h,
1046
- tokens: this.lexer.inlineTokens(h)
1047
- };
1048
- }
1049
- }
1050
- }
1051
- autolink(e) {
1052
- let t = this.rules.inline.autolink.exec(e);
1053
- if (t) {
1054
- let n, s;
1055
- return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), {
1056
- type: "link",
1057
- raw: t[0],
1058
- text: n,
1059
- href: s,
1060
- tokens: [{
1061
- type: "text",
1062
- raw: n,
1063
- text: n
1064
- }]
1065
- };
1066
- }
1067
- }
1068
- url(e) {
1069
- let t;
1070
- if (t = this.rules.inline.url.exec(e)) {
1071
- let n, s;
1072
- if (t[2] === "@") n = t[0], s = "mailto:" + n;
1073
- else {
1074
- let r;
1075
- do
1076
- r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
1077
- while (r !== t[0]);
1078
- n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
1079
- }
1080
- return {
1081
- type: "link",
1082
- raw: t[0],
1083
- text: n,
1084
- href: s,
1085
- tokens: [{
1086
- type: "text",
1087
- raw: n,
1088
- text: n
1089
- }]
1090
- };
1091
- }
1092
- }
1093
- inlineText(e) {
1094
- let t = this.rules.inline.text.exec(e);
1095
- if (t) {
1096
- let n = this.lexer.state.inRawBlock;
1097
- return {
1098
- type: "text",
1099
- raw: t[0],
1100
- text: t[0],
1101
- escaped: n
1102
- };
1103
- }
1104
- }
1105
- };
1106
- var x = class l {
1107
- tokens;
1108
- options;
1109
- state;
1110
- inlineQueue;
1111
- tokenizer;
1112
- constructor(e) {
1113
- this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
1114
- inLink: !1,
1115
- inRawBlock: !1,
1116
- top: !0
1117
- };
1118
- let t = {
1119
- other: m,
1120
- block: D.normal,
1121
- inline: A.normal
1122
- };
1123
- this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
1124
- }
1125
- static get rules() {
1126
- return {
1127
- block: D,
1128
- inline: A
1129
- };
1130
- }
1131
- static lex(e, t) {
1132
- return new l(t).lex(e);
1133
- }
1134
- static lexInline(e, t) {
1135
- return new l(t).inlineTokens(e);
1136
- }
1137
- lex(e) {
1138
- e = e.replace(m.carriageReturn, `
1139
- `), this.blockTokens(e, this.tokens);
1140
- for (let t = 0; t < this.inlineQueue.length; t++) {
1141
- let n = this.inlineQueue[t];
1142
- this.inlineTokens(n.src, n.tokens);
1143
- }
1144
- return this.inlineQueue = [], this.tokens;
1145
- }
1146
- blockTokens(e, t = [], n = !1) {
1147
- this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
1148
- let s = Infinity;
1149
- for (; e;) {
1150
- if (e.length < s) s = e.length;
1151
- else {
1152
- this.infiniteLoopError(e.charCodeAt(0));
1153
- break;
1154
- }
1155
- let r;
1156
- if (this.options.extensions?.block?.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue;
1157
- if (r = this.tokenizer.space(e)) {
1158
- e = e.substring(r.raw.length);
1159
- let o = t.at(-1);
1160
- r.raw.length === 1 && o !== void 0 ? o.raw += `
1161
- ` : t.push(r);
1162
- continue;
1163
- }
1164
- if (r = this.tokenizer.code(e)) {
1165
- e = e.substring(r.raw.length);
1166
- let o = t.at(-1);
1167
- o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
1168
- `) ? "" : `
1169
- `) + r.raw, o.text += `
1170
- ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
1171
- continue;
1172
- }
1173
- if (r = this.tokenizer.fences(e)) {
1174
- e = e.substring(r.raw.length), t.push(r);
1175
- continue;
1176
- }
1177
- if (r = this.tokenizer.heading(e)) {
1178
- e = e.substring(r.raw.length), t.push(r);
1179
- continue;
1180
- }
1181
- if (r = this.tokenizer.hr(e)) {
1182
- e = e.substring(r.raw.length), t.push(r);
1183
- continue;
1184
- }
1185
- if (r = this.tokenizer.blockquote(e)) {
1186
- e = e.substring(r.raw.length), t.push(r);
1187
- continue;
1188
- }
1189
- if (r = this.tokenizer.list(e)) {
1190
- e = e.substring(r.raw.length), t.push(r);
1191
- continue;
1192
- }
1193
- if (r = this.tokenizer.html(e)) {
1194
- e = e.substring(r.raw.length), t.push(r);
1195
- continue;
1196
- }
1197
- if (r = this.tokenizer.def(e)) {
1198
- e = e.substring(r.raw.length);
1199
- let o = t.at(-1);
1200
- o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
1201
- `) ? "" : `
1202
- `) + r.raw, o.text += `
1203
- ` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
1204
- href: r.href,
1205
- title: r.title
1206
- }, t.push(r));
1207
- continue;
1208
- }
1209
- if (r = this.tokenizer.table(e)) {
1210
- e = e.substring(r.raw.length), t.push(r);
1211
- continue;
1212
- }
1213
- if (r = this.tokenizer.lheading(e)) {
1214
- e = e.substring(r.raw.length), t.push(r);
1215
- continue;
1216
- }
1217
- let i = e;
1218
- if (this.options.extensions?.startBlock) {
1219
- let o = Infinity, u = e.slice(1), a;
1220
- this.options.extensions.startBlock.forEach((c) => {
1221
- a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
1222
- }), o < Infinity && o >= 0 && (i = e.substring(0, o + 1));
1223
- }
1224
- if (this.state.top && (r = this.tokenizer.paragraph(i))) {
1225
- let o = t.at(-1);
1226
- n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
1227
- `) ? "" : `
1228
- `) + r.raw, o.text += `
1229
- ` + 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);
1230
- continue;
1231
- }
1232
- if (r = this.tokenizer.text(e)) {
1233
- e = e.substring(r.raw.length);
1234
- let o = t.at(-1);
1235
- o?.type === "text" ? (o.raw += (o.raw.endsWith(`
1236
- `) ? "" : `
1237
- `) + r.raw, o.text += `
1238
- ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
1239
- continue;
1240
- }
1241
- if (e) {
1242
- this.infiniteLoopError(e.charCodeAt(0));
1243
- break;
1244
- }
1245
- }
1246
- return this.state.top = !0, t;
1247
- }
1248
- inline(e, t = []) {
1249
- return this.inlineQueue.push({
1250
- src: e,
1251
- tokens: t
1252
- }), t;
1253
- }
1254
- inlineTokens(e, t = []) {
1255
- this.tokenizer.lexer = this;
1256
- let n = e, s = null;
1257
- if (this.tokens.links) {
1258
- let a = Object.keys(this.tokens.links);
1259
- if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null;) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1260
- }
1261
- for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null;) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1262
- let r;
1263
- for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null;) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1264
- n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
1265
- let i = !1, o = "", u = Infinity;
1266
- for (; e;) {
1267
- if (e.length < u) u = e.length;
1268
- else {
1269
- this.infiniteLoopError(e.charCodeAt(0));
1270
- break;
1271
- }
1272
- i || (o = ""), i = !1;
1273
- let a;
1274
- if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), !0) : !1)) continue;
1275
- if (a = this.tokenizer.escape(e)) {
1276
- e = e.substring(a.raw.length), t.push(a);
1277
- continue;
1278
- }
1279
- if (a = this.tokenizer.tag(e)) {
1280
- e = e.substring(a.raw.length), t.push(a);
1281
- continue;
1282
- }
1283
- if (a = this.tokenizer.link(e)) {
1284
- e = e.substring(a.raw.length), t.push(a);
1285
- continue;
1286
- }
1287
- if (a = this.tokenizer.reflink(e, this.tokens.links)) {
1288
- e = e.substring(a.raw.length);
1289
- let p = t.at(-1);
1290
- a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
1291
- continue;
1292
- }
1293
- if (a = this.tokenizer.emStrong(e, n, o)) {
1294
- e = e.substring(a.raw.length), t.push(a);
1295
- continue;
1296
- }
1297
- if (a = this.tokenizer.codespan(e)) {
1298
- e = e.substring(a.raw.length), t.push(a);
1299
- continue;
1300
- }
1301
- if (a = this.tokenizer.br(e)) {
1302
- e = e.substring(a.raw.length), t.push(a);
1303
- continue;
1304
- }
1305
- if (a = this.tokenizer.del(e, n, o)) {
1306
- e = e.substring(a.raw.length), t.push(a);
1307
- continue;
1308
- }
1309
- if (a = this.tokenizer.autolink(e)) {
1310
- e = e.substring(a.raw.length), t.push(a);
1311
- continue;
1312
- }
1313
- if (!this.state.inLink && (a = this.tokenizer.url(e))) {
1314
- e = e.substring(a.raw.length), t.push(a);
1315
- continue;
1316
- }
1317
- let c = e;
1318
- if (this.options.extensions?.startInline) {
1319
- let p = Infinity, k = e.slice(1), h;
1320
- this.options.extensions.startInline.forEach((R) => {
1321
- h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
1322
- }), p < Infinity && p >= 0 && (c = e.substring(0, p + 1));
1323
- }
1324
- if (a = this.tokenizer.inlineText(c)) {
1325
- e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = !0;
1326
- let p = t.at(-1);
1327
- p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
1328
- continue;
1329
- }
1330
- if (e) {
1331
- this.infiniteLoopError(e.charCodeAt(0));
1332
- break;
1333
- }
1334
- }
1335
- return t;
1336
- }
1337
- infiniteLoopError(e) {
1338
- let t = "Infinite loop on byte: " + e;
1339
- if (this.options.silent) console.error(t);
1340
- else throw new Error(t);
1341
- }
1342
- };
1343
- var y = class {
1344
- options;
1345
- parser;
1346
- constructor(e) {
1347
- this.options = e || T;
1348
- }
1349
- space(e) {
1350
- return "";
1351
- }
1352
- code({ text: e, lang: t, escaped: n }) {
1353
- let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
1354
- `;
1355
- return s ? "<pre><code class=\"language-" + O(s) + "\">" + (n ? r : O(r, !0)) + `</code></pre>
1356
- ` : "<pre><code>" + (n ? r : O(r, !0)) + `</code></pre>
1357
- `;
1358
- }
1359
- blockquote({ tokens: e }) {
1360
- return `<blockquote>
1361
- ${this.parser.parse(e)}</blockquote>
1362
- `;
1363
- }
1364
- html({ text: e }) {
1365
- return e;
1366
- }
1367
- def(e) {
1368
- return "";
1369
- }
1370
- heading({ tokens: e, depth: t }) {
1371
- return `<h${t}>${this.parser.parseInline(e)}</h${t}>
1372
- `;
1373
- }
1374
- hr(e) {
1375
- return `<hr>
1376
- `;
1377
- }
1378
- list(e) {
1379
- let t = e.ordered, n = e.start, s = "";
1380
- for (let o = 0; o < e.items.length; o++) {
1381
- let u = e.items[o];
1382
- s += this.listitem(u);
1383
- }
1384
- let r = t ? "ol" : "ul", i = t && n !== 1 ? " start=\"" + n + "\"" : "";
1385
- return "<" + r + i + `>
1386
- ` + s + "</" + r + `>
1387
- `;
1388
- }
1389
- listitem(e) {
1390
- return `<li>${this.parser.parse(e.tokens)}</li>
1391
- `;
1392
- }
1393
- checkbox({ checked: e }) {
1394
- return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
1395
- }
1396
- paragraph({ tokens: e }) {
1397
- return `<p>${this.parser.parseInline(e)}</p>
1398
- `;
1399
- }
1400
- table(e) {
1401
- let t = "", n = "";
1402
- for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
1403
- t += this.tablerow({ text: n });
1404
- let s = "";
1405
- for (let r = 0; r < e.rows.length; r++) {
1406
- let i = e.rows[r];
1407
- n = "";
1408
- for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
1409
- s += this.tablerow({ text: n });
1410
- }
1411
- return s && (s = `<tbody>${s}</tbody>`), `<table>
1412
- <thead>
1413
- ` + t + `</thead>
1414
- ` + s + `</table>
1415
- `;
1416
- }
1417
- tablerow({ text: e }) {
1418
- return `<tr>
1419
- ${e}</tr>
1420
- `;
1421
- }
1422
- tablecell(e) {
1423
- let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
1424
- return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
1425
- `;
1426
- }
1427
- strong({ tokens: e }) {
1428
- return `<strong>${this.parser.parseInline(e)}</strong>`;
1429
- }
1430
- em({ tokens: e }) {
1431
- return `<em>${this.parser.parseInline(e)}</em>`;
1432
- }
1433
- codespan({ text: e }) {
1434
- return `<code>${O(e, !0)}</code>`;
1435
- }
1436
- br(e) {
1437
- return "<br>";
1438
- }
1439
- del({ tokens: e }) {
1440
- return `<del>${this.parser.parseInline(e)}</del>`;
1441
- }
1442
- link({ href: e, title: t, tokens: n }) {
1443
- let s = this.parser.parseInline(n), r = V(e);
1444
- if (r === null) return s;
1445
- e = r;
1446
- let i = "<a href=\"" + e + "\"";
1447
- return t && (i += " title=\"" + O(t) + "\""), i += ">" + s + "</a>", i;
1448
- }
1449
- image({ href: e, title: t, text: n, tokens: s }) {
1450
- s && (n = this.parser.parseInline(s, this.parser.textRenderer));
1451
- let r = V(e);
1452
- if (r === null) return O(n);
1453
- e = r;
1454
- let i = `<img src="${e}" alt="${O(n)}"`;
1455
- return t && (i += ` title="${O(t)}"`), i += ">", i;
1456
- }
1457
- text(e) {
1458
- return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
1459
- }
1460
- };
1461
- var L = class {
1462
- strong({ text: e }) {
1463
- return e;
1464
- }
1465
- em({ text: e }) {
1466
- return e;
1467
- }
1468
- codespan({ text: e }) {
1469
- return e;
1470
- }
1471
- del({ text: e }) {
1472
- return e;
1473
- }
1474
- html({ text: e }) {
1475
- return e;
1476
- }
1477
- text({ text: e }) {
1478
- return e;
1479
- }
1480
- link({ text: e }) {
1481
- return "" + e;
1482
- }
1483
- image({ text: e }) {
1484
- return "" + e;
1485
- }
1486
- br() {
1487
- return "";
1488
- }
1489
- checkbox({ raw: e }) {
1490
- return e;
1491
- }
1492
- };
1493
- var b = class l {
1494
- options;
1495
- renderer;
1496
- textRenderer;
1497
- constructor(e) {
1498
- this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
1499
- }
1500
- static parse(e, t) {
1501
- return new l(t).parse(e);
1502
- }
1503
- static parseInline(e, t) {
1504
- return new l(t).parseInline(e);
1505
- }
1506
- parse(e) {
1507
- this.renderer.parser = this;
1508
- let t = "";
1509
- for (let n = 0; n < e.length; n++) {
1510
- let s = e[n];
1511
- if (this.options.extensions?.renderers?.[s.type]) {
1512
- let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1513
- if (o !== !1 || ![
1514
- "space",
1515
- "hr",
1516
- "heading",
1517
- "code",
1518
- "table",
1519
- "blockquote",
1520
- "list",
1521
- "html",
1522
- "def",
1523
- "paragraph",
1524
- "text"
1525
- ].includes(i.type)) {
1526
- t += o || "";
1527
- continue;
1528
- }
1529
- }
1530
- let r = s;
1531
- switch (r.type) {
1532
- case "space":
1533
- t += this.renderer.space(r);
1534
- break;
1535
- case "hr":
1536
- t += this.renderer.hr(r);
1537
- break;
1538
- case "heading":
1539
- t += this.renderer.heading(r);
1540
- break;
1541
- case "code":
1542
- t += this.renderer.code(r);
1543
- break;
1544
- case "table":
1545
- t += this.renderer.table(r);
1546
- break;
1547
- case "blockquote":
1548
- t += this.renderer.blockquote(r);
1549
- break;
1550
- case "list":
1551
- t += this.renderer.list(r);
1552
- break;
1553
- case "checkbox":
1554
- t += this.renderer.checkbox(r);
1555
- break;
1556
- case "html":
1557
- t += this.renderer.html(r);
1558
- break;
1559
- case "def":
1560
- t += this.renderer.def(r);
1561
- break;
1562
- case "paragraph":
1563
- t += this.renderer.paragraph(r);
1564
- break;
1565
- case "text":
1566
- t += this.renderer.text(r);
1567
- break;
1568
- default: {
1569
- let i = "Token with \"" + r.type + "\" type was not found.";
1570
- if (this.options.silent) return console.error(i), "";
1571
- throw new Error(i);
1572
- }
1573
- }
1574
- }
1575
- return t;
1576
- }
1577
- parseInline(e, t = this.renderer) {
1578
- this.renderer.parser = this;
1579
- let n = "";
1580
- for (let s = 0; s < e.length; s++) {
1581
- let r = e[s];
1582
- if (this.options.extensions?.renderers?.[r.type]) {
1583
- let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1584
- if (o !== !1 || ![
1585
- "escape",
1586
- "html",
1587
- "link",
1588
- "image",
1589
- "strong",
1590
- "em",
1591
- "codespan",
1592
- "br",
1593
- "del",
1594
- "text"
1595
- ].includes(r.type)) {
1596
- n += o || "";
1597
- continue;
1598
- }
1599
- }
1600
- let i = r;
1601
- switch (i.type) {
1602
- case "escape":
1603
- n += t.text(i);
1604
- break;
1605
- case "html":
1606
- n += t.html(i);
1607
- break;
1608
- case "link":
1609
- n += t.link(i);
1610
- break;
1611
- case "image":
1612
- n += t.image(i);
1613
- break;
1614
- case "checkbox":
1615
- n += t.checkbox(i);
1616
- break;
1617
- case "strong":
1618
- n += t.strong(i);
1619
- break;
1620
- case "em":
1621
- n += t.em(i);
1622
- break;
1623
- case "codespan":
1624
- n += t.codespan(i);
1625
- break;
1626
- case "br":
1627
- n += t.br(i);
1628
- break;
1629
- case "del":
1630
- n += t.del(i);
1631
- break;
1632
- case "text":
1633
- n += t.text(i);
1634
- break;
1635
- default: {
1636
- let o = "Token with \"" + i.type + "\" type was not found.";
1637
- if (this.options.silent) return console.error(o), "";
1638
- throw new Error(o);
1639
- }
1640
- }
1641
- }
1642
- return n;
1643
- }
1644
- };
1645
- var P = class {
1646
- options;
1647
- block;
1648
- constructor(e) {
1649
- this.options = e || T;
1650
- }
1651
- static passThroughHooks = /* @__PURE__ */ new Set([
1652
- "preprocess",
1653
- "postprocess",
1654
- "processAllTokens",
1655
- "emStrongMask"
1656
- ]);
1657
- static passThroughHooksRespectAsync = /* @__PURE__ */ new Set([
1658
- "preprocess",
1659
- "postprocess",
1660
- "processAllTokens"
1661
- ]);
1662
- preprocess(e) {
1663
- return e;
1664
- }
1665
- postprocess(e) {
1666
- return e;
1667
- }
1668
- processAllTokens(e) {
1669
- return e;
1670
- }
1671
- emStrongMask(e) {
1672
- return e;
1673
- }
1674
- provideLexer(e = this.block) {
1675
- return e ? x.lex : x.lexInline;
1676
- }
1677
- provideParser(e = this.block) {
1678
- return e ? b.parse : b.parseInline;
1679
- }
1680
- };
1681
- var q = class {
1682
- defaults = M();
1683
- options = this.setOptions;
1684
- parse = this.parseMarkdown(!0);
1685
- parseInline = this.parseMarkdown(!1);
1686
- Parser = b;
1687
- Renderer = y;
1688
- TextRenderer = L;
1689
- Lexer = x;
1690
- Tokenizer = w;
1691
- Hooks = P;
1692
- constructor(...e) {
1693
- this.use(...e);
1694
- }
1695
- walkTokens(e, t) {
1696
- let n = [];
1697
- for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
1698
- case "table": {
1699
- let r = s;
1700
- for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
1701
- for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
1702
- break;
1703
- }
1704
- case "list": {
1705
- let r = s;
1706
- n = n.concat(this.walkTokens(r.items, t));
1707
- break;
1708
- }
1709
- default: {
1710
- let r = s;
1711
- this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1712
- let o = r[i].flat(Infinity);
1713
- n = n.concat(this.walkTokens(o, t));
1714
- }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
1715
- }
1716
- }
1717
- return n;
1718
- }
1719
- use(...e) {
1720
- let t = this.defaults.extensions || {
1721
- renderers: {},
1722
- childTokens: {}
1723
- };
1724
- return e.forEach((n) => {
1725
- let s = { ...n };
1726
- if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((r) => {
1727
- if (!r.name) throw new Error("extension name required");
1728
- if ("renderer" in r) {
1729
- let i = t.renderers[r.name];
1730
- i ? t.renderers[r.name] = function(...o) {
1731
- let u = r.renderer.apply(this, o);
1732
- return u === !1 && (u = i.apply(this, o)), u;
1733
- } : t.renderers[r.name] = r.renderer;
1734
- }
1735
- if ("tokenizer" in r) {
1736
- if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1737
- let i = t[r.level];
1738
- 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]));
1739
- }
1740
- "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
1741
- }), s.extensions = t), n.renderer) {
1742
- let r = this.defaults.renderer || new y(this.defaults);
1743
- for (let i in n.renderer) {
1744
- if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
1745
- if (["options", "parser"].includes(i)) continue;
1746
- let o = i, u = n.renderer[o], a = r[o];
1747
- r[o] = (...c) => {
1748
- let p = u.apply(r, c);
1749
- return p === !1 && (p = a.apply(r, c)), p || "";
1750
- };
1751
- }
1752
- s.renderer = r;
1753
- }
1754
- if (n.tokenizer) {
1755
- let r = this.defaults.tokenizer || new w(this.defaults);
1756
- for (let i in n.tokenizer) {
1757
- if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
1758
- if ([
1759
- "options",
1760
- "rules",
1761
- "lexer"
1762
- ].includes(i)) continue;
1763
- let o = i, u = n.tokenizer[o], a = r[o];
1764
- r[o] = (...c) => {
1765
- let p = u.apply(r, c);
1766
- return p === !1 && (p = a.apply(r, c)), p;
1767
- };
1768
- }
1769
- s.tokenizer = r;
1770
- }
1771
- if (n.hooks) {
1772
- let r = this.defaults.hooks || new P();
1773
- for (let i in n.hooks) {
1774
- if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
1775
- if (["options", "block"].includes(i)) continue;
1776
- let o = i, u = n.hooks[o], a = r[o];
1777
- P.passThroughHooks.has(i) ? r[o] = (c) => {
1778
- if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
1779
- let k = await u.call(r, c);
1780
- return a.call(r, k);
1781
- })();
1782
- let p = u.call(r, c);
1783
- return a.call(r, p);
1784
- } : r[o] = (...c) => {
1785
- if (this.defaults.async) return (async () => {
1786
- let k = await u.apply(r, c);
1787
- return k === !1 && (k = await a.apply(r, c)), k;
1788
- })();
1789
- let p = u.apply(r, c);
1790
- return p === !1 && (p = a.apply(r, c)), p;
1791
- };
1792
- }
1793
- s.hooks = r;
1794
- }
1795
- if (n.walkTokens) {
1796
- let r = this.defaults.walkTokens, i = n.walkTokens;
1797
- s.walkTokens = function(o) {
1798
- let u = [];
1799
- return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
1800
- };
1801
- }
1802
- this.defaults = {
1803
- ...this.defaults,
1804
- ...s
1805
- };
1806
- }), this;
1807
- }
1808
- setOptions(e) {
1809
- return this.defaults = {
1810
- ...this.defaults,
1811
- ...e
1812
- }, this;
1813
- }
1814
- lexer(e, t) {
1815
- return x.lex(e, t ?? this.defaults);
1816
- }
1817
- parser(e, t) {
1818
- return b.parse(e, t ?? this.defaults);
1819
- }
1820
- parseMarkdown(e) {
1821
- return (n, s) => {
1822
- let r = { ...s }, i = {
1823
- ...this.defaults,
1824
- ...r
1825
- }, o = this.onError(!!i.silent, !!i.async);
1826
- if (this.defaults.async === !0 && r.async === !1) return o(/* @__PURE__ */ 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."));
1827
- if (typeof n > "u" || n === null) return o(/* @__PURE__ */ new Error("marked(): input parameter is undefined or null"));
1828
- if (typeof n != "string") return o(/* @__PURE__ */ new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1829
- if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
1830
- let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
1831
- i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
1832
- let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
1833
- return i.hooks ? await i.hooks.postprocess(h) : h;
1834
- })().catch(o);
1835
- try {
1836
- i.hooks && (n = i.hooks.preprocess(n));
1837
- let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
1838
- i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
1839
- let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
1840
- return i.hooks && (p = i.hooks.postprocess(p)), p;
1841
- } catch (u) {
1842
- return o(u);
1843
- }
1844
- };
1845
- }
1846
- onError(e, t) {
1847
- return (n) => {
1848
- if (n.message += `
1849
- Please report this to https://github.com/markedjs/marked.`, e) {
1850
- let s = "<p>An error occurred:</p><pre>" + O(n.message + "", !0) + "</pre>";
1851
- return t ? Promise.resolve(s) : s;
1852
- }
1853
- if (t) return Promise.reject(n);
1854
- throw n;
1855
- };
1856
- }
1857
- };
1858
- var z = new q();
1859
- function g(l, e) {
1860
- return z.parse(l, e);
1861
- }
1862
- g.options = g.setOptions = function(l) {
1863
- return z.setOptions(l), g.defaults = z.defaults, N(g.defaults), g;
1864
- };
1865
- g.getDefaults = M;
1866
- g.defaults = T;
1867
- g.use = function(...l) {
1868
- return z.use(...l), g.defaults = z.defaults, N(g.defaults), g;
1869
- };
1870
- g.walkTokens = function(l, e) {
1871
- return z.walkTokens(l, e);
1872
- };
1873
- g.parseInline = z.parseInline;
1874
- g.Parser = b;
1875
- g.parser = b.parse;
1876
- g.Renderer = y;
1877
- g.TextRenderer = L;
1878
- g.Lexer = x;
1879
- g.lexer = x.lex;
1880
- g.Tokenizer = w;
1881
- g.Hooks = P;
1882
- g.parse = g;
1883
- g.options;
1884
- g.setOptions;
1885
- g.use;
1886
- g.walkTokens;
1887
- g.parseInline;
1888
- b.parse;
1889
- x.lex;
1890
- //#endregion
1891
- //#region ../../node_modules/.pnpm/@earendil-works+pi-tui@0.83.0/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
1892
- const STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
1893
- var StrictStrikethroughTokenizer = class extends w {
1894
- del(src) {
1895
- const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
1896
- if (!match) return;
1897
- const text = match[2];
1898
- return {
1899
- type: "del",
1900
- raw: match[0],
1901
- text,
1902
- tokens: this.lexer.inlineTokens(text)
1903
- };
1904
- }
1905
- };
1906
- new q().setOptions({ tokenizer: new StrictStrikethroughTokenizer() });
1907
- createRequire(import.meta.url);
1908
- createRequire(import.meta.url);
1909
97
  //#endregion
1910
98
  //#region src/index.ts
1911
99
  const EXTENSION_ID = "fast-mode";
@@ -1980,7 +168,7 @@ function fastMode(pi) {
1980
168
  ctx.ui.notify(message, "info");
1981
169
  }
1982
170
  pi.on("session_start", async (_event, ctx) => {
1983
- config = await Effect.runPromise(loadExtensionConfig(FastModeConfig, EXTENSION_ID).pipe(Effect.orElseSucceed(() => config), Effect.provide(NodeServices.layer)));
171
+ config = await loadExtensionConfig(ctx, FastModeConfig, EXTENSION_ID, config);
1984
172
  enabled = pi.getFlag("fast") === true || config.enabled;
1985
173
  updateStatus(ctx);
1986
174
  });
@@ -2002,11 +190,11 @@ function fastMode(pi) {
2002
190
  pi.registerCommand("fast", {
2003
191
  description: "Toggle fast mode (faster, costlier inference) for configured models",
2004
192
  getArgumentCompletions: (prefix) => {
2005
- const items = pipe(COMMAND_ARGS, Array$1.filter(String$1.startsWith(prefix)), Array$1.map((arg) => ({
193
+ const items = pipe(COMMAND_ARGS, Array.filter(String.startsWith(prefix)), Array.map((arg) => ({
2006
194
  value: arg,
2007
195
  label: arg
2008
196
  })));
2009
- return Array$1.match(items, {
197
+ return Array.match(items, {
2010
198
  onNonEmpty: (matched) => [...matched],
2011
199
  onEmpty: () => null
2012
200
  });