free-pi-cli 0.4.9 → 0.4.10
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/dist/index.js +1 -1
- package/dist/{main-jaz36mav.js → main-m7w02sv8.js} +45 -2583
- package/package.json +3 -2
|
@@ -46,7 +46,7 @@ function openBrowser(url, platform = process.platform, spawnImpl = spawn) {
|
|
|
46
46
|
// package.json
|
|
47
47
|
var package_default = {
|
|
48
48
|
name: "free-pi-cli",
|
|
49
|
-
version: "0.4.
|
|
49
|
+
version: "0.4.10",
|
|
50
50
|
description: "Free, ad-supported distribution of the pi coding agent. Inference paid for by ads.",
|
|
51
51
|
license: "MIT",
|
|
52
52
|
type: "module",
|
|
@@ -62,11 +62,12 @@ var package_default = {
|
|
|
62
62
|
node: ">=22.19.0"
|
|
63
63
|
},
|
|
64
64
|
scripts: {
|
|
65
|
-
build: "rm -rf dist && bun build src/index.ts --target=node --outdir dist --splitting --external @earendil-works/pi-coding-agent --banner '#!/usr/bin/env node' && chmod +x dist/index.js",
|
|
65
|
+
build: "rm -rf dist && bun build src/index.ts --target=node --outdir dist --splitting --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --banner '#!/usr/bin/env node' && chmod +x dist/index.js",
|
|
66
66
|
prepublishOnly: "bun run build"
|
|
67
67
|
},
|
|
68
68
|
dependencies: {
|
|
69
69
|
"@earendil-works/pi-coding-agent": "1.2.0",
|
|
70
|
+
"@earendil-works/pi-tui": "1.2.0",
|
|
70
71
|
"@gravity-ai/api": "1.2.1"
|
|
71
72
|
},
|
|
72
73
|
devDependencies: {
|
|
@@ -5278,2585 +5279,7 @@ async function fetchMe(deps) {
|
|
|
5278
5279
|
|
|
5279
5280
|
// ../pi-ads/src/style.ts
|
|
5280
5281
|
import { createHash as createHash2 } from "node:crypto";
|
|
5281
|
-
|
|
5282
|
-
// ../../node_modules/.bun/marked@18.0.11/node_modules/marked/lib/marked.esm.js
|
|
5283
|
-
function A() {
|
|
5284
|
-
return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
|
|
5285
|
-
}
|
|
5286
|
-
var R = A();
|
|
5287
|
-
function j(l) {
|
|
5288
|
-
R = l;
|
|
5289
|
-
}
|
|
5290
|
-
var z = { exec: () => null };
|
|
5291
|
-
function I(l) {
|
|
5292
|
-
let e = [];
|
|
5293
|
-
return (t) => {
|
|
5294
|
-
let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
|
|
5295
|
-
return s || (s = l(n), e[n] = s), s;
|
|
5296
|
-
};
|
|
5297
|
-
}
|
|
5298
|
-
function k(l, e = "") {
|
|
5299
|
-
let t = typeof l == "string" ? l : l.source, n = { replace: (s, r) => {
|
|
5300
|
-
let i = typeof r == "string" ? r : r.source;
|
|
5301
|
-
return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
|
|
5302
|
-
}, getRegex: () => new RegExp(t, e) };
|
|
5303
|
-
return n;
|
|
5304
|
-
}
|
|
5305
|
-
var Oe = ((l = "") => {
|
|
5306
|
-
try {
|
|
5307
|
-
return !!new RegExp("(?<=1)(?<!1)" + l);
|
|
5308
|
-
} catch {
|
|
5309
|
-
return false;
|
|
5310
|
-
}
|
|
5311
|
-
})();
|
|
5312
|
-
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: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((l) => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: I((l) => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((l) => new RegExp(`^ {0,${l}}#`)), htmlBeginRegex: I((l) => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: I((l) => new RegExp(`^ {0,${l}}>`)) };
|
|
5313
|
-
var Te = /^(?:[ \t]*(?:\n|$))+/;
|
|
5314
|
-
var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
|
|
5315
|
-
var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
|
|
5316
|
-
var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
|
|
5317
|
-
var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
|
|
5318
|
-
var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
|
|
5319
|
-
var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
|
|
5320
|
-
var ae = k(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();
|
|
5321
|
-
var Se = k(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();
|
|
5322
|
-
var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
|
5323
|
-
var _e = /^[^\n]+/;
|
|
5324
|
-
var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
|
|
5325
|
-
var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
|
|
5326
|
-
var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
|
|
5327
|
-
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";
|
|
5328
|
-
var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
|
|
5329
|
-
var Ee = k("^ {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[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
|
|
5330
|
-
var le = (l) => k(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", l).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
|
|
5331
|
-
var ze = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
|
|
5332
|
-
var Me = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
|
|
5333
|
-
var Ae = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Me).getRegex();
|
|
5334
|
-
var J = { blockquote: Ae, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: Ee, lheading: ae, list: Le, newline: Te, paragraph: ze, table: z, text: _e };
|
|
5335
|
-
var se = k("^ *([^\\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}\t)[^\\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();
|
|
5336
|
-
var Ie = { ...J, lheading: Se, table: se, paragraph: k(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() };
|
|
5337
|
-
var Ce = { ...J, html: k(`^ *(?: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: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
|
|
5338
|
-
]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
|
|
5339
|
-
var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
|
|
5340
|
-
var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
|
|
5341
|
-
var ue = /^( {2,}|\\)\n(?!\s*$)/;
|
|
5342
|
-
var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
|
|
5343
|
-
var _ = /[\p{P}\p{S}]/u;
|
|
5344
|
-
var C = /[\s\p{P}\p{S}]/u;
|
|
5345
|
-
var v = /[^\s\p{P}\p{S}]/u;
|
|
5346
|
-
var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, C).getRegex();
|
|
5347
|
-
var He = /[\p{Pi}\p{Ps}"']/u;
|
|
5348
|
-
var pe = /(?!~)[\p{P}\p{S}]/u;
|
|
5349
|
-
var Ze = /(?!~)[\s\p{P}\p{S}]/u;
|
|
5350
|
-
var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
|
|
5351
|
-
var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Oe ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
|
|
5352
|
-
var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
|
|
5353
|
-
var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
|
|
5354
|
-
var je = k(ce, "u").replace(/punct/g, pe).getRegex();
|
|
5355
|
-
var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
|
|
5356
|
-
var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
|
|
5357
|
-
var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
|
|
5358
|
-
var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
|
|
5359
|
-
var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, pe).getRegex();
|
|
5360
|
-
var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
|
|
5361
|
-
var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
|
|
5362
|
-
var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
|
|
5363
|
-
var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
|
|
5364
|
-
var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
|
|
5365
|
-
var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
|
|
5366
|
-
var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
|
|
5367
|
-
var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
|
|
5368
|
-
var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
|
|
5369
|
-
var it = k(/^<(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();
|
|
5370
|
-
var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
|
|
5371
|
-
var at = k("^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();
|
|
5372
|
-
var G = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
|
|
5373
|
-
var lt = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
|
|
5374
|
-
var ke = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
|
|
5375
|
-
var de = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
|
|
5376
|
-
var ut = k("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
|
|
5377
|
-
var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
|
|
5378
|
-
var V = { _backpedal: z, anyPunctuation: st, autolink: it, blockSkip: Qe, br: ue, code: De, del: z, delLDelim: z, delRDelim: z, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: lt, nolink: de, punctuation: ve, reflink: ke, reflinkSearch: ut, tag: at, text: qe, url: z };
|
|
5379
|
-
var pt = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
|
|
5380
|
-
var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?: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: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {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() };
|
|
5381
|
-
var ct = { ...F, br: k(ue).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
|
|
5382
|
-
var H = { normal: J, gfm: Ie, pedantic: Ce };
|
|
5383
|
-
var B = { normal: V, gfm: F, breaks: ct, pedantic: pt };
|
|
5384
|
-
var ht = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
5385
|
-
var ge = (l) => ht[l];
|
|
5386
|
-
function T(l, e) {
|
|
5387
|
-
if (e) {
|
|
5388
|
-
if (m.escapeTest.test(l))
|
|
5389
|
-
return l.replace(m.escapeReplace, ge);
|
|
5390
|
-
} else if (m.escapeTestNoEncode.test(l))
|
|
5391
|
-
return l.replace(m.escapeReplaceNoEncode, ge);
|
|
5392
|
-
return l;
|
|
5393
|
-
}
|
|
5394
|
-
function Y(l) {
|
|
5395
|
-
try {
|
|
5396
|
-
l = encodeURI(l).replace(m.percentDecode, "%");
|
|
5397
|
-
} catch {
|
|
5398
|
-
return null;
|
|
5399
|
-
}
|
|
5400
|
-
return l;
|
|
5401
|
-
}
|
|
5402
|
-
function ee(l, e) {
|
|
5403
|
-
let t = l.replace(m.findPipe, (r, i, o) => {
|
|
5404
|
-
let u = false, a = i;
|
|
5405
|
-
for (;--a >= 0 && o[a] === "\\"; )
|
|
5406
|
-
u = !u;
|
|
5407
|
-
return u ? "|" : " |";
|
|
5408
|
-
}), n = t.split(m.splitPipe), s = 0;
|
|
5409
|
-
if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
|
|
5410
|
-
if (n.length > e)
|
|
5411
|
-
n.splice(e);
|
|
5412
|
-
else
|
|
5413
|
-
for (;n.length < e; )
|
|
5414
|
-
n.push("");
|
|
5415
|
-
for (;s < n.length; s++)
|
|
5416
|
-
n[s] = n[s].trim().replace(m.slashPipe, "|");
|
|
5417
|
-
return n;
|
|
5418
|
-
}
|
|
5419
|
-
function $(l, e, t) {
|
|
5420
|
-
let n = l.length;
|
|
5421
|
-
if (n === 0)
|
|
5422
|
-
return "";
|
|
5423
|
-
let s = 0;
|
|
5424
|
-
for (;s < n; ) {
|
|
5425
|
-
let r = l.charAt(n - s - 1);
|
|
5426
|
-
if (r === e && !t)
|
|
5427
|
-
s++;
|
|
5428
|
-
else if (r !== e && t)
|
|
5429
|
-
s++;
|
|
5430
|
-
else
|
|
5431
|
-
break;
|
|
5432
|
-
}
|
|
5433
|
-
return l.slice(0, n - s);
|
|
5434
|
-
}
|
|
5435
|
-
function te(l) {
|
|
5436
|
-
let e = l.split(`
|
|
5437
|
-
`), t = e.length - 1;
|
|
5438
|
-
for (;t >= 0 && m.blankLine.test(e[t]); )
|
|
5439
|
-
t--;
|
|
5440
|
-
return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
|
|
5441
|
-
`);
|
|
5442
|
-
}
|
|
5443
|
-
function fe(l, e) {
|
|
5444
|
-
if (l.indexOf(e[1]) === -1)
|
|
5445
|
-
return -1;
|
|
5446
|
-
let t = 0;
|
|
5447
|
-
for (let n = 0;n < l.length; n++)
|
|
5448
|
-
if (l[n] === "\\")
|
|
5449
|
-
n++;
|
|
5450
|
-
else if (l[n] === e[0])
|
|
5451
|
-
t++;
|
|
5452
|
-
else if (l[n] === e[1] && (t--, t < 0))
|
|
5453
|
-
return n;
|
|
5454
|
-
return t > 0 ? -2 : -1;
|
|
5455
|
-
}
|
|
5456
|
-
function me(l, e = 0) {
|
|
5457
|
-
let t = e, n = "";
|
|
5458
|
-
for (let s of l)
|
|
5459
|
-
if (s === "\t") {
|
|
5460
|
-
let r = 4 - t % 4;
|
|
5461
|
-
n += " ".repeat(r), t += r;
|
|
5462
|
-
} else
|
|
5463
|
-
n += s, t++;
|
|
5464
|
-
return n;
|
|
5465
|
-
}
|
|
5466
|
-
function xe(l, e, t, n, s) {
|
|
5467
|
-
let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1"), u = l[0].charAt(0) === "!";
|
|
5468
|
-
n.state.inLink = true;
|
|
5469
|
-
let a = n.state.linkEmitted, p = n.state.inRawBlock;
|
|
5470
|
-
n.state.linkEmitted = false;
|
|
5471
|
-
let c = n.inlineTokens(o), h = n.state.linkEmitted;
|
|
5472
|
-
if (n.state.linkEmitted = a, n.state.inLink = false, !u) {
|
|
5473
|
-
if (h) {
|
|
5474
|
-
n.state.inRawBlock = p;
|
|
5475
|
-
return;
|
|
5476
|
-
}
|
|
5477
|
-
n.state.linkEmitted = true;
|
|
5478
|
-
}
|
|
5479
|
-
return { type: u ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: c };
|
|
5480
|
-
}
|
|
5481
|
-
function kt(l, e, t) {
|
|
5482
|
-
let n = l.match(t.other.indentCodeCompensation);
|
|
5483
|
-
if (n === null)
|
|
5484
|
-
return e;
|
|
5485
|
-
let s = n[1];
|
|
5486
|
-
return e.split(`
|
|
5487
|
-
`).map((r) => {
|
|
5488
|
-
let i = r.match(t.other.beginningSpace);
|
|
5489
|
-
if (i === null)
|
|
5490
|
-
return r;
|
|
5491
|
-
let [o] = i;
|
|
5492
|
-
return o.length >= s.length ? r.slice(s.length) : r;
|
|
5493
|
-
}).join(`
|
|
5494
|
-
`);
|
|
5495
|
-
}
|
|
5496
|
-
var y = class {
|
|
5497
|
-
options;
|
|
5498
|
-
rules;
|
|
5499
|
-
lexer;
|
|
5500
|
-
constructor(e) {
|
|
5501
|
-
this.options = e || R;
|
|
5502
|
-
}
|
|
5503
|
-
space(e) {
|
|
5504
|
-
let t = this.rules.block.newline.exec(e);
|
|
5505
|
-
if (t && t[0].length > 0)
|
|
5506
|
-
return { type: "space", raw: t[0] };
|
|
5507
|
-
}
|
|
5508
|
-
code(e) {
|
|
5509
|
-
let t = this.rules.block.code.exec(e);
|
|
5510
|
-
if (t) {
|
|
5511
|
-
let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
|
|
5512
|
-
return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
|
|
5513
|
-
}
|
|
5514
|
-
}
|
|
5515
|
-
fences(e) {
|
|
5516
|
-
let t = this.rules.block.fences.exec(e);
|
|
5517
|
-
if (t) {
|
|
5518
|
-
let n = t[0], s = kt(n, t[3] || "", this.rules);
|
|
5519
|
-
return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
|
|
5520
|
-
}
|
|
5521
|
-
}
|
|
5522
|
-
heading(e) {
|
|
5523
|
-
let t = this.rules.block.heading.exec(e);
|
|
5524
|
-
if (t) {
|
|
5525
|
-
let n = t[2].trim();
|
|
5526
|
-
if (this.rules.other.endingHash.test(n)) {
|
|
5527
|
-
let s = $(n, "#");
|
|
5528
|
-
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
5529
|
-
}
|
|
5530
|
-
return { type: "heading", raw: $(t[0], `
|
|
5531
|
-
`), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
|
|
5532
|
-
}
|
|
5533
|
-
}
|
|
5534
|
-
hr(e) {
|
|
5535
|
-
let t = this.rules.block.hr.exec(e);
|
|
5536
|
-
if (t)
|
|
5537
|
-
return { type: "hr", raw: $(t[0], `
|
|
5538
|
-
`) };
|
|
5539
|
-
}
|
|
5540
|
-
blockquote(e) {
|
|
5541
|
-
let t = this.rules.block.blockquote.exec(e);
|
|
5542
|
-
if (t) {
|
|
5543
|
-
let n = $(t[0], `
|
|
5544
|
-
`).split(`
|
|
5545
|
-
`), s = "", r = "", i = [];
|
|
5546
|
-
for (;n.length > 0; ) {
|
|
5547
|
-
let o = false, u = [], a;
|
|
5548
|
-
for (a = 0;a < n.length; a++)
|
|
5549
|
-
if (this.rules.other.blockquoteStart.test(n[a]))
|
|
5550
|
-
u.push(n[a]), o = true;
|
|
5551
|
-
else if (!o)
|
|
5552
|
-
u.push(n[a]);
|
|
5553
|
-
else
|
|
5554
|
-
break;
|
|
5555
|
-
n = n.slice(a);
|
|
5556
|
-
let p = u.join(`
|
|
5557
|
-
`), c = p.replace(this.rules.other.blockquoteSetextReplace, `
|
|
5558
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
5559
|
-
s = s ? `${s}
|
|
5560
|
-
${p}` : p, r = r ? `${r}
|
|
5561
|
-
${c}` : c;
|
|
5562
|
-
let h = this.lexer.state.top;
|
|
5563
|
-
if (this.lexer.state.top = true, this.lexer.blockTokens(c, i, true), this.lexer.state.top = h, n.length === 0)
|
|
5564
|
-
break;
|
|
5565
|
-
let d = i.at(-1);
|
|
5566
|
-
if (d?.type === "code")
|
|
5567
|
-
break;
|
|
5568
|
-
if (d?.type === "blockquote") {
|
|
5569
|
-
let O = d, g = n.join(`
|
|
5570
|
-
`), w = O.raw + `
|
|
5571
|
-
` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), E = this.blockquote(w);
|
|
5572
|
-
i[i.length - 1] = E, s = `${s}
|
|
5573
|
-
${g}`, r = r.substring(0, r.length - O.text.length) + E.text;
|
|
5574
|
-
break;
|
|
5575
|
-
} else if (d?.type === "list") {
|
|
5576
|
-
let O = d, g = O.raw + `
|
|
5577
|
-
` + n.join(`
|
|
5578
|
-
`), w = this.list(g);
|
|
5579
|
-
i[i.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - O.raw.length) + w.raw, n = g.substring(i.at(-1).raw.length).split(`
|
|
5580
|
-
`);
|
|
5581
|
-
continue;
|
|
5582
|
-
}
|
|
5583
|
-
}
|
|
5584
|
-
return { type: "blockquote", raw: s, tokens: i, text: r };
|
|
5585
|
-
}
|
|
5586
|
-
}
|
|
5587
|
-
list(e) {
|
|
5588
|
-
let t = this.rules.block.list.exec(e);
|
|
5589
|
-
if (t) {
|
|
5590
|
-
let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
|
|
5591
|
-
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
5592
|
-
let i = this.rules.other.listItemRegex(n), o = false;
|
|
5593
|
-
for (;e; ) {
|
|
5594
|
-
let a = false, p = "", c = "";
|
|
5595
|
-
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
|
|
5596
|
-
break;
|
|
5597
|
-
p = t[0], e = e.substring(p.length);
|
|
5598
|
-
let h = me(t[2].split(`
|
|
5599
|
-
`, 1)[0], t[1].length), d = e.split(`
|
|
5600
|
-
`, 1)[0], O = !h.trim(), g = 0;
|
|
5601
|
-
if (this.options.pedantic ? (g = 2, c = h.trimStart()) : O ? 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), O && this.rules.other.blankLine.test(d) && (p += d + `
|
|
5602
|
-
`, e = e.substring(d.length + 1), a = true), !a) {
|
|
5603
|
-
let w = this.rules.other.nextBulletRegex(g), E = 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);
|
|
5604
|
-
for (;e; ) {
|
|
5605
|
-
let N = e.split(`
|
|
5606
|
-
`, 1)[0], D;
|
|
5607
|
-
if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || E.test(d))
|
|
5608
|
-
break;
|
|
5609
|
-
if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim())
|
|
5610
|
-
c += `
|
|
5611
|
-
` + D.slice(g);
|
|
5612
|
-
else {
|
|
5613
|
-
if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || E.test(h))
|
|
5614
|
-
break;
|
|
5615
|
-
c += `
|
|
5616
|
-
` + d;
|
|
5617
|
-
}
|
|
5618
|
-
O = !d.trim(), p += N + `
|
|
5619
|
-
`, e = e.substring(N.length + 1), h = D.slice(g);
|
|
5620
|
-
}
|
|
5621
|
-
}
|
|
5622
|
-
r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(p) && (o = true)), r.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += p;
|
|
5623
|
-
}
|
|
5624
|
-
let u = r.items.at(-1);
|
|
5625
|
-
if (u)
|
|
5626
|
-
u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
|
|
5627
|
-
else
|
|
5628
|
-
return;
|
|
5629
|
-
r.raw = r.raw.trimEnd();
|
|
5630
|
-
for (let a of r.items)
|
|
5631
|
-
if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r.loose) {
|
|
5632
|
-
let p = a.tokens.filter((h) => h.type === "space"), c = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
|
|
5633
|
-
r.loose = c;
|
|
5634
|
-
}
|
|
5635
|
-
for (let a of r.items) {
|
|
5636
|
-
let p = a.tokens[0];
|
|
5637
|
-
if (a.task && (p?.type === "text" || p?.type === "paragraph")) {
|
|
5638
|
-
a.text = a.text.replace(this.rules.other.listReplaceTask, ""), p.raw = p.raw.replace(this.rules.other.listReplaceTask, ""), p.text = p.text.replace(this.rules.other.listReplaceTask, "");
|
|
5639
|
-
for (let h = this.lexer.inlineQueue.length - 1;h >= 0; h--)
|
|
5640
|
-
if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
|
|
5641
|
-
this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
|
|
5642
|
-
break;
|
|
5643
|
-
}
|
|
5644
|
-
let c = this.rules.other.listTaskCheckbox.exec(a.raw);
|
|
5645
|
-
if (c) {
|
|
5646
|
-
let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
|
|
5647
|
-
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);
|
|
5648
|
-
}
|
|
5649
|
-
} else
|
|
5650
|
-
a.task && (a.task = false);
|
|
5651
|
-
}
|
|
5652
|
-
if (r.loose)
|
|
5653
|
-
for (let a of r.items) {
|
|
5654
|
-
a.loose = true;
|
|
5655
|
-
for (let p of a.tokens)
|
|
5656
|
-
p.type === "text" && (p.type = "paragraph");
|
|
5657
|
-
}
|
|
5658
|
-
return r;
|
|
5659
|
-
}
|
|
5660
|
-
}
|
|
5661
|
-
html(e) {
|
|
5662
|
-
let t = this.rules.block.html.exec(e);
|
|
5663
|
-
if (t) {
|
|
5664
|
-
let n = te(t[0]);
|
|
5665
|
-
return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
|
|
5666
|
-
}
|
|
5667
|
-
}
|
|
5668
|
-
def(e) {
|
|
5669
|
-
let t = this.rules.block.def.exec(e);
|
|
5670
|
-
if (t) {
|
|
5671
|
-
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];
|
|
5672
|
-
return { type: "def", tag: n, raw: $(t[0], `
|
|
5673
|
-
`), href: s, title: r };
|
|
5674
|
-
}
|
|
5675
|
-
}
|
|
5676
|
-
table(e) {
|
|
5677
|
-
let t = this.rules.block.table.exec(e);
|
|
5678
|
-
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
|
|
5679
|
-
return;
|
|
5680
|
-
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(`
|
|
5681
|
-
`) : [], i = { type: "table", raw: $(t[0], `
|
|
5682
|
-
`), header: [], align: [], rows: [] };
|
|
5683
|
-
if (n.length === s.length) {
|
|
5684
|
-
for (let o of s)
|
|
5685
|
-
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);
|
|
5686
|
-
for (let o = 0;o < n.length; o++)
|
|
5687
|
-
i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
|
|
5688
|
-
for (let o of r)
|
|
5689
|
-
i.rows.push(ee(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
|
|
5690
|
-
return i;
|
|
5691
|
-
}
|
|
5692
|
-
}
|
|
5693
|
-
lheading(e) {
|
|
5694
|
-
let t = this.rules.block.lheading.exec(e);
|
|
5695
|
-
if (t) {
|
|
5696
|
-
let n = t[1].trim();
|
|
5697
|
-
return { type: "heading", raw: $(t[0], `
|
|
5698
|
-
`), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
|
|
5699
|
-
}
|
|
5700
|
-
}
|
|
5701
|
-
paragraph(e) {
|
|
5702
|
-
let t = this.rules.block.paragraph.exec(e);
|
|
5703
|
-
if (t) {
|
|
5704
|
-
let n = t[1].charAt(t[1].length - 1) === `
|
|
5705
|
-
` ? t[1].slice(0, -1) : t[1];
|
|
5706
|
-
return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
|
|
5707
|
-
}
|
|
5708
|
-
}
|
|
5709
|
-
text(e) {
|
|
5710
|
-
let t = this.rules.block.text.exec(e);
|
|
5711
|
-
if (t)
|
|
5712
|
-
return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
|
|
5713
|
-
}
|
|
5714
|
-
escape(e) {
|
|
5715
|
-
let t = this.rules.inline.escape.exec(e);
|
|
5716
|
-
if (t)
|
|
5717
|
-
return { type: "escape", raw: t[0], text: t[1] };
|
|
5718
|
-
}
|
|
5719
|
-
tag(e) {
|
|
5720
|
-
let t = this.rules.inline.tag.exec(e);
|
|
5721
|
-
if (t)
|
|
5722
|
-
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] };
|
|
5723
|
-
}
|
|
5724
|
-
link(e) {
|
|
5725
|
-
let t = this.rules.inline.link.exec(e);
|
|
5726
|
-
if (t) {
|
|
5727
|
-
let n = t[2].trim();
|
|
5728
|
-
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
5729
|
-
if (!this.rules.other.endAngleBracket.test(n))
|
|
5730
|
-
return;
|
|
5731
|
-
let i = $(n.slice(0, -1), "\\");
|
|
5732
|
-
if ((n.length - i.length) % 2 === 0)
|
|
5733
|
-
return;
|
|
5734
|
-
} else {
|
|
5735
|
-
let i = fe(t[2], "()");
|
|
5736
|
-
if (i === -2)
|
|
5737
|
-
return;
|
|
5738
|
-
if (i > -1) {
|
|
5739
|
-
let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
5740
|
-
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
|
|
5741
|
-
}
|
|
5742
|
-
}
|
|
5743
|
-
let s = t[2], r = "";
|
|
5744
|
-
if (this.options.pedantic) {
|
|
5745
|
-
let i = this.rules.other.pedanticHrefTitle.exec(s);
|
|
5746
|
-
i && (s = i[1], r = i[3]);
|
|
5747
|
-
} else
|
|
5748
|
-
r = t[3] ? t[3].slice(1, -1) : "";
|
|
5749
|
-
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);
|
|
5750
|
-
}
|
|
5751
|
-
}
|
|
5752
|
-
reflink(e, t) {
|
|
5753
|
-
let n;
|
|
5754
|
-
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
5755
|
-
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
5756
|
-
if (!r) {
|
|
5757
|
-
let i = n[0].charAt(0);
|
|
5758
|
-
return { type: "text", raw: i, text: i };
|
|
5759
|
-
}
|
|
5760
|
-
return xe(n, r, n[0], this.lexer, this.rules);
|
|
5761
|
-
}
|
|
5762
|
-
}
|
|
5763
|
-
emStrong(e, t, n = "") {
|
|
5764
|
-
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
5765
|
-
if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
5766
|
-
return;
|
|
5767
|
-
if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
5768
|
-
let i = [...s[0]].length - 1, o, u, a = i, p = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
5769
|
-
for (d.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = d.exec(t)) !== null; ) {
|
|
5770
|
-
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o)
|
|
5771
|
-
continue;
|
|
5772
|
-
if (u = [...o].length, s[3] || s[4]) {
|
|
5773
|
-
a += u;
|
|
5774
|
-
continue;
|
|
5775
|
-
} else if (s[5] || s[6]) {
|
|
5776
|
-
if (i % 3 && !((i + u) % 3)) {
|
|
5777
|
-
p += u;
|
|
5778
|
-
continue;
|
|
5779
|
-
}
|
|
5780
|
-
if (h)
|
|
5781
|
-
break;
|
|
5782
|
-
}
|
|
5783
|
-
if (a -= u, a > 0)
|
|
5784
|
-
continue;
|
|
5785
|
-
u = Math.min(u, u + a + p);
|
|
5786
|
-
let O = [...s[0]][0].length, g = e.slice(0, i + s.index + O + u);
|
|
5787
|
-
if (Math.min(i, u) % 2) {
|
|
5788
|
-
let E = g.slice(1, -1);
|
|
5789
|
-
return { type: "em", raw: g, text: E, tokens: this.lexer.inlineTokens(E) };
|
|
5790
|
-
}
|
|
5791
|
-
let w = g.slice(2, -2);
|
|
5792
|
-
return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
|
|
5793
|
-
}
|
|
5794
|
-
}
|
|
5795
|
-
}
|
|
5796
|
-
codespan(e) {
|
|
5797
|
-
let t = this.rules.inline.code.exec(e);
|
|
5798
|
-
if (t) {
|
|
5799
|
-
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);
|
|
5800
|
-
return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
|
|
5801
|
-
}
|
|
5802
|
-
}
|
|
5803
|
-
br(e) {
|
|
5804
|
-
let t = this.rules.inline.br.exec(e);
|
|
5805
|
-
if (t)
|
|
5806
|
-
return { type: "br", raw: t[0] };
|
|
5807
|
-
}
|
|
5808
|
-
del(e, t, n = "") {
|
|
5809
|
-
let s = this.rules.inline.delLDelim.exec(e);
|
|
5810
|
-
if (!s)
|
|
5811
|
-
return;
|
|
5812
|
-
if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
5813
|
-
let i = [...s[0]].length - 1, o, u, a = i, p = this.rules.inline.delRDelim;
|
|
5814
|
-
for (p.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = p.exec(t)) !== null; ) {
|
|
5815
|
-
if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i))
|
|
5816
|
-
continue;
|
|
5817
|
-
if (s[3] || s[4]) {
|
|
5818
|
-
a += u;
|
|
5819
|
-
continue;
|
|
5820
|
-
}
|
|
5821
|
-
if (a -= u, a > 0)
|
|
5822
|
-
continue;
|
|
5823
|
-
u = Math.min(u, u + a);
|
|
5824
|
-
let c = [...s[0]][0].length, h = e.slice(0, i + s.index + c + u), d = h.slice(i, -i);
|
|
5825
|
-
return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
|
|
5826
|
-
}
|
|
5827
|
-
}
|
|
5828
|
-
}
|
|
5829
|
-
autolink(e) {
|
|
5830
|
-
let t = this.rules.inline.autolink.exec(e);
|
|
5831
|
-
if (t) {
|
|
5832
|
-
let n, s;
|
|
5833
|
-
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 }] };
|
|
5834
|
-
}
|
|
5835
|
-
}
|
|
5836
|
-
url(e) {
|
|
5837
|
-
let t;
|
|
5838
|
-
if (t = this.rules.inline.url.exec(e)) {
|
|
5839
|
-
let n, s;
|
|
5840
|
-
if (t[2] === "@")
|
|
5841
|
-
n = t[0], s = "mailto:" + n;
|
|
5842
|
-
else {
|
|
5843
|
-
let r;
|
|
5844
|
-
do
|
|
5845
|
-
r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
5846
|
-
while (r !== t[0]);
|
|
5847
|
-
n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
|
|
5848
|
-
}
|
|
5849
|
-
return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
|
|
5850
|
-
}
|
|
5851
|
-
}
|
|
5852
|
-
inlineText(e) {
|
|
5853
|
-
let t = this.rules.inline.text.exec(e);
|
|
5854
|
-
if (t) {
|
|
5855
|
-
let n = this.lexer.state.inRawBlock;
|
|
5856
|
-
return { type: "text", raw: t[0], text: t[0], escaped: n };
|
|
5857
|
-
}
|
|
5858
|
-
}
|
|
5859
|
-
};
|
|
5860
|
-
var x = class l {
|
|
5861
|
-
tokens;
|
|
5862
|
-
options;
|
|
5863
|
-
state;
|
|
5864
|
-
inlineQueue;
|
|
5865
|
-
tokenizer;
|
|
5866
|
-
constructor(e) {
|
|
5867
|
-
this.tokens = [], this.tokens.links = 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, linkEmitted: false, top: true };
|
|
5868
|
-
let t = { other: m, block: H.normal, inline: B.normal };
|
|
5869
|
-
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;
|
|
5870
|
-
}
|
|
5871
|
-
static get rules() {
|
|
5872
|
-
return { block: H, inline: B };
|
|
5873
|
-
}
|
|
5874
|
-
static lex(e, t) {
|
|
5875
|
-
return new l(t).lex(e);
|
|
5876
|
-
}
|
|
5877
|
-
static lexInline(e, t) {
|
|
5878
|
-
return new l(t).inlineTokens(e);
|
|
5879
|
-
}
|
|
5880
|
-
lex(e) {
|
|
5881
|
-
e = e.replace(m.carriageReturn, `
|
|
5882
|
-
`), this.blockTokens(e, this.tokens);
|
|
5883
|
-
for (let t = 0;t < this.inlineQueue.length; t++) {
|
|
5884
|
-
let n = this.inlineQueue[t];
|
|
5885
|
-
this.inlineTokens(n.src, n.tokens);
|
|
5886
|
-
}
|
|
5887
|
-
return this.inlineQueue = [], this.tokens;
|
|
5888
|
-
}
|
|
5889
|
-
blockTokens(e, t = [], n = false) {
|
|
5890
|
-
this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
|
|
5891
|
-
let s = 1 / 0;
|
|
5892
|
-
for (;e; ) {
|
|
5893
|
-
if (e.length < s)
|
|
5894
|
-
s = e.length;
|
|
5895
|
-
else {
|
|
5896
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
5897
|
-
break;
|
|
5898
|
-
}
|
|
5899
|
-
let r;
|
|
5900
|
-
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))
|
|
5901
|
-
continue;
|
|
5902
|
-
if (r = this.tokenizer.space(e)) {
|
|
5903
|
-
e = e.substring(r.raw.length);
|
|
5904
|
-
let o = t.at(-1);
|
|
5905
|
-
r.raw.length === 1 && o !== undefined ? o.raw += `
|
|
5906
|
-
` : t.push(r);
|
|
5907
|
-
continue;
|
|
5908
|
-
}
|
|
5909
|
-
if (r = this.tokenizer.code(e)) {
|
|
5910
|
-
e = e.substring(r.raw.length);
|
|
5911
|
-
let o = t.at(-1);
|
|
5912
|
-
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
5913
|
-
`) ? "" : `
|
|
5914
|
-
`) + r.raw, o.text += `
|
|
5915
|
-
` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
5916
|
-
continue;
|
|
5917
|
-
}
|
|
5918
|
-
if (r = this.tokenizer.fences(e)) {
|
|
5919
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5920
|
-
continue;
|
|
5921
|
-
}
|
|
5922
|
-
if (r = this.tokenizer.heading(e)) {
|
|
5923
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5924
|
-
continue;
|
|
5925
|
-
}
|
|
5926
|
-
if (r = this.tokenizer.hr(e)) {
|
|
5927
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5928
|
-
continue;
|
|
5929
|
-
}
|
|
5930
|
-
if (r = this.tokenizer.blockquote(e)) {
|
|
5931
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5932
|
-
continue;
|
|
5933
|
-
}
|
|
5934
|
-
if (r = this.tokenizer.list(e)) {
|
|
5935
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5936
|
-
continue;
|
|
5937
|
-
}
|
|
5938
|
-
if (r = this.tokenizer.html(e)) {
|
|
5939
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5940
|
-
continue;
|
|
5941
|
-
}
|
|
5942
|
-
if (r = this.tokenizer.def(e)) {
|
|
5943
|
-
e = e.substring(r.raw.length);
|
|
5944
|
-
let o = t.at(-1);
|
|
5945
|
-
o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
5946
|
-
`) ? "" : `
|
|
5947
|
-
`) + r.raw, o.text += `
|
|
5948
|
-
` + 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));
|
|
5949
|
-
continue;
|
|
5950
|
-
}
|
|
5951
|
-
if (r = this.tokenizer.table(e)) {
|
|
5952
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5953
|
-
continue;
|
|
5954
|
-
}
|
|
5955
|
-
if (r = this.tokenizer.lheading(e)) {
|
|
5956
|
-
e = e.substring(r.raw.length), t.push(r);
|
|
5957
|
-
continue;
|
|
5958
|
-
}
|
|
5959
|
-
let i = e;
|
|
5960
|
-
if (this.options.extensions?.startBlock) {
|
|
5961
|
-
let o = 1 / 0, u = e.slice(1), a;
|
|
5962
|
-
this.options.extensions.startBlock.forEach((p) => {
|
|
5963
|
-
a = p.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
|
|
5964
|
-
}), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
|
|
5965
|
-
}
|
|
5966
|
-
if (this.state.top && (r = this.tokenizer.paragraph(i))) {
|
|
5967
|
-
let o = t.at(-1);
|
|
5968
|
-
n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
|
|
5969
|
-
`) ? "" : `
|
|
5970
|
-
`) + r.raw, o.text += `
|
|
5971
|
-
` + 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);
|
|
5972
|
-
continue;
|
|
5973
|
-
}
|
|
5974
|
-
if (r = this.tokenizer.text(e)) {
|
|
5975
|
-
e = e.substring(r.raw.length);
|
|
5976
|
-
let o = t.at(-1);
|
|
5977
|
-
o?.type === "text" ? (o.raw += (o.raw.endsWith(`
|
|
5978
|
-
`) ? "" : `
|
|
5979
|
-
`) + r.raw, o.text += `
|
|
5980
|
-
` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
|
|
5981
|
-
continue;
|
|
5982
|
-
}
|
|
5983
|
-
if (e) {
|
|
5984
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
5985
|
-
break;
|
|
5986
|
-
}
|
|
5987
|
-
}
|
|
5988
|
-
return this.state.top = true, t;
|
|
5989
|
-
}
|
|
5990
|
-
inline(e, t = []) {
|
|
5991
|
-
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
5992
|
-
}
|
|
5993
|
-
linkInText(e) {
|
|
5994
|
-
if (!e.includes("["))
|
|
5995
|
-
return false;
|
|
5996
|
-
let t = this.tokenizer.rules.inline.link;
|
|
5997
|
-
for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))
|
|
5998
|
-
if (t.test(n[0]) && e.charAt(n.index - 1) !== "!")
|
|
5999
|
-
return true;
|
|
6000
|
-
for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
|
|
6001
|
-
let s = n[0], r = s.lastIndexOf("[");
|
|
6002
|
-
if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, s.slice(r + 1, -1))) && !(r > 1 && this.linkInText(s.slice(1, r - 1))))
|
|
6003
|
-
return true;
|
|
6004
|
-
}
|
|
6005
|
-
return false;
|
|
6006
|
-
}
|
|
6007
|
-
inlineTokens(e, t = []) {
|
|
6008
|
-
this.tokenizer.lexer = this;
|
|
6009
|
-
let n = e;
|
|
6010
|
-
if (this.tokens.links && e.includes("[")) {
|
|
6011
|
-
let o = this.tokenizer.rules.inline.reflinkSearch, u = (a) => {
|
|
6012
|
-
let p = a.lastIndexOf("[");
|
|
6013
|
-
if (!Object.hasOwn(this.tokens.links, a.slice(p + 1, -1)))
|
|
6014
|
-
return a;
|
|
6015
|
-
if (p > 1 && a.charAt(0) !== "!") {
|
|
6016
|
-
let c = a.slice(1, p - 1);
|
|
6017
|
-
if (this.linkInText(c))
|
|
6018
|
-
return "[" + c.replace(o, u) + "][" + "a".repeat(a.length - p - 2) + "]";
|
|
6019
|
-
}
|
|
6020
|
-
return "[" + "a".repeat(a.length - 2) + "]";
|
|
6021
|
-
};
|
|
6022
|
-
n = n.replace(o, u);
|
|
6023
|
-
}
|
|
6024
|
-
n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (o) => "+".repeat(o.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (o, u, a) => {
|
|
6025
|
-
let p = a ? a.length : 0;
|
|
6026
|
-
return o.slice(0, p) + "[" + "a".repeat(o.length - p - 2) + "]";
|
|
6027
|
-
}), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
|
|
6028
|
-
let s = false, r = "", i = 1 / 0;
|
|
6029
|
-
for (;e; ) {
|
|
6030
|
-
if (e.length < i)
|
|
6031
|
-
i = e.length;
|
|
6032
|
-
else {
|
|
6033
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
6034
|
-
break;
|
|
6035
|
-
}
|
|
6036
|
-
s || (r = ""), s = false;
|
|
6037
|
-
let o;
|
|
6038
|
-
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))
|
|
6039
|
-
continue;
|
|
6040
|
-
if (o = this.tokenizer.escape(e)) {
|
|
6041
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6042
|
-
continue;
|
|
6043
|
-
}
|
|
6044
|
-
if (o = this.tokenizer.tag(e)) {
|
|
6045
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6046
|
-
continue;
|
|
6047
|
-
}
|
|
6048
|
-
if (o = this.tokenizer.link(e)) {
|
|
6049
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6050
|
-
continue;
|
|
6051
|
-
}
|
|
6052
|
-
if (o = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
6053
|
-
e = e.substring(o.raw.length);
|
|
6054
|
-
let a = t.at(-1);
|
|
6055
|
-
o.type === "text" && a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
6056
|
-
continue;
|
|
6057
|
-
}
|
|
6058
|
-
if (o = this.tokenizer.emStrong(e, n, r)) {
|
|
6059
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6060
|
-
continue;
|
|
6061
|
-
}
|
|
6062
|
-
if (o = this.tokenizer.codespan(e)) {
|
|
6063
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6064
|
-
continue;
|
|
6065
|
-
}
|
|
6066
|
-
if (o = this.tokenizer.br(e)) {
|
|
6067
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6068
|
-
continue;
|
|
6069
|
-
}
|
|
6070
|
-
if (o = this.tokenizer.del(e, n, r)) {
|
|
6071
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6072
|
-
continue;
|
|
6073
|
-
}
|
|
6074
|
-
if (o = this.tokenizer.autolink(e)) {
|
|
6075
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6076
|
-
continue;
|
|
6077
|
-
}
|
|
6078
|
-
if (!this.state.inLink && (o = this.tokenizer.url(e))) {
|
|
6079
|
-
e = e.substring(o.raw.length), t.push(o);
|
|
6080
|
-
continue;
|
|
6081
|
-
}
|
|
6082
|
-
let u = e;
|
|
6083
|
-
if (this.options.extensions?.startInline) {
|
|
6084
|
-
let a = 1 / 0, p = e.slice(1), c;
|
|
6085
|
-
this.options.extensions.startInline.forEach((h) => {
|
|
6086
|
-
c = h.call({ lexer: this }, p), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
|
|
6087
|
-
}), a < 1 / 0 && a >= 0 && (u = e.substring(0, a + 1));
|
|
6088
|
-
}
|
|
6089
|
-
if (o = this.tokenizer.inlineText(u)) {
|
|
6090
|
-
e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (r = o.raw.slice(-1)), s = true;
|
|
6091
|
-
let a = t.at(-1);
|
|
6092
|
-
a?.type === "text" ? (a.raw += o.raw, a.text += o.text) : t.push(o);
|
|
6093
|
-
continue;
|
|
6094
|
-
}
|
|
6095
|
-
if (e) {
|
|
6096
|
-
this.infiniteLoopError(e.charCodeAt(0));
|
|
6097
|
-
break;
|
|
6098
|
-
}
|
|
6099
|
-
}
|
|
6100
|
-
return t;
|
|
6101
|
-
}
|
|
6102
|
-
infiniteLoopError(e) {
|
|
6103
|
-
let t = "Infinite loop on byte: " + e;
|
|
6104
|
-
if (this.options.silent)
|
|
6105
|
-
console.error(t);
|
|
6106
|
-
else
|
|
6107
|
-
throw new Error(t);
|
|
6108
|
-
}
|
|
6109
|
-
};
|
|
6110
|
-
var P = class {
|
|
6111
|
-
options;
|
|
6112
|
-
parser;
|
|
6113
|
-
constructor(e) {
|
|
6114
|
-
this.options = e || R;
|
|
6115
|
-
}
|
|
6116
|
-
space(e) {
|
|
6117
|
-
return "";
|
|
6118
|
-
}
|
|
6119
|
-
code({ text: e, lang: t, escaped: n }) {
|
|
6120
|
-
let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
|
|
6121
|
-
`;
|
|
6122
|
-
return s ? '<pre><code class="language-' + T(s) + '">' + (n ? r : T(r, true)) + `</code></pre>
|
|
6123
|
-
` : "<pre><code>" + (n ? r : T(r, true)) + `</code></pre>
|
|
6124
|
-
`;
|
|
6125
|
-
}
|
|
6126
|
-
blockquote({ tokens: e }) {
|
|
6127
|
-
return `<blockquote>
|
|
6128
|
-
${this.parser.parse(e)}</blockquote>
|
|
6129
|
-
`;
|
|
6130
|
-
}
|
|
6131
|
-
html({ text: e }) {
|
|
6132
|
-
return e;
|
|
6133
|
-
}
|
|
6134
|
-
def(e) {
|
|
6135
|
-
return "";
|
|
6136
|
-
}
|
|
6137
|
-
heading({ tokens: e, depth: t }) {
|
|
6138
|
-
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
6139
|
-
`;
|
|
6140
|
-
}
|
|
6141
|
-
hr(e) {
|
|
6142
|
-
return `<hr>
|
|
6143
|
-
`;
|
|
6144
|
-
}
|
|
6145
|
-
list(e) {
|
|
6146
|
-
let { ordered: t, start: n } = e, s = "";
|
|
6147
|
-
for (let o = 0;o < e.items.length; o++) {
|
|
6148
|
-
let u = e.items[o];
|
|
6149
|
-
s += this.listitem(u);
|
|
6150
|
-
}
|
|
6151
|
-
let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
6152
|
-
return "<" + r + i + `>
|
|
6153
|
-
` + s + "</" + r + `>
|
|
6154
|
-
`;
|
|
6155
|
-
}
|
|
6156
|
-
listitem(e) {
|
|
6157
|
-
return `<li>${this.parser.parse(e.tokens)}</li>
|
|
6158
|
-
`;
|
|
6159
|
-
}
|
|
6160
|
-
checkbox({ checked: e }) {
|
|
6161
|
-
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
|
|
6162
|
-
}
|
|
6163
|
-
paragraph({ tokens: e }) {
|
|
6164
|
-
return `<p>${this.parser.parseInline(e)}</p>
|
|
6165
|
-
`;
|
|
6166
|
-
}
|
|
6167
|
-
table(e) {
|
|
6168
|
-
let t = "", n = "";
|
|
6169
|
-
for (let r = 0;r < e.header.length; r++)
|
|
6170
|
-
n += this.tablecell(e.header[r]);
|
|
6171
|
-
t += this.tablerow({ text: n });
|
|
6172
|
-
let s = "";
|
|
6173
|
-
for (let r = 0;r < e.rows.length; r++) {
|
|
6174
|
-
let i = e.rows[r];
|
|
6175
|
-
n = "";
|
|
6176
|
-
for (let o = 0;o < i.length; o++)
|
|
6177
|
-
n += this.tablecell(i[o]);
|
|
6178
|
-
s += this.tablerow({ text: n });
|
|
6179
|
-
}
|
|
6180
|
-
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
6181
|
-
<thead>
|
|
6182
|
-
` + t + `</thead>
|
|
6183
|
-
` + s + `</table>
|
|
6184
|
-
`;
|
|
6185
|
-
}
|
|
6186
|
-
tablerow({ text: e }) {
|
|
6187
|
-
return `<tr>
|
|
6188
|
-
${e}</tr>
|
|
6189
|
-
`;
|
|
6190
|
-
}
|
|
6191
|
-
tablecell(e) {
|
|
6192
|
-
let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
6193
|
-
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
6194
|
-
`;
|
|
6195
|
-
}
|
|
6196
|
-
strong({ tokens: e }) {
|
|
6197
|
-
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
6198
|
-
}
|
|
6199
|
-
em({ tokens: e }) {
|
|
6200
|
-
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
6201
|
-
}
|
|
6202
|
-
codespan({ text: e }) {
|
|
6203
|
-
return `<code>${T(e, true)}</code>`;
|
|
6204
|
-
}
|
|
6205
|
-
br(e) {
|
|
6206
|
-
return "<br>";
|
|
6207
|
-
}
|
|
6208
|
-
del({ tokens: e }) {
|
|
6209
|
-
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
6210
|
-
}
|
|
6211
|
-
link({ href: e, title: t, tokens: n }) {
|
|
6212
|
-
let s = this.parser.parseInline(n), r = Y(e);
|
|
6213
|
-
if (r === null)
|
|
6214
|
-
return s;
|
|
6215
|
-
e = r;
|
|
6216
|
-
let i = '<a href="' + e + '"';
|
|
6217
|
-
return t && (i += ' title="' + T(t) + '"'), i += ">" + s + "</a>", i;
|
|
6218
|
-
}
|
|
6219
|
-
image({ href: e, title: t, text: n, tokens: s }) {
|
|
6220
|
-
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
|
|
6221
|
-
let r = Y(e);
|
|
6222
|
-
if (r === null)
|
|
6223
|
-
return T(n);
|
|
6224
|
-
e = r;
|
|
6225
|
-
let i = `<img src="${e}" alt="${T(n)}"`;
|
|
6226
|
-
return t && (i += ` title="${T(t)}"`), i += ">", i;
|
|
6227
|
-
}
|
|
6228
|
-
text(e) {
|
|
6229
|
-
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : T(e.text);
|
|
6230
|
-
}
|
|
6231
|
-
};
|
|
6232
|
-
var L = class {
|
|
6233
|
-
strong({ text: e }) {
|
|
6234
|
-
return e;
|
|
6235
|
-
}
|
|
6236
|
-
em({ text: e }) {
|
|
6237
|
-
return e;
|
|
6238
|
-
}
|
|
6239
|
-
codespan({ text: e }) {
|
|
6240
|
-
return e;
|
|
6241
|
-
}
|
|
6242
|
-
del({ text: e }) {
|
|
6243
|
-
return e;
|
|
6244
|
-
}
|
|
6245
|
-
html({ text: e }) {
|
|
6246
|
-
return e;
|
|
6247
|
-
}
|
|
6248
|
-
text({ text: e }) {
|
|
6249
|
-
return e;
|
|
6250
|
-
}
|
|
6251
|
-
link({ text: e }) {
|
|
6252
|
-
return "" + e;
|
|
6253
|
-
}
|
|
6254
|
-
image({ text: e }) {
|
|
6255
|
-
return "" + e;
|
|
6256
|
-
}
|
|
6257
|
-
br() {
|
|
6258
|
-
return "";
|
|
6259
|
-
}
|
|
6260
|
-
checkbox({ raw: e }) {
|
|
6261
|
-
return e;
|
|
6262
|
-
}
|
|
6263
|
-
};
|
|
6264
|
-
var b = class l {
|
|
6265
|
-
options;
|
|
6266
|
-
renderer;
|
|
6267
|
-
textRenderer;
|
|
6268
|
-
constructor(e) {
|
|
6269
|
-
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;
|
|
6270
|
-
}
|
|
6271
|
-
static parse(e, t) {
|
|
6272
|
-
return new l(t).parse(e);
|
|
6273
|
-
}
|
|
6274
|
-
static parseInline(e, t) {
|
|
6275
|
-
return new l(t).parseInline(e);
|
|
6276
|
-
}
|
|
6277
|
-
parse(e) {
|
|
6278
|
-
this.renderer.parser = this;
|
|
6279
|
-
let t = "";
|
|
6280
|
-
for (let n = 0;n < e.length; n++) {
|
|
6281
|
-
let s = e[n];
|
|
6282
|
-
if (this.options.extensions?.renderers?.[s.type]) {
|
|
6283
|
-
let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
6284
|
-
if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "checkbox", "html", "def", "paragraph", "text"].includes(i.type)) {
|
|
6285
|
-
t += o || "";
|
|
6286
|
-
continue;
|
|
6287
|
-
}
|
|
6288
|
-
}
|
|
6289
|
-
let r = s;
|
|
6290
|
-
switch (r.type) {
|
|
6291
|
-
case "space": {
|
|
6292
|
-
t += this.renderer.space(r);
|
|
6293
|
-
break;
|
|
6294
|
-
}
|
|
6295
|
-
case "hr": {
|
|
6296
|
-
t += this.renderer.hr(r);
|
|
6297
|
-
break;
|
|
6298
|
-
}
|
|
6299
|
-
case "heading": {
|
|
6300
|
-
t += this.renderer.heading(r);
|
|
6301
|
-
break;
|
|
6302
|
-
}
|
|
6303
|
-
case "code": {
|
|
6304
|
-
t += this.renderer.code(r);
|
|
6305
|
-
break;
|
|
6306
|
-
}
|
|
6307
|
-
case "table": {
|
|
6308
|
-
t += this.renderer.table(r);
|
|
6309
|
-
break;
|
|
6310
|
-
}
|
|
6311
|
-
case "blockquote": {
|
|
6312
|
-
t += this.renderer.blockquote(r);
|
|
6313
|
-
break;
|
|
6314
|
-
}
|
|
6315
|
-
case "list": {
|
|
6316
|
-
t += this.renderer.list(r);
|
|
6317
|
-
break;
|
|
6318
|
-
}
|
|
6319
|
-
case "checkbox": {
|
|
6320
|
-
t += this.renderer.checkbox(r);
|
|
6321
|
-
break;
|
|
6322
|
-
}
|
|
6323
|
-
case "html": {
|
|
6324
|
-
t += this.renderer.html(r);
|
|
6325
|
-
break;
|
|
6326
|
-
}
|
|
6327
|
-
case "def": {
|
|
6328
|
-
t += this.renderer.def(r);
|
|
6329
|
-
break;
|
|
6330
|
-
}
|
|
6331
|
-
case "paragraph": {
|
|
6332
|
-
t += this.renderer.paragraph(r);
|
|
6333
|
-
break;
|
|
6334
|
-
}
|
|
6335
|
-
case "text": {
|
|
6336
|
-
t += this.renderer.text(r);
|
|
6337
|
-
break;
|
|
6338
|
-
}
|
|
6339
|
-
default: {
|
|
6340
|
-
let i = 'Token with "' + r.type + '" type was not found.';
|
|
6341
|
-
if (this.options.silent)
|
|
6342
|
-
return console.error(i), "";
|
|
6343
|
-
throw new Error(i);
|
|
6344
|
-
}
|
|
6345
|
-
}
|
|
6346
|
-
}
|
|
6347
|
-
return t;
|
|
6348
|
-
}
|
|
6349
|
-
parseInline(e, t = this.renderer) {
|
|
6350
|
-
this.renderer.parser = this;
|
|
6351
|
-
let n = "";
|
|
6352
|
-
for (let s = 0;s < e.length; s++) {
|
|
6353
|
-
let r = e[s];
|
|
6354
|
-
if (this.options.extensions?.renderers?.[r.type]) {
|
|
6355
|
-
let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
|
|
6356
|
-
if (o !== false || !["escape", "html", "link", "image", "checkbox", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
|
|
6357
|
-
n += o || "";
|
|
6358
|
-
continue;
|
|
6359
|
-
}
|
|
6360
|
-
}
|
|
6361
|
-
let i = r;
|
|
6362
|
-
switch (i.type) {
|
|
6363
|
-
case "escape": {
|
|
6364
|
-
n += t.text(i);
|
|
6365
|
-
break;
|
|
6366
|
-
}
|
|
6367
|
-
case "html": {
|
|
6368
|
-
n += t.html(i);
|
|
6369
|
-
break;
|
|
6370
|
-
}
|
|
6371
|
-
case "link": {
|
|
6372
|
-
n += t.link(i);
|
|
6373
|
-
break;
|
|
6374
|
-
}
|
|
6375
|
-
case "image": {
|
|
6376
|
-
n += t.image(i);
|
|
6377
|
-
break;
|
|
6378
|
-
}
|
|
6379
|
-
case "checkbox": {
|
|
6380
|
-
n += t.checkbox(i);
|
|
6381
|
-
break;
|
|
6382
|
-
}
|
|
6383
|
-
case "strong": {
|
|
6384
|
-
n += t.strong(i);
|
|
6385
|
-
break;
|
|
6386
|
-
}
|
|
6387
|
-
case "em": {
|
|
6388
|
-
n += t.em(i);
|
|
6389
|
-
break;
|
|
6390
|
-
}
|
|
6391
|
-
case "codespan": {
|
|
6392
|
-
n += t.codespan(i);
|
|
6393
|
-
break;
|
|
6394
|
-
}
|
|
6395
|
-
case "br": {
|
|
6396
|
-
n += t.br(i);
|
|
6397
|
-
break;
|
|
6398
|
-
}
|
|
6399
|
-
case "del": {
|
|
6400
|
-
n += t.del(i);
|
|
6401
|
-
break;
|
|
6402
|
-
}
|
|
6403
|
-
case "text": {
|
|
6404
|
-
n += t.text(i);
|
|
6405
|
-
break;
|
|
6406
|
-
}
|
|
6407
|
-
default: {
|
|
6408
|
-
let o = 'Token with "' + i.type + '" type was not found.';
|
|
6409
|
-
if (this.options.silent)
|
|
6410
|
-
return console.error(o), "";
|
|
6411
|
-
throw new Error(o);
|
|
6412
|
-
}
|
|
6413
|
-
}
|
|
6414
|
-
}
|
|
6415
|
-
return n;
|
|
6416
|
-
}
|
|
6417
|
-
};
|
|
6418
|
-
var S = class {
|
|
6419
|
-
options;
|
|
6420
|
-
block;
|
|
6421
|
-
constructor(e) {
|
|
6422
|
-
this.options = e || R;
|
|
6423
|
-
}
|
|
6424
|
-
static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
|
|
6425
|
-
static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
|
|
6426
|
-
preprocess(e) {
|
|
6427
|
-
return e;
|
|
6428
|
-
}
|
|
6429
|
-
postprocess(e) {
|
|
6430
|
-
return e;
|
|
6431
|
-
}
|
|
6432
|
-
processAllTokens(e) {
|
|
6433
|
-
return e;
|
|
6434
|
-
}
|
|
6435
|
-
emStrongMask(e) {
|
|
6436
|
-
return e;
|
|
6437
|
-
}
|
|
6438
|
-
provideLexer(e = this.block) {
|
|
6439
|
-
return e ? x.lex : x.lexInline;
|
|
6440
|
-
}
|
|
6441
|
-
provideParser(e = this.block) {
|
|
6442
|
-
return e ? b.parse : b.parseInline;
|
|
6443
|
-
}
|
|
6444
|
-
};
|
|
6445
|
-
var Z = class {
|
|
6446
|
-
defaults = A();
|
|
6447
|
-
options = this.setOptions;
|
|
6448
|
-
parse = this.parseMarkdown(true);
|
|
6449
|
-
parseInline = this.parseMarkdown(false);
|
|
6450
|
-
Parser = b;
|
|
6451
|
-
Renderer = P;
|
|
6452
|
-
TextRenderer = L;
|
|
6453
|
-
Lexer = x;
|
|
6454
|
-
Tokenizer = y;
|
|
6455
|
-
Hooks = S;
|
|
6456
|
-
constructor(...e) {
|
|
6457
|
-
this.use(...e);
|
|
6458
|
-
}
|
|
6459
|
-
walkTokens(e, t) {
|
|
6460
|
-
let n = [];
|
|
6461
|
-
for (let s of e)
|
|
6462
|
-
switch (n = n.concat(t.call(this, s)), s.type) {
|
|
6463
|
-
case "table": {
|
|
6464
|
-
let r = s;
|
|
6465
|
-
for (let i of r.header)
|
|
6466
|
-
n = n.concat(this.walkTokens(i.tokens, t));
|
|
6467
|
-
for (let i of r.rows)
|
|
6468
|
-
for (let o of i)
|
|
6469
|
-
n = n.concat(this.walkTokens(o.tokens, t));
|
|
6470
|
-
break;
|
|
6471
|
-
}
|
|
6472
|
-
case "list": {
|
|
6473
|
-
let r = s;
|
|
6474
|
-
n = n.concat(this.walkTokens(r.items, t));
|
|
6475
|
-
break;
|
|
6476
|
-
}
|
|
6477
|
-
default: {
|
|
6478
|
-
let r = s;
|
|
6479
|
-
this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
|
|
6480
|
-
let o = r[i].flat(1 / 0);
|
|
6481
|
-
n = n.concat(this.walkTokens(o, t));
|
|
6482
|
-
}) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
|
|
6483
|
-
}
|
|
6484
|
-
}
|
|
6485
|
-
return n;
|
|
6486
|
-
}
|
|
6487
|
-
use(...e) {
|
|
6488
|
-
let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
6489
|
-
return e.forEach((n) => {
|
|
6490
|
-
let s = { ...n };
|
|
6491
|
-
if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
|
|
6492
|
-
if (!r.name)
|
|
6493
|
-
throw new Error("extension name required");
|
|
6494
|
-
if ("renderer" in r) {
|
|
6495
|
-
let i = t.renderers[r.name];
|
|
6496
|
-
i ? t.renderers[r.name] = function(...o) {
|
|
6497
|
-
let u = r.renderer.apply(this, o);
|
|
6498
|
-
return u === false && (u = i.apply(this, o)), u;
|
|
6499
|
-
} : t.renderers[r.name] = r.renderer;
|
|
6500
|
-
}
|
|
6501
|
-
if ("tokenizer" in r) {
|
|
6502
|
-
if (!r.level || r.level !== "block" && r.level !== "inline")
|
|
6503
|
-
throw new Error("extension level must be 'block' or 'inline'");
|
|
6504
|
-
let i = t[r.level];
|
|
6505
|
-
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]));
|
|
6506
|
-
}
|
|
6507
|
-
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
6508
|
-
}), s.extensions = t), n.renderer) {
|
|
6509
|
-
let r = this.defaults.renderer || new P(this.defaults);
|
|
6510
|
-
for (let i in n.renderer) {
|
|
6511
|
-
if (!(i in r))
|
|
6512
|
-
throw new Error(`renderer '${i}' does not exist`);
|
|
6513
|
-
if (["options", "parser"].includes(i))
|
|
6514
|
-
continue;
|
|
6515
|
-
let o = i, u = n.renderer[o], a = r[o];
|
|
6516
|
-
r[o] = (...p) => {
|
|
6517
|
-
let c = u.apply(r, p);
|
|
6518
|
-
return c === false && (c = a.apply(r, p)), c || "";
|
|
6519
|
-
};
|
|
6520
|
-
}
|
|
6521
|
-
s.renderer = r;
|
|
6522
|
-
}
|
|
6523
|
-
if (n.tokenizer) {
|
|
6524
|
-
let r = this.defaults.tokenizer || new y(this.defaults);
|
|
6525
|
-
for (let i in n.tokenizer) {
|
|
6526
|
-
if (!(i in r))
|
|
6527
|
-
throw new Error(`tokenizer '${i}' does not exist`);
|
|
6528
|
-
if (["options", "rules", "lexer"].includes(i))
|
|
6529
|
-
continue;
|
|
6530
|
-
let o = i, u = n.tokenizer[o], a = r[o];
|
|
6531
|
-
r[o] = (...p) => {
|
|
6532
|
-
let c = u.apply(r, p);
|
|
6533
|
-
return c === false && (c = a.apply(r, p)), c;
|
|
6534
|
-
};
|
|
6535
|
-
}
|
|
6536
|
-
s.tokenizer = r;
|
|
6537
|
-
}
|
|
6538
|
-
if (n.hooks) {
|
|
6539
|
-
let r = this.defaults.hooks || new S;
|
|
6540
|
-
for (let i in n.hooks) {
|
|
6541
|
-
if (!(i in r))
|
|
6542
|
-
throw new Error(`hook '${i}' does not exist`);
|
|
6543
|
-
if (["options", "block"].includes(i))
|
|
6544
|
-
continue;
|
|
6545
|
-
let o = i, u = n.hooks[o], a = r[o];
|
|
6546
|
-
S.passThroughHooks.has(i) ? r[o] = (p) => {
|
|
6547
|
-
if (this.defaults.async && S.passThroughHooksRespectAsync.has(i))
|
|
6548
|
-
return (async () => {
|
|
6549
|
-
let h = await u.call(r, p);
|
|
6550
|
-
return a.call(r, h);
|
|
6551
|
-
})();
|
|
6552
|
-
let c = u.call(r, p);
|
|
6553
|
-
return a.call(r, c);
|
|
6554
|
-
} : r[o] = (...p) => {
|
|
6555
|
-
if (this.defaults.async)
|
|
6556
|
-
return (async () => {
|
|
6557
|
-
let h = await u.apply(r, p);
|
|
6558
|
-
return h === false && (h = await a.apply(r, p)), h;
|
|
6559
|
-
})();
|
|
6560
|
-
let c = u.apply(r, p);
|
|
6561
|
-
return c === false && (c = a.apply(r, p)), c;
|
|
6562
|
-
};
|
|
6563
|
-
}
|
|
6564
|
-
s.hooks = r;
|
|
6565
|
-
}
|
|
6566
|
-
if (n.walkTokens) {
|
|
6567
|
-
let r = this.defaults.walkTokens, i = n.walkTokens;
|
|
6568
|
-
s.walkTokens = function(o) {
|
|
6569
|
-
let u = [];
|
|
6570
|
-
return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
|
|
6571
|
-
};
|
|
6572
|
-
}
|
|
6573
|
-
this.defaults = { ...this.defaults, ...s };
|
|
6574
|
-
}), this;
|
|
6575
|
-
}
|
|
6576
|
-
setOptions(e) {
|
|
6577
|
-
return this.defaults = { ...this.defaults, ...e }, this;
|
|
6578
|
-
}
|
|
6579
|
-
lexer(e, t) {
|
|
6580
|
-
return x.lex(e, t ?? this.defaults);
|
|
6581
|
-
}
|
|
6582
|
-
parser(e, t) {
|
|
6583
|
-
return b.parse(e, t ?? this.defaults);
|
|
6584
|
-
}
|
|
6585
|
-
parseMarkdown(e) {
|
|
6586
|
-
return (n, s) => {
|
|
6587
|
-
let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
|
|
6588
|
-
if (this.defaults.async === true && r.async === false)
|
|
6589
|
-
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."));
|
|
6590
|
-
if (typeof n > "u" || n === null)
|
|
6591
|
-
return o(new Error("marked(): input parameter is undefined or null"));
|
|
6592
|
-
if (typeof n != "string")
|
|
6593
|
-
return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
6594
|
-
if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async)
|
|
6595
|
-
return (async () => {
|
|
6596
|
-
let u = i.hooks ? await i.hooks.preprocess(n) : n, p = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), c = i.hooks ? await i.hooks.processAllTokens(p) : p;
|
|
6597
|
-
i.walkTokens && await Promise.all(this.walkTokens(c, i.walkTokens));
|
|
6598
|
-
let d = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, i);
|
|
6599
|
-
return i.hooks ? await i.hooks.postprocess(d) : d;
|
|
6600
|
-
})().catch(o);
|
|
6601
|
-
try {
|
|
6602
|
-
i.hooks && (n = i.hooks.preprocess(n));
|
|
6603
|
-
let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
|
|
6604
|
-
i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
|
|
6605
|
-
let c = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
|
|
6606
|
-
return i.hooks && (c = i.hooks.postprocess(c)), c;
|
|
6607
|
-
} catch (u) {
|
|
6608
|
-
return o(u);
|
|
6609
|
-
}
|
|
6610
|
-
};
|
|
6611
|
-
}
|
|
6612
|
-
onError(e, t) {
|
|
6613
|
-
return (n) => {
|
|
6614
|
-
if (n.message += `
|
|
6615
|
-
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
6616
|
-
let s = "<p>An error occurred:</p><pre>" + T(n.message + "", true) + "</pre>";
|
|
6617
|
-
return t ? Promise.resolve(s) : s;
|
|
6618
|
-
}
|
|
6619
|
-
if (t)
|
|
6620
|
-
return Promise.reject(n);
|
|
6621
|
-
throw n;
|
|
6622
|
-
};
|
|
6623
|
-
}
|
|
6624
|
-
};
|
|
6625
|
-
var M = new Z;
|
|
6626
|
-
function f(l, e) {
|
|
6627
|
-
return M.parse(l, e);
|
|
6628
|
-
}
|
|
6629
|
-
f.options = f.setOptions = function(l) {
|
|
6630
|
-
return M.setOptions(l), f.defaults = M.defaults, j(f.defaults), f;
|
|
6631
|
-
};
|
|
6632
|
-
f.getDefaults = A;
|
|
6633
|
-
f.defaults = R;
|
|
6634
|
-
function dt(...l) {
|
|
6635
|
-
return M.use(...l), f.defaults = M.defaults, j(f.defaults), f;
|
|
6636
|
-
}
|
|
6637
|
-
f.use = dt;
|
|
6638
|
-
f.walkTokens = function(l, e) {
|
|
6639
|
-
return M.walkTokens(l, e);
|
|
6640
|
-
};
|
|
6641
|
-
f.parseInline = M.parseInline;
|
|
6642
|
-
f.Parser = b;
|
|
6643
|
-
f.parser = b.parse;
|
|
6644
|
-
f.Renderer = P;
|
|
6645
|
-
f.TextRenderer = L;
|
|
6646
|
-
f.Lexer = x;
|
|
6647
|
-
f.lexer = x.lex;
|
|
6648
|
-
f.Tokenizer = y;
|
|
6649
|
-
f.Hooks = S;
|
|
6650
|
-
f.parse = f;
|
|
6651
|
-
var nn = f.options;
|
|
6652
|
-
var rn = f.setOptions;
|
|
6653
|
-
var sn = f.walkTokens;
|
|
6654
|
-
var on = f.parseInline;
|
|
6655
|
-
var ln = b.parse;
|
|
6656
|
-
var un = x.lex;
|
|
6657
|
-
// ../../node_modules/.bun/get-east-asian-width@1.6.0/node_modules/get-east-asian-width/lookup-data.js
|
|
6658
|
-
var ambiguousMinimalCodePoint = 161;
|
|
6659
|
-
var ambiguousMaximumCodePoint = 1114109;
|
|
6660
|
-
var ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
6661
|
-
var fullwidthMinimalCodePoint = 12288;
|
|
6662
|
-
var fullwidthMaximumCodePoint = 65510;
|
|
6663
|
-
var fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
6664
|
-
var wideMinimalCodePoint = 4352;
|
|
6665
|
-
var wideMaximumCodePoint = 262141;
|
|
6666
|
-
var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
|
|
6667
|
-
|
|
6668
|
-
// ../../node_modules/.bun/get-east-asian-width@1.6.0/node_modules/get-east-asian-width/utilities.js
|
|
6669
|
-
var isInRange = (ranges, codePoint) => {
|
|
6670
|
-
let low = 0;
|
|
6671
|
-
let high = Math.floor(ranges.length / 2) - 1;
|
|
6672
|
-
while (low <= high) {
|
|
6673
|
-
const mid = Math.floor((low + high) / 2);
|
|
6674
|
-
const i = mid * 2;
|
|
6675
|
-
if (codePoint < ranges[i]) {
|
|
6676
|
-
high = mid - 1;
|
|
6677
|
-
} else if (codePoint > ranges[i + 1]) {
|
|
6678
|
-
low = mid + 1;
|
|
6679
|
-
} else {
|
|
6680
|
-
return true;
|
|
6681
|
-
}
|
|
6682
|
-
}
|
|
6683
|
-
return false;
|
|
6684
|
-
};
|
|
6685
|
-
|
|
6686
|
-
// ../../node_modules/.bun/get-east-asian-width@1.6.0/node_modules/get-east-asian-width/lookup.js
|
|
6687
|
-
var commonCjkCodePoint = 19968;
|
|
6688
|
-
var [wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
|
|
6689
|
-
function findWideFastPathRange(ranges) {
|
|
6690
|
-
let fastPathStart = ranges[0];
|
|
6691
|
-
let fastPathEnd = ranges[1];
|
|
6692
|
-
for (let index = 0;index < ranges.length; index += 2) {
|
|
6693
|
-
const start = ranges[index];
|
|
6694
|
-
const end = ranges[index + 1];
|
|
6695
|
-
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
6696
|
-
return [start, end];
|
|
6697
|
-
}
|
|
6698
|
-
if (end - start > fastPathEnd - fastPathStart) {
|
|
6699
|
-
fastPathStart = start;
|
|
6700
|
-
fastPathEnd = end;
|
|
6701
|
-
}
|
|
6702
|
-
}
|
|
6703
|
-
return [fastPathStart, fastPathEnd];
|
|
6704
|
-
}
|
|
6705
|
-
var isAmbiguous = (codePoint) => {
|
|
6706
|
-
if (codePoint < ambiguousMinimalCodePoint || codePoint > ambiguousMaximumCodePoint) {
|
|
6707
|
-
return false;
|
|
6708
|
-
}
|
|
6709
|
-
return isInRange(ambiguousRanges, codePoint);
|
|
6710
|
-
};
|
|
6711
|
-
var isFullWidth = (codePoint) => {
|
|
6712
|
-
if (codePoint < fullwidthMinimalCodePoint || codePoint > fullwidthMaximumCodePoint) {
|
|
6713
|
-
return false;
|
|
6714
|
-
}
|
|
6715
|
-
return isInRange(fullwidthRanges, codePoint);
|
|
6716
|
-
};
|
|
6717
|
-
var isWide = (codePoint) => {
|
|
6718
|
-
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
6719
|
-
return true;
|
|
6720
|
-
}
|
|
6721
|
-
if (codePoint < wideMinimalCodePoint || codePoint > wideMaximumCodePoint) {
|
|
6722
|
-
return false;
|
|
6723
|
-
}
|
|
6724
|
-
return isInRange(wideRanges, codePoint);
|
|
6725
|
-
};
|
|
6726
|
-
|
|
6727
|
-
// ../../node_modules/.bun/get-east-asian-width@1.6.0/node_modules/get-east-asian-width/index.js
|
|
6728
|
-
function validate(codePoint) {
|
|
6729
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
6730
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
6731
|
-
}
|
|
6732
|
-
}
|
|
6733
|
-
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
6734
|
-
validate(codePoint);
|
|
6735
|
-
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
6736
|
-
return 2;
|
|
6737
|
-
}
|
|
6738
|
-
return 1;
|
|
6739
|
-
}
|
|
6740
|
-
|
|
6741
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/utils.js
|
|
6742
|
-
var graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
6743
|
-
var wordSegmenter = new Intl.Segmenter(undefined, { granularity: "word" });
|
|
6744
|
-
function getGraphemeSegmenter() {
|
|
6745
|
-
return graphemeSegmenter;
|
|
6746
|
-
}
|
|
6747
|
-
function getWordSegmenter() {
|
|
6748
|
-
return wordSegmenter;
|
|
6749
|
-
}
|
|
6750
|
-
function couldBeEmoji(segment) {
|
|
6751
|
-
const cp = segment.codePointAt(0);
|
|
6752
|
-
return cp >= 126976 && cp <= 130047 || cp >= 8960 && cp <= 9215 || cp >= 9728 && cp <= 10175 || cp >= 11088 && cp <= 11093 || segment.includes("️") || segment.length > 2;
|
|
6753
|
-
}
|
|
6754
|
-
var zeroWidthRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Mark}|\p{Surrogate})+$/v;
|
|
6755
|
-
var leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Mark}\p{Surrogate}]+/v;
|
|
6756
|
-
var nonPrintingCharRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Mark}|\p{Surrogate})$/v;
|
|
6757
|
-
var markCharRegex = /^\p{Mark}$/v;
|
|
6758
|
-
var terminalSpacingMarkRegex = /^(?:[\p{Spacing_Mark}--[\u1734\u302E\u302F]]|[\u065F\u0F7F\u102B\u102C\u1031\u1033-\u1035\u1038\u103A-\u103E])+$/v;
|
|
6759
|
-
var rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
6760
|
-
var WIDTH_CACHE_SIZE = 512;
|
|
6761
|
-
var widthCache = new Map;
|
|
6762
|
-
var cjkBreakRegex = /[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}\p{Script_Extensions=Hangul}\p{Script_Extensions=Bopomofo}]/u;
|
|
6763
|
-
var cjkPunctuationRegex = new RegExp(`(?:(?=\\p{Punctuation})${cjkBreakRegex.source}|[,.:;!?()[]{}“”‘’…—])`, "u");
|
|
6764
|
-
var autocompleteSeparatorRegex = new RegExp(`(?:\\s|${cjkPunctuationRegex.source})`, "u");
|
|
6765
|
-
var autocompleteBoundaryRegex = new RegExp(`(?:^|${autocompleteSeparatorRegex.source})`, "u");
|
|
6766
|
-
function isPrintableAscii(str) {
|
|
6767
|
-
for (let i = 0;i < str.length; i++) {
|
|
6768
|
-
const code = str.charCodeAt(i);
|
|
6769
|
-
if (code < 32 || code > 126) {
|
|
6770
|
-
return false;
|
|
6771
|
-
}
|
|
6772
|
-
}
|
|
6773
|
-
return true;
|
|
6774
|
-
}
|
|
6775
|
-
function truncateFragmentToWidth(text, maxWidth) {
|
|
6776
|
-
if (maxWidth <= 0 || text.length === 0) {
|
|
6777
|
-
return { text: "", width: 0 };
|
|
6778
|
-
}
|
|
6779
|
-
if (isPrintableAscii(text)) {
|
|
6780
|
-
const clipped = text.slice(0, maxWidth);
|
|
6781
|
-
return { text: clipped, width: clipped.length };
|
|
6782
|
-
}
|
|
6783
|
-
const hasAnsi = text.includes("\x1B");
|
|
6784
|
-
const hasTabs = text.includes("\t");
|
|
6785
|
-
if (!hasAnsi && !hasTabs) {
|
|
6786
|
-
let result = "";
|
|
6787
|
-
let width = 0;
|
|
6788
|
-
for (const { segment } of graphemeSegmenter.segment(text)) {
|
|
6789
|
-
const w = graphemeWidth(segment);
|
|
6790
|
-
if (width + w > maxWidth) {
|
|
6791
|
-
break;
|
|
6792
|
-
}
|
|
6793
|
-
result += segment;
|
|
6794
|
-
width += w;
|
|
6795
|
-
}
|
|
6796
|
-
return { text: result, width };
|
|
6797
|
-
}
|
|
6798
|
-
let result = "";
|
|
6799
|
-
let width = 0;
|
|
6800
|
-
let i = 0;
|
|
6801
|
-
let pendingAnsi = "";
|
|
6802
|
-
while (i < text.length) {
|
|
6803
|
-
const ansi = extractAnsiCode(text, i);
|
|
6804
|
-
if (ansi) {
|
|
6805
|
-
pendingAnsi += ansi.code;
|
|
6806
|
-
i += ansi.length;
|
|
6807
|
-
continue;
|
|
6808
|
-
}
|
|
6809
|
-
if (text[i] === "\t") {
|
|
6810
|
-
if (width + 3 > maxWidth) {
|
|
6811
|
-
break;
|
|
6812
|
-
}
|
|
6813
|
-
if (pendingAnsi) {
|
|
6814
|
-
result += pendingAnsi;
|
|
6815
|
-
pendingAnsi = "";
|
|
6816
|
-
}
|
|
6817
|
-
result += "\t";
|
|
6818
|
-
width += 3;
|
|
6819
|
-
i++;
|
|
6820
|
-
continue;
|
|
6821
|
-
}
|
|
6822
|
-
let end = i;
|
|
6823
|
-
while (end < text.length && text[end] !== "\t") {
|
|
6824
|
-
const nextAnsi = extractAnsiCode(text, end);
|
|
6825
|
-
if (nextAnsi) {
|
|
6826
|
-
break;
|
|
6827
|
-
}
|
|
6828
|
-
end++;
|
|
6829
|
-
}
|
|
6830
|
-
for (const { segment } of graphemeSegmenter.segment(text.slice(i, end))) {
|
|
6831
|
-
const w = graphemeWidth(segment);
|
|
6832
|
-
if (width + w > maxWidth) {
|
|
6833
|
-
return { text: result, width };
|
|
6834
|
-
}
|
|
6835
|
-
if (pendingAnsi) {
|
|
6836
|
-
result += pendingAnsi;
|
|
6837
|
-
pendingAnsi = "";
|
|
6838
|
-
}
|
|
6839
|
-
result += segment;
|
|
6840
|
-
width += w;
|
|
6841
|
-
}
|
|
6842
|
-
i = end;
|
|
6843
|
-
}
|
|
6844
|
-
return { text: result, width };
|
|
6845
|
-
}
|
|
6846
|
-
function finalizeTruncatedResult(prefix, prefixWidth, ellipsis, ellipsisWidth, maxWidth, pad) {
|
|
6847
|
-
const reset = "\x1B[0m";
|
|
6848
|
-
const hyperlinkClose = getActiveOsc8Close(prefix);
|
|
6849
|
-
const visibleWidth = prefixWidth + ellipsisWidth;
|
|
6850
|
-
let result;
|
|
6851
|
-
if (ellipsis.length > 0) {
|
|
6852
|
-
result = `${prefix}${hyperlinkClose}${reset}${ellipsis}${reset}`;
|
|
6853
|
-
} else {
|
|
6854
|
-
result = `${prefix}${hyperlinkClose}${reset}`;
|
|
6855
|
-
}
|
|
6856
|
-
return pad ? result + " ".repeat(Math.max(0, maxWidth - visibleWidth)) : result;
|
|
6857
|
-
}
|
|
6858
|
-
function graphemeWidth(segment) {
|
|
6859
|
-
if (segment.length === 1) {
|
|
6860
|
-
const code = segment.charCodeAt(0);
|
|
6861
|
-
if (code >= 32 && code <= 126)
|
|
6862
|
-
return 1;
|
|
6863
|
-
if (code === 9)
|
|
6864
|
-
return 3;
|
|
6865
|
-
}
|
|
6866
|
-
if (terminalSpacingMarkRegex.test(segment)) {
|
|
6867
|
-
return [...segment].length;
|
|
6868
|
-
}
|
|
6869
|
-
if (zeroWidthRegex.test(segment)) {
|
|
6870
|
-
return 0;
|
|
6871
|
-
}
|
|
6872
|
-
if (couldBeEmoji(segment) && rgiEmojiRegex.test(segment)) {
|
|
6873
|
-
return 2;
|
|
6874
|
-
}
|
|
6875
|
-
const base = segment.replace(leadingNonPrintingRegex, "");
|
|
6876
|
-
const cp = base.codePointAt(0);
|
|
6877
|
-
if (cp === undefined) {
|
|
6878
|
-
return 0;
|
|
6879
|
-
}
|
|
6880
|
-
if (cp >= 127462 && cp <= 127487) {
|
|
6881
|
-
return 2;
|
|
6882
|
-
}
|
|
6883
|
-
let width = eastAsianWidth(cp);
|
|
6884
|
-
let followsMark = false;
|
|
6885
|
-
const chars = [...base];
|
|
6886
|
-
for (const char of chars.slice(1)) {
|
|
6887
|
-
if (terminalSpacingMarkRegex.test(char)) {
|
|
6888
|
-
width += 1;
|
|
6889
|
-
followsMark = false;
|
|
6890
|
-
} else if (markCharRegex.test(char)) {
|
|
6891
|
-
followsMark = true;
|
|
6892
|
-
} else if (!nonPrintingCharRegex.test(char)) {
|
|
6893
|
-
const c = char.codePointAt(0);
|
|
6894
|
-
if (followsMark || c >= 65280 && c <= 65519) {
|
|
6895
|
-
width += eastAsianWidth(c);
|
|
6896
|
-
} else if (c === 3635 || c === 3763) {
|
|
6897
|
-
width += 1;
|
|
6898
|
-
}
|
|
6899
|
-
followsMark = false;
|
|
6900
|
-
}
|
|
6901
|
-
}
|
|
6902
|
-
return width;
|
|
6903
|
-
}
|
|
6904
|
-
function visibleWidth(str) {
|
|
6905
|
-
if (str.length === 0) {
|
|
6906
|
-
return 0;
|
|
6907
|
-
}
|
|
6908
|
-
const asciiWidth = asciiVisibleWidth(str);
|
|
6909
|
-
if (asciiWidth !== -1) {
|
|
6910
|
-
return asciiWidth;
|
|
6911
|
-
}
|
|
6912
|
-
const cached = widthCache.get(str);
|
|
6913
|
-
if (cached !== undefined) {
|
|
6914
|
-
return cached;
|
|
6915
|
-
}
|
|
6916
|
-
let clean = str;
|
|
6917
|
-
if (str.includes("\t")) {
|
|
6918
|
-
clean = clean.replace(/\t/g, " ");
|
|
6919
|
-
}
|
|
6920
|
-
let escapeIndex = clean.indexOf("\x1B");
|
|
6921
|
-
if (escapeIndex !== -1) {
|
|
6922
|
-
let stripped = "";
|
|
6923
|
-
let copyFrom = 0;
|
|
6924
|
-
while (escapeIndex !== -1) {
|
|
6925
|
-
const length = ansiCodeLength(clean, escapeIndex);
|
|
6926
|
-
if (length > 0) {
|
|
6927
|
-
stripped += clean.slice(copyFrom, escapeIndex);
|
|
6928
|
-
escapeIndex += length;
|
|
6929
|
-
copyFrom = escapeIndex;
|
|
6930
|
-
} else {
|
|
6931
|
-
escapeIndex++;
|
|
6932
|
-
}
|
|
6933
|
-
escapeIndex = clean.indexOf("\x1B", escapeIndex);
|
|
6934
|
-
}
|
|
6935
|
-
clean = stripped + clean.slice(copyFrom);
|
|
6936
|
-
}
|
|
6937
|
-
let width = 0;
|
|
6938
|
-
for (const { segment } of graphemeSegmenter.segment(clean)) {
|
|
6939
|
-
width += graphemeWidth(segment);
|
|
6940
|
-
}
|
|
6941
|
-
if (widthCache.size >= WIDTH_CACHE_SIZE) {
|
|
6942
|
-
const firstKey = widthCache.keys().next().value;
|
|
6943
|
-
if (firstKey !== undefined) {
|
|
6944
|
-
widthCache.delete(firstKey);
|
|
6945
|
-
}
|
|
6946
|
-
}
|
|
6947
|
-
widthCache.set(str, width);
|
|
6948
|
-
return width;
|
|
6949
|
-
}
|
|
6950
|
-
function extractAnsiCode(str, pos) {
|
|
6951
|
-
const length = ansiCodeLength(str, pos);
|
|
6952
|
-
return length > 0 ? { code: str.substring(pos, pos + length), length } : null;
|
|
6953
|
-
}
|
|
6954
|
-
function asciiVisibleWidth(str) {
|
|
6955
|
-
let width = 0;
|
|
6956
|
-
let i = 0;
|
|
6957
|
-
while (i < str.length) {
|
|
6958
|
-
const code = str.charCodeAt(i);
|
|
6959
|
-
if (code >= 32 && code <= 126) {
|
|
6960
|
-
width++;
|
|
6961
|
-
i++;
|
|
6962
|
-
} else if (code === 9) {
|
|
6963
|
-
width += 3;
|
|
6964
|
-
i++;
|
|
6965
|
-
} else if (code === 27) {
|
|
6966
|
-
const length = ansiCodeLength(str, i);
|
|
6967
|
-
if (length === 0)
|
|
6968
|
-
return -1;
|
|
6969
|
-
i += length;
|
|
6970
|
-
} else {
|
|
6971
|
-
return -1;
|
|
6972
|
-
}
|
|
6973
|
-
}
|
|
6974
|
-
return width;
|
|
6975
|
-
}
|
|
6976
|
-
function ansiCodeLength(str, pos) {
|
|
6977
|
-
if (pos >= str.length || str.charCodeAt(pos) !== 27)
|
|
6978
|
-
return 0;
|
|
6979
|
-
const next = str[pos + 1];
|
|
6980
|
-
if (next === "[") {
|
|
6981
|
-
for (let j = pos + 2;j < str.length; j++) {
|
|
6982
|
-
const c = str.charCodeAt(j);
|
|
6983
|
-
if (c === 109 || c === 71 || c === 75 || c === 72 || c === 74)
|
|
6984
|
-
return j + 1 - pos;
|
|
6985
|
-
}
|
|
6986
|
-
return 0;
|
|
6987
|
-
}
|
|
6988
|
-
if (next === "]" || next === "_") {
|
|
6989
|
-
for (let j = pos + 2;j < str.length; j++) {
|
|
6990
|
-
const c = str.charCodeAt(j);
|
|
6991
|
-
if (c === 7)
|
|
6992
|
-
return j + 1 - pos;
|
|
6993
|
-
if (c === 27 && str[j + 1] === "\\")
|
|
6994
|
-
return j + 2 - pos;
|
|
6995
|
-
}
|
|
6996
|
-
return 0;
|
|
6997
|
-
}
|
|
6998
|
-
return 0;
|
|
6999
|
-
}
|
|
7000
|
-
function parseOsc8Hyperlink(ansiCode) {
|
|
7001
|
-
if (!ansiCode.startsWith("\x1B]8;")) {
|
|
7002
|
-
return;
|
|
7003
|
-
}
|
|
7004
|
-
const terminator = ansiCode.endsWith("\x07") ? "\x07" : "\x1B\\";
|
|
7005
|
-
const body = ansiCode.slice(4, terminator === "\x07" ? -1 : -2);
|
|
7006
|
-
const separatorIndex = body.indexOf(";");
|
|
7007
|
-
if (separatorIndex === -1) {
|
|
7008
|
-
return;
|
|
7009
|
-
}
|
|
7010
|
-
const params = body.slice(0, separatorIndex);
|
|
7011
|
-
const url = body.slice(separatorIndex + 1);
|
|
7012
|
-
if (!url) {
|
|
7013
|
-
return null;
|
|
7014
|
-
}
|
|
7015
|
-
return { params, url, terminator };
|
|
7016
|
-
}
|
|
7017
|
-
function formatOsc8Hyperlink(hyperlink) {
|
|
7018
|
-
return `\x1B]8;${hyperlink.params};${hyperlink.url}${hyperlink.terminator}`;
|
|
7019
|
-
}
|
|
7020
|
-
function formatOsc8Close(terminator) {
|
|
7021
|
-
return `\x1B]8;;${terminator}`;
|
|
7022
|
-
}
|
|
7023
|
-
function getActiveOsc8Close(prefix) {
|
|
7024
|
-
if (!prefix.includes("\x1B]8;")) {
|
|
7025
|
-
return "";
|
|
7026
|
-
}
|
|
7027
|
-
let activeHyperlink = null;
|
|
7028
|
-
let i = 0;
|
|
7029
|
-
while (i < prefix.length) {
|
|
7030
|
-
const ansi = extractAnsiCode(prefix, i);
|
|
7031
|
-
if (ansi) {
|
|
7032
|
-
const hyperlink = parseOsc8Hyperlink(ansi.code);
|
|
7033
|
-
if (hyperlink !== undefined) {
|
|
7034
|
-
activeHyperlink = hyperlink;
|
|
7035
|
-
}
|
|
7036
|
-
i += ansi.length;
|
|
7037
|
-
} else {
|
|
7038
|
-
i++;
|
|
7039
|
-
}
|
|
7040
|
-
}
|
|
7041
|
-
return activeHyperlink ? formatOsc8Close(activeHyperlink.terminator) : "";
|
|
7042
|
-
}
|
|
7043
|
-
|
|
7044
|
-
class AnsiCodeTracker {
|
|
7045
|
-
bold = false;
|
|
7046
|
-
dim = false;
|
|
7047
|
-
italic = false;
|
|
7048
|
-
underline = false;
|
|
7049
|
-
blink = false;
|
|
7050
|
-
inverse = false;
|
|
7051
|
-
hidden = false;
|
|
7052
|
-
strikethrough = false;
|
|
7053
|
-
fgColor = null;
|
|
7054
|
-
bgColor = null;
|
|
7055
|
-
activeHyperlink = null;
|
|
7056
|
-
process(ansiCode) {
|
|
7057
|
-
const hyperlink = parseOsc8Hyperlink(ansiCode);
|
|
7058
|
-
if (hyperlink !== undefined) {
|
|
7059
|
-
this.activeHyperlink = hyperlink;
|
|
7060
|
-
return;
|
|
7061
|
-
}
|
|
7062
|
-
if (!ansiCode.endsWith("m")) {
|
|
7063
|
-
return;
|
|
7064
|
-
}
|
|
7065
|
-
const match = ansiCode.match(/\x1b\[([\d;]*)m/);
|
|
7066
|
-
if (!match)
|
|
7067
|
-
return;
|
|
7068
|
-
const params = match[1];
|
|
7069
|
-
if (params === "" || params === "0") {
|
|
7070
|
-
this.reset();
|
|
7071
|
-
return;
|
|
7072
|
-
}
|
|
7073
|
-
const parts = params.split(";");
|
|
7074
|
-
let i = 0;
|
|
7075
|
-
while (i < parts.length) {
|
|
7076
|
-
const code = Number.parseInt(parts[i], 10);
|
|
7077
|
-
if (code === 38 || code === 48) {
|
|
7078
|
-
if (parts[i + 1] === "5" && parts[i + 2] !== undefined) {
|
|
7079
|
-
const colorCode = `${parts[i]};${parts[i + 1]};${parts[i + 2]}`;
|
|
7080
|
-
if (code === 38) {
|
|
7081
|
-
this.fgColor = colorCode;
|
|
7082
|
-
} else {
|
|
7083
|
-
this.bgColor = colorCode;
|
|
7084
|
-
}
|
|
7085
|
-
i += 3;
|
|
7086
|
-
continue;
|
|
7087
|
-
} else if (parts[i + 1] === "2" && parts[i + 4] !== undefined) {
|
|
7088
|
-
const colorCode = `${parts[i]};${parts[i + 1]};${parts[i + 2]};${parts[i + 3]};${parts[i + 4]}`;
|
|
7089
|
-
if (code === 38) {
|
|
7090
|
-
this.fgColor = colorCode;
|
|
7091
|
-
} else {
|
|
7092
|
-
this.bgColor = colorCode;
|
|
7093
|
-
}
|
|
7094
|
-
i += 5;
|
|
7095
|
-
continue;
|
|
7096
|
-
}
|
|
7097
|
-
}
|
|
7098
|
-
switch (code) {
|
|
7099
|
-
case 0:
|
|
7100
|
-
this.reset();
|
|
7101
|
-
break;
|
|
7102
|
-
case 1:
|
|
7103
|
-
this.bold = true;
|
|
7104
|
-
break;
|
|
7105
|
-
case 2:
|
|
7106
|
-
this.dim = true;
|
|
7107
|
-
break;
|
|
7108
|
-
case 3:
|
|
7109
|
-
this.italic = true;
|
|
7110
|
-
break;
|
|
7111
|
-
case 4:
|
|
7112
|
-
this.underline = true;
|
|
7113
|
-
break;
|
|
7114
|
-
case 5:
|
|
7115
|
-
this.blink = true;
|
|
7116
|
-
break;
|
|
7117
|
-
case 7:
|
|
7118
|
-
this.inverse = true;
|
|
7119
|
-
break;
|
|
7120
|
-
case 8:
|
|
7121
|
-
this.hidden = true;
|
|
7122
|
-
break;
|
|
7123
|
-
case 9:
|
|
7124
|
-
this.strikethrough = true;
|
|
7125
|
-
break;
|
|
7126
|
-
case 21:
|
|
7127
|
-
this.bold = false;
|
|
7128
|
-
break;
|
|
7129
|
-
case 22:
|
|
7130
|
-
this.bold = false;
|
|
7131
|
-
this.dim = false;
|
|
7132
|
-
break;
|
|
7133
|
-
case 23:
|
|
7134
|
-
this.italic = false;
|
|
7135
|
-
break;
|
|
7136
|
-
case 24:
|
|
7137
|
-
this.underline = false;
|
|
7138
|
-
break;
|
|
7139
|
-
case 25:
|
|
7140
|
-
this.blink = false;
|
|
7141
|
-
break;
|
|
7142
|
-
case 27:
|
|
7143
|
-
this.inverse = false;
|
|
7144
|
-
break;
|
|
7145
|
-
case 28:
|
|
7146
|
-
this.hidden = false;
|
|
7147
|
-
break;
|
|
7148
|
-
case 29:
|
|
7149
|
-
this.strikethrough = false;
|
|
7150
|
-
break;
|
|
7151
|
-
case 39:
|
|
7152
|
-
this.fgColor = null;
|
|
7153
|
-
break;
|
|
7154
|
-
case 49:
|
|
7155
|
-
this.bgColor = null;
|
|
7156
|
-
break;
|
|
7157
|
-
default:
|
|
7158
|
-
if (code >= 30 && code <= 37 || code >= 90 && code <= 97) {
|
|
7159
|
-
this.fgColor = String(code);
|
|
7160
|
-
} else if (code >= 40 && code <= 47 || code >= 100 && code <= 107) {
|
|
7161
|
-
this.bgColor = String(code);
|
|
7162
|
-
}
|
|
7163
|
-
break;
|
|
7164
|
-
}
|
|
7165
|
-
i++;
|
|
7166
|
-
}
|
|
7167
|
-
}
|
|
7168
|
-
reset() {
|
|
7169
|
-
this.bold = false;
|
|
7170
|
-
this.dim = false;
|
|
7171
|
-
this.italic = false;
|
|
7172
|
-
this.underline = false;
|
|
7173
|
-
this.blink = false;
|
|
7174
|
-
this.inverse = false;
|
|
7175
|
-
this.hidden = false;
|
|
7176
|
-
this.strikethrough = false;
|
|
7177
|
-
this.fgColor = null;
|
|
7178
|
-
this.bgColor = null;
|
|
7179
|
-
}
|
|
7180
|
-
clear() {
|
|
7181
|
-
this.reset();
|
|
7182
|
-
this.activeHyperlink = null;
|
|
7183
|
-
}
|
|
7184
|
-
getActiveCodes() {
|
|
7185
|
-
const codes = [];
|
|
7186
|
-
if (this.bold)
|
|
7187
|
-
codes.push("1");
|
|
7188
|
-
if (this.dim)
|
|
7189
|
-
codes.push("2");
|
|
7190
|
-
if (this.italic)
|
|
7191
|
-
codes.push("3");
|
|
7192
|
-
if (this.underline)
|
|
7193
|
-
codes.push("4");
|
|
7194
|
-
if (this.blink)
|
|
7195
|
-
codes.push("5");
|
|
7196
|
-
if (this.inverse)
|
|
7197
|
-
codes.push("7");
|
|
7198
|
-
if (this.hidden)
|
|
7199
|
-
codes.push("8");
|
|
7200
|
-
if (this.strikethrough)
|
|
7201
|
-
codes.push("9");
|
|
7202
|
-
if (this.fgColor)
|
|
7203
|
-
codes.push(this.fgColor);
|
|
7204
|
-
if (this.bgColor)
|
|
7205
|
-
codes.push(this.bgColor);
|
|
7206
|
-
let result = codes.length > 0 ? `\x1B[${codes.join(";")}m` : "";
|
|
7207
|
-
if (this.activeHyperlink) {
|
|
7208
|
-
result += formatOsc8Hyperlink(this.activeHyperlink);
|
|
7209
|
-
}
|
|
7210
|
-
return result;
|
|
7211
|
-
}
|
|
7212
|
-
getActiveBackgroundCode() {
|
|
7213
|
-
return this.bgColor ? `\x1B[${this.bgColor}m` : "";
|
|
7214
|
-
}
|
|
7215
|
-
hasActiveCodes() {
|
|
7216
|
-
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;
|
|
7217
|
-
}
|
|
7218
|
-
getLineEndReset() {
|
|
7219
|
-
let result = "";
|
|
7220
|
-
if (this.underline) {
|
|
7221
|
-
result += "\x1B[24m";
|
|
7222
|
-
}
|
|
7223
|
-
if (this.activeHyperlink) {
|
|
7224
|
-
result += formatOsc8Close(this.activeHyperlink.terminator);
|
|
7225
|
-
}
|
|
7226
|
-
return result;
|
|
7227
|
-
}
|
|
7228
|
-
}
|
|
7229
|
-
function truncateToWidth(text, maxWidth, ellipsis = "...", pad = false) {
|
|
7230
|
-
if (maxWidth <= 0) {
|
|
7231
|
-
return "";
|
|
7232
|
-
}
|
|
7233
|
-
if (text.length === 0) {
|
|
7234
|
-
return pad ? " ".repeat(maxWidth) : "";
|
|
7235
|
-
}
|
|
7236
|
-
const ellipsisWidth = visibleWidth(ellipsis);
|
|
7237
|
-
if (ellipsisWidth >= maxWidth) {
|
|
7238
|
-
const textWidth = visibleWidth(text);
|
|
7239
|
-
if (textWidth <= maxWidth) {
|
|
7240
|
-
return pad ? text + " ".repeat(maxWidth - textWidth) : text;
|
|
7241
|
-
}
|
|
7242
|
-
const clippedEllipsis = truncateFragmentToWidth(ellipsis, maxWidth);
|
|
7243
|
-
if (clippedEllipsis.width === 0) {
|
|
7244
|
-
return pad ? " ".repeat(maxWidth) : "";
|
|
7245
|
-
}
|
|
7246
|
-
return finalizeTruncatedResult("", 0, clippedEllipsis.text, clippedEllipsis.width, maxWidth, pad);
|
|
7247
|
-
}
|
|
7248
|
-
if (isPrintableAscii(text)) {
|
|
7249
|
-
if (text.length <= maxWidth) {
|
|
7250
|
-
return pad ? text + " ".repeat(maxWidth - text.length) : text;
|
|
7251
|
-
}
|
|
7252
|
-
const targetWidth = maxWidth - ellipsisWidth;
|
|
7253
|
-
return finalizeTruncatedResult(text.slice(0, targetWidth), targetWidth, ellipsis, ellipsisWidth, maxWidth, pad);
|
|
7254
|
-
}
|
|
7255
|
-
const targetWidth = maxWidth - ellipsisWidth;
|
|
7256
|
-
let result = "";
|
|
7257
|
-
let pendingAnsi = "";
|
|
7258
|
-
let visibleSoFar = 0;
|
|
7259
|
-
let keptWidth = 0;
|
|
7260
|
-
let keepContiguousPrefix = true;
|
|
7261
|
-
let overflowed = false;
|
|
7262
|
-
let exhaustedInput = false;
|
|
7263
|
-
const hasAnsi = text.includes("\x1B");
|
|
7264
|
-
const hasTabs = text.includes("\t");
|
|
7265
|
-
if (!hasAnsi && !hasTabs) {
|
|
7266
|
-
for (const { segment } of graphemeSegmenter.segment(text)) {
|
|
7267
|
-
const width = graphemeWidth(segment);
|
|
7268
|
-
if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
|
|
7269
|
-
result += segment;
|
|
7270
|
-
keptWidth += width;
|
|
7271
|
-
} else {
|
|
7272
|
-
keepContiguousPrefix = false;
|
|
7273
|
-
}
|
|
7274
|
-
visibleSoFar += width;
|
|
7275
|
-
if (visibleSoFar > maxWidth) {
|
|
7276
|
-
overflowed = true;
|
|
7277
|
-
break;
|
|
7278
|
-
}
|
|
7279
|
-
}
|
|
7280
|
-
exhaustedInput = !overflowed;
|
|
7281
|
-
} else {
|
|
7282
|
-
let i = 0;
|
|
7283
|
-
while (i < text.length) {
|
|
7284
|
-
const ansi = extractAnsiCode(text, i);
|
|
7285
|
-
if (ansi) {
|
|
7286
|
-
pendingAnsi += ansi.code;
|
|
7287
|
-
i += ansi.length;
|
|
7288
|
-
continue;
|
|
7289
|
-
}
|
|
7290
|
-
if (text[i] === "\t") {
|
|
7291
|
-
if (keepContiguousPrefix && keptWidth + 3 <= targetWidth) {
|
|
7292
|
-
if (pendingAnsi) {
|
|
7293
|
-
result += pendingAnsi;
|
|
7294
|
-
pendingAnsi = "";
|
|
7295
|
-
}
|
|
7296
|
-
result += "\t";
|
|
7297
|
-
keptWidth += 3;
|
|
7298
|
-
} else {
|
|
7299
|
-
keepContiguousPrefix = false;
|
|
7300
|
-
pendingAnsi = "";
|
|
7301
|
-
}
|
|
7302
|
-
visibleSoFar += 3;
|
|
7303
|
-
if (visibleSoFar > maxWidth) {
|
|
7304
|
-
overflowed = true;
|
|
7305
|
-
break;
|
|
7306
|
-
}
|
|
7307
|
-
i++;
|
|
7308
|
-
continue;
|
|
7309
|
-
}
|
|
7310
|
-
let end = i;
|
|
7311
|
-
while (end < text.length && text[end] !== "\t") {
|
|
7312
|
-
const nextAnsi = extractAnsiCode(text, end);
|
|
7313
|
-
if (nextAnsi) {
|
|
7314
|
-
break;
|
|
7315
|
-
}
|
|
7316
|
-
end++;
|
|
7317
|
-
}
|
|
7318
|
-
for (const { segment } of graphemeSegmenter.segment(text.slice(i, end))) {
|
|
7319
|
-
const width = graphemeWidth(segment);
|
|
7320
|
-
if (keepContiguousPrefix && keptWidth + width <= targetWidth) {
|
|
7321
|
-
if (pendingAnsi) {
|
|
7322
|
-
result += pendingAnsi;
|
|
7323
|
-
pendingAnsi = "";
|
|
7324
|
-
}
|
|
7325
|
-
result += segment;
|
|
7326
|
-
keptWidth += width;
|
|
7327
|
-
} else {
|
|
7328
|
-
keepContiguousPrefix = false;
|
|
7329
|
-
pendingAnsi = "";
|
|
7330
|
-
}
|
|
7331
|
-
visibleSoFar += width;
|
|
7332
|
-
if (visibleSoFar > maxWidth) {
|
|
7333
|
-
overflowed = true;
|
|
7334
|
-
break;
|
|
7335
|
-
}
|
|
7336
|
-
}
|
|
7337
|
-
if (overflowed) {
|
|
7338
|
-
break;
|
|
7339
|
-
}
|
|
7340
|
-
i = end;
|
|
7341
|
-
}
|
|
7342
|
-
exhaustedInput = i >= text.length;
|
|
7343
|
-
}
|
|
7344
|
-
if (!overflowed && exhaustedInput) {
|
|
7345
|
-
return pad ? text + " ".repeat(Math.max(0, maxWidth - visibleSoFar)) : text;
|
|
7346
|
-
}
|
|
7347
|
-
return finalizeTruncatedResult(result, keptWidth, ellipsis, ellipsisWidth, maxWidth, pad);
|
|
7348
|
-
}
|
|
7349
|
-
var pooledStyleTracker = new AnsiCodeTracker;
|
|
7350
|
-
|
|
7351
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/autocomplete.js
|
|
7352
|
-
var PATH_DELIMITERS = new Set([" ", "\t", '"', "'", "="]);
|
|
7353
|
-
var tokenStartRegex = new RegExp(`${autocompleteBoundaryRegex.source}$`, "u");
|
|
7354
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/oklab.js
|
|
7355
|
-
var K1 = 0.206;
|
|
7356
|
-
var K2 = 0.03;
|
|
7357
|
-
var K3 = (1 + K1) / (1 + K2);
|
|
7358
|
-
|
|
7359
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/colors.js
|
|
7360
|
-
var NUMBER_PATTERN = String.raw`[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?`;
|
|
7361
|
-
var OKLCH_PATTERN = new RegExp(`^oklch\\(\\s*(${NUMBER_PATTERN})(%)?\\s+(${NUMBER_PATTERN})\\s+(${NUMBER_PATTERN})(?:deg)?\\s*\\)$`, "i");
|
|
7362
|
-
var OKHSL_PATTERN = new RegExp(`^okhsl\\(\\s*(${NUMBER_PATTERN})(?:deg)?\\s+(${NUMBER_PATTERN})(%)?\\s+(${NUMBER_PATTERN})(%)?\\s*\\)$`, "i");
|
|
7363
|
-
var GRAY_VALUES = Array.from({ length: 24 }, (_, index) => 8 + index * 10);
|
|
7364
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/keys.js
|
|
7365
|
-
var SYMBOL_KEYS = new Set([
|
|
7366
|
-
"`",
|
|
7367
|
-
"-",
|
|
7368
|
-
"=",
|
|
7369
|
-
"[",
|
|
7370
|
-
"]",
|
|
7371
|
-
"\\",
|
|
7372
|
-
";",
|
|
7373
|
-
"'",
|
|
7374
|
-
",",
|
|
7375
|
-
".",
|
|
7376
|
-
"/",
|
|
7377
|
-
"!",
|
|
7378
|
-
"@",
|
|
7379
|
-
"#",
|
|
7380
|
-
"$",
|
|
7381
|
-
"%",
|
|
7382
|
-
"^",
|
|
7383
|
-
"&",
|
|
7384
|
-
"*",
|
|
7385
|
-
"(",
|
|
7386
|
-
")",
|
|
7387
|
-
"_",
|
|
7388
|
-
"+",
|
|
7389
|
-
"|",
|
|
7390
|
-
"~",
|
|
7391
|
-
"{",
|
|
7392
|
-
"}",
|
|
7393
|
-
":",
|
|
7394
|
-
"<",
|
|
7395
|
-
">",
|
|
7396
|
-
"?"
|
|
7397
|
-
]);
|
|
7398
|
-
var SHIFTED_SYMBOL_KEYS = new Set("~!@#$%^&*()_+|{}:<>?");
|
|
7399
|
-
var MODIFIERS = {
|
|
7400
|
-
shift: 1,
|
|
7401
|
-
alt: 2,
|
|
7402
|
-
ctrl: 4,
|
|
7403
|
-
super: 8
|
|
7404
|
-
};
|
|
7405
|
-
var LOCK_MASK = 64 + 128;
|
|
7406
|
-
var ARROW_CODEPOINTS = {
|
|
7407
|
-
up: -1,
|
|
7408
|
-
down: -2,
|
|
7409
|
-
right: -3,
|
|
7410
|
-
left: -4
|
|
7411
|
-
};
|
|
7412
|
-
var FUNCTIONAL_CODEPOINTS = {
|
|
7413
|
-
delete: -10,
|
|
7414
|
-
insert: -11,
|
|
7415
|
-
pageUp: -12,
|
|
7416
|
-
pageDown: -13,
|
|
7417
|
-
home: -14,
|
|
7418
|
-
end: -15
|
|
7419
|
-
};
|
|
7420
|
-
var KITTY_FUNCTIONAL_KEY_EQUIVALENTS = new Map([
|
|
7421
|
-
[57399, 48],
|
|
7422
|
-
[57400, 49],
|
|
7423
|
-
[57401, 50],
|
|
7424
|
-
[57402, 51],
|
|
7425
|
-
[57403, 52],
|
|
7426
|
-
[57404, 53],
|
|
7427
|
-
[57405, 54],
|
|
7428
|
-
[57406, 55],
|
|
7429
|
-
[57407, 56],
|
|
7430
|
-
[57408, 57],
|
|
7431
|
-
[57409, 46],
|
|
7432
|
-
[57410, 47],
|
|
7433
|
-
[57411, 42],
|
|
7434
|
-
[57412, 45],
|
|
7435
|
-
[57413, 43],
|
|
7436
|
-
[57415, 61],
|
|
7437
|
-
[57416, 44],
|
|
7438
|
-
[57417, ARROW_CODEPOINTS.left],
|
|
7439
|
-
[57418, ARROW_CODEPOINTS.right],
|
|
7440
|
-
[57419, ARROW_CODEPOINTS.up],
|
|
7441
|
-
[57420, ARROW_CODEPOINTS.down],
|
|
7442
|
-
[57421, FUNCTIONAL_CODEPOINTS.pageUp],
|
|
7443
|
-
[57422, FUNCTIONAL_CODEPOINTS.pageDown],
|
|
7444
|
-
[57423, FUNCTIONAL_CODEPOINTS.home],
|
|
7445
|
-
[57424, FUNCTIONAL_CODEPOINTS.end],
|
|
7446
|
-
[57425, FUNCTIONAL_CODEPOINTS.insert],
|
|
7447
|
-
[57426, FUNCTIONAL_CODEPOINTS.delete]
|
|
7448
|
-
]);
|
|
7449
|
-
var KITTY_PRINTABLE_ALLOWED_MODIFIERS = MODIFIERS.shift | LOCK_MASK;
|
|
7450
|
-
|
|
7451
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/terminal-image.js
|
|
7452
|
-
var kittyImageMetadata = new Map;
|
|
7453
|
-
var KITTY_PLACEMENT_CONTROL_KEYS = new Set([
|
|
7454
|
-
"i",
|
|
7455
|
-
"p",
|
|
7456
|
-
"x",
|
|
7457
|
-
"y",
|
|
7458
|
-
"w",
|
|
7459
|
-
"h",
|
|
7460
|
-
"X",
|
|
7461
|
-
"Y",
|
|
7462
|
-
"c",
|
|
7463
|
-
"r",
|
|
7464
|
-
"C",
|
|
7465
|
-
"U",
|
|
7466
|
-
"z",
|
|
7467
|
-
"P",
|
|
7468
|
-
"Q",
|
|
7469
|
-
"H",
|
|
7470
|
-
"V"
|
|
7471
|
-
]);
|
|
7472
|
-
|
|
7473
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/tui.js
|
|
7474
|
-
var TERMINAL_PALETTE_SIZE = 16;
|
|
7475
|
-
var TERMINAL_COLOR_REPLY_COUNT = 2 + TERMINAL_PALETTE_SIZE;
|
|
7476
|
-
var TERMINAL_COLOR_QUERY = `\x1B]10;?\x07\x1B]11;?\x07${Array.from({ length: TERMINAL_PALETTE_SIZE }, (_, index) => `\x1B]4;${index};?\x07`).join("")}\x1B[c`;
|
|
7477
|
-
var VIEWPORT_TUI = Symbol.for("@earendil-works/pi-tui/viewport");
|
|
7478
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/word-navigation.js
|
|
7479
|
-
var wordSegmenter2 = getWordSegmenter();
|
|
7480
|
-
|
|
7481
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/components/editor.js
|
|
7482
|
-
var graphemeSegmenter2 = getGraphemeSegmenter();
|
|
7483
|
-
var wordSegmenter3 = getWordSegmenter();
|
|
7484
|
-
var unquotedAutocompleteSuffixRegex = new RegExp(`(?:(?!${autocompleteSeparatorRegex.source}).)*`, "u");
|
|
7485
|
-
var autocompleteTokenStartSource = `${autocompleteBoundaryRegex.source}[([{<\`]*`;
|
|
7486
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/layout-node.js
|
|
7487
|
-
var LAYOUT_NODE = Symbol.for("@earendil-works/pi-tui/layout-node");
|
|
7488
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/components/image.js
|
|
7489
|
-
var pngCache = new Map;
|
|
7490
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/components/input.js
|
|
7491
|
-
var segmenter = getGraphemeSegmenter();
|
|
7492
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/latex.js
|
|
7493
|
-
var NAMED_OPERATORS = new Set([
|
|
7494
|
-
"arccos",
|
|
7495
|
-
"arcsin",
|
|
7496
|
-
"arctan",
|
|
7497
|
-
"arg",
|
|
7498
|
-
"cos",
|
|
7499
|
-
"cosh",
|
|
7500
|
-
"cot",
|
|
7501
|
-
"coth",
|
|
7502
|
-
"csc",
|
|
7503
|
-
"deg",
|
|
7504
|
-
"det",
|
|
7505
|
-
"dim",
|
|
7506
|
-
"exp",
|
|
7507
|
-
"gcd",
|
|
7508
|
-
"hom",
|
|
7509
|
-
"inf",
|
|
7510
|
-
"ker",
|
|
7511
|
-
"lg",
|
|
7512
|
-
"lim",
|
|
7513
|
-
"liminf",
|
|
7514
|
-
"limsup",
|
|
7515
|
-
"ln",
|
|
7516
|
-
"log",
|
|
7517
|
-
"max",
|
|
7518
|
-
"min",
|
|
7519
|
-
"Pr",
|
|
7520
|
-
"sec",
|
|
7521
|
-
"sin",
|
|
7522
|
-
"sinh",
|
|
7523
|
-
"sup",
|
|
7524
|
-
"tan",
|
|
7525
|
-
"tanh"
|
|
7526
|
-
]);
|
|
7527
|
-
var LIMIT_OPERATORS = new Set([
|
|
7528
|
-
"argmax",
|
|
7529
|
-
"argmin",
|
|
7530
|
-
"inf",
|
|
7531
|
-
"injlim",
|
|
7532
|
-
"lim",
|
|
7533
|
-
"liminf",
|
|
7534
|
-
"limsup",
|
|
7535
|
-
"max",
|
|
7536
|
-
"min",
|
|
7537
|
-
"projlim",
|
|
7538
|
-
"sup"
|
|
7539
|
-
]);
|
|
7540
|
-
var DISPLAY_LIMIT_SYMBOLS = new Set([
|
|
7541
|
-
"bigcap",
|
|
7542
|
-
"bigcup",
|
|
7543
|
-
"bigodot",
|
|
7544
|
-
"bigoplus",
|
|
7545
|
-
"bigotimes",
|
|
7546
|
-
"bigsqcup",
|
|
7547
|
-
"biguplus",
|
|
7548
|
-
"bigvee",
|
|
7549
|
-
"bigwedge",
|
|
7550
|
-
"coprod",
|
|
7551
|
-
"int",
|
|
7552
|
-
"iint",
|
|
7553
|
-
"iiint",
|
|
7554
|
-
"oint",
|
|
7555
|
-
"prod",
|
|
7556
|
-
"sum"
|
|
7557
|
-
]);
|
|
7558
|
-
var RELATION_COMMANDS = new Set([
|
|
7559
|
-
"Leftarrow",
|
|
7560
|
-
"Leftrightarrow",
|
|
7561
|
-
"Longleftarrow",
|
|
7562
|
-
"Longleftrightarrow",
|
|
7563
|
-
"Longrightarrow",
|
|
7564
|
-
"Rightarrow",
|
|
7565
|
-
"Join",
|
|
7566
|
-
"Vdash",
|
|
7567
|
-
"Vvdash",
|
|
7568
|
-
"approx",
|
|
7569
|
-
"asymp",
|
|
7570
|
-
"bowtie",
|
|
7571
|
-
"cong",
|
|
7572
|
-
"dashv",
|
|
7573
|
-
"fullouterjoin",
|
|
7574
|
-
"doteq",
|
|
7575
|
-
"downarrow",
|
|
7576
|
-
"equiv",
|
|
7577
|
-
"ge",
|
|
7578
|
-
"geq",
|
|
7579
|
-
"geqslant",
|
|
7580
|
-
"gets",
|
|
7581
|
-
"gg",
|
|
7582
|
-
"hookleftarrow",
|
|
7583
|
-
"hookrightarrow",
|
|
7584
|
-
"iff",
|
|
7585
|
-
"implies",
|
|
7586
|
-
"in",
|
|
7587
|
-
"leadsto",
|
|
7588
|
-
"le",
|
|
7589
|
-
"leftarrow",
|
|
7590
|
-
"leftharpoondown",
|
|
7591
|
-
"leftharpoonup",
|
|
7592
|
-
"leftrightarrow",
|
|
7593
|
-
"leftrightharpoons",
|
|
7594
|
-
"leftouterjoin",
|
|
7595
|
-
"leq",
|
|
7596
|
-
"leqslant",
|
|
7597
|
-
"ll",
|
|
7598
|
-
"longleftarrow",
|
|
7599
|
-
"longleftrightarrow",
|
|
7600
|
-
"longmapsto",
|
|
7601
|
-
"longrightarrow",
|
|
7602
|
-
"ltimes",
|
|
7603
|
-
"mapsto",
|
|
7604
|
-
"mid",
|
|
7605
|
-
"models",
|
|
7606
|
-
"ne",
|
|
7607
|
-
"nearrow",
|
|
7608
|
-
"neq",
|
|
7609
|
-
"ni",
|
|
7610
|
-
"notin",
|
|
7611
|
-
"nvdash",
|
|
7612
|
-
"nvDash",
|
|
7613
|
-
"nwarrow",
|
|
7614
|
-
"parallel",
|
|
7615
|
-
"perp",
|
|
7616
|
-
"prec",
|
|
7617
|
-
"preceq",
|
|
7618
|
-
"propto",
|
|
7619
|
-
"rightharpoondown",
|
|
7620
|
-
"rightharpoonup",
|
|
7621
|
-
"rightleftharpoons",
|
|
7622
|
-
"rightouterjoin",
|
|
7623
|
-
"rightarrow",
|
|
7624
|
-
"rightsquigarrow",
|
|
7625
|
-
"rtimes",
|
|
7626
|
-
"searrow",
|
|
7627
|
-
"sim",
|
|
7628
|
-
"simeq",
|
|
7629
|
-
"sqsubset",
|
|
7630
|
-
"sqsubseteq",
|
|
7631
|
-
"sqsupset",
|
|
7632
|
-
"sqsupseteq",
|
|
7633
|
-
"subset",
|
|
7634
|
-
"subseteq",
|
|
7635
|
-
"succ",
|
|
7636
|
-
"succeq",
|
|
7637
|
-
"supset",
|
|
7638
|
-
"supseteq",
|
|
7639
|
-
"swarrow",
|
|
7640
|
-
"to",
|
|
7641
|
-
"triangleleft",
|
|
7642
|
-
"triangleright",
|
|
7643
|
-
"twoheadleftarrow",
|
|
7644
|
-
"twoheadrightarrow",
|
|
7645
|
-
"uparrow",
|
|
7646
|
-
"vdash"
|
|
7647
|
-
]);
|
|
7648
|
-
var SPACING_COMMANDS = new Set([
|
|
7649
|
-
",",
|
|
7650
|
-
":",
|
|
7651
|
-
";",
|
|
7652
|
-
" ",
|
|
7653
|
-
">",
|
|
7654
|
-
"enspace",
|
|
7655
|
-
"enskip",
|
|
7656
|
-
"medspace",
|
|
7657
|
-
"quad",
|
|
7658
|
-
"qquad",
|
|
7659
|
-
"thickspace",
|
|
7660
|
-
"thinspace"
|
|
7661
|
-
]);
|
|
7662
|
-
var NEGATIVE_SPACING_COMMANDS = new Set(["!", "negmedspace", "negthickspace", "negthinspace"]);
|
|
7663
|
-
var FONT_SWITCH_COMMANDS = new Set(["bf", "cal", "it", "rm", "sf", "sl", "tt"]);
|
|
7664
|
-
var IGNORED_COMMANDS = new Set([
|
|
7665
|
-
"displaystyle",
|
|
7666
|
-
"limits",
|
|
7667
|
-
"nolimits",
|
|
7668
|
-
"scriptstyle",
|
|
7669
|
-
"scriptscriptstyle",
|
|
7670
|
-
"textstyle"
|
|
7671
|
-
]);
|
|
7672
|
-
var SIZE_COMMANDS = new Set([
|
|
7673
|
-
"big",
|
|
7674
|
-
"Big",
|
|
7675
|
-
"bigg",
|
|
7676
|
-
"Bigg",
|
|
7677
|
-
"bigl",
|
|
7678
|
-
"Bigl",
|
|
7679
|
-
"biggl",
|
|
7680
|
-
"Biggl",
|
|
7681
|
-
"bigr",
|
|
7682
|
-
"Bigr",
|
|
7683
|
-
"biggr",
|
|
7684
|
-
"Biggr"
|
|
7685
|
-
]);
|
|
7686
|
-
var PLAIN_WRAPPERS = new Set([
|
|
7687
|
-
"emph",
|
|
7688
|
-
"mathcal",
|
|
7689
|
-
"mathbf",
|
|
7690
|
-
"mathfrak",
|
|
7691
|
-
"mathit",
|
|
7692
|
-
"mathrm",
|
|
7693
|
-
"mathnormal",
|
|
7694
|
-
"mathscr",
|
|
7695
|
-
"mathsf",
|
|
7696
|
-
"mathtt",
|
|
7697
|
-
"mathup",
|
|
7698
|
-
"mbox",
|
|
7699
|
-
"overbrace",
|
|
7700
|
-
"pmb",
|
|
7701
|
-
"smash",
|
|
7702
|
-
"substack",
|
|
7703
|
-
"text",
|
|
7704
|
-
"textbf",
|
|
7705
|
-
"textit",
|
|
7706
|
-
"textmd",
|
|
7707
|
-
"textnormal",
|
|
7708
|
-
"textrm",
|
|
7709
|
-
"textsc",
|
|
7710
|
-
"textsf",
|
|
7711
|
-
"textsl",
|
|
7712
|
-
"texttt",
|
|
7713
|
-
"textup",
|
|
7714
|
-
"underbrace",
|
|
7715
|
-
"bm",
|
|
7716
|
-
"boldsymbol"
|
|
7717
|
-
]);
|
|
7718
|
-
|
|
7719
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/components/markdown.js
|
|
7720
|
-
var STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
|
7721
|
-
|
|
7722
|
-
class StrictStrikethroughTokenizer extends y {
|
|
7723
|
-
del(src) {
|
|
7724
|
-
const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
|
|
7725
|
-
if (!match) {
|
|
7726
|
-
return;
|
|
7727
|
-
}
|
|
7728
|
-
const text = match[2];
|
|
7729
|
-
return {
|
|
7730
|
-
type: "del",
|
|
7731
|
-
raw: match[0],
|
|
7732
|
-
text,
|
|
7733
|
-
tokens: this.lexer.inlineTokens(text)
|
|
7734
|
-
};
|
|
7735
|
-
}
|
|
7736
|
-
}
|
|
7737
|
-
function isEscaped(source, index) {
|
|
7738
|
-
let backslashes = 0;
|
|
7739
|
-
for (let position = index - 1;position >= 0 && source[position] === "\\"; position--) {
|
|
7740
|
-
backslashes++;
|
|
7741
|
-
}
|
|
7742
|
-
return backslashes % 2 === 1;
|
|
7743
|
-
}
|
|
7744
|
-
function findClosingDelimiter(source, closing, start) {
|
|
7745
|
-
let index = source.indexOf(closing, start);
|
|
7746
|
-
while (index >= 0 && isEscaped(source, index)) {
|
|
7747
|
-
index = source.indexOf(closing, index + closing.length);
|
|
7748
|
-
}
|
|
7749
|
-
return index;
|
|
7750
|
-
}
|
|
7751
|
-
function looksLikePendingDollarMath(source) {
|
|
7752
|
-
return /\\[A-Za-z]+|[_^=+*/<>()[\]|±≤≥≠≈∈→⇒∞∫∑√-]/.test(source);
|
|
7753
|
-
}
|
|
7754
|
-
function tokenizeInlineLatex(source) {
|
|
7755
|
-
let opening = "";
|
|
7756
|
-
let closing = "";
|
|
7757
|
-
if (source.startsWith("$$")) {
|
|
7758
|
-
opening = "$$";
|
|
7759
|
-
closing = "$$";
|
|
7760
|
-
} else if (source.startsWith("\\(")) {
|
|
7761
|
-
opening = "\\(";
|
|
7762
|
-
closing = "\\)";
|
|
7763
|
-
} else if (source.startsWith("\\[")) {
|
|
7764
|
-
opening = "\\[";
|
|
7765
|
-
closing = "\\]";
|
|
7766
|
-
} else if (source.startsWith("$") && !/^\$\s/.test(source)) {
|
|
7767
|
-
opening = "$";
|
|
7768
|
-
closing = "$";
|
|
7769
|
-
} else {
|
|
7770
|
-
return;
|
|
7771
|
-
}
|
|
7772
|
-
const closingIndex = findClosingDelimiter(source, closing, opening.length);
|
|
7773
|
-
if (closingIndex >= 0 && opening === "$" && (/\s$/.test(source.slice(opening.length, closingIndex)) || /^\d/.test(source.slice(closingIndex + 1)) || /^[A-Z_][A-Z0-9_]*(?:[^A-Za-z0-9_\s])?$/.test(source.slice(opening.length, closingIndex)) && /^[A-Za-z_][A-Za-z0-9_]*/.test(source.slice(closingIndex + 1)) || source.slice(opening.length, closingIndex).includes("`"))) {
|
|
7774
|
-
return;
|
|
7775
|
-
}
|
|
7776
|
-
if (closingIndex < 0) {
|
|
7777
|
-
const pendingSource = source.slice(opening.length);
|
|
7778
|
-
if (opening.startsWith("\\") || looksLikePendingDollarMath(pendingSource)) {
|
|
7779
|
-
return { type: "latex", raw: source, text: pendingSource, pending: true };
|
|
7780
|
-
}
|
|
7781
|
-
return;
|
|
7782
|
-
}
|
|
7783
|
-
const text = source.slice(opening.length, closingIndex);
|
|
7784
|
-
if (!text || text.includes(`
|
|
7785
|
-
`)) {
|
|
7786
|
-
return;
|
|
7787
|
-
}
|
|
7788
|
-
const raw = source.slice(0, closingIndex + closing.length);
|
|
7789
|
-
return { type: "latex", raw, text };
|
|
7790
|
-
}
|
|
7791
|
-
function tokenizeBlockLatex(source) {
|
|
7792
|
-
const dollarMatch = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*?)\$\$[ \t]*(?:\n|$)/.exec(source);
|
|
7793
|
-
if (dollarMatch?.[1]) {
|
|
7794
|
-
return { type: "latexBlock", raw: dollarMatch[0], text: dollarMatch[1].trim() };
|
|
7795
|
-
}
|
|
7796
|
-
const bracketMatch = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*?)\\\][ \t]*(?:\n|$)/.exec(source);
|
|
7797
|
-
if (bracketMatch?.[1]) {
|
|
7798
|
-
return { type: "latexBlock", raw: bracketMatch[0], text: bracketMatch[1].trim() };
|
|
7799
|
-
}
|
|
7800
|
-
const pendingBracket = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
|
|
7801
|
-
if (pendingBracket) {
|
|
7802
|
-
return { type: "latexBlock", raw: pendingBracket[0], text: pendingBracket[1], pending: true };
|
|
7803
|
-
}
|
|
7804
|
-
const pendingDollar = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
|
|
7805
|
-
if (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1])) {
|
|
7806
|
-
return { type: "latexBlock", raw: pendingDollar[0], text: pendingDollar[1], pending: true };
|
|
7807
|
-
}
|
|
7808
|
-
return;
|
|
7809
|
-
}
|
|
7810
|
-
var LATEX_MARKDOWN_EXTENSIONS = [
|
|
7811
|
-
{
|
|
7812
|
-
name: "latexBlock",
|
|
7813
|
-
level: "block",
|
|
7814
|
-
start(source) {
|
|
7815
|
-
const match = /(?:^|\n) {0,3}(?:\$\$|\\\[)/.exec(source);
|
|
7816
|
-
return match ? match.index + (match[0].startsWith(`
|
|
7817
|
-
`) ? 1 : 0) : undefined;
|
|
7818
|
-
},
|
|
7819
|
-
tokenizer: tokenizeBlockLatex
|
|
7820
|
-
},
|
|
7821
|
-
{
|
|
7822
|
-
name: "latex",
|
|
7823
|
-
level: "inline",
|
|
7824
|
-
start(source) {
|
|
7825
|
-
const indices = [source.indexOf("$"), source.indexOf("\\("), source.indexOf("\\[")].filter((index) => index >= 0);
|
|
7826
|
-
return indices.length > 0 ? Math.min(...indices) : undefined;
|
|
7827
|
-
},
|
|
7828
|
-
tokenizer: tokenizeInlineLatex
|
|
7829
|
-
}
|
|
7830
|
-
];
|
|
7831
|
-
var markdownParser = new Z;
|
|
7832
|
-
markdownParser.setOptions({
|
|
7833
|
-
tokenizer: new StrictStrikethroughTokenizer
|
|
7834
|
-
});
|
|
7835
|
-
markdownParser.use({ extensions: [...LATEX_MARKDOWN_EXTENSIONS] });
|
|
7836
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/native-platform.js
|
|
7837
|
-
import { createRequire as createRequire2 } from "node:module";
|
|
7838
|
-
|
|
7839
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/native-module-path.js
|
|
7840
|
-
import { createRequire } from "node:module";
|
|
7841
|
-
var moduleRequire = createRequire(import.meta.url);
|
|
7842
|
-
|
|
7843
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/native-platform.js
|
|
7844
|
-
var cjsRequire = createRequire2(import.meta.url);
|
|
7845
|
-
var helpers = new Map;
|
|
7846
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/terminal.js
|
|
7847
|
-
var DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;
|
|
7848
|
-
var KITTY_KEYBOARD_PROTOCOL_QUERY = `\x1B[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\x1B[?u`;
|
|
7849
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js
|
|
7850
|
-
var segmenter2 = getGraphemeSegmenter();
|
|
7851
|
-
|
|
7852
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js
|
|
7853
|
-
var MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES = 32 * 1024 * 1024;
|
|
7854
|
-
var MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES = 64 * 1024 * 1024;
|
|
7855
|
-
var TERMINAL_WORD_SELECTION_JOINERS = new Set(["/", "-"]);
|
|
7856
|
-
var wordSegmenter4 = getWordSegmenter();
|
|
7857
|
-
// ../../node_modules/.bun/@earendil-works+pi-tui@1.2.0/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js
|
|
7858
|
-
var MAX_RENDER_WRITE_CHARS = 1024 * 1024;
|
|
7859
|
-
// ../pi-ads/src/style.ts
|
|
5282
|
+
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
7860
5283
|
var OSC_RE = /\x1b\][\s\S]*?(?:\x07|\x1b\\)/g;
|
|
7861
5284
|
var CSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
7862
5285
|
var C1_RE = /[\x80-\x9f]/g;
|
|
@@ -8586,8 +6009,10 @@ function createUsageToolExtension(opts) {
|
|
|
8586
6009
|
|
|
8587
6010
|
// src/image-tool.ts
|
|
8588
6011
|
import { randomBytes } from "node:crypto";
|
|
6012
|
+
import { readFileSync as readFileSync2, statSync } from "node:fs";
|
|
8589
6013
|
import { mkdir as mkdir2, open } from "node:fs/promises";
|
|
8590
6014
|
import { join as join3 } from "node:path";
|
|
6015
|
+
import { getCapabilities, Image, Text } from "@earendil-works/pi-tui";
|
|
8591
6016
|
var IMAGE_TOOL_NAME = "generate_image";
|
|
8592
6017
|
var MAX_BYTES = 8 * 1024 * 1024;
|
|
8593
6018
|
var TIMEOUT_MS = 120000;
|
|
@@ -8633,6 +6058,36 @@ async function post(opts, body, signal) {
|
|
|
8633
6058
|
function slug(s) {
|
|
8634
6059
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+/, "").slice(0, 40).replace(/-+$/, "") || "image";
|
|
8635
6060
|
}
|
|
6061
|
+
var MIME = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" };
|
|
6062
|
+
var SAFE_PATH = /^images\/[a-z0-9-]+-[0-9a-f]{6}\.(png|jpg|webp)$/;
|
|
6063
|
+
var MAX_CELLS_W = 60;
|
|
6064
|
+
var MAX_CELLS_H = 40;
|
|
6065
|
+
function renderImageResult(res, ctx, theme) {
|
|
6066
|
+
const d = res.details;
|
|
6067
|
+
const text = d?.ok && d.path ? `Saved image to ${d.path}` : res.content.find((c) => c.type === "text")?.text ?? "";
|
|
6068
|
+
const textBlock = new Text(theme.fg("toolOutput", text), 0, 0);
|
|
6069
|
+
let img;
|
|
6070
|
+
if (d?.ok && d.path && SAFE_PATH.test(d.path) && ctx.showImages && getCapabilities().images) {
|
|
6071
|
+
try {
|
|
6072
|
+
const st = ctx.state;
|
|
6073
|
+
if (st.path !== d.path) {
|
|
6074
|
+
const ext = d.path.split(".").pop() ?? "";
|
|
6075
|
+
const mime = Object.hasOwn(MIME, ext) ? MIME[ext] : undefined;
|
|
6076
|
+
const file = join3(ctx.cwd, d.path);
|
|
6077
|
+
st.path = d.path;
|
|
6078
|
+
st.img = mime && statSync(file).size <= MAX_BYTES ? new Image(readFileSync2(file).toString("base64"), mime, { fallbackColor: (s) => theme.fg("toolOutput", s) }, { maxWidthCells: MAX_CELLS_W, maxHeightCells: MAX_CELLS_H }) : undefined;
|
|
6079
|
+
}
|
|
6080
|
+
img = st.img;
|
|
6081
|
+
} catch {}
|
|
6082
|
+
}
|
|
6083
|
+
return {
|
|
6084
|
+
render: (w) => img ? [...textBlock.render(w), "", ...img.render(w)] : textBlock.render(w),
|
|
6085
|
+
invalidate: () => {
|
|
6086
|
+
textBlock.invalidate();
|
|
6087
|
+
img?.invalidate();
|
|
6088
|
+
}
|
|
6089
|
+
};
|
|
6090
|
+
}
|
|
8636
6091
|
var done = (text, details) => ({ content: [{ type: "text", text }], details });
|
|
8637
6092
|
var fail = (text) => done(text, { ok: false });
|
|
8638
6093
|
function createImageToolExtension(opts) {
|
|
@@ -8650,6 +6105,7 @@ function createImageToolExtension(opts) {
|
|
|
8650
6105
|
aspect_ratio: Optional(Union([Literal("1:1"), Literal("16:9"), Literal("9:16"), Literal("4:3"), Literal("3:2")], { description: "Default 1:1" })),
|
|
8651
6106
|
name: Optional(String2({ maxLength: 60, description: "Short file name hint, e.g. hero-banner; used only for the saved file's name" }))
|
|
8652
6107
|
}),
|
|
6108
|
+
renderResult: (res, _opts, theme, ctx) => renderImageResult(res, ctx, theme),
|
|
8653
6109
|
async execute(_id, params, signal) {
|
|
8654
6110
|
const r = await post(opts, { prompt: params.prompt, ...params.aspect_ratio ? { aspect_ratio: params.aspect_ratio } : {} }, signal);
|
|
8655
6111
|
if (!r.ok)
|
|
@@ -9459,6 +6915,12 @@ function installFooterRightAlign(mode) {
|
|
|
9459
6915
|
|
|
9460
6916
|
// src/changelog.ts
|
|
9461
6917
|
var CHANGELOG_HIGHLIGHTS = [
|
|
6918
|
+
{
|
|
6919
|
+
version: "0.4.10",
|
|
6920
|
+
highlights: [
|
|
6921
|
+
"Images you generate now show right in your terminal (iTerm2, Kitty, Ghostty, WezTerm, Warp). Other terminals still get the saved file path."
|
|
6922
|
+
]
|
|
6923
|
+
},
|
|
9462
6924
|
{
|
|
9463
6925
|
version: "0.4.9",
|
|
9464
6926
|
highlights: [
|
|
@@ -10528,12 +7990,12 @@ ${INTRO_TEXT}
|
|
|
10528
7990
|
}
|
|
10529
7991
|
|
|
10530
7992
|
// src/whats-new.ts
|
|
10531
|
-
import { existsSync as existsSync3, mkdirSync, readFileSync as
|
|
7993
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
10532
7994
|
import { dirname as dirname4 } from "node:path";
|
|
10533
7995
|
function maybeWhatsNew(cliVersion, agentDir) {
|
|
10534
7996
|
try {
|
|
10535
7997
|
const path = getLastSeenVersionPath(agentDir);
|
|
10536
|
-
const lastSeen = existsSync3(path) ?
|
|
7998
|
+
const lastSeen = existsSync3(path) ? readFileSync3(path, "utf-8").trim() : undefined;
|
|
10537
7999
|
writeLastSeen(path, cliVersion);
|
|
10538
8000
|
if (lastSeen === undefined)
|
|
10539
8001
|
return;
|