@hasna/instructions 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,6 +151,1341 @@ import { createHash as createHash6 } from "crypto";
151
151
  import { createHash as createHash5 } from "crypto";
152
152
  import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync as realpathSync2, statSync as statSync3 } from "fs";
153
153
  import { homedir as homedir4 } from "os";
154
+
155
+ // ../../node_modules/.bun/marked@18.0.5/node_modules/marked/lib/marked.esm.js
156
+ function M() {
157
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
158
+ }
159
+ var T = M();
160
+ function N(l) {
161
+ T = l;
162
+ }
163
+ var _ = { exec: () => null };
164
+ function E(l) {
165
+ let e = [];
166
+ return (t) => {
167
+ let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
168
+ return s || (s = l(n), e[n] = s), s;
169
+ };
170
+ }
171
+ function d(l, e = "") {
172
+ let t = typeof l == "string" ? l : l.source, n = { replace: (s, r) => {
173
+ let i = typeof r == "string" ? r : r.source;
174
+ return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
175
+ }, getRegex: () => new RegExp(t, e) };
176
+ return n;
177
+ }
178
+ var Te = ((l = "") => {
179
+ try {
180
+ return !!new RegExp("(?<=1)(?<!1)" + l);
181
+ } catch {
182
+ return false;
183
+ }
184
+ })();
185
+ 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: E((l) => new RegExp(`^ {0,${l}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: E((l) => new RegExp(`^ {0,${l}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: E((l) => new RegExp(`^ {0,${l}}(?:\`\`\`|~~~)`)), headingBeginRegex: E((l) => new RegExp(`^ {0,${l}}#`)), htmlBeginRegex: E((l) => new RegExp(`^ {0,${l}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: E((l) => new RegExp(`^ {0,${l}}>`)) };
186
+ var Oe = /^(?:[ \t]*(?:\n|$))+/;
187
+ var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
188
+ var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
189
+ var B = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
190
+ var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
191
+ var j = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
192
+ var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
193
+ var ae = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
194
+ var Se = d(oe).replace(/bull/g, j).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
195
+ var F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
196
+ var $e = /^[^\n]+/;
197
+ var U = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
198
+ var Le = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
199
+ var _e = d(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, j).getRegex();
200
+ var H = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
201
+ var K = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
202
+ var ze = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \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", K).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
203
+ var le = d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
204
+ var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", le).getRegex();
205
+ var W = { blockquote: Me, code: we, def: Le, fences: ye, heading: Pe, hr: B, html: ze, lheading: ae, list: _e, newline: Oe, paragraph: le, table: _, text: $e };
206
+ var se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex();
207
+ var Ee = { ...W, lheading: Se, table: se, paragraph: d(F).replace("hr", B).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex() };
208
+ var Ie = { ...W, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", K).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(F).replace("hr", B).replace("heading", ` *#{1,6} *[^
209
+ ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
210
+ var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
211
+ var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
212
+ var ue = /^( {2,}|\\)\n(?!\s*$)/;
213
+ var Be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
214
+ var I = /[\p{P}\p{S}]/u;
215
+ var Z = /[\s\p{P}\p{S}]/u;
216
+ var X = /[^\s\p{P}\p{S}]/u;
217
+ var De = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex();
218
+ var pe = /(?!~)[\p{P}\p{S}]/u;
219
+ var qe = /(?!~)[\s\p{P}\p{S}]/u;
220
+ var ve = /(?:[^\s\p{P}\p{S}]|~)/u;
221
+ var He = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
222
+ var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
223
+ var Ze = d(ce, "u").replace(/punct/g, I).getRegex();
224
+ var Ge = d(ce, "u").replace(/punct/g, pe).getRegex();
225
+ var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
226
+ var Ne = d(he, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
227
+ var Qe = d(he, "gu").replace(/notPunctSpace/g, ve).replace(/punctSpace/g, qe).replace(/punct/g, pe).getRegex();
228
+ var je = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
229
+ var Fe = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, I).getRegex();
230
+ var Ue = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
231
+ var Ke = d(Ue, "gu").replace(/notPunctSpace/g, X).replace(/punctSpace/g, Z).replace(/punct/g, I).getRegex();
232
+ var We = d(/\\(punct)/, "gu").replace(/punct/g, I).getRegex();
233
+ var Xe = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
234
+ var Je = d(K).replace("(?:-->|$)", "-->").getRegex();
235
+ var Ve = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
236
+ var v = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
237
+ var Ye = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", v).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
238
+ var ke = d(/^!?\[(label)\]\[(ref)\]/).replace("label", v).replace("ref", U).getRegex();
239
+ var de = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex();
240
+ var et = d("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
241
+ var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
242
+ var J = { _backpedal: _, anyPunctuation: We, autolink: Xe, blockSkip: He, br: ue, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: Ze, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Ae, link: Ye, nolink: de, punctuation: De, reflink: ke, reflinkSearch: et, tag: Ve, text: Be, url: _ };
243
+ var tt = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", v).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", v).getRegex() };
244
+ var Q = { ...J, emStrongRDelimAst: Qe, emStrongLDelim: Ge, delLDelim: Fe, delRDelim: Ke, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
245
+ var nt = { ...Q, br: d(ue).replace("{2,}", "*").getRegex(), text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
246
+ var D = { normal: W, gfm: Ee, pedantic: Ie };
247
+ var A = { normal: J, gfm: Q, breaks: nt, pedantic: tt };
248
+ var rt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
249
+ var ge = (l) => rt[l];
250
+ function O(l, e) {
251
+ if (e) {
252
+ if (m.escapeTest.test(l))
253
+ return l.replace(m.escapeReplace, ge);
254
+ } else if (m.escapeTestNoEncode.test(l))
255
+ return l.replace(m.escapeReplaceNoEncode, ge);
256
+ return l;
257
+ }
258
+ function V(l) {
259
+ try {
260
+ l = encodeURI(l).replace(m.percentDecode, "%");
261
+ } catch {
262
+ return null;
263
+ }
264
+ return l;
265
+ }
266
+ function Y(l, e) {
267
+ let t = l.replace(m.findPipe, (r, i, o) => {
268
+ let u = false, a = i;
269
+ for (;--a >= 0 && o[a] === "\\"; )
270
+ u = !u;
271
+ return u ? "|" : " |";
272
+ }), n = t.split(m.splitPipe), s = 0;
273
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
274
+ if (n.length > e)
275
+ n.splice(e);
276
+ else
277
+ for (;n.length < e; )
278
+ n.push("");
279
+ for (;s < n.length; s++)
280
+ n[s] = n[s].trim().replace(m.slashPipe, "|");
281
+ return n;
282
+ }
283
+ function $(l, e, t) {
284
+ let n = l.length;
285
+ if (n === 0)
286
+ return "";
287
+ let s = 0;
288
+ for (;s < n; ) {
289
+ let r = l.charAt(n - s - 1);
290
+ if (r === e && !t)
291
+ s++;
292
+ else if (r !== e && t)
293
+ s++;
294
+ else
295
+ break;
296
+ }
297
+ return l.slice(0, n - s);
298
+ }
299
+ function ee(l) {
300
+ let e = l.split(`
301
+ `), t = e.length - 1;
302
+ for (;t >= 0 && m.blankLine.test(e[t]); )
303
+ t--;
304
+ return e.length - t <= 2 ? l : e.slice(0, t + 1).join(`
305
+ `);
306
+ }
307
+ function fe(l, e) {
308
+ if (l.indexOf(e[1]) === -1)
309
+ return -1;
310
+ let t = 0;
311
+ for (let n = 0;n < l.length; n++)
312
+ if (l[n] === "\\")
313
+ n++;
314
+ else if (l[n] === e[0])
315
+ t++;
316
+ else if (l[n] === e[1] && (t--, t < 0))
317
+ return n;
318
+ return t > 0 ? -2 : -1;
319
+ }
320
+ function me(l, e = 0) {
321
+ let t = e, n = "";
322
+ for (let s of l)
323
+ if (s === "\t") {
324
+ let r = 4 - t % 4;
325
+ n += " ".repeat(r), t += r;
326
+ } else
327
+ n += s, t++;
328
+ return n;
329
+ }
330
+ function xe(l, e, t, n, s) {
331
+ let r = e.href, i = e.title || null, o = l[1].replace(s.other.outputLinkReplace, "$1");
332
+ n.state.inLink = true;
333
+ let u = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
334
+ return n.state.inLink = false, u;
335
+ }
336
+ function st(l, e, t) {
337
+ let n = l.match(t.other.indentCodeCompensation);
338
+ if (n === null)
339
+ return e;
340
+ let s = n[1];
341
+ return e.split(`
342
+ `).map((r) => {
343
+ let i = r.match(t.other.beginningSpace);
344
+ if (i === null)
345
+ return r;
346
+ let [o] = i;
347
+ return o.length >= s.length ? r.slice(s.length) : r;
348
+ }).join(`
349
+ `);
350
+ }
351
+ var w = class {
352
+ options;
353
+ rules;
354
+ lexer;
355
+ constructor(e) {
356
+ this.options = e || T;
357
+ }
358
+ space(e) {
359
+ let t = this.rules.block.newline.exec(e);
360
+ if (t && t[0].length > 0)
361
+ return { type: "space", raw: t[0] };
362
+ }
363
+ code(e) {
364
+ let t = this.rules.block.code.exec(e);
365
+ if (t) {
366
+ let n = this.options.pedantic ? t[0] : ee(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
367
+ return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
368
+ }
369
+ }
370
+ fences(e) {
371
+ let t = this.rules.block.fences.exec(e);
372
+ if (t) {
373
+ let n = t[0], s = st(n, t[3] || "", this.rules);
374
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
375
+ }
376
+ }
377
+ heading(e) {
378
+ let t = this.rules.block.heading.exec(e);
379
+ if (t) {
380
+ let n = t[2].trim();
381
+ if (this.rules.other.endingHash.test(n)) {
382
+ let s = $(n, "#");
383
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
384
+ }
385
+ return { type: "heading", raw: $(t[0], `
386
+ `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
387
+ }
388
+ }
389
+ hr(e) {
390
+ let t = this.rules.block.hr.exec(e);
391
+ if (t)
392
+ return { type: "hr", raw: $(t[0], `
393
+ `) };
394
+ }
395
+ blockquote(e) {
396
+ let t = this.rules.block.blockquote.exec(e);
397
+ if (t) {
398
+ let n = $(t[0], `
399
+ `).split(`
400
+ `), s = "", r = "", i = [];
401
+ for (;n.length > 0; ) {
402
+ let o = false, u = [], a;
403
+ for (a = 0;a < n.length; a++)
404
+ if (this.rules.other.blockquoteStart.test(n[a]))
405
+ u.push(n[a]), o = true;
406
+ else if (!o)
407
+ u.push(n[a]);
408
+ else
409
+ break;
410
+ n = n.slice(a);
411
+ let c = u.join(`
412
+ `), p = c.replace(this.rules.other.blockquoteSetextReplace, `
413
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
414
+ s = s ? `${s}
415
+ ${c}` : c, r = r ? `${r}
416
+ ${p}` : p;
417
+ let k = this.lexer.state.top;
418
+ if (this.lexer.state.top = true, this.lexer.blockTokens(p, i, true), this.lexer.state.top = k, n.length === 0)
419
+ break;
420
+ let h = i.at(-1);
421
+ if (h?.type === "code")
422
+ break;
423
+ if (h?.type === "blockquote") {
424
+ let R = h, f = R.raw + `
425
+ ` + n.join(`
426
+ `), S = this.blockquote(f);
427
+ i[i.length - 1] = S, s = s.substring(0, s.length - R.raw.length) + S.raw, r = r.substring(0, r.length - R.text.length) + S.text;
428
+ break;
429
+ } else if (h?.type === "list") {
430
+ let R = h, f = R.raw + `
431
+ ` + n.join(`
432
+ `), S = this.list(f);
433
+ i[i.length - 1] = S, s = s.substring(0, s.length - h.raw.length) + S.raw, r = r.substring(0, r.length - R.raw.length) + S.raw, n = f.substring(i.at(-1).raw.length).split(`
434
+ `);
435
+ continue;
436
+ }
437
+ }
438
+ return { type: "blockquote", raw: s, tokens: i, text: r };
439
+ }
440
+ }
441
+ list(e) {
442
+ let t = this.rules.block.list.exec(e);
443
+ if (t) {
444
+ let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
445
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
446
+ let i = this.rules.other.listItemRegex(n), o = false;
447
+ for (;e; ) {
448
+ let a = false, c = "", p = "";
449
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
450
+ break;
451
+ c = t[0], e = e.substring(c.length);
452
+ let k = me(t[2].split(`
453
+ `, 1)[0], t[1].length), h = e.split(`
454
+ `, 1)[0], R = !k.trim(), f = 0;
455
+ if (this.options.pedantic ? (f = 2, p = k.trimStart()) : R ? f = t[1].length + 1 : (f = k.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, p = k.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (c += h + `
456
+ `, e = e.substring(h.length + 1), a = true), !a) {
457
+ let S = this.rules.other.nextBulletRegex(f), te = this.rules.other.hrRegex(f), ne = this.rules.other.fencesBeginRegex(f), re = this.rules.other.headingBeginRegex(f), be = this.rules.other.htmlBeginRegex(f), Re = this.rules.other.blockquoteBeginRegex(f);
458
+ for (;e; ) {
459
+ let G = e.split(`
460
+ `, 1)[0], C;
461
+ if (h = G, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), C = h) : C = h.replace(this.rules.other.tabCharGlobal, " "), ne.test(h) || re.test(h) || be.test(h) || Re.test(h) || S.test(h) || te.test(h))
462
+ break;
463
+ if (C.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
464
+ p += `
465
+ ` + C.slice(f);
466
+ else {
467
+ if (R || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(k) || re.test(k) || te.test(k))
468
+ break;
469
+ p += `
470
+ ` + h;
471
+ }
472
+ R = !h.trim(), c += G + `
473
+ `, e = e.substring(G.length + 1), k = C.slice(f);
474
+ }
475
+ }
476
+ r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c) && (o = true)), r.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(p), loose: false, text: p, tokens: [] }), r.raw += c;
477
+ }
478
+ let u = r.items.at(-1);
479
+ if (u)
480
+ u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
481
+ else
482
+ return;
483
+ r.raw = r.raw.trimEnd();
484
+ for (let a of r.items) {
485
+ this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
486
+ let c = a.tokens[0];
487
+ if (a.task && (c?.type === "text" || c?.type === "paragraph")) {
488
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c.raw = c.raw.replace(this.rules.other.listReplaceTask, ""), c.text = c.text.replace(this.rules.other.listReplaceTask, "");
489
+ for (let k = this.lexer.inlineQueue.length - 1;k >= 0; k--)
490
+ if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k].src)) {
491
+ this.lexer.inlineQueue[k].src = this.lexer.inlineQueue[k].src.replace(this.rules.other.listReplaceTask, "");
492
+ break;
493
+ }
494
+ let p = this.rules.other.listTaskCheckbox.exec(a.raw);
495
+ if (p) {
496
+ let k = { type: "checkbox", raw: p[0] + " ", checked: p[0] !== "[ ]" };
497
+ a.checked = k.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k.raw + a.tokens[0].raw, a.tokens[0].text = k.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k)) : a.tokens.unshift({ type: "paragraph", raw: k.raw, text: k.raw, tokens: [k] }) : a.tokens.unshift(k);
498
+ }
499
+ } else
500
+ a.task && (a.task = false);
501
+ if (!r.loose) {
502
+ let p = a.tokens.filter((h) => h.type === "space"), k = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
503
+ r.loose = k;
504
+ }
505
+ }
506
+ if (r.loose)
507
+ for (let a of r.items) {
508
+ a.loose = true;
509
+ for (let c of a.tokens)
510
+ c.type === "text" && (c.type = "paragraph");
511
+ }
512
+ return r;
513
+ }
514
+ }
515
+ html(e) {
516
+ let t = this.rules.block.html.exec(e);
517
+ if (t) {
518
+ let n = ee(t[0]);
519
+ return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
520
+ }
521
+ }
522
+ def(e) {
523
+ let t = this.rules.block.def.exec(e);
524
+ if (t) {
525
+ 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];
526
+ return { type: "def", tag: n, raw: $(t[0], `
527
+ `), href: s, title: r };
528
+ }
529
+ }
530
+ table(e) {
531
+ let t = this.rules.block.table.exec(e);
532
+ if (!t || !this.rules.other.tableDelimiter.test(t[2]))
533
+ return;
534
+ let n = Y(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
535
+ `) : [], i = { type: "table", raw: $(t[0], `
536
+ `), header: [], align: [], rows: [] };
537
+ if (n.length === s.length) {
538
+ for (let o of s)
539
+ 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);
540
+ for (let o = 0;o < n.length; o++)
541
+ i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
542
+ for (let o of r)
543
+ i.rows.push(Y(o, i.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: i.align[a] })));
544
+ return i;
545
+ }
546
+ }
547
+ lheading(e) {
548
+ let t = this.rules.block.lheading.exec(e);
549
+ if (t) {
550
+ let n = t[1].trim();
551
+ return { type: "heading", raw: $(t[0], `
552
+ `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
553
+ }
554
+ }
555
+ paragraph(e) {
556
+ let t = this.rules.block.paragraph.exec(e);
557
+ if (t) {
558
+ let n = t[1].charAt(t[1].length - 1) === `
559
+ ` ? t[1].slice(0, -1) : t[1];
560
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
561
+ }
562
+ }
563
+ text(e) {
564
+ let t = this.rules.block.text.exec(e);
565
+ if (t)
566
+ return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
567
+ }
568
+ escape(e) {
569
+ let t = this.rules.inline.escape.exec(e);
570
+ if (t)
571
+ return { type: "escape", raw: t[0], text: t[1] };
572
+ }
573
+ tag(e) {
574
+ let t = this.rules.inline.tag.exec(e);
575
+ if (t)
576
+ 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] };
577
+ }
578
+ link(e) {
579
+ let t = this.rules.inline.link.exec(e);
580
+ if (t) {
581
+ let n = t[2].trim();
582
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
583
+ if (!this.rules.other.endAngleBracket.test(n))
584
+ return;
585
+ let i = $(n.slice(0, -1), "\\");
586
+ if ((n.length - i.length) % 2 === 0)
587
+ return;
588
+ } else {
589
+ let i = fe(t[2], "()");
590
+ if (i === -2)
591
+ return;
592
+ if (i > -1) {
593
+ let u = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
594
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u).trim(), t[3] = "";
595
+ }
596
+ }
597
+ let s = t[2], r = "";
598
+ if (this.options.pedantic) {
599
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
600
+ i && (s = i[1], r = i[3]);
601
+ } else
602
+ r = t[3] ? t[3].slice(1, -1) : "";
603
+ 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);
604
+ }
605
+ }
606
+ reflink(e, t) {
607
+ let n;
608
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
609
+ let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
610
+ if (!r) {
611
+ let i = n[0].charAt(0);
612
+ return { type: "text", raw: i, text: i };
613
+ }
614
+ return xe(n, r, n[0], this.lexer, this.rules);
615
+ }
616
+ }
617
+ emStrong(e, t, n = "") {
618
+ let s = this.rules.inline.emStrongLDelim.exec(e);
619
+ if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric))
620
+ return;
621
+ if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
622
+ let i = [...s[0]].length - 1, o, u, a = i, c = 0, p = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
623
+ for (p.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = p.exec(t)) !== null; ) {
624
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o)
625
+ continue;
626
+ if (u = [...o].length, s[3] || s[4]) {
627
+ a += u;
628
+ continue;
629
+ } else if ((s[5] || s[6]) && i % 3 && !((i + u) % 3)) {
630
+ c += u;
631
+ continue;
632
+ }
633
+ if (a -= u, a > 0)
634
+ continue;
635
+ u = Math.min(u, u + a + c);
636
+ let k = [...s[0]][0].length, h = e.slice(0, i + s.index + k + u);
637
+ if (Math.min(i, u) % 2) {
638
+ let f = h.slice(1, -1);
639
+ return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
640
+ }
641
+ let R = h.slice(2, -2);
642
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
643
+ }
644
+ }
645
+ }
646
+ codespan(e) {
647
+ let t = this.rules.inline.code.exec(e);
648
+ if (t) {
649
+ 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);
650
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
651
+ }
652
+ }
653
+ br(e) {
654
+ let t = this.rules.inline.br.exec(e);
655
+ if (t)
656
+ return { type: "br", raw: t[0] };
657
+ }
658
+ del(e, t, n = "") {
659
+ let s = this.rules.inline.delLDelim.exec(e);
660
+ if (!s)
661
+ return;
662
+ if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
663
+ let i = [...s[0]].length - 1, o, u, a = i, c = this.rules.inline.delRDelim;
664
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + i);(s = c.exec(t)) !== null; ) {
665
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u = [...o].length, u !== i))
666
+ continue;
667
+ if (s[3] || s[4]) {
668
+ a += u;
669
+ continue;
670
+ }
671
+ if (a -= u, a > 0)
672
+ continue;
673
+ u = Math.min(u, u + a);
674
+ let p = [...s[0]][0].length, k = e.slice(0, i + s.index + p + u), h = k.slice(i, -i);
675
+ return { type: "del", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
676
+ }
677
+ }
678
+ }
679
+ autolink(e) {
680
+ let t = this.rules.inline.autolink.exec(e);
681
+ if (t) {
682
+ let n, s;
683
+ 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 }] };
684
+ }
685
+ }
686
+ url(e) {
687
+ let t;
688
+ if (t = this.rules.inline.url.exec(e)) {
689
+ let n, s;
690
+ if (t[2] === "@")
691
+ n = t[0], s = "mailto:" + n;
692
+ else {
693
+ let r;
694
+ do
695
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
696
+ while (r !== t[0]);
697
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
698
+ }
699
+ return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
700
+ }
701
+ }
702
+ inlineText(e) {
703
+ let t = this.rules.inline.text.exec(e);
704
+ if (t) {
705
+ let n = this.lexer.state.inRawBlock;
706
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
707
+ }
708
+ }
709
+ };
710
+ var x = class l {
711
+ tokens;
712
+ options;
713
+ state;
714
+ inlineQueue;
715
+ tokenizer;
716
+ constructor(e) {
717
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
718
+ let t = { other: m, block: D.normal, inline: A.normal };
719
+ this.options.pedantic ? (t.block = D.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = D.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
720
+ }
721
+ static get rules() {
722
+ return { block: D, inline: A };
723
+ }
724
+ static lex(e, t) {
725
+ return new l(t).lex(e);
726
+ }
727
+ static lexInline(e, t) {
728
+ return new l(t).inlineTokens(e);
729
+ }
730
+ lex(e) {
731
+ e = e.replace(m.carriageReturn, `
732
+ `), this.blockTokens(e, this.tokens);
733
+ for (let t = 0;t < this.inlineQueue.length; t++) {
734
+ let n = this.inlineQueue[t];
735
+ this.inlineTokens(n.src, n.tokens);
736
+ }
737
+ return this.inlineQueue = [], this.tokens;
738
+ }
739
+ blockTokens(e, t = [], n = false) {
740
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
741
+ let s = 1 / 0;
742
+ for (;e; ) {
743
+ if (e.length < s)
744
+ s = e.length;
745
+ else {
746
+ this.infiniteLoopError(e.charCodeAt(0));
747
+ break;
748
+ }
749
+ let r;
750
+ 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))
751
+ continue;
752
+ if (r = this.tokenizer.space(e)) {
753
+ e = e.substring(r.raw.length);
754
+ let o = t.at(-1);
755
+ r.raw.length === 1 && o !== undefined ? o.raw += `
756
+ ` : t.push(r);
757
+ continue;
758
+ }
759
+ if (r = this.tokenizer.code(e)) {
760
+ e = e.substring(r.raw.length);
761
+ let o = t.at(-1);
762
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
763
+ `) ? "" : `
764
+ `) + r.raw, o.text += `
765
+ ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
766
+ continue;
767
+ }
768
+ if (r = this.tokenizer.fences(e)) {
769
+ e = e.substring(r.raw.length), t.push(r);
770
+ continue;
771
+ }
772
+ if (r = this.tokenizer.heading(e)) {
773
+ e = e.substring(r.raw.length), t.push(r);
774
+ continue;
775
+ }
776
+ if (r = this.tokenizer.hr(e)) {
777
+ e = e.substring(r.raw.length), t.push(r);
778
+ continue;
779
+ }
780
+ if (r = this.tokenizer.blockquote(e)) {
781
+ e = e.substring(r.raw.length), t.push(r);
782
+ continue;
783
+ }
784
+ if (r = this.tokenizer.list(e)) {
785
+ e = e.substring(r.raw.length), t.push(r);
786
+ continue;
787
+ }
788
+ if (r = this.tokenizer.html(e)) {
789
+ e = e.substring(r.raw.length), t.push(r);
790
+ continue;
791
+ }
792
+ if (r = this.tokenizer.def(e)) {
793
+ e = e.substring(r.raw.length);
794
+ let o = t.at(-1);
795
+ o?.type === "paragraph" || o?.type === "text" ? (o.raw += (o.raw.endsWith(`
796
+ `) ? "" : `
797
+ `) + r.raw, o.text += `
798
+ ` + 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));
799
+ continue;
800
+ }
801
+ if (r = this.tokenizer.table(e)) {
802
+ e = e.substring(r.raw.length), t.push(r);
803
+ continue;
804
+ }
805
+ if (r = this.tokenizer.lheading(e)) {
806
+ e = e.substring(r.raw.length), t.push(r);
807
+ continue;
808
+ }
809
+ let i = e;
810
+ if (this.options.extensions?.startBlock) {
811
+ let o = 1 / 0, u = e.slice(1), a;
812
+ this.options.extensions.startBlock.forEach((c) => {
813
+ a = c.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
814
+ }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
815
+ }
816
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
817
+ let o = t.at(-1);
818
+ n && o?.type === "paragraph" ? (o.raw += (o.raw.endsWith(`
819
+ `) ? "" : `
820
+ `) + r.raw, o.text += `
821
+ ` + 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);
822
+ continue;
823
+ }
824
+ if (r = this.tokenizer.text(e)) {
825
+ e = e.substring(r.raw.length);
826
+ let o = t.at(-1);
827
+ o?.type === "text" ? (o.raw += (o.raw.endsWith(`
828
+ `) ? "" : `
829
+ `) + r.raw, o.text += `
830
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
831
+ continue;
832
+ }
833
+ if (e) {
834
+ this.infiniteLoopError(e.charCodeAt(0));
835
+ break;
836
+ }
837
+ }
838
+ return this.state.top = true, t;
839
+ }
840
+ inline(e, t = []) {
841
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
842
+ }
843
+ inlineTokens(e, t = []) {
844
+ this.tokenizer.lexer = this;
845
+ let n = e, s = null;
846
+ if (this.tokens.links) {
847
+ let a = Object.keys(this.tokens.links);
848
+ if (a.length > 0)
849
+ for (;(s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; )
850
+ a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
851
+ }
852
+ for (;(s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; )
853
+ n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
854
+ let r;
855
+ for (;(s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; )
856
+ r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
857
+ n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
858
+ let i = false, o = "", u = 1 / 0;
859
+ for (;e; ) {
860
+ if (e.length < u)
861
+ u = e.length;
862
+ else {
863
+ this.infiniteLoopError(e.charCodeAt(0));
864
+ break;
865
+ }
866
+ i || (o = ""), i = false;
867
+ let a;
868
+ if (this.options.extensions?.inline?.some((p) => (a = p.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false))
869
+ continue;
870
+ if (a = this.tokenizer.escape(e)) {
871
+ e = e.substring(a.raw.length), t.push(a);
872
+ continue;
873
+ }
874
+ if (a = this.tokenizer.tag(e)) {
875
+ e = e.substring(a.raw.length), t.push(a);
876
+ continue;
877
+ }
878
+ if (a = this.tokenizer.link(e)) {
879
+ e = e.substring(a.raw.length), t.push(a);
880
+ continue;
881
+ }
882
+ if (a = this.tokenizer.reflink(e, this.tokens.links)) {
883
+ e = e.substring(a.raw.length);
884
+ let p = t.at(-1);
885
+ a.type === "text" && p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
886
+ continue;
887
+ }
888
+ if (a = this.tokenizer.emStrong(e, n, o)) {
889
+ e = e.substring(a.raw.length), t.push(a);
890
+ continue;
891
+ }
892
+ if (a = this.tokenizer.codespan(e)) {
893
+ e = e.substring(a.raw.length), t.push(a);
894
+ continue;
895
+ }
896
+ if (a = this.tokenizer.br(e)) {
897
+ e = e.substring(a.raw.length), t.push(a);
898
+ continue;
899
+ }
900
+ if (a = this.tokenizer.del(e, n, o)) {
901
+ e = e.substring(a.raw.length), t.push(a);
902
+ continue;
903
+ }
904
+ if (a = this.tokenizer.autolink(e)) {
905
+ e = e.substring(a.raw.length), t.push(a);
906
+ continue;
907
+ }
908
+ if (!this.state.inLink && (a = this.tokenizer.url(e))) {
909
+ e = e.substring(a.raw.length), t.push(a);
910
+ continue;
911
+ }
912
+ let c = e;
913
+ if (this.options.extensions?.startInline) {
914
+ let p = 1 / 0, k = e.slice(1), h;
915
+ this.options.extensions.startInline.forEach((R) => {
916
+ h = R.call({ lexer: this }, k), typeof h == "number" && h >= 0 && (p = Math.min(p, h));
917
+ }), p < 1 / 0 && p >= 0 && (c = e.substring(0, p + 1));
918
+ }
919
+ if (a = this.tokenizer.inlineText(c)) {
920
+ e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
921
+ let p = t.at(-1);
922
+ p?.type === "text" ? (p.raw += a.raw, p.text += a.text) : t.push(a);
923
+ continue;
924
+ }
925
+ if (e) {
926
+ this.infiniteLoopError(e.charCodeAt(0));
927
+ break;
928
+ }
929
+ }
930
+ return t;
931
+ }
932
+ infiniteLoopError(e) {
933
+ let t = "Infinite loop on byte: " + e;
934
+ if (this.options.silent)
935
+ console.error(t);
936
+ else
937
+ throw new Error(t);
938
+ }
939
+ };
940
+ var y = class {
941
+ options;
942
+ parser;
943
+ constructor(e) {
944
+ this.options = e || T;
945
+ }
946
+ space(e) {
947
+ return "";
948
+ }
949
+ code({ text: e, lang: t, escaped: n }) {
950
+ let s = (t || "").match(m.notSpaceStart)?.[0], r = e.replace(m.endingNewline, "") + `
951
+ `;
952
+ return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
953
+ ` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
954
+ `;
955
+ }
956
+ blockquote({ tokens: e }) {
957
+ return `<blockquote>
958
+ ${this.parser.parse(e)}</blockquote>
959
+ `;
960
+ }
961
+ html({ text: e }) {
962
+ return e;
963
+ }
964
+ def(e) {
965
+ return "";
966
+ }
967
+ heading({ tokens: e, depth: t }) {
968
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
969
+ `;
970
+ }
971
+ hr(e) {
972
+ return `<hr>
973
+ `;
974
+ }
975
+ list(e) {
976
+ let { ordered: t, start: n } = e, s = "";
977
+ for (let o = 0;o < e.items.length; o++) {
978
+ let u = e.items[o];
979
+ s += this.listitem(u);
980
+ }
981
+ let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
982
+ return "<" + r + i + `>
983
+ ` + s + "</" + r + `>
984
+ `;
985
+ }
986
+ listitem(e) {
987
+ return `<li>${this.parser.parse(e.tokens)}</li>
988
+ `;
989
+ }
990
+ checkbox({ checked: e }) {
991
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
992
+ }
993
+ paragraph({ tokens: e }) {
994
+ return `<p>${this.parser.parseInline(e)}</p>
995
+ `;
996
+ }
997
+ table(e) {
998
+ let t = "", n = "";
999
+ for (let r = 0;r < e.header.length; r++)
1000
+ n += this.tablecell(e.header[r]);
1001
+ t += this.tablerow({ text: n });
1002
+ let s = "";
1003
+ for (let r = 0;r < e.rows.length; r++) {
1004
+ let i = e.rows[r];
1005
+ n = "";
1006
+ for (let o = 0;o < i.length; o++)
1007
+ n += this.tablecell(i[o]);
1008
+ s += this.tablerow({ text: n });
1009
+ }
1010
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
1011
+ <thead>
1012
+ ` + t + `</thead>
1013
+ ` + s + `</table>
1014
+ `;
1015
+ }
1016
+ tablerow({ text: e }) {
1017
+ return `<tr>
1018
+ ${e}</tr>
1019
+ `;
1020
+ }
1021
+ tablecell(e) {
1022
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
1023
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
1024
+ `;
1025
+ }
1026
+ strong({ tokens: e }) {
1027
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
1028
+ }
1029
+ em({ tokens: e }) {
1030
+ return `<em>${this.parser.parseInline(e)}</em>`;
1031
+ }
1032
+ codespan({ text: e }) {
1033
+ return `<code>${O(e, true)}</code>`;
1034
+ }
1035
+ br(e) {
1036
+ return "<br>";
1037
+ }
1038
+ del({ tokens: e }) {
1039
+ return `<del>${this.parser.parseInline(e)}</del>`;
1040
+ }
1041
+ link({ href: e, title: t, tokens: n }) {
1042
+ let s = this.parser.parseInline(n), r = V(e);
1043
+ if (r === null)
1044
+ return s;
1045
+ e = r;
1046
+ let i = '<a href="' + e + '"';
1047
+ return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
1048
+ }
1049
+ image({ href: e, title: t, text: n, tokens: s }) {
1050
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
1051
+ let r = V(e);
1052
+ if (r === null)
1053
+ return O(n);
1054
+ e = r;
1055
+ let i = `<img src="${e}" alt="${O(n)}"`;
1056
+ return t && (i += ` title="${O(t)}"`), i += ">", i;
1057
+ }
1058
+ text(e) {
1059
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : O(e.text);
1060
+ }
1061
+ };
1062
+ var L = class {
1063
+ strong({ text: e }) {
1064
+ return e;
1065
+ }
1066
+ em({ text: e }) {
1067
+ return e;
1068
+ }
1069
+ codespan({ text: e }) {
1070
+ return e;
1071
+ }
1072
+ del({ text: e }) {
1073
+ return e;
1074
+ }
1075
+ html({ text: e }) {
1076
+ return e;
1077
+ }
1078
+ text({ text: e }) {
1079
+ return e;
1080
+ }
1081
+ link({ text: e }) {
1082
+ return "" + e;
1083
+ }
1084
+ image({ text: e }) {
1085
+ return "" + e;
1086
+ }
1087
+ br() {
1088
+ return "";
1089
+ }
1090
+ checkbox({ raw: e }) {
1091
+ return e;
1092
+ }
1093
+ };
1094
+ var b = class l2 {
1095
+ options;
1096
+ renderer;
1097
+ textRenderer;
1098
+ constructor(e) {
1099
+ this.options = e || T, this.options.renderer = this.options.renderer || new y, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L;
1100
+ }
1101
+ static parse(e, t) {
1102
+ return new l2(t).parse(e);
1103
+ }
1104
+ static parseInline(e, t) {
1105
+ return new l2(t).parseInline(e);
1106
+ }
1107
+ parse(e) {
1108
+ this.renderer.parser = this;
1109
+ let t = "";
1110
+ for (let n = 0;n < e.length; n++) {
1111
+ let s = e[n];
1112
+ if (this.options.extensions?.renderers?.[s.type]) {
1113
+ let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1114
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
1115
+ t += o || "";
1116
+ continue;
1117
+ }
1118
+ }
1119
+ let r = s;
1120
+ switch (r.type) {
1121
+ case "space": {
1122
+ t += this.renderer.space(r);
1123
+ break;
1124
+ }
1125
+ case "hr": {
1126
+ t += this.renderer.hr(r);
1127
+ break;
1128
+ }
1129
+ case "heading": {
1130
+ t += this.renderer.heading(r);
1131
+ break;
1132
+ }
1133
+ case "code": {
1134
+ t += this.renderer.code(r);
1135
+ break;
1136
+ }
1137
+ case "table": {
1138
+ t += this.renderer.table(r);
1139
+ break;
1140
+ }
1141
+ case "blockquote": {
1142
+ t += this.renderer.blockquote(r);
1143
+ break;
1144
+ }
1145
+ case "list": {
1146
+ t += this.renderer.list(r);
1147
+ break;
1148
+ }
1149
+ case "checkbox": {
1150
+ t += this.renderer.checkbox(r);
1151
+ break;
1152
+ }
1153
+ case "html": {
1154
+ t += this.renderer.html(r);
1155
+ break;
1156
+ }
1157
+ case "def": {
1158
+ t += this.renderer.def(r);
1159
+ break;
1160
+ }
1161
+ case "paragraph": {
1162
+ t += this.renderer.paragraph(r);
1163
+ break;
1164
+ }
1165
+ case "text": {
1166
+ t += this.renderer.text(r);
1167
+ break;
1168
+ }
1169
+ default: {
1170
+ let i = 'Token with "' + r.type + '" type was not found.';
1171
+ if (this.options.silent)
1172
+ return console.error(i), "";
1173
+ throw new Error(i);
1174
+ }
1175
+ }
1176
+ }
1177
+ return t;
1178
+ }
1179
+ parseInline(e, t = this.renderer) {
1180
+ this.renderer.parser = this;
1181
+ let n = "";
1182
+ for (let s = 0;s < e.length; s++) {
1183
+ let r = e[s];
1184
+ if (this.options.extensions?.renderers?.[r.type]) {
1185
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1186
+ if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
1187
+ n += o || "";
1188
+ continue;
1189
+ }
1190
+ }
1191
+ let i = r;
1192
+ switch (i.type) {
1193
+ case "escape": {
1194
+ n += t.text(i);
1195
+ break;
1196
+ }
1197
+ case "html": {
1198
+ n += t.html(i);
1199
+ break;
1200
+ }
1201
+ case "link": {
1202
+ n += t.link(i);
1203
+ break;
1204
+ }
1205
+ case "image": {
1206
+ n += t.image(i);
1207
+ break;
1208
+ }
1209
+ case "checkbox": {
1210
+ n += t.checkbox(i);
1211
+ break;
1212
+ }
1213
+ case "strong": {
1214
+ n += t.strong(i);
1215
+ break;
1216
+ }
1217
+ case "em": {
1218
+ n += t.em(i);
1219
+ break;
1220
+ }
1221
+ case "codespan": {
1222
+ n += t.codespan(i);
1223
+ break;
1224
+ }
1225
+ case "br": {
1226
+ n += t.br(i);
1227
+ break;
1228
+ }
1229
+ case "del": {
1230
+ n += t.del(i);
1231
+ break;
1232
+ }
1233
+ case "text": {
1234
+ n += t.text(i);
1235
+ break;
1236
+ }
1237
+ default: {
1238
+ let o = 'Token with "' + i.type + '" type was not found.';
1239
+ if (this.options.silent)
1240
+ return console.error(o), "";
1241
+ throw new Error(o);
1242
+ }
1243
+ }
1244
+ }
1245
+ return n;
1246
+ }
1247
+ };
1248
+ var P = class {
1249
+ options;
1250
+ block;
1251
+ constructor(e) {
1252
+ this.options = e || T;
1253
+ }
1254
+ static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
1255
+ static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
1256
+ preprocess(e) {
1257
+ return e;
1258
+ }
1259
+ postprocess(e) {
1260
+ return e;
1261
+ }
1262
+ processAllTokens(e) {
1263
+ return e;
1264
+ }
1265
+ emStrongMask(e) {
1266
+ return e;
1267
+ }
1268
+ provideLexer(e = this.block) {
1269
+ return e ? x.lex : x.lexInline;
1270
+ }
1271
+ provideParser(e = this.block) {
1272
+ return e ? b.parse : b.parseInline;
1273
+ }
1274
+ };
1275
+ var q = class {
1276
+ defaults = M();
1277
+ options = this.setOptions;
1278
+ parse = this.parseMarkdown(true);
1279
+ parseInline = this.parseMarkdown(false);
1280
+ Parser = b;
1281
+ Renderer = y;
1282
+ TextRenderer = L;
1283
+ Lexer = x;
1284
+ Tokenizer = w;
1285
+ Hooks = P;
1286
+ constructor(...e) {
1287
+ this.use(...e);
1288
+ }
1289
+ walkTokens(e, t) {
1290
+ let n = [];
1291
+ for (let s of e)
1292
+ switch (n = n.concat(t.call(this, s)), s.type) {
1293
+ case "table": {
1294
+ let r = s;
1295
+ for (let i of r.header)
1296
+ n = n.concat(this.walkTokens(i.tokens, t));
1297
+ for (let i of r.rows)
1298
+ for (let o of i)
1299
+ n = n.concat(this.walkTokens(o.tokens, t));
1300
+ break;
1301
+ }
1302
+ case "list": {
1303
+ let r = s;
1304
+ n = n.concat(this.walkTokens(r.items, t));
1305
+ break;
1306
+ }
1307
+ default: {
1308
+ let r = s;
1309
+ this.defaults.extensions?.childTokens?.[r.type] ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1310
+ let o = r[i].flat(1 / 0);
1311
+ n = n.concat(this.walkTokens(o, t));
1312
+ }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
1313
+ }
1314
+ }
1315
+ return n;
1316
+ }
1317
+ use(...e) {
1318
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1319
+ return e.forEach((n) => {
1320
+ let s = { ...n };
1321
+ if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
1322
+ if (!r.name)
1323
+ throw new Error("extension name required");
1324
+ if ("renderer" in r) {
1325
+ let i = t.renderers[r.name];
1326
+ i ? t.renderers[r.name] = function(...o) {
1327
+ let u = r.renderer.apply(this, o);
1328
+ return u === false && (u = i.apply(this, o)), u;
1329
+ } : t.renderers[r.name] = r.renderer;
1330
+ }
1331
+ if ("tokenizer" in r) {
1332
+ if (!r.level || r.level !== "block" && r.level !== "inline")
1333
+ throw new Error("extension level must be 'block' or 'inline'");
1334
+ let i = t[r.level];
1335
+ 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]));
1336
+ }
1337
+ "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
1338
+ }), s.extensions = t), n.renderer) {
1339
+ let r = this.defaults.renderer || new y(this.defaults);
1340
+ for (let i in n.renderer) {
1341
+ if (!(i in r))
1342
+ throw new Error(`renderer '${i}' does not exist`);
1343
+ if (["options", "parser"].includes(i))
1344
+ continue;
1345
+ let o = i, u = n.renderer[o], a = r[o];
1346
+ r[o] = (...c) => {
1347
+ let p = u.apply(r, c);
1348
+ return p === false && (p = a.apply(r, c)), p || "";
1349
+ };
1350
+ }
1351
+ s.renderer = r;
1352
+ }
1353
+ if (n.tokenizer) {
1354
+ let r = this.defaults.tokenizer || new w(this.defaults);
1355
+ for (let i in n.tokenizer) {
1356
+ if (!(i in r))
1357
+ throw new Error(`tokenizer '${i}' does not exist`);
1358
+ if (["options", "rules", "lexer"].includes(i))
1359
+ continue;
1360
+ let o = i, u = n.tokenizer[o], a = r[o];
1361
+ r[o] = (...c) => {
1362
+ let p = u.apply(r, c);
1363
+ return p === false && (p = a.apply(r, c)), p;
1364
+ };
1365
+ }
1366
+ s.tokenizer = r;
1367
+ }
1368
+ if (n.hooks) {
1369
+ let r = this.defaults.hooks || new P;
1370
+ for (let i in n.hooks) {
1371
+ if (!(i in r))
1372
+ throw new Error(`hook '${i}' does not exist`);
1373
+ if (["options", "block"].includes(i))
1374
+ continue;
1375
+ let o = i, u = n.hooks[o], a = r[o];
1376
+ P.passThroughHooks.has(i) ? r[o] = (c) => {
1377
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(i))
1378
+ return (async () => {
1379
+ let k = await u.call(r, c);
1380
+ return a.call(r, k);
1381
+ })();
1382
+ let p = u.call(r, c);
1383
+ return a.call(r, p);
1384
+ } : r[o] = (...c) => {
1385
+ if (this.defaults.async)
1386
+ return (async () => {
1387
+ let k = await u.apply(r, c);
1388
+ return k === false && (k = await a.apply(r, c)), k;
1389
+ })();
1390
+ let p = u.apply(r, c);
1391
+ return p === false && (p = a.apply(r, c)), p;
1392
+ };
1393
+ }
1394
+ s.hooks = r;
1395
+ }
1396
+ if (n.walkTokens) {
1397
+ let r = this.defaults.walkTokens, i = n.walkTokens;
1398
+ s.walkTokens = function(o) {
1399
+ let u = [];
1400
+ return u.push(i.call(this, o)), r && (u = u.concat(r.call(this, o))), u;
1401
+ };
1402
+ }
1403
+ this.defaults = { ...this.defaults, ...s };
1404
+ }), this;
1405
+ }
1406
+ setOptions(e) {
1407
+ return this.defaults = { ...this.defaults, ...e }, this;
1408
+ }
1409
+ lexer(e, t) {
1410
+ return x.lex(e, t ?? this.defaults);
1411
+ }
1412
+ parser(e, t) {
1413
+ return b.parse(e, t ?? this.defaults);
1414
+ }
1415
+ parseMarkdown(e) {
1416
+ return (n, s) => {
1417
+ let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
1418
+ if (this.defaults.async === true && r.async === false)
1419
+ 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."));
1420
+ if (typeof n > "u" || n === null)
1421
+ return o(new Error("marked(): input parameter is undefined or null"));
1422
+ if (typeof n != "string")
1423
+ return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1424
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async)
1425
+ return (async () => {
1426
+ let u = i.hooks ? await i.hooks.preprocess(n) : n, c = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u, i), p = i.hooks ? await i.hooks.processAllTokens(c) : c;
1427
+ i.walkTokens && await Promise.all(this.walkTokens(p, i.walkTokens));
1428
+ let h = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p, i);
1429
+ return i.hooks ? await i.hooks.postprocess(h) : h;
1430
+ })().catch(o);
1431
+ try {
1432
+ i.hooks && (n = i.hooks.preprocess(n));
1433
+ let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
1434
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
1435
+ let p = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
1436
+ return i.hooks && (p = i.hooks.postprocess(p)), p;
1437
+ } catch (u) {
1438
+ return o(u);
1439
+ }
1440
+ };
1441
+ }
1442
+ onError(e, t) {
1443
+ return (n) => {
1444
+ if (n.message += `
1445
+ Please report this to https://github.com/markedjs/marked.`, e) {
1446
+ let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
1447
+ return t ? Promise.resolve(s) : s;
1448
+ }
1449
+ if (t)
1450
+ return Promise.reject(n);
1451
+ throw n;
1452
+ };
1453
+ }
1454
+ };
1455
+ var z = new q;
1456
+ function g(l3, e) {
1457
+ return z.parse(l3, e);
1458
+ }
1459
+ g.options = g.setOptions = function(l3) {
1460
+ return z.setOptions(l3), g.defaults = z.defaults, N(g.defaults), g;
1461
+ };
1462
+ g.getDefaults = M;
1463
+ g.defaults = T;
1464
+ g.use = function(...l3) {
1465
+ return z.use(...l3), g.defaults = z.defaults, N(g.defaults), g;
1466
+ };
1467
+ g.walkTokens = function(l3, e) {
1468
+ return z.walkTokens(l3, e);
1469
+ };
1470
+ g.parseInline = z.parseInline;
1471
+ g.Parser = b;
1472
+ g.parser = b.parse;
1473
+ g.Renderer = y;
1474
+ g.TextRenderer = L;
1475
+ g.Lexer = x;
1476
+ g.lexer = x.lex;
1477
+ g.Tokenizer = w;
1478
+ g.Hooks = P;
1479
+ g.parse = g;
1480
+ var Ft = g.options;
1481
+ var Ut = g.setOptions;
1482
+ var Kt = g.use;
1483
+ var Wt = g.walkTokens;
1484
+ var Xt = g.parseInline;
1485
+ var Vt = b.parse;
1486
+ var Yt = x.lex;
1487
+
1488
+ // src/lib/session-render.ts
154
1489
  import { basename as basename4, dirname as dirname4, extname as extname2, isAbsolute as isAbsolute3, join as join5, parse as parse2, posix as posix2, relative as relative2, resolve as resolve6 } from "path";
155
1490
 
156
1491
  // src/lib/codewith-shared-todos-storage-standard.ts
@@ -369,7 +1704,7 @@ __export(exports_external, {
369
1704
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
370
1705
  var util;
371
1706
  (function(util2) {
372
- util2.assertEqual = (_) => {};
1707
+ util2.assertEqual = (_2) => {};
373
1708
  function assertIs(_arg) {}
374
1709
  util2.assertIs = assertIs;
375
1710
  function assertNever(_x) {
@@ -417,7 +1752,7 @@ var util;
417
1752
  return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
418
1753
  }
419
1754
  util2.joinValues = joinValues;
420
- util2.jsonStringifyReplacer = (_, value) => {
1755
+ util2.jsonStringifyReplacer = (_2, value) => {
421
1756
  if (typeof value === "bigint") {
422
1757
  return value.toString();
423
1758
  }
@@ -743,7 +2078,7 @@ var makeIssue = (params) => {
743
2078
  };
744
2079
  }
745
2080
  let errorMessage = "";
746
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
2081
+ const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
747
2082
  for (const map of maps) {
748
2083
  errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
749
2084
  }
@@ -765,7 +2100,7 @@ function addIssueToContext(ctx, issueData) {
765
2100
  ctx.schemaErrorMap,
766
2101
  overrideMap,
767
2102
  overrideMap === en_default ? undefined : en_default
768
- ].filter((x) => !!x)
2103
+ ].filter((x2) => !!x2)
769
2104
  });
770
2105
  ctx.common.issues.push(issue);
771
2106
  }
@@ -829,10 +2164,10 @@ var INVALID = Object.freeze({
829
2164
  });
830
2165
  var DIRTY = (value) => ({ status: "dirty", value });
831
2166
  var OK = (value) => ({ status: "valid", value });
832
- var isAborted = (x) => x.status === "aborted";
833
- var isDirty = (x) => x.status === "dirty";
834
- var isValid = (x) => x.status === "valid";
835
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
2167
+ var isAborted = (x2) => x2.status === "aborted";
2168
+ var isDirty = (x2) => x2.status === "dirty";
2169
+ var isValid = (x2) => x2.status === "valid";
2170
+ var isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
836
2171
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
837
2172
  var errorUtil;
838
2173
  (function(errorUtil2) {
@@ -3072,17 +4407,17 @@ class ZodDiscriminatedUnion extends ZodType {
3072
4407
  });
3073
4408
  }
3074
4409
  }
3075
- function mergeValues(a, b) {
4410
+ function mergeValues(a, b2) {
3076
4411
  const aType = getParsedType(a);
3077
- const bType = getParsedType(b);
3078
- if (a === b) {
4412
+ const bType = getParsedType(b2);
4413
+ if (a === b2) {
3079
4414
  return { valid: true, data: a };
3080
4415
  } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3081
- const bKeys = util.objectKeys(b);
4416
+ const bKeys = util.objectKeys(b2);
3082
4417
  const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3083
- const newObj = { ...a, ...b };
4418
+ const newObj = { ...a, ...b2 };
3084
4419
  for (const key of sharedKeys) {
3085
- const sharedValue = mergeValues(a[key], b[key]);
4420
+ const sharedValue = mergeValues(a[key], b2[key]);
3086
4421
  if (!sharedValue.valid) {
3087
4422
  return { valid: false };
3088
4423
  }
@@ -3090,13 +4425,13 @@ function mergeValues(a, b) {
3090
4425
  }
3091
4426
  return { valid: true, data: newObj };
3092
4427
  } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3093
- if (a.length !== b.length) {
4428
+ if (a.length !== b2.length) {
3094
4429
  return { valid: false };
3095
4430
  }
3096
4431
  const newArray = [];
3097
4432
  for (let index = 0;index < a.length; index++) {
3098
4433
  const itemA = a[index];
3099
- const itemB = b[index];
4434
+ const itemB = b2[index];
3100
4435
  const sharedValue = mergeValues(itemA, itemB);
3101
4436
  if (!sharedValue.valid) {
3102
4437
  return { valid: false };
@@ -3104,7 +4439,7 @@ function mergeValues(a, b) {
3104
4439
  newArray.push(sharedValue.data);
3105
4440
  }
3106
4441
  return { valid: true, data: newArray };
3107
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
4442
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b2) {
3108
4443
  return { valid: true, data: a };
3109
4444
  } else {
3110
4445
  return { valid: false };
@@ -3202,7 +4537,7 @@ class ZodTuple extends ZodType {
3202
4537
  if (!schema)
3203
4538
  return null;
3204
4539
  return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3205
- }).filter((x) => !!x);
4540
+ }).filter((x2) => !!x2);
3206
4541
  if (ctx.common.async) {
3207
4542
  return Promise.all(items).then((results) => {
3208
4543
  return ParseStatus.mergeArray(status, results);
@@ -3459,7 +4794,7 @@ class ZodFunction extends ZodType {
3459
4794
  return makeIssue({
3460
4795
  data: args,
3461
4796
  path: ctx.path,
3462
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4797
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
3463
4798
  issueData: {
3464
4799
  code: ZodIssueCode.invalid_arguments,
3465
4800
  argumentsError: error
@@ -3470,7 +4805,7 @@ class ZodFunction extends ZodType {
3470
4805
  return makeIssue({
3471
4806
  data: returns,
3472
4807
  path: ctx.path,
3473
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4808
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x2) => !!x2),
3474
4809
  issueData: {
3475
4810
  code: ZodIssueCode.invalid_return_type,
3476
4811
  returnTypeError: error
@@ -3480,29 +4815,29 @@ class ZodFunction extends ZodType {
3480
4815
  const params = { errorMap: ctx.common.contextualErrorMap };
3481
4816
  const fn = ctx.data;
3482
4817
  if (this._def.returns instanceof ZodPromise) {
3483
- const me = this;
4818
+ const me2 = this;
3484
4819
  return OK(async function(...args) {
3485
4820
  const error = new ZodError([]);
3486
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
4821
+ const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e) => {
3487
4822
  error.addIssue(makeArgsIssue(args, e));
3488
4823
  throw error;
3489
4824
  });
3490
4825
  const result = await Reflect.apply(fn, this, parsedArgs);
3491
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
4826
+ const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e) => {
3492
4827
  error.addIssue(makeReturnsIssue(result, e));
3493
4828
  throw error;
3494
4829
  });
3495
4830
  return parsedReturns;
3496
4831
  });
3497
4832
  } else {
3498
- const me = this;
4833
+ const me2 = this;
3499
4834
  return OK(function(...args) {
3500
- const parsedArgs = me._def.args.safeParse(args, params);
4835
+ const parsedArgs = me2._def.args.safeParse(args, params);
3501
4836
  if (!parsedArgs.success) {
3502
4837
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3503
4838
  }
3504
4839
  const result = Reflect.apply(fn, this, parsedArgs.data);
3505
- const parsedReturns = me._def.returns.safeParse(result, params);
4840
+ const parsedReturns = me2._def.returns.safeParse(result, params);
3506
4841
  if (!parsedReturns.success) {
3507
4842
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3508
4843
  }
@@ -4076,10 +5411,10 @@ class ZodPipeline extends ZodType {
4076
5411
  }
4077
5412
  }
4078
5413
  }
4079
- static create(a, b) {
5414
+ static create(a, b2) {
4080
5415
  return new ZodPipeline({
4081
5416
  in: a,
4082
- out: b,
5417
+ out: b2,
4083
5418
  typeName: ZodFirstPartyTypeKind.ZodPipeline
4084
5419
  });
4085
5420
  }
@@ -4247,9 +5582,9 @@ function redactShell(content) {
4247
5582
  const out = [];
4248
5583
  for (let i = 0;i < lines.length; i++) {
4249
5584
  const line = lines[i];
4250
- const m = line.match(/^(\s*(?:export\s+)?)([A-Z][A-Z0-9_]*)(\s*=\s*)(['"]?)(.+?)\4\s*$/);
4251
- if (m) {
4252
- const [, prefix, key, eq, quote, value] = m;
5585
+ const m2 = line.match(/^(\s*(?:export\s+)?)([A-Z][A-Z0-9_]*)(\s*=\s*)(['"]?)(.+?)\4\s*$/);
5586
+ if (m2) {
5587
+ const [, prefix, key, eq, quote, value] = m2;
4253
5588
  if (shouldRedactKeyValue(key, value)) {
4254
5589
  const reason = reasonFor(key, value);
4255
5590
  redacted.push({ varName: key, line: i + 1, reason });
@@ -4269,9 +5604,9 @@ function redactJson(content) {
4269
5604
  const out = [];
4270
5605
  for (let i = 0;i < lines.length; i++) {
4271
5606
  const line = lines[i];
4272
- const m = line.match(/^(\s*"([^"]+)"\s*:\s*)"([^"]+)"(,?)(\s*)$/);
4273
- if (m) {
4274
- const [, prefix, key, value, comma, trail] = m;
5607
+ const m2 = line.match(/^(\s*"([^"]+)"\s*:\s*)"([^"]+)"(,?)(\s*)$/);
5608
+ if (m2) {
5609
+ const [, prefix, key, value, comma, trail] = m2;
4275
5610
  if (shouldRedactKeyValue(key, value)) {
4276
5611
  const varName = key.toUpperCase().replace(/[^A-Z0-9]/g, "_");
4277
5612
  redacted.push({ varName, line: i + 1, reason: reasonFor(key, value) });
@@ -4299,9 +5634,9 @@ function redactToml(content) {
4299
5634
  const out = [];
4300
5635
  for (let i = 0;i < lines.length; i++) {
4301
5636
  const line = lines[i];
4302
- const m = line.match(/^(\s*)([a-zA-Z][a-zA-Z0-9_\-]*)(\s*=\s*)(['"]?)(.+?)\4\s*$/);
4303
- if (m) {
4304
- const [, indent, key, eq, quote, value] = m;
5637
+ const m2 = line.match(/^(\s*)([a-zA-Z][a-zA-Z0-9_\-]*)(\s*=\s*)(['"]?)(.+?)\4\s*$/);
5638
+ if (m2) {
5639
+ const [, indent, key, eq, quote, value] = m2;
4305
5640
  if (shouldRedactKeyValue(key, value)) {
4306
5641
  const varName = key.toUpperCase().replace(/[^A-Z0-9]/g, "_");
4307
5642
  redacted.push({ varName, line: i + 1, reason: reasonFor(key, value) });
@@ -4327,9 +5662,9 @@ function redactIni(content) {
4327
5662
  out.push(`${authM[1]}\${NPM_TOKEN}`);
4328
5663
  continue;
4329
5664
  }
4330
- const m = line.match(/^(\s*)([a-zA-Z][a-zA-Z0-9_\-]*)(\s*=\s*)(.+?)\s*$/);
4331
- if (m) {
4332
- const [, indent, key, eq, value] = m;
5665
+ const m2 = line.match(/^(\s*)([a-zA-Z][a-zA-Z0-9_\-]*)(\s*=\s*)(.+?)\s*$/);
5666
+ if (m2) {
5667
+ const [, indent, key, eq, value] = m2;
4333
5668
  if (shouldRedactKeyValue(key, value)) {
4334
5669
  const varName = key.toUpperCase().replace(/[^A-Z0-9]/g, "_");
4335
5670
  redacted.push({ varName, line: i + 1, reason: reasonFor(key, value) });
@@ -5318,8 +6653,8 @@ function parseManagedBlock(content, force) {
5318
6653
  const begin = starts[0];
5319
6654
  const end = ends[0];
5320
6655
  const a = begin.marker;
5321
- const b = end.marker;
5322
- if (a.id !== b.id || a.revision !== b.revision || a.hash !== b.hash) {
6656
+ const b2 = end.marker;
6657
+ if (a.id !== b2.id || a.revision !== b2.revision || a.hash !== b2.hash) {
5323
6658
  if (!force)
5324
6659
  throw new ProjectContextError("MANAGED_BLOCK_CONFLICT", "managed project-context marker metadata is inconsistent");
5325
6660
  return { block: null, forceRange: { start: begin.start, end: lineContentEnd(end) } };
@@ -5337,7 +6672,7 @@ function parseManagedBlock(content, force) {
5337
6672
  id: a.id,
5338
6673
  revision: a.revision,
5339
6674
  hash: a.hash,
5340
- legacy: a.legacy || b.legacy
6675
+ legacy: a.legacy || b2.legacy
5341
6676
  },
5342
6677
  forceRange: null
5343
6678
  };
@@ -7149,11 +8484,11 @@ function durableSourcePath(path, workspaceRoot) {
7149
8484
  }
7150
8485
  function compareRevisions(incoming, previous) {
7151
8486
  const a = revisionKey(incoming);
7152
- const b = revisionKey(previous);
7153
- if (!a || !b || a.kind !== b.kind) {
8487
+ const b2 = revisionKey(previous);
8488
+ if (!a || !b2 || a.kind !== b2.kind) {
7154
8489
  throw new ProjectContextError("PROJECT_CONTEXT_REVISION_INCOMPARABLE", "project-context revisions use incompatible ordering schemes");
7155
8490
  }
7156
- return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
8491
+ return a.value < b2.value ? -1 : a.value > b2.value ? 1 : 0;
7157
8492
  }
7158
8493
  function revisionKey(value) {
7159
8494
  const sequence = value.match(/^(?:rev-)?([0-9]+)$/);
@@ -7342,8 +8677,8 @@ function yamlQuote(value) {
7342
8677
  return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
7343
8678
  }
7344
8679
  function headingLevel(line) {
7345
- const m = line.match(/^(#{1,6})\s+/);
7346
- return m ? m[1].length : null;
8680
+ const m2 = line.match(/^(#{1,6})\s+/);
8681
+ return m2 ? m2[1].length : null;
7347
8682
  }
7348
8683
  function stripClaudeOnlySections(content) {
7349
8684
  const withoutMarkedBlocks = content.replace(/<!--\s*claude-only:start\s*-->[\s\S]*?<!--\s*claude-only:end\s*-->/gi, "");
@@ -7381,7 +8716,7 @@ function ruleLabel(config) {
7381
8716
  return file.replace(/\.(md|mdc|markdown)$/i, "");
7382
8717
  }
7383
8718
  function claudeRules(source, context) {
7384
- return (context.configs ?? []).filter((config) => isClaudeRuleConfig(source, config)).sort((a, b) => (a.target_path ?? a.name).localeCompare(b.target_path ?? b.name));
8719
+ return (context.configs ?? []).filter((config) => isClaudeRuleConfig(source, config)).sort((a, b2) => (a.target_path ?? a.name).localeCompare(b2.target_path ?? b2.name));
7385
8720
  }
7386
8721
  function flattenWithRules(source, context) {
7387
8722
  const parts = [stripClaudeOnlySections(source.content)];
@@ -7951,7 +9286,7 @@ function sha2562(value) {
7951
9286
  return createHash2("sha256").update(value).digest("hex");
7952
9287
  }
7953
9288
  function stableJson(value) {
7954
- const canonical = (entry) => Array.isArray(entry) ? entry.map(canonical) : entry && typeof entry === "object" ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => [key, canonical(child)])) : entry;
9289
+ const canonical = (entry) => Array.isArray(entry) ? entry.map(canonical) : entry && typeof entry === "object" ? Object.fromEntries(Object.entries(entry).sort(([a], [b2]) => a.localeCompare(b2)).map(([key, child]) => [key, canonical(child)])) : entry;
7955
9290
  return JSON.stringify(canonical(value));
7956
9291
  }
7957
9292
  function deepFreeze(value) {
@@ -8725,8 +10060,8 @@ function normalizeSources(sources, tool, allowEmptySources) {
8725
10060
  rejectDuplicateRulePaths(ordered);
8726
10061
  return { sources: ordered, skipped: [...providerSkipped, ...deduplicated.skipped] };
8727
10062
  }
8728
- function compareSessionInstructionSources(a, b) {
8729
- return SESSION_LAYER_RANK[a.resolvedLayer] - SESSION_LAYER_RANK[b.resolvedLayer] || a.resolvedOrder - b.resolvedOrder || a.id.localeCompare(b.id);
10063
+ function compareSessionInstructionSources(a, b2) {
10064
+ return SESSION_LAYER_RANK[a.resolvedLayer] - SESSION_LAYER_RANK[b2.resolvedLayer] || a.resolvedOrder - b2.resolvedOrder || a.id.localeCompare(b2.id);
8730
10065
  }
8731
10066
  function semanticPolicyIntegrity(body) {
8732
10067
  return sha2565(body) === AGENT_OPERATING_RULES_PAYLOAD_SHA256 ? "pinned-digest" : "unverified-self-declared";
@@ -9603,10 +10938,54 @@ function resolveSessionTargetOwnership(input, target) {
9603
10938
  };
9604
10939
  }
9605
10940
  function planSessionRender(input) {
10941
+ if (input.claudeProjectImport)
10942
+ throw new Error("CLAUDE_PROJECT_IMPORT_REQUIRES_PROFILE: use explicit shared profile bindings.");
10943
+ return buildSessionRenderPlan(input);
10944
+ }
10945
+ function planCompiledProfileSessionRender(input, companionSources) {
10946
+ if (input.claudeProjectImport) {
10947
+ if (!companionSources || fingerprint(input.sources) !== fingerprint(companionSources)) {
10948
+ throw new Error("CLAUDE_PROJECT_IMPORT_DIVERGENT: both consumers must compile the same ordered source bodies and activation semantics.");
10949
+ }
10950
+ const normalizedFor = (sources, tool) => composeSources(normalizeSources(sources, tool, input.allowEmptySources === true).sources, tool).sources;
10951
+ if (fingerprint(normalizedFor(input.sources, "sumi")) !== fingerprint(normalizedFor(companionSources, "claude"))) {
10952
+ throw new Error("CLAUDE_PROJECT_IMPORT_DIVERGENT: provider filtering or composition changes the shared canonical policy.");
10953
+ }
10954
+ }
10955
+ return buildSessionRenderPlan(input);
10956
+ }
10957
+ function assertNoUnmanagedClaudeImports(content) {
10958
+ const markdown = new q({ gfm: false, async: false, renderer: {
10959
+ codespan: () => "",
10960
+ def: ({ raw }) => raw,
10961
+ code: ({ raw }) => {
10962
+ const lines = raw.trimEnd().split(`
10963
+ `);
10964
+ const first = lines[0]?.match(/^ {0,3}(`{3,}|~{3,})/);
10965
+ const last = lines.at(-1)?.match(/^ {0,3}(`{3,}|~{3,})\s*$/);
10966
+ return lines.length > 1 && first && last && first[1][0] === last[1][0] && last[1].length >= first[1].length ? "" : raw;
10967
+ }
10968
+ } });
10969
+ const prose = markdown.parse(content.replaceAll(`<!-- ${SESSION_RENDER_MANAGED_MARKER}. Do not edit this generated file directly. -->`, "")).replace(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}(?=$|[\s<>),.;:])/gi, "");
10970
+ if (prose.includes("@"))
10971
+ throw new Error("CLAUDE_PROJECT_IMPORT_NESTED: shared canonical policy cannot contain native @ imports; quote literal package/path references in Markdown code.");
10972
+ }
10973
+ function buildSessionRenderPlan(input) {
9606
10974
  if (!SESSION_RENDER_TOOLS.includes(input.tool))
9607
10975
  throw new Error(`Unsupported session render tool: ${input.tool}`);
9608
10976
  if (!input.profile.trim())
9609
10977
  throw new Error("Session render profile is required.");
10978
+ if (input.claudeProjectImport) {
10979
+ if (input.tool !== "sumi" || !input.projectRoot || input.targetHome && resolveSessionPath(input.targetHome) !== resolveSessionPath(input.projectRoot)) {
10980
+ throw new Error("CLAUDE_PROJECT_IMPORT_TARGET: requires a Sumi project root with one shared manifest owner.");
10981
+ }
10982
+ if (Object.keys(input.claudeProjectImport).some((key) => key !== "providerVersion") || input.claudeProjectImport.providerVersion !== "2.1.278") {
10983
+ throw new Error("CLAUDE_PROJECT_IMPORT_CAPABILITY: only verified Claude 2.1.278 relative project imports are supported.");
10984
+ }
10985
+ }
10986
+ if (JSON.stringify(input.refreshSelector?.claudeProjectImport) !== JSON.stringify(input.claudeProjectImport) && input.refreshSelector) {
10987
+ throw new Error("CLAUDE_PROJECT_IMPORT_SELECTOR: refresh must preserve the exact companion capability.");
10988
+ }
9610
10989
  const adapter = adapterFor(input);
9611
10990
  const {
9612
10991
  targetHome,
@@ -9667,7 +11046,25 @@ function planSessionRender(input) {
9667
11046
  if (projectContext && orderedSources.some((source) => source.id === projectContext.source.id)) {
9668
11047
  throw new Error(`Session source ${projectContext.source.id} is reserved for the durable Instructions project-context renderer.`);
9669
11048
  }
9670
- const files = projectContext?.files ?? baseFiles;
11049
+ const files = [...projectContext?.files ?? baseFiles];
11050
+ let claudeProjectImport;
11051
+ if (input.claudeProjectImport && !blocked) {
11052
+ const canonical = files.find((file) => file.relativePath === "AGENTS.md");
11053
+ if (!canonical)
11054
+ throw new Error("CLAUDE_PROJECT_IMPORT_CANONICAL: missing canonical project AGENTS.md.");
11055
+ assertNoUnmanagedClaudeImports(canonical.content);
11056
+ claudeProjectImport = {
11057
+ ...input.claudeProjectImport,
11058
+ capability: "claude-project-relative-import/v1",
11059
+ canonicalPath: "AGENTS.md",
11060
+ canonicalSha256: canonical.sha256,
11061
+ importPath: "CLAUDE.md"
11062
+ };
11063
+ files.push(makeFile(targetHome, "CLAUDE.md", "index", `<!-- ${SESSION_RENDER_MANAGED_MARKER}. Do not edit this generated file directly. -->
11064
+
11065
+ @./AGENTS.md
11066
+ `, canonical.sourceIds));
11067
+ }
9671
11068
  const assetFiles = buildAssetFiles(input, targetHome, blocked);
9672
11069
  rejectDuplicateRenderPaths([...files, ...assetFiles]);
9673
11070
  const manifest = {
@@ -9677,6 +11074,7 @@ function planSessionRender(input) {
9677
11074
  profile: input.profile,
9678
11075
  sessionId: input.sessionId ?? null,
9679
11076
  ...input.refreshSelector ? { refreshSelector: input.refreshSelector } : {},
11077
+ ...claudeProjectImport ? { claudeProjectImport } : {},
9680
11078
  targetHome,
9681
11079
  targetKind,
9682
11080
  targetOwner,
@@ -9692,12 +11090,14 @@ function planSessionRender(input) {
9692
11090
  providerSurface: input.providerSurface ?? null,
9693
11091
  providerConfig: input.providerConfig ? { sourceId: input.providerConfig.sourceId, content: input.providerConfig.content } : null,
9694
11092
  projectContext: projectContext.project_context,
9695
- assetPlanDigest: input.assetPlan?.planDigest ?? null
11093
+ assetPlanDigest: input.assetPlan?.planDigest ?? null,
11094
+ ...claudeProjectImport ? { claudeProjectImport } : {}
9696
11095
  } : {
9697
11096
  sources: orderedSources.map(sourceFingerprint),
9698
11097
  providerSurface: input.providerSurface ?? null,
9699
11098
  providerConfig: input.providerConfig ? { sourceId: input.providerConfig.sourceId, content: input.providerConfig.content } : null,
9700
- assetPlanDigest: input.assetPlan?.planDigest ?? null
11099
+ assetPlanDigest: input.assetPlan?.planDigest ?? null,
11100
+ ...claudeProjectImport ? { claudeProjectImport } : {}
9701
11101
  }),
9702
11102
  sources: [
9703
11103
  ...orderedSources.map((source) => ({
@@ -10552,6 +11952,23 @@ function planProfileSessionRender(input) {
10552
11952
  ...nativeProfile ? { provider_variant: "native-profile" } : {}
10553
11953
  }
10554
11954
  });
11955
+ let companionSources;
11956
+ if (input.claudeProjectImport) {
11957
+ if (input.extra_sources?.length)
11958
+ throw new Error("CLAUDE_PROJECT_IMPORT_UNBOUND: shared project imports cannot include extra sources outside explicit profile bindings.");
11959
+ for (const unit of compiled.plan.units) {
11960
+ const providers = input.bindings.find((row) => row.config_id === unit.config_id && row.profile_id === input.profile_id)?.binding.providers;
11961
+ if (!providers?.some((entry) => entry.provider === "sumi") || !providers.some((entry) => entry.provider === "claude")) {
11962
+ throw new Error(`CLAUDE_PROJECT_IMPORT_BINDING: ${unit.config_id} requires explicit Sumi and Claude provider bindings.`);
11963
+ }
11964
+ }
11965
+ companionSources = compileInstructionGraph({
11966
+ profile_id: input.profile_id,
11967
+ configs: input.configs,
11968
+ bindings: input.bindings,
11969
+ context: { ...input.graph_context, provider: "claude", provider_version: input.claudeProjectImport.providerVersion, provider_variant: undefined }
11970
+ }).sources;
11971
+ }
10555
11972
  const assetPlan = compileAssetPlan({
10556
11973
  profileId: input.profile_id,
10557
11974
  provider: input.tool,
@@ -10585,13 +12002,13 @@ function planProfileSessionRender(input) {
10585
12002
  ]);
10586
12003
  }
10587
12004
  return deepFreeze2({
10588
- ...planSessionRender({
12005
+ ...planCompiledProfileSessionRender({
10589
12006
  ...renderInput,
10590
12007
  ...compiled.capability.session_surface ? { providerSurface: compiled.capability.session_surface } : {},
10591
12008
  sources: [...compiled.sources, ...input.extra_sources ?? []],
10592
12009
  assetPlan,
10593
12010
  assetContents: Object.fromEntries((input.asset_configs ?? []).map((config) => [config.id, config.content]))
10594
- }),
12011
+ }, companionSources),
10595
12012
  instructionGraph: compiled.plan
10596
12013
  });
10597
12014
  }
@@ -10727,7 +12144,7 @@ function sha2566(value) {
10727
12144
  return createHash6("sha256").update(value).digest("hex");
10728
12145
  }
10729
12146
  function stableJson2(value) {
10730
- const canonical = (entry) => Array.isArray(entry) ? entry.map(canonical) : entry && typeof entry === "object" ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => [key, canonical(child)])) : entry;
12147
+ const canonical = (entry) => Array.isArray(entry) ? entry.map(canonical) : entry && typeof entry === "object" ? Object.fromEntries(Object.entries(entry).sort(([a], [b2]) => a.localeCompare(b2)).map(([key, child]) => [key, canonical(child)])) : entry;
10731
12148
  return JSON.stringify(canonical(value));
10732
12149
  }
10733
12150
  function deepFreeze2(value) {
@@ -11627,8 +13044,8 @@ function appendQuery(path, query) {
11627
13044
  if (value === null || value === undefined)
11628
13045
  continue;
11629
13046
  if (Array.isArray(value)) {
11630
- for (const v of value)
11631
- params.append(key, String(v));
13047
+ for (const v2 of value)
13048
+ params.append(key, String(v2));
11632
13049
  } else {
11633
13050
  params.append(key, String(value));
11634
13051
  }
@@ -11833,9 +13250,9 @@ function entityPath(resource, id) {
11833
13250
  return `${resourcePath(resource)}/${encodeURIComponent(String(id))}`;
11834
13251
  }
11835
13252
  function newIdempotencyKey() {
11836
- const g = globalThis;
11837
- if (g.crypto?.randomUUID)
11838
- return g.crypto.randomUUID();
13253
+ const g2 = globalThis;
13254
+ if (g2.crypto?.randomUUID)
13255
+ return g2.crypto.randomUUID();
11839
13256
  return `idmp_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 12)}`;
11840
13257
  }
11841
13258
  function extractItems(raw) {
@@ -12089,7 +13506,7 @@ function formatCliError(err, env = process.env) {
12089
13506
  var localStoreModulePromise = null;
12090
13507
  function localStoreModule() {
12091
13508
  if (!localStoreModulePromise)
12092
- localStoreModulePromise = import("./local-jqfx3kbq.js");
13509
+ localStoreModulePromise = import("./local-nbck7fs2.js");
12093
13510
  return localStoreModulePromise;
12094
13511
  }
12095
13512