hanbiro-react16-sdk 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2180 +0,0 @@
1
- var Re = Object.defineProperty;
2
- var $e = (n, e, t) => e in n ? Re(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var g = (n, e, t) => $e(n, typeof e != "symbol" ? e + "" : e, t);
4
- import * as u from "react";
5
- import { v4 as Ee } from "uuid";
6
- import { Copy as pe, Settings as Te, Send as Ce } from "react-feather";
7
- const W = [
8
- { label: "Korean", value: "KR", extra: "ko" },
9
- { label: "English", value: "US", extra: "en" },
10
- { label: "Japanese", value: "JP" },
11
- { label: "Simplified Chinese", value: "zh-CN", extra: "zh-chs" },
12
- { label: "Traditional Chinese (Taiwan)", value: "zh-TW" },
13
- { label: "Traditional Chinese (Hong Kong)", value: "zh-HK", extra: "zh-cht" },
14
- { label: "Vietnamese", value: "VN", extra: "vi" },
15
- { label: "Indonesian", value: "ID", extra: "id" }
16
- ], ze = ({ isGradient: n = !1, stroke: e = 1.5, size: t = 40 }) => {
17
- const r = "ai-gradient-" + Math.random().toString(36).substr(2, 9);
18
- return /* @__PURE__ */ u.createElement(
19
- "svg",
20
- {
21
- xmlns: "http://www.w3.org/2000/svg",
22
- width: t,
23
- height: t,
24
- viewBox: "0 0 24 24",
25
- style: { flexShrink: 0 }
26
- },
27
- n && /* @__PURE__ */ u.createElement("defs", null, /* @__PURE__ */ u.createElement("linearGradient", { id: r, x1: "0%", y1: "0%", x2: "0%", y2: "100%" }, /* @__PURE__ */ u.createElement("stop", { offset: "0%", stopColor: "#9D50BB" }, /* @__PURE__ */ u.createElement(
28
- "animate",
29
- {
30
- attributeName: "offset",
31
- values: "0%;0.4;0%",
32
- dur: "1s",
33
- repeatCount: "indefinite"
34
- }
35
- )), /* @__PURE__ */ u.createElement("stop", { offset: "30%", stopColor: "#6E48AA" }, /* @__PURE__ */ u.createElement(
36
- "animate",
37
- {
38
- attributeName: "offset",
39
- values: "0.4;0.7;0.4",
40
- dur: "1s",
41
- repeatCount: "indefinite"
42
- }
43
- )), /* @__PURE__ */ u.createElement("stop", { offset: "50%", stopColor: "#4776E6" }, /* @__PURE__ */ u.createElement(
44
- "animate",
45
- {
46
- attributeName: "offset",
47
- values: "0.5;0.7;0.5",
48
- dur: "1s",
49
- repeatCount: "indefinite"
50
- }
51
- )), /* @__PURE__ */ u.createElement(
52
- "animateTransform",
53
- {
54
- attributeName: "gradientTransform",
55
- type: "translate",
56
- from: "0,0",
57
- to: "100,0",
58
- dur: "1s",
59
- repeatCount: "indefinite"
60
- }
61
- ))),
62
- /* @__PURE__ */ u.createElement(
63
- "path",
64
- {
65
- fill: "none",
66
- stroke: n ? `url(#${r})` : "currentColor",
67
- strokeLinecap: "round",
68
- strokeLinejoin: "round",
69
- strokeWidth: e,
70
- d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0zM20 3v4m2-2h-4M4 17v2m1-1H3"
71
- }
72
- )
73
- );
74
- };
75
- async function Ae(n, { setContent: e, setIsLoading: t, setConversationId: r, signer: i, baseUrl: s }) {
76
- let c = "";
77
- try {
78
- t(!0);
79
- const a = {
80
- method: "POST",
81
- baseURL: s,
82
- url: "/nmail/chatdraft",
83
- params: n
84
- };
85
- let h = {};
86
- i && typeof i.generateHeaders == "function" && (h = await i.generateHeaders(a));
87
- const l = await fetch(`${s}/nmail/chatdraft`, {
88
- method: "POST",
89
- body: JSON.stringify(n),
90
- headers: {
91
- "Content-Type": "application/json",
92
- "Access-Control-Allow-Origin": "*",
93
- ...h
94
- }
95
- });
96
- if (t(!1), !l.body)
97
- throw new Error("Response body is not available for streaming.");
98
- const o = l.body.getReader();
99
- let d = "", p = 0;
100
- for (; ; ) {
101
- const { done: x, value: f } = await o.read();
102
- if (x)
103
- break;
104
- let b = "", y = "";
105
- try {
106
- const S = new TextDecoder().decode(f);
107
- d += S;
108
- const A = /"answer":".*?"/g, v = /"conversation_id"\s*:\s*"([^"]+)"/, I = [...d.matchAll(A)], L = d.match(v);
109
- for (L && L[1] && r(L[1]); p < I.length; ) {
110
- const _ = I[p];
111
- try {
112
- b = _[0];
113
- const R = b.slice(10, b.length - 1);
114
- y = `"${R}"`, R.endsWith("\\") && (y = `"${R}\\"`);
115
- const Se = JSON.parse(y);
116
- c += Se, e(c);
117
- } catch (R) {
118
- console.error("Parse error: ", R, b, y);
119
- }
120
- p++;
121
- }
122
- } catch (S) {
123
- console.error("TextDecoder error: ", S, b);
124
- }
125
- }
126
- return c;
127
- } catch (a) {
128
- console.error("Summary error:", a), e("");
129
- } finally {
130
- t(!1);
131
- }
132
- return "";
133
- }
134
- function J() {
135
- return {
136
- async: !1,
137
- breaks: !1,
138
- extensions: null,
139
- gfm: !0,
140
- hooks: null,
141
- pedantic: !1,
142
- renderer: null,
143
- silent: !1,
144
- tokenizer: null,
145
- walkTokens: null
146
- };
147
- }
148
- var z = J();
149
- function ue(n) {
150
- z = n;
151
- }
152
- var D = { exec: () => null };
153
- function k(n, e = "") {
154
- let t = typeof n == "string" ? n : n.source;
155
- const r = {
156
- replace: (i, s) => {
157
- let c = typeof s == "string" ? s : s.source;
158
- return c = c.replace(w.caret, "$1"), t = t.replace(i, c), r;
159
- },
160
- getRegex: () => new RegExp(t, e)
161
- };
162
- return r;
163
- }
164
- var w = {
165
- codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
166
- outputLinkReplace: /\\([\[\]])/g,
167
- indentCodeCompensation: /^(\s+)(?:```)/,
168
- beginningSpace: /^\s+/,
169
- endingHash: /#$/,
170
- startingSpaceChar: /^ /,
171
- endingSpaceChar: / $/,
172
- nonSpaceChar: /[^ ]/,
173
- newLineCharGlobal: /\n/g,
174
- tabCharGlobal: /\t/g,
175
- multipleSpaceGlobal: /\s+/g,
176
- blankLine: /^[ \t]*$/,
177
- doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
178
- blockquoteStart: /^ {0,3}>/,
179
- blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
180
- blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
181
- listReplaceTabs: /^\t+/,
182
- listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
183
- listIsTask: /^\[[ xX]\] /,
184
- listReplaceTask: /^\[[ xX]\] +/,
185
- anyLine: /\n.*\n/,
186
- hrefBrackets: /^<(.*)>$/,
187
- tableDelimiter: /[:|]/,
188
- tableAlignChars: /^\||\| *$/g,
189
- tableRowBlankLine: /\n[ \t]*$/,
190
- tableAlignRight: /^ *-+: *$/,
191
- tableAlignCenter: /^ *:-+: *$/,
192
- tableAlignLeft: /^ *:-+ *$/,
193
- startATag: /^<a /i,
194
- endATag: /^<\/a>/i,
195
- startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
196
- endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
197
- startAngleBracket: /^</,
198
- endAngleBracket: />$/,
199
- pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
200
- unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
201
- escapeTest: /[&<>"']/,
202
- escapeReplace: /[&<>"']/g,
203
- escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
204
- escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
205
- unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
206
- caret: /(^|[^\[])\^/g,
207
- percentDecode: /%25/g,
208
- findPipe: /\|/g,
209
- splitPipe: / \|/,
210
- slashPipe: /\\\|/g,
211
- carriageReturn: /\r\n|\r/g,
212
- spaceLine: /^ +$/gm,
213
- notSpaceStart: /^\S*/,
214
- endingNewline: /\n$/,
215
- listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
216
- nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
217
- hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
218
- fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
219
- headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
220
- htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
221
- }, Ie = /^(?:[ \t]*(?:\n|$))+/, Le = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, _e = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, V = /(?:[*+-]|\d{1,9}[.)])/, ge = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, de = k(ge).replace(/bull/g, V).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(), Be = k(ge).replace(/bull/g, V).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(), X = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, De = /^[^\n]+/, Y = /(?!\s*\])(?:\\.|[^\[\]\\])+/, qe = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Y).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Me = k(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, V).getRegex(), 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", ee = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Oe = k(
222
- "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))",
223
- "i"
224
- ).replace("comment", ee).replace("tag", H).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), fe = k(X).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)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), Ne = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", fe).getRegex(), te = {
225
- blockquote: Ne,
226
- code: Le,
227
- def: qe,
228
- fences: _e,
229
- heading: Pe,
230
- hr: q,
231
- html: Oe,
232
- lheading: de,
233
- list: Me,
234
- newline: Ie,
235
- paragraph: fe,
236
- table: D,
237
- text: De
238
- }, se = k(
239
- "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
240
- ).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex(), je = {
241
- ...te,
242
- lheading: Be,
243
- table: se,
244
- paragraph: k(X).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)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", H).getRegex()
245
- }, Ze = {
246
- ...te,
247
- html: k(
248
- `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
249
- ).replace("comment", ee).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(),
250
- def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
251
- heading: /^(#{1,6})(.*)(?:\n+|$)/,
252
- fences: D,
253
- // fences not supported
254
- lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
255
- paragraph: k(X).replace("hr", q).replace("heading", ` *#{1,6} *[^
256
- ]`).replace("lheading", de).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
257
- }, He = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ge = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, me = /^( {2,}|\\)\n(?!\s*$)/, Qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, G = /[\p{P}\p{S}]/u, ne = /[\s\p{P}\p{S}]/u, ke = /[^\s\p{P}\p{S}]/u, We = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, ne).getRegex(), be = /(?!~)[\p{P}\p{S}]/u, Fe = /(?!~)[\s\p{P}\p{S}]/u, Ke = /(?:[^\s\p{P}\p{S}]|~)/u, Ue = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, xe = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Je = k(xe, "u").replace(/punct/g, G).getRegex(), Ve = k(xe, "u").replace(/punct/g, be).getRegex(), we = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Xe = k(we, "gu").replace(/notPunctSpace/g, ke).replace(/punctSpace/g, ne).replace(/punct/g, G).getRegex(), Ye = k(we, "gu").replace(/notPunctSpace/g, Ke).replace(/punctSpace/g, Fe).replace(/punct/g, be).getRegex(), et = k(
258
- "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
259
- "gu"
260
- ).replace(/notPunctSpace/g, ke).replace(/punctSpace/g, ne).replace(/punct/g, G).getRegex(), tt = k(/\\(punct)/, "gu").replace(/punct/g, G).getRegex(), nt = 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(), rt = k(ee).replace("(?:-->|$)", "-->").getRegex(), it = k(
261
- "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
262
- ).replace("comment", rt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), N = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, st = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", N).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ye = k(/^!?\[(label)\]\[(ref)\]/).replace("label", N).replace("ref", Y).getRegex(), ve = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", Y).getRegex(), at = k("reflink|nolink(?!\\()", "g").replace("reflink", ye).replace("nolink", ve).getRegex(), re = {
263
- _backpedal: D,
264
- // only used for GFM url
265
- anyPunctuation: tt,
266
- autolink: nt,
267
- blockSkip: Ue,
268
- br: me,
269
- code: Ge,
270
- del: D,
271
- emStrongLDelim: Je,
272
- emStrongRDelimAst: Xe,
273
- emStrongRDelimUnd: et,
274
- escape: He,
275
- link: st,
276
- nolink: ve,
277
- punctuation: We,
278
- reflink: ye,
279
- reflinkSearch: at,
280
- tag: it,
281
- text: Qe,
282
- url: D
283
- }, lt = {
284
- ...re,
285
- link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", N).getRegex(),
286
- reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", N).getRegex()
287
- }, F = {
288
- ...re,
289
- emStrongRDelimAst: Ye,
290
- emStrongLDelim: Ve,
291
- url: k(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
292
- _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
293
- del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
294
- text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
295
- }, ot = {
296
- ...F,
297
- br: k(me).replace("{2,}", "*").getRegex(),
298
- text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
299
- }, M = {
300
- normal: te,
301
- gfm: je,
302
- pedantic: Ze
303
- }, P = {
304
- normal: re,
305
- gfm: F,
306
- breaks: ot,
307
- pedantic: lt
308
- }, ct = {
309
- "&": "&amp;",
310
- "<": "&lt;",
311
- ">": "&gt;",
312
- '"': "&quot;",
313
- "'": "&#39;"
314
- }, ae = (n) => ct[n];
315
- function $(n, e) {
316
- if (e) {
317
- if (w.escapeTest.test(n))
318
- return n.replace(w.escapeReplace, ae);
319
- } else if (w.escapeTestNoEncode.test(n))
320
- return n.replace(w.escapeReplaceNoEncode, ae);
321
- return n;
322
- }
323
- function le(n) {
324
- try {
325
- n = encodeURI(n).replace(w.percentDecode, "%");
326
- } catch {
327
- return null;
328
- }
329
- return n;
330
- }
331
- function oe(n, e) {
332
- var s;
333
- const t = n.replace(w.findPipe, (c, a, h) => {
334
- let l = !1, o = a;
335
- for (; --o >= 0 && h[o] === "\\"; ) l = !l;
336
- return l ? "|" : " |";
337
- }), r = t.split(w.splitPipe);
338
- let i = 0;
339
- if (r[0].trim() || r.shift(), r.length > 0 && !((s = r.at(-1)) != null && s.trim()) && r.pop(), e)
340
- if (r.length > e)
341
- r.splice(e);
342
- else
343
- for (; r.length < e; ) r.push("");
344
- for (; i < r.length; i++)
345
- r[i] = r[i].trim().replace(w.slashPipe, "|");
346
- return r;
347
- }
348
- function B(n, e, t) {
349
- const r = n.length;
350
- if (r === 0)
351
- return "";
352
- let i = 0;
353
- for (; i < r && n.charAt(r - i - 1) === e; )
354
- i++;
355
- return n.slice(0, r - i);
356
- }
357
- function ht(n, e) {
358
- if (n.indexOf(e[1]) === -1)
359
- return -1;
360
- let t = 0;
361
- for (let r = 0; r < n.length; r++)
362
- if (n[r] === "\\")
363
- r++;
364
- else if (n[r] === e[0])
365
- t++;
366
- else if (n[r] === e[1] && (t--, t < 0))
367
- return r;
368
- return t > 0 ? -2 : -1;
369
- }
370
- function ce(n, e, t, r, i) {
371
- const s = e.href, c = e.title || null, a = n[1].replace(i.other.outputLinkReplace, "$1");
372
- r.state.inLink = !0;
373
- const h = {
374
- type: n[0].charAt(0) === "!" ? "image" : "link",
375
- raw: t,
376
- href: s,
377
- title: c,
378
- text: a,
379
- tokens: r.inlineTokens(a)
380
- };
381
- return r.state.inLink = !1, h;
382
- }
383
- function pt(n, e, t) {
384
- const r = n.match(t.other.indentCodeCompensation);
385
- if (r === null)
386
- return e;
387
- const i = r[1];
388
- return e.split(`
389
- `).map((s) => {
390
- const c = s.match(t.other.beginningSpace);
391
- if (c === null)
392
- return s;
393
- const [a] = c;
394
- return a.length >= i.length ? s.slice(i.length) : s;
395
- }).join(`
396
- `);
397
- }
398
- var j = class {
399
- // set by the lexer
400
- constructor(n) {
401
- g(this, "options");
402
- g(this, "rules");
403
- // set by the lexer
404
- g(this, "lexer");
405
- this.options = n || z;
406
- }
407
- space(n) {
408
- const e = this.rules.block.newline.exec(n);
409
- if (e && e[0].length > 0)
410
- return {
411
- type: "space",
412
- raw: e[0]
413
- };
414
- }
415
- code(n) {
416
- const e = this.rules.block.code.exec(n);
417
- if (e) {
418
- const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
419
- return {
420
- type: "code",
421
- raw: e[0],
422
- codeBlockStyle: "indented",
423
- text: this.options.pedantic ? t : B(t, `
424
- `)
425
- };
426
- }
427
- }
428
- fences(n) {
429
- const e = this.rules.block.fences.exec(n);
430
- if (e) {
431
- const t = e[0], r = pt(t, e[3] || "", this.rules);
432
- return {
433
- type: "code",
434
- raw: t,
435
- lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
436
- text: r
437
- };
438
- }
439
- }
440
- heading(n) {
441
- const e = this.rules.block.heading.exec(n);
442
- if (e) {
443
- let t = e[2].trim();
444
- if (this.rules.other.endingHash.test(t)) {
445
- const r = B(t, "#");
446
- (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (t = r.trim());
447
- }
448
- return {
449
- type: "heading",
450
- raw: e[0],
451
- depth: e[1].length,
452
- text: t,
453
- tokens: this.lexer.inline(t)
454
- };
455
- }
456
- }
457
- hr(n) {
458
- const e = this.rules.block.hr.exec(n);
459
- if (e)
460
- return {
461
- type: "hr",
462
- raw: B(e[0], `
463
- `)
464
- };
465
- }
466
- blockquote(n) {
467
- const e = this.rules.block.blockquote.exec(n);
468
- if (e) {
469
- let t = B(e[0], `
470
- `).split(`
471
- `), r = "", i = "";
472
- const s = [];
473
- for (; t.length > 0; ) {
474
- let c = !1;
475
- const a = [];
476
- let h;
477
- for (h = 0; h < t.length; h++)
478
- if (this.rules.other.blockquoteStart.test(t[h]))
479
- a.push(t[h]), c = !0;
480
- else if (!c)
481
- a.push(t[h]);
482
- else
483
- break;
484
- t = t.slice(h);
485
- const l = a.join(`
486
- `), o = l.replace(this.rules.other.blockquoteSetextReplace, `
487
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
488
- r = r ? `${r}
489
- ${l}` : l, i = i ? `${i}
490
- ${o}` : o;
491
- const d = this.lexer.state.top;
492
- if (this.lexer.state.top = !0, this.lexer.blockTokens(o, s, !0), this.lexer.state.top = d, t.length === 0)
493
- break;
494
- const p = s.at(-1);
495
- if ((p == null ? void 0 : p.type) === "code")
496
- break;
497
- if ((p == null ? void 0 : p.type) === "blockquote") {
498
- const x = p, f = x.raw + `
499
- ` + t.join(`
500
- `), b = this.blockquote(f);
501
- s[s.length - 1] = b, r = r.substring(0, r.length - x.raw.length) + b.raw, i = i.substring(0, i.length - x.text.length) + b.text;
502
- break;
503
- } else if ((p == null ? void 0 : p.type) === "list") {
504
- const x = p, f = x.raw + `
505
- ` + t.join(`
506
- `), b = this.list(f);
507
- s[s.length - 1] = b, r = r.substring(0, r.length - p.raw.length) + b.raw, i = i.substring(0, i.length - x.raw.length) + b.raw, t = f.substring(s.at(-1).raw.length).split(`
508
- `);
509
- continue;
510
- }
511
- }
512
- return {
513
- type: "blockquote",
514
- raw: r,
515
- tokens: s,
516
- text: i
517
- };
518
- }
519
- }
520
- list(n) {
521
- let e = this.rules.block.list.exec(n);
522
- if (e) {
523
- let t = e[1].trim();
524
- const r = t.length > 1, i = {
525
- type: "list",
526
- raw: "",
527
- ordered: r,
528
- start: r ? +t.slice(0, -1) : "",
529
- loose: !1,
530
- items: []
531
- };
532
- t = r ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = r ? t : "[*+-]");
533
- const s = this.rules.other.listItemRegex(t);
534
- let c = !1;
535
- for (; n; ) {
536
- let h = !1, l = "", o = "";
537
- if (!(e = s.exec(n)) || this.rules.block.hr.test(n))
538
- break;
539
- l = e[0], n = n.substring(l.length);
540
- let d = e[2].split(`
541
- `, 1)[0].replace(this.rules.other.listReplaceTabs, (S) => " ".repeat(3 * S.length)), p = n.split(`
542
- `, 1)[0], x = !d.trim(), f = 0;
543
- if (this.options.pedantic ? (f = 2, o = d.trimStart()) : x ? f = e[1].length + 1 : (f = e[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, o = d.slice(f), f += e[1].length), x && this.rules.other.blankLine.test(p) && (l += p + `
544
- `, n = n.substring(p.length + 1), h = !0), !h) {
545
- const S = this.rules.other.nextBulletRegex(f), A = this.rules.other.hrRegex(f), v = this.rules.other.fencesBeginRegex(f), I = this.rules.other.headingBeginRegex(f), L = this.rules.other.htmlBeginRegex(f);
546
- for (; n; ) {
547
- const _ = n.split(`
548
- `, 1)[0];
549
- let R;
550
- if (p = _, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), R = p) : R = p.replace(this.rules.other.tabCharGlobal, " "), v.test(p) || I.test(p) || L.test(p) || S.test(p) || A.test(p))
551
- break;
552
- if (R.search(this.rules.other.nonSpaceChar) >= f || !p.trim())
553
- o += `
554
- ` + R.slice(f);
555
- else {
556
- if (x || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || v.test(d) || I.test(d) || A.test(d))
557
- break;
558
- o += `
559
- ` + p;
560
- }
561
- !x && !p.trim() && (x = !0), l += _ + `
562
- `, n = n.substring(_.length + 1), d = R.slice(f);
563
- }
564
- }
565
- i.loose || (c ? i.loose = !0 : this.rules.other.doubleBlankLine.test(l) && (c = !0));
566
- let b = null, y;
567
- this.options.gfm && (b = this.rules.other.listIsTask.exec(o), b && (y = b[0] !== "[ ] ", o = o.replace(this.rules.other.listReplaceTask, ""))), i.items.push({
568
- type: "list_item",
569
- raw: l,
570
- task: !!b,
571
- checked: y,
572
- loose: !1,
573
- text: o,
574
- tokens: []
575
- }), i.raw += l;
576
- }
577
- const a = i.items.at(-1);
578
- if (a)
579
- a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();
580
- else
581
- return;
582
- i.raw = i.raw.trimEnd();
583
- for (let h = 0; h < i.items.length; h++)
584
- if (this.lexer.state.top = !1, i.items[h].tokens = this.lexer.blockTokens(i.items[h].text, []), !i.loose) {
585
- const l = i.items[h].tokens.filter((d) => d.type === "space"), o = l.length > 0 && l.some((d) => this.rules.other.anyLine.test(d.raw));
586
- i.loose = o;
587
- }
588
- if (i.loose)
589
- for (let h = 0; h < i.items.length; h++)
590
- i.items[h].loose = !0;
591
- return i;
592
- }
593
- }
594
- html(n) {
595
- const e = this.rules.block.html.exec(n);
596
- if (e)
597
- return {
598
- type: "html",
599
- block: !0,
600
- raw: e[0],
601
- pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
602
- text: e[0]
603
- };
604
- }
605
- def(n) {
606
- const e = this.rules.block.def.exec(n);
607
- if (e) {
608
- const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), r = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
609
- return {
610
- type: "def",
611
- tag: t,
612
- raw: e[0],
613
- href: r,
614
- title: i
615
- };
616
- }
617
- }
618
- table(n) {
619
- var c;
620
- const e = this.rules.block.table.exec(n);
621
- if (!e || !this.rules.other.tableDelimiter.test(e[2]))
622
- return;
623
- const t = oe(e[1]), r = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = (c = e[3]) != null && c.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
624
- `) : [], s = {
625
- type: "table",
626
- raw: e[0],
627
- header: [],
628
- align: [],
629
- rows: []
630
- };
631
- if (t.length === r.length) {
632
- for (const a of r)
633
- this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
634
- for (let a = 0; a < t.length; a++)
635
- s.header.push({
636
- text: t[a],
637
- tokens: this.lexer.inline(t[a]),
638
- header: !0,
639
- align: s.align[a]
640
- });
641
- for (const a of i)
642
- s.rows.push(oe(a, s.header.length).map((h, l) => ({
643
- text: h,
644
- tokens: this.lexer.inline(h),
645
- header: !1,
646
- align: s.align[l]
647
- })));
648
- return s;
649
- }
650
- }
651
- lheading(n) {
652
- const e = this.rules.block.lheading.exec(n);
653
- if (e)
654
- return {
655
- type: "heading",
656
- raw: e[0],
657
- depth: e[2].charAt(0) === "=" ? 1 : 2,
658
- text: e[1],
659
- tokens: this.lexer.inline(e[1])
660
- };
661
- }
662
- paragraph(n) {
663
- const e = this.rules.block.paragraph.exec(n);
664
- if (e) {
665
- const t = e[1].charAt(e[1].length - 1) === `
666
- ` ? e[1].slice(0, -1) : e[1];
667
- return {
668
- type: "paragraph",
669
- raw: e[0],
670
- text: t,
671
- tokens: this.lexer.inline(t)
672
- };
673
- }
674
- }
675
- text(n) {
676
- const e = this.rules.block.text.exec(n);
677
- if (e)
678
- return {
679
- type: "text",
680
- raw: e[0],
681
- text: e[0],
682
- tokens: this.lexer.inline(e[0])
683
- };
684
- }
685
- escape(n) {
686
- const e = this.rules.inline.escape.exec(n);
687
- if (e)
688
- return {
689
- type: "escape",
690
- raw: e[0],
691
- text: e[1]
692
- };
693
- }
694
- tag(n) {
695
- const e = this.rules.inline.tag.exec(n);
696
- if (e)
697
- return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
698
- type: "html",
699
- raw: e[0],
700
- inLink: this.lexer.state.inLink,
701
- inRawBlock: this.lexer.state.inRawBlock,
702
- block: !1,
703
- text: e[0]
704
- };
705
- }
706
- link(n) {
707
- const e = this.rules.inline.link.exec(n);
708
- if (e) {
709
- const t = e[2].trim();
710
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
711
- if (!this.rules.other.endAngleBracket.test(t))
712
- return;
713
- const s = B(t.slice(0, -1), "\\");
714
- if ((t.length - s.length) % 2 === 0)
715
- return;
716
- } else {
717
- const s = ht(e[2], "()");
718
- if (s === -2)
719
- return;
720
- if (s > -1) {
721
- const a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + s;
722
- e[2] = e[2].substring(0, s), e[0] = e[0].substring(0, a).trim(), e[3] = "";
723
- }
724
- }
725
- let r = e[2], i = "";
726
- if (this.options.pedantic) {
727
- const s = this.rules.other.pedanticHrefTitle.exec(r);
728
- s && (r = s[1], i = s[3]);
729
- } else
730
- i = e[3] ? e[3].slice(1, -1) : "";
731
- return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? r = r.slice(1) : r = r.slice(1, -1)), ce(e, {
732
- href: r && r.replace(this.rules.inline.anyPunctuation, "$1"),
733
- title: i && i.replace(this.rules.inline.anyPunctuation, "$1")
734
- }, e[0], this.lexer, this.rules);
735
- }
736
- }
737
- reflink(n, e) {
738
- let t;
739
- if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
740
- const r = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = e[r.toLowerCase()];
741
- if (!i) {
742
- const s = t[0].charAt(0);
743
- return {
744
- type: "text",
745
- raw: s,
746
- text: s
747
- };
748
- }
749
- return ce(t, i, t[0], this.lexer, this.rules);
750
- }
751
- }
752
- emStrong(n, e, t = "") {
753
- let r = this.rules.inline.emStrongLDelim.exec(n);
754
- if (!r || r[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
755
- if (!(r[1] || r[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
756
- const s = [...r[0]].length - 1;
757
- let c, a, h = s, l = 0;
758
- const o = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
759
- for (o.lastIndex = 0, e = e.slice(-1 * n.length + s); (r = o.exec(e)) != null; ) {
760
- if (c = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !c) continue;
761
- if (a = [...c].length, r[3] || r[4]) {
762
- h += a;
763
- continue;
764
- } else if ((r[5] || r[6]) && s % 3 && !((s + a) % 3)) {
765
- l += a;
766
- continue;
767
- }
768
- if (h -= a, h > 0) continue;
769
- a = Math.min(a, a + h + l);
770
- const d = [...r[0]][0].length, p = n.slice(0, s + r.index + d + a);
771
- if (Math.min(s, a) % 2) {
772
- const f = p.slice(1, -1);
773
- return {
774
- type: "em",
775
- raw: p,
776
- text: f,
777
- tokens: this.lexer.inlineTokens(f)
778
- };
779
- }
780
- const x = p.slice(2, -2);
781
- return {
782
- type: "strong",
783
- raw: p,
784
- text: x,
785
- tokens: this.lexer.inlineTokens(x)
786
- };
787
- }
788
- }
789
- }
790
- codespan(n) {
791
- const e = this.rules.inline.code.exec(n);
792
- if (e) {
793
- let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
794
- const r = this.rules.other.nonSpaceChar.test(t), i = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
795
- return r && i && (t = t.substring(1, t.length - 1)), {
796
- type: "codespan",
797
- raw: e[0],
798
- text: t
799
- };
800
- }
801
- }
802
- br(n) {
803
- const e = this.rules.inline.br.exec(n);
804
- if (e)
805
- return {
806
- type: "br",
807
- raw: e[0]
808
- };
809
- }
810
- del(n) {
811
- const e = this.rules.inline.del.exec(n);
812
- if (e)
813
- return {
814
- type: "del",
815
- raw: e[0],
816
- text: e[2],
817
- tokens: this.lexer.inlineTokens(e[2])
818
- };
819
- }
820
- autolink(n) {
821
- const e = this.rules.inline.autolink.exec(n);
822
- if (e) {
823
- let t, r;
824
- return e[2] === "@" ? (t = e[1], r = "mailto:" + t) : (t = e[1], r = t), {
825
- type: "link",
826
- raw: e[0],
827
- text: t,
828
- href: r,
829
- tokens: [
830
- {
831
- type: "text",
832
- raw: t,
833
- text: t
834
- }
835
- ]
836
- };
837
- }
838
- }
839
- url(n) {
840
- var t;
841
- let e;
842
- if (e = this.rules.inline.url.exec(n)) {
843
- let r, i;
844
- if (e[2] === "@")
845
- r = e[0], i = "mailto:" + r;
846
- else {
847
- let s;
848
- do
849
- s = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
850
- while (s !== e[0]);
851
- r = e[0], e[1] === "www." ? i = "http://" + e[0] : i = e[0];
852
- }
853
- return {
854
- type: "link",
855
- raw: e[0],
856
- text: r,
857
- href: i,
858
- tokens: [
859
- {
860
- type: "text",
861
- raw: r,
862
- text: r
863
- }
864
- ]
865
- };
866
- }
867
- }
868
- inlineText(n) {
869
- const e = this.rules.inline.text.exec(n);
870
- if (e) {
871
- const t = this.lexer.state.inRawBlock;
872
- return {
873
- type: "text",
874
- raw: e[0],
875
- text: e[0],
876
- escaped: t
877
- };
878
- }
879
- }
880
- }, E = class K {
881
- constructor(e) {
882
- g(this, "tokens");
883
- g(this, "options");
884
- g(this, "state");
885
- g(this, "tokenizer");
886
- g(this, "inlineQueue");
887
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || z, this.options.tokenizer = this.options.tokenizer || new j(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
888
- inLink: !1,
889
- inRawBlock: !1,
890
- top: !0
891
- };
892
- const t = {
893
- other: w,
894
- block: M.normal,
895
- inline: P.normal
896
- };
897
- this.options.pedantic ? (t.block = M.pedantic, t.inline = P.pedantic) : this.options.gfm && (t.block = M.gfm, this.options.breaks ? t.inline = P.breaks : t.inline = P.gfm), this.tokenizer.rules = t;
898
- }
899
- /**
900
- * Expose Rules
901
- */
902
- static get rules() {
903
- return {
904
- block: M,
905
- inline: P
906
- };
907
- }
908
- /**
909
- * Static Lex Method
910
- */
911
- static lex(e, t) {
912
- return new K(t).lex(e);
913
- }
914
- /**
915
- * Static Lex Inline Method
916
- */
917
- static lexInline(e, t) {
918
- return new K(t).inlineTokens(e);
919
- }
920
- /**
921
- * Preprocessing
922
- */
923
- lex(e) {
924
- e = e.replace(w.carriageReturn, `
925
- `), this.blockTokens(e, this.tokens);
926
- for (let t = 0; t < this.inlineQueue.length; t++) {
927
- const r = this.inlineQueue[t];
928
- this.inlineTokens(r.src, r.tokens);
929
- }
930
- return this.inlineQueue = [], this.tokens;
931
- }
932
- blockTokens(e, t = [], r = !1) {
933
- var i, s, c;
934
- for (this.options.pedantic && (e = e.replace(w.tabCharGlobal, " ").replace(w.spaceLine, "")); e; ) {
935
- let a;
936
- if ((s = (i = this.options.extensions) == null ? void 0 : i.block) != null && s.some((l) => (a = l.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), !0) : !1))
937
- continue;
938
- if (a = this.tokenizer.space(e)) {
939
- e = e.substring(a.raw.length);
940
- const l = t.at(-1);
941
- a.raw.length === 1 && l !== void 0 ? l.raw += `
942
- ` : t.push(a);
943
- continue;
944
- }
945
- if (a = this.tokenizer.code(e)) {
946
- e = e.substring(a.raw.length);
947
- const l = t.at(-1);
948
- (l == null ? void 0 : l.type) === "paragraph" || (l == null ? void 0 : l.type) === "text" ? (l.raw += `
949
- ` + a.raw, l.text += `
950
- ` + a.text, this.inlineQueue.at(-1).src = l.text) : t.push(a);
951
- continue;
952
- }
953
- if (a = this.tokenizer.fences(e)) {
954
- e = e.substring(a.raw.length), t.push(a);
955
- continue;
956
- }
957
- if (a = this.tokenizer.heading(e)) {
958
- e = e.substring(a.raw.length), t.push(a);
959
- continue;
960
- }
961
- if (a = this.tokenizer.hr(e)) {
962
- e = e.substring(a.raw.length), t.push(a);
963
- continue;
964
- }
965
- if (a = this.tokenizer.blockquote(e)) {
966
- e = e.substring(a.raw.length), t.push(a);
967
- continue;
968
- }
969
- if (a = this.tokenizer.list(e)) {
970
- e = e.substring(a.raw.length), t.push(a);
971
- continue;
972
- }
973
- if (a = this.tokenizer.html(e)) {
974
- e = e.substring(a.raw.length), t.push(a);
975
- continue;
976
- }
977
- if (a = this.tokenizer.def(e)) {
978
- e = e.substring(a.raw.length);
979
- const l = t.at(-1);
980
- (l == null ? void 0 : l.type) === "paragraph" || (l == null ? void 0 : l.type) === "text" ? (l.raw += `
981
- ` + a.raw, l.text += `
982
- ` + a.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[a.tag] || (this.tokens.links[a.tag] = {
983
- href: a.href,
984
- title: a.title
985
- });
986
- continue;
987
- }
988
- if (a = this.tokenizer.table(e)) {
989
- e = e.substring(a.raw.length), t.push(a);
990
- continue;
991
- }
992
- if (a = this.tokenizer.lheading(e)) {
993
- e = e.substring(a.raw.length), t.push(a);
994
- continue;
995
- }
996
- let h = e;
997
- if ((c = this.options.extensions) != null && c.startBlock) {
998
- let l = 1 / 0;
999
- const o = e.slice(1);
1000
- let d;
1001
- this.options.extensions.startBlock.forEach((p) => {
1002
- d = p.call({ lexer: this }, o), typeof d == "number" && d >= 0 && (l = Math.min(l, d));
1003
- }), l < 1 / 0 && l >= 0 && (h = e.substring(0, l + 1));
1004
- }
1005
- if (this.state.top && (a = this.tokenizer.paragraph(h))) {
1006
- const l = t.at(-1);
1007
- r && (l == null ? void 0 : l.type) === "paragraph" ? (l.raw += `
1008
- ` + a.raw, l.text += `
1009
- ` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(a), r = h.length !== e.length, e = e.substring(a.raw.length);
1010
- continue;
1011
- }
1012
- if (a = this.tokenizer.text(e)) {
1013
- e = e.substring(a.raw.length);
1014
- const l = t.at(-1);
1015
- (l == null ? void 0 : l.type) === "text" ? (l.raw += `
1016
- ` + a.raw, l.text += `
1017
- ` + a.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : t.push(a);
1018
- continue;
1019
- }
1020
- if (e) {
1021
- const l = "Infinite loop on byte: " + e.charCodeAt(0);
1022
- if (this.options.silent) {
1023
- console.error(l);
1024
- break;
1025
- } else
1026
- throw new Error(l);
1027
- }
1028
- }
1029
- return this.state.top = !0, t;
1030
- }
1031
- inline(e, t = []) {
1032
- return this.inlineQueue.push({ src: e, tokens: t }), t;
1033
- }
1034
- /**
1035
- * Lexing/Compiling
1036
- */
1037
- inlineTokens(e, t = []) {
1038
- var a, h, l;
1039
- let r = e, i = null;
1040
- if (this.tokens.links) {
1041
- const o = Object.keys(this.tokens.links);
1042
- if (o.length > 0)
1043
- for (; (i = this.tokenizer.rules.inline.reflinkSearch.exec(r)) != null; )
1044
- o.includes(i[0].slice(i[0].lastIndexOf("[") + 1, -1)) && (r = r.slice(0, i.index) + "[" + "a".repeat(i[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
1045
- }
1046
- for (; (i = this.tokenizer.rules.inline.anyPunctuation.exec(r)) != null; )
1047
- r = r.slice(0, i.index) + "++" + r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1048
- for (; (i = this.tokenizer.rules.inline.blockSkip.exec(r)) != null; )
1049
- r = r.slice(0, i.index) + "[" + "a".repeat(i[0].length - 2) + "]" + r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1050
- let s = !1, c = "";
1051
- for (; e; ) {
1052
- s || (c = ""), s = !1;
1053
- let o;
1054
- if ((h = (a = this.options.extensions) == null ? void 0 : a.inline) != null && h.some((p) => (o = p.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), !0) : !1))
1055
- continue;
1056
- if (o = this.tokenizer.escape(e)) {
1057
- e = e.substring(o.raw.length), t.push(o);
1058
- continue;
1059
- }
1060
- if (o = this.tokenizer.tag(e)) {
1061
- e = e.substring(o.raw.length), t.push(o);
1062
- continue;
1063
- }
1064
- if (o = this.tokenizer.link(e)) {
1065
- e = e.substring(o.raw.length), t.push(o);
1066
- continue;
1067
- }
1068
- if (o = this.tokenizer.reflink(e, this.tokens.links)) {
1069
- e = e.substring(o.raw.length);
1070
- const p = t.at(-1);
1071
- o.type === "text" && (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
1072
- continue;
1073
- }
1074
- if (o = this.tokenizer.emStrong(e, r, c)) {
1075
- e = e.substring(o.raw.length), t.push(o);
1076
- continue;
1077
- }
1078
- if (o = this.tokenizer.codespan(e)) {
1079
- e = e.substring(o.raw.length), t.push(o);
1080
- continue;
1081
- }
1082
- if (o = this.tokenizer.br(e)) {
1083
- e = e.substring(o.raw.length), t.push(o);
1084
- continue;
1085
- }
1086
- if (o = this.tokenizer.del(e)) {
1087
- e = e.substring(o.raw.length), t.push(o);
1088
- continue;
1089
- }
1090
- if (o = this.tokenizer.autolink(e)) {
1091
- e = e.substring(o.raw.length), t.push(o);
1092
- continue;
1093
- }
1094
- if (!this.state.inLink && (o = this.tokenizer.url(e))) {
1095
- e = e.substring(o.raw.length), t.push(o);
1096
- continue;
1097
- }
1098
- let d = e;
1099
- if ((l = this.options.extensions) != null && l.startInline) {
1100
- let p = 1 / 0;
1101
- const x = e.slice(1);
1102
- let f;
1103
- this.options.extensions.startInline.forEach((b) => {
1104
- f = b.call({ lexer: this }, x), typeof f == "number" && f >= 0 && (p = Math.min(p, f));
1105
- }), p < 1 / 0 && p >= 0 && (d = e.substring(0, p + 1));
1106
- }
1107
- if (o = this.tokenizer.inlineText(d)) {
1108
- e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (c = o.raw.slice(-1)), s = !0;
1109
- const p = t.at(-1);
1110
- (p == null ? void 0 : p.type) === "text" ? (p.raw += o.raw, p.text += o.text) : t.push(o);
1111
- continue;
1112
- }
1113
- if (e) {
1114
- const p = "Infinite loop on byte: " + e.charCodeAt(0);
1115
- if (this.options.silent) {
1116
- console.error(p);
1117
- break;
1118
- } else
1119
- throw new Error(p);
1120
- }
1121
- }
1122
- return t;
1123
- }
1124
- }, Z = class {
1125
- // set by the parser
1126
- constructor(n) {
1127
- g(this, "options");
1128
- g(this, "parser");
1129
- this.options = n || z;
1130
- }
1131
- space(n) {
1132
- return "";
1133
- }
1134
- code({ text: n, lang: e, escaped: t }) {
1135
- var s;
1136
- const r = (s = (e || "").match(w.notSpaceStart)) == null ? void 0 : s[0], i = n.replace(w.endingNewline, "") + `
1137
- `;
1138
- return r ? '<pre><code class="language-' + $(r) + '">' + (t ? i : $(i, !0)) + `</code></pre>
1139
- ` : "<pre><code>" + (t ? i : $(i, !0)) + `</code></pre>
1140
- `;
1141
- }
1142
- blockquote({ tokens: n }) {
1143
- return `<blockquote>
1144
- ${this.parser.parse(n)}</blockquote>
1145
- `;
1146
- }
1147
- html({ text: n }) {
1148
- return n;
1149
- }
1150
- heading({ tokens: n, depth: e }) {
1151
- return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1152
- `;
1153
- }
1154
- hr(n) {
1155
- return `<hr>
1156
- `;
1157
- }
1158
- list(n) {
1159
- const e = n.ordered, t = n.start;
1160
- let r = "";
1161
- for (let c = 0; c < n.items.length; c++) {
1162
- const a = n.items[c];
1163
- r += this.listitem(a);
1164
- }
1165
- const i = e ? "ol" : "ul", s = e && t !== 1 ? ' start="' + t + '"' : "";
1166
- return "<" + i + s + `>
1167
- ` + r + "</" + i + `>
1168
- `;
1169
- }
1170
- listitem(n) {
1171
- var t;
1172
- let e = "";
1173
- if (n.task) {
1174
- const r = this.checkbox({ checked: !!n.checked });
1175
- n.loose ? ((t = n.tokens[0]) == null ? void 0 : t.type) === "paragraph" ? (n.tokens[0].text = r + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = r + " " + $(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1176
- type: "text",
1177
- raw: r + " ",
1178
- text: r + " ",
1179
- escaped: !0
1180
- }) : e += r + " ";
1181
- }
1182
- return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1183
- `;
1184
- }
1185
- checkbox({ checked: n }) {
1186
- return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1187
- }
1188
- paragraph({ tokens: n }) {
1189
- return `<p>${this.parser.parseInline(n)}</p>
1190
- `;
1191
- }
1192
- table(n) {
1193
- let e = "", t = "";
1194
- for (let i = 0; i < n.header.length; i++)
1195
- t += this.tablecell(n.header[i]);
1196
- e += this.tablerow({ text: t });
1197
- let r = "";
1198
- for (let i = 0; i < n.rows.length; i++) {
1199
- const s = n.rows[i];
1200
- t = "";
1201
- for (let c = 0; c < s.length; c++)
1202
- t += this.tablecell(s[c]);
1203
- r += this.tablerow({ text: t });
1204
- }
1205
- return r && (r = `<tbody>${r}</tbody>`), `<table>
1206
- <thead>
1207
- ` + e + `</thead>
1208
- ` + r + `</table>
1209
- `;
1210
- }
1211
- tablerow({ text: n }) {
1212
- return `<tr>
1213
- ${n}</tr>
1214
- `;
1215
- }
1216
- tablecell(n) {
1217
- const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1218
- return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1219
- `;
1220
- }
1221
- /**
1222
- * span level renderer
1223
- */
1224
- strong({ tokens: n }) {
1225
- return `<strong>${this.parser.parseInline(n)}</strong>`;
1226
- }
1227
- em({ tokens: n }) {
1228
- return `<em>${this.parser.parseInline(n)}</em>`;
1229
- }
1230
- codespan({ text: n }) {
1231
- return `<code>${$(n, !0)}</code>`;
1232
- }
1233
- br(n) {
1234
- return "<br>";
1235
- }
1236
- del({ tokens: n }) {
1237
- return `<del>${this.parser.parseInline(n)}</del>`;
1238
- }
1239
- link({ href: n, title: e, tokens: t }) {
1240
- const r = this.parser.parseInline(t), i = le(n);
1241
- if (i === null)
1242
- return r;
1243
- n = i;
1244
- let s = '<a href="' + n + '"';
1245
- return e && (s += ' title="' + $(e) + '"'), s += ">" + r + "</a>", s;
1246
- }
1247
- image({ href: n, title: e, text: t, tokens: r }) {
1248
- r && (t = this.parser.parseInline(r, this.parser.textRenderer));
1249
- const i = le(n);
1250
- if (i === null)
1251
- return $(t);
1252
- n = i;
1253
- let s = `<img src="${n}" alt="${t}"`;
1254
- return e && (s += ` title="${$(e)}"`), s += ">", s;
1255
- }
1256
- text(n) {
1257
- return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : $(n.text);
1258
- }
1259
- }, ie = class {
1260
- // no need for block level renderers
1261
- strong({ text: n }) {
1262
- return n;
1263
- }
1264
- em({ text: n }) {
1265
- return n;
1266
- }
1267
- codespan({ text: n }) {
1268
- return n;
1269
- }
1270
- del({ text: n }) {
1271
- return n;
1272
- }
1273
- html({ text: n }) {
1274
- return n;
1275
- }
1276
- text({ text: n }) {
1277
- return n;
1278
- }
1279
- link({ text: n }) {
1280
- return "" + n;
1281
- }
1282
- image({ text: n }) {
1283
- return "" + n;
1284
- }
1285
- br() {
1286
- return "";
1287
- }
1288
- }, T = class U {
1289
- constructor(e) {
1290
- g(this, "options");
1291
- g(this, "renderer");
1292
- g(this, "textRenderer");
1293
- this.options = e || z, this.options.renderer = this.options.renderer || new Z(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new ie();
1294
- }
1295
- /**
1296
- * Static Parse Method
1297
- */
1298
- static parse(e, t) {
1299
- return new U(t).parse(e);
1300
- }
1301
- /**
1302
- * Static Parse Inline Method
1303
- */
1304
- static parseInline(e, t) {
1305
- return new U(t).parseInline(e);
1306
- }
1307
- /**
1308
- * Parse Loop
1309
- */
1310
- parse(e, t = !0) {
1311
- var i, s;
1312
- let r = "";
1313
- for (let c = 0; c < e.length; c++) {
1314
- const a = e[c];
1315
- if ((s = (i = this.options.extensions) == null ? void 0 : i.renderers) != null && s[a.type]) {
1316
- const l = a, o = this.options.extensions.renderers[l.type].call({ parser: this }, l);
1317
- if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(l.type)) {
1318
- r += o || "";
1319
- continue;
1320
- }
1321
- }
1322
- const h = a;
1323
- switch (h.type) {
1324
- case "space": {
1325
- r += this.renderer.space(h);
1326
- continue;
1327
- }
1328
- case "hr": {
1329
- r += this.renderer.hr(h);
1330
- continue;
1331
- }
1332
- case "heading": {
1333
- r += this.renderer.heading(h);
1334
- continue;
1335
- }
1336
- case "code": {
1337
- r += this.renderer.code(h);
1338
- continue;
1339
- }
1340
- case "table": {
1341
- r += this.renderer.table(h);
1342
- continue;
1343
- }
1344
- case "blockquote": {
1345
- r += this.renderer.blockquote(h);
1346
- continue;
1347
- }
1348
- case "list": {
1349
- r += this.renderer.list(h);
1350
- continue;
1351
- }
1352
- case "html": {
1353
- r += this.renderer.html(h);
1354
- continue;
1355
- }
1356
- case "paragraph": {
1357
- r += this.renderer.paragraph(h);
1358
- continue;
1359
- }
1360
- case "text": {
1361
- let l = h, o = this.renderer.text(l);
1362
- for (; c + 1 < e.length && e[c + 1].type === "text"; )
1363
- l = e[++c], o += `
1364
- ` + this.renderer.text(l);
1365
- t ? r += this.renderer.paragraph({
1366
- type: "paragraph",
1367
- raw: o,
1368
- text: o,
1369
- tokens: [{ type: "text", raw: o, text: o, escaped: !0 }]
1370
- }) : r += o;
1371
- continue;
1372
- }
1373
- default: {
1374
- const l = 'Token with "' + h.type + '" type was not found.';
1375
- if (this.options.silent)
1376
- return console.error(l), "";
1377
- throw new Error(l);
1378
- }
1379
- }
1380
- }
1381
- return r;
1382
- }
1383
- /**
1384
- * Parse Inline Tokens
1385
- */
1386
- parseInline(e, t = this.renderer) {
1387
- var i, s;
1388
- let r = "";
1389
- for (let c = 0; c < e.length; c++) {
1390
- const a = e[c];
1391
- if ((s = (i = this.options.extensions) == null ? void 0 : i.renderers) != null && s[a.type]) {
1392
- const l = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1393
- if (l !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(a.type)) {
1394
- r += l || "";
1395
- continue;
1396
- }
1397
- }
1398
- const h = a;
1399
- switch (h.type) {
1400
- case "escape": {
1401
- r += t.text(h);
1402
- break;
1403
- }
1404
- case "html": {
1405
- r += t.html(h);
1406
- break;
1407
- }
1408
- case "link": {
1409
- r += t.link(h);
1410
- break;
1411
- }
1412
- case "image": {
1413
- r += t.image(h);
1414
- break;
1415
- }
1416
- case "strong": {
1417
- r += t.strong(h);
1418
- break;
1419
- }
1420
- case "em": {
1421
- r += t.em(h);
1422
- break;
1423
- }
1424
- case "codespan": {
1425
- r += t.codespan(h);
1426
- break;
1427
- }
1428
- case "br": {
1429
- r += t.br(h);
1430
- break;
1431
- }
1432
- case "del": {
1433
- r += t.del(h);
1434
- break;
1435
- }
1436
- case "text": {
1437
- r += t.text(h);
1438
- break;
1439
- }
1440
- default: {
1441
- const l = 'Token with "' + h.type + '" type was not found.';
1442
- if (this.options.silent)
1443
- return console.error(l), "";
1444
- throw new Error(l);
1445
- }
1446
- }
1447
- }
1448
- return r;
1449
- }
1450
- }, Q, O = (Q = class {
1451
- constructor(n) {
1452
- g(this, "options");
1453
- g(this, "block");
1454
- this.options = n || z;
1455
- }
1456
- /**
1457
- * Process markdown before marked
1458
- */
1459
- preprocess(n) {
1460
- return n;
1461
- }
1462
- /**
1463
- * Process HTML after marked is finished
1464
- */
1465
- postprocess(n) {
1466
- return n;
1467
- }
1468
- /**
1469
- * Process all tokens before walk tokens
1470
- */
1471
- processAllTokens(n) {
1472
- return n;
1473
- }
1474
- /**
1475
- * Provide function to tokenize markdown
1476
- */
1477
- provideLexer() {
1478
- return this.block ? E.lex : E.lexInline;
1479
- }
1480
- /**
1481
- * Provide function to parse tokens
1482
- */
1483
- provideParser() {
1484
- return this.block ? T.parse : T.parseInline;
1485
- }
1486
- }, g(Q, "passThroughHooks", /* @__PURE__ */ new Set([
1487
- "preprocess",
1488
- "postprocess",
1489
- "processAllTokens"
1490
- ])), Q), ut = class {
1491
- constructor(...n) {
1492
- g(this, "defaults", J());
1493
- g(this, "options", this.setOptions);
1494
- g(this, "parse", this.parseMarkdown(!0));
1495
- g(this, "parseInline", this.parseMarkdown(!1));
1496
- g(this, "Parser", T);
1497
- g(this, "Renderer", Z);
1498
- g(this, "TextRenderer", ie);
1499
- g(this, "Lexer", E);
1500
- g(this, "Tokenizer", j);
1501
- g(this, "Hooks", O);
1502
- this.use(...n);
1503
- }
1504
- /**
1505
- * Run callback for every token
1506
- */
1507
- walkTokens(n, e) {
1508
- var r, i;
1509
- let t = [];
1510
- for (const s of n)
1511
- switch (t = t.concat(e.call(this, s)), s.type) {
1512
- case "table": {
1513
- const c = s;
1514
- for (const a of c.header)
1515
- t = t.concat(this.walkTokens(a.tokens, e));
1516
- for (const a of c.rows)
1517
- for (const h of a)
1518
- t = t.concat(this.walkTokens(h.tokens, e));
1519
- break;
1520
- }
1521
- case "list": {
1522
- const c = s;
1523
- t = t.concat(this.walkTokens(c.items, e));
1524
- break;
1525
- }
1526
- default: {
1527
- const c = s;
1528
- (i = (r = this.defaults.extensions) == null ? void 0 : r.childTokens) != null && i[c.type] ? this.defaults.extensions.childTokens[c.type].forEach((a) => {
1529
- const h = c[a].flat(1 / 0);
1530
- t = t.concat(this.walkTokens(h, e));
1531
- }) : c.tokens && (t = t.concat(this.walkTokens(c.tokens, e)));
1532
- }
1533
- }
1534
- return t;
1535
- }
1536
- use(...n) {
1537
- const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1538
- return n.forEach((t) => {
1539
- const r = { ...t };
1540
- if (r.async = this.defaults.async || r.async || !1, t.extensions && (t.extensions.forEach((i) => {
1541
- if (!i.name)
1542
- throw new Error("extension name required");
1543
- if ("renderer" in i) {
1544
- const s = e.renderers[i.name];
1545
- s ? e.renderers[i.name] = function(...c) {
1546
- let a = i.renderer.apply(this, c);
1547
- return a === !1 && (a = s.apply(this, c)), a;
1548
- } : e.renderers[i.name] = i.renderer;
1549
- }
1550
- if ("tokenizer" in i) {
1551
- if (!i.level || i.level !== "block" && i.level !== "inline")
1552
- throw new Error("extension level must be 'block' or 'inline'");
1553
- const s = e[i.level];
1554
- s ? s.unshift(i.tokenizer) : e[i.level] = [i.tokenizer], i.start && (i.level === "block" ? e.startBlock ? e.startBlock.push(i.start) : e.startBlock = [i.start] : i.level === "inline" && (e.startInline ? e.startInline.push(i.start) : e.startInline = [i.start]));
1555
- }
1556
- "childTokens" in i && i.childTokens && (e.childTokens[i.name] = i.childTokens);
1557
- }), r.extensions = e), t.renderer) {
1558
- const i = this.defaults.renderer || new Z(this.defaults);
1559
- for (const s in t.renderer) {
1560
- if (!(s in i))
1561
- throw new Error(`renderer '${s}' does not exist`);
1562
- if (["options", "parser"].includes(s))
1563
- continue;
1564
- const c = s, a = t.renderer[c], h = i[c];
1565
- i[c] = (...l) => {
1566
- let o = a.apply(i, l);
1567
- return o === !1 && (o = h.apply(i, l)), o || "";
1568
- };
1569
- }
1570
- r.renderer = i;
1571
- }
1572
- if (t.tokenizer) {
1573
- const i = this.defaults.tokenizer || new j(this.defaults);
1574
- for (const s in t.tokenizer) {
1575
- if (!(s in i))
1576
- throw new Error(`tokenizer '${s}' does not exist`);
1577
- if (["options", "rules", "lexer"].includes(s))
1578
- continue;
1579
- const c = s, a = t.tokenizer[c], h = i[c];
1580
- i[c] = (...l) => {
1581
- let o = a.apply(i, l);
1582
- return o === !1 && (o = h.apply(i, l)), o;
1583
- };
1584
- }
1585
- r.tokenizer = i;
1586
- }
1587
- if (t.hooks) {
1588
- const i = this.defaults.hooks || new O();
1589
- for (const s in t.hooks) {
1590
- if (!(s in i))
1591
- throw new Error(`hook '${s}' does not exist`);
1592
- if (["options", "block"].includes(s))
1593
- continue;
1594
- const c = s, a = t.hooks[c], h = i[c];
1595
- O.passThroughHooks.has(s) ? i[c] = (l) => {
1596
- if (this.defaults.async)
1597
- return Promise.resolve(a.call(i, l)).then((d) => h.call(i, d));
1598
- const o = a.call(i, l);
1599
- return h.call(i, o);
1600
- } : i[c] = (...l) => {
1601
- let o = a.apply(i, l);
1602
- return o === !1 && (o = h.apply(i, l)), o;
1603
- };
1604
- }
1605
- r.hooks = i;
1606
- }
1607
- if (t.walkTokens) {
1608
- const i = this.defaults.walkTokens, s = t.walkTokens;
1609
- r.walkTokens = function(c) {
1610
- let a = [];
1611
- return a.push(s.call(this, c)), i && (a = a.concat(i.call(this, c))), a;
1612
- };
1613
- }
1614
- this.defaults = { ...this.defaults, ...r };
1615
- }), this;
1616
- }
1617
- setOptions(n) {
1618
- return this.defaults = { ...this.defaults, ...n }, this;
1619
- }
1620
- lexer(n, e) {
1621
- return E.lex(n, e ?? this.defaults);
1622
- }
1623
- parser(n, e) {
1624
- return T.parse(n, e ?? this.defaults);
1625
- }
1626
- parseMarkdown(n) {
1627
- return (t, r) => {
1628
- const i = { ...r }, s = { ...this.defaults, ...i }, c = this.onError(!!s.silent, !!s.async);
1629
- if (this.defaults.async === !0 && i.async === !1)
1630
- return c(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."));
1631
- if (typeof t > "u" || t === null)
1632
- return c(new Error("marked(): input parameter is undefined or null"));
1633
- if (typeof t != "string")
1634
- return c(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1635
- s.hooks && (s.hooks.options = s, s.hooks.block = n);
1636
- const a = s.hooks ? s.hooks.provideLexer() : n ? E.lex : E.lexInline, h = s.hooks ? s.hooks.provideParser() : n ? T.parse : T.parseInline;
1637
- if (s.async)
1638
- return Promise.resolve(s.hooks ? s.hooks.preprocess(t) : t).then((l) => a(l, s)).then((l) => s.hooks ? s.hooks.processAllTokens(l) : l).then((l) => s.walkTokens ? Promise.all(this.walkTokens(l, s.walkTokens)).then(() => l) : l).then((l) => h(l, s)).then((l) => s.hooks ? s.hooks.postprocess(l) : l).catch(c);
1639
- try {
1640
- s.hooks && (t = s.hooks.preprocess(t));
1641
- let l = a(t, s);
1642
- s.hooks && (l = s.hooks.processAllTokens(l)), s.walkTokens && this.walkTokens(l, s.walkTokens);
1643
- let o = h(l, s);
1644
- return s.hooks && (o = s.hooks.postprocess(o)), o;
1645
- } catch (l) {
1646
- return c(l);
1647
- }
1648
- };
1649
- }
1650
- onError(n, e) {
1651
- return (t) => {
1652
- if (t.message += `
1653
- Please report this to https://github.com/markedjs/marked.`, n) {
1654
- const r = "<p>An error occurred:</p><pre>" + $(t.message + "", !0) + "</pre>";
1655
- return e ? Promise.resolve(r) : r;
1656
- }
1657
- if (e)
1658
- return Promise.reject(t);
1659
- throw t;
1660
- };
1661
- }
1662
- }, C = new ut();
1663
- function m(n, e) {
1664
- return C.parse(n, e);
1665
- }
1666
- m.options = m.setOptions = function(n) {
1667
- return C.setOptions(n), m.defaults = C.defaults, ue(m.defaults), m;
1668
- };
1669
- m.getDefaults = J;
1670
- m.defaults = z;
1671
- m.use = function(...n) {
1672
- return C.use(...n), m.defaults = C.defaults, ue(m.defaults), m;
1673
- };
1674
- m.walkTokens = function(n, e) {
1675
- return C.walkTokens(n, e);
1676
- };
1677
- m.parseInline = C.parseInline;
1678
- m.Parser = T;
1679
- m.parser = T.parse;
1680
- m.Renderer = Z;
1681
- m.TextRenderer = ie;
1682
- m.Lexer = E;
1683
- m.lexer = E.lex;
1684
- m.Tokenizer = j;
1685
- m.Hooks = O;
1686
- m.parse = m;
1687
- m.options;
1688
- m.setOptions;
1689
- m.use;
1690
- m.walkTokens;
1691
- m.parseInline;
1692
- T.parse;
1693
- E.lex;
1694
- const he = ({ data: n, style: e }) => /* @__PURE__ */ u.createElement(
1695
- "div",
1696
- {
1697
- style: {
1698
- maxWidth: "80%",
1699
- ...e
1700
- }
1701
- },
1702
- n && n.subject ? /* @__PURE__ */ u.createElement(
1703
- "div",
1704
- {
1705
- dangerouslySetInnerHTML: {
1706
- __html: m.parse(n.body, { async: !1 })
1707
- }
1708
- }
1709
- ) : /* @__PURE__ */ u.createElement("p", { style: { margin: 0, whiteSpace: "pre-wrap" } }, n ? n.question : "")
1710
- ), gt = ({
1711
- items: n,
1712
- onApply: e,
1713
- getEditorContent: t
1714
- }) => {
1715
- const r = async (i) => {
1716
- const s = /제목:[^\n]*/g;
1717
- ((s.exec(i) || [])[0] || "").replace("제목: ", "").replace(`
1718
- `, "");
1719
- const a = i.replace(s, "").replace("본문: ", "");
1720
- let h = await m.parse(a);
1721
- const l = /<!--HanbiroSignatureStart-->([\s\S]*?)<!--HanbiroSignatureEnd-->/g, o = t ? t() : "", d = l.exec(o) || [];
1722
- d[0] && (h = h + "<br>" + d[0]), e({ html: h });
1723
- };
1724
- return /* @__PURE__ */ u.createElement(
1725
- "div",
1726
- {
1727
- style: {
1728
- flex: 1,
1729
- minHeight: 0,
1730
- position: "relative",
1731
- overflowY: "auto",
1732
- paddingRight: 16,
1733
- marginRight: -16,
1734
- marginBottom: 8,
1735
- display: "flex",
1736
- flexDirection: "column"
1737
- }
1738
- },
1739
- n && n.map((i) => /* @__PURE__ */ u.createElement(
1740
- "div",
1741
- {
1742
- key: i.id,
1743
- style: {
1744
- display: "flex",
1745
- flexDirection: "column",
1746
- marginBottom: 16
1747
- }
1748
- },
1749
- /* @__PURE__ */ u.createElement(
1750
- "div",
1751
- {
1752
- style: {
1753
- width: "100%",
1754
- display: "flex",
1755
- alignItems: "flex-end",
1756
- flexDirection: "column",
1757
- position: "relative",
1758
- marginTop: 8
1759
- }
1760
- },
1761
- /* @__PURE__ */ u.createElement(
1762
- he,
1763
- {
1764
- data: { question: i.question },
1765
- style: {
1766
- borderRadius: 8,
1767
- borderTopRightRadius: 0,
1768
- padding: "8px 12px",
1769
- background: "var(--background-softGrey)"
1770
- }
1771
- }
1772
- )
1773
- ),
1774
- /* @__PURE__ */ u.createElement(
1775
- "div",
1776
- {
1777
- style: {
1778
- width: "100%",
1779
- display: "flex",
1780
- alignItems: "flex-start",
1781
- flexDirection: "column",
1782
- position: "relative",
1783
- marginTop: 8
1784
- }
1785
- },
1786
- i.isLoading ? /* @__PURE__ */ u.createElement(
1787
- "div",
1788
- {
1789
- style: {
1790
- marginTop: 8,
1791
- fontStyle: "italic",
1792
- color: "var(--text-secondary)"
1793
- }
1794
- },
1795
- "Loading..."
1796
- ) : /* @__PURE__ */ u.createElement(
1797
- "div",
1798
- {
1799
- style: {
1800
- display: "flex",
1801
- flexDirection: "row",
1802
- alignItems: "flex-end",
1803
- width: "100%"
1804
- }
1805
- },
1806
- /* @__PURE__ */ u.createElement(
1807
- he,
1808
- {
1809
- data: { subject: i.subject, body: i.body },
1810
- style: {
1811
- background: "var(--background-softGrey)",
1812
- borderRadius: 8,
1813
- borderTopLeftRadius: 0,
1814
- padding: "8px 12px",
1815
- flexShrink: 0
1816
- }
1817
- }
1818
- ),
1819
- /* @__PURE__ */ u.createElement(
1820
- "button",
1821
- {
1822
- type: "button",
1823
- title: "Apply content",
1824
- onClick: () => r(i.body),
1825
- style: {
1826
- marginLeft: 4,
1827
- background: "none",
1828
- border: "none",
1829
- cursor: "pointer",
1830
- display: "flex",
1831
- alignItems: "center",
1832
- justifyContent: "center",
1833
- padding: 8,
1834
- borderRadius: 4
1835
- }
1836
- },
1837
- /* @__PURE__ */ u.createElement(pe, { size: 16, color: "#666" })
1838
- )
1839
- )
1840
- )
1841
- ))
1842
- );
1843
- };
1844
- class dt extends u.Component {
1845
- constructor(t) {
1846
- super(t);
1847
- g(this, "containerRef");
1848
- g(this, "handleClickOutside", (t) => {
1849
- this.containerRef.current && !this.containerRef.current.contains(t.target) && this.setState({ open: !1 });
1850
- });
1851
- g(this, "togglePopper", () => {
1852
- this.setState((t) => ({ open: !t.open }));
1853
- });
1854
- g(this, "handleLangChange", (t) => {
1855
- const r = W.find((i) => i.value === t.target.value);
1856
- this.props.setLang(r || null);
1857
- });
1858
- this.state = { open: !1 }, this.containerRef = u.createRef();
1859
- }
1860
- componentDidMount() {
1861
- document.addEventListener("mousedown", this.handleClickOutside);
1862
- }
1863
- componentWillUnmount() {
1864
- document.removeEventListener("mousedown", this.handleClickOutside);
1865
- }
1866
- render() {
1867
- const { lang: t, originalEmail: r, setOriginalEmail: i, getEditorContent: s } = this.props, { open: c } = this.state;
1868
- return /* @__PURE__ */ u.createElement(
1869
- "div",
1870
- {
1871
- ref: this.containerRef,
1872
- style: { position: "relative", display: "inline-block" }
1873
- },
1874
- /* @__PURE__ */ u.createElement(
1875
- "button",
1876
- {
1877
- type: "button",
1878
- onClick: this.togglePopper,
1879
- className: "icon-button small"
1880
- },
1881
- /* @__PURE__ */ u.createElement(Te, { size: 16 })
1882
- ),
1883
- c && /* @__PURE__ */ u.createElement(
1884
- "div",
1885
- {
1886
- style: {
1887
- position: "absolute",
1888
- bottom: "100%",
1889
- left: 0,
1890
- zIndex: 1051,
1891
- background: "#fff",
1892
- border: "1px solid #ddd",
1893
- boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.1)",
1894
- borderRadius: 8,
1895
- padding: 16,
1896
- width: 320,
1897
- marginBottom: 8
1898
- }
1899
- },
1900
- /* @__PURE__ */ u.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ u.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 4 } }, /* @__PURE__ */ u.createElement(
1901
- "span",
1902
- {
1903
- style: {
1904
- fontSize: 12,
1905
- fontWeight: 500,
1906
- color: "var(--text-secondary)"
1907
- }
1908
- },
1909
- "Language"
1910
- ), /* @__PURE__ */ u.createElement(
1911
- "select",
1912
- {
1913
- value: t ? t.value : "",
1914
- onChange: this.handleLangChange,
1915
- style: {
1916
- padding: "6px 8px",
1917
- borderRadius: 4,
1918
- border: "1px solid #ccc",
1919
- fontSize: 14
1920
- }
1921
- },
1922
- /* @__PURE__ */ u.createElement("option", { value: "", disabled: !0 }, "Select Language"),
1923
- W.map((a) => /* @__PURE__ */ u.createElement("option", { key: a.value, value: a.value }, a.label))
1924
- )), /* @__PURE__ */ u.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 4 } }, /* @__PURE__ */ u.createElement(
1925
- "div",
1926
- {
1927
- style: {
1928
- display: "flex",
1929
- alignItems: "center",
1930
- justifyContent: "space-between"
1931
- }
1932
- },
1933
- /* @__PURE__ */ u.createElement(
1934
- "span",
1935
- {
1936
- style: {
1937
- fontSize: 12,
1938
- fontWeight: 500,
1939
- color: "var(--text-secondary)"
1940
- }
1941
- },
1942
- "AI Context"
1943
- ),
1944
- s && /* @__PURE__ */ u.createElement(
1945
- "button",
1946
- {
1947
- type: "button",
1948
- title: "Copy from origin email",
1949
- onClick: () => {
1950
- const a = s();
1951
- i(a);
1952
- },
1953
- className: "icon-button"
1954
- },
1955
- /* @__PURE__ */ u.createElement(pe, null)
1956
- )
1957
- ), /* @__PURE__ */ u.createElement(
1958
- "textarea",
1959
- {
1960
- value: r,
1961
- onChange: (a) => i(a.target.value),
1962
- style: {
1963
- width: "100%",
1964
- height: 120,
1965
- resize: "vertical",
1966
- padding: 8,
1967
- border: "1px solid #ccc",
1968
- borderRadius: 4,
1969
- fontSize: 13,
1970
- fontFamily: "inherit",
1971
- boxSizing: "border-box"
1972
- }
1973
- }
1974
- )))
1975
- )
1976
- );
1977
- }
1978
- }
1979
- class bt extends u.Component {
1980
- constructor(t) {
1981
- super(t);
1982
- // Equivalent to useImperativeHandle
1983
- g(this, "setAiContext", (t) => {
1984
- this.setState({ originalEmail: t });
1985
- });
1986
- g(this, "handleMessageChange", (t) => {
1987
- this.setState({ message: t.target.value });
1988
- });
1989
- g(this, "handleSubmit", async () => {
1990
- const { message: t, messages: r, lang: i, originalEmail: s, conversationId: c } = this.state, { signer: a, baseUrl: h = "" } = this.props;
1991
- if (!t.trim()) return;
1992
- const l = Ee();
1993
- let o = {
1994
- id: l,
1995
- question: t,
1996
- subject: "",
1997
- body: "",
1998
- created_at: (/* @__PURE__ */ new Date()).getTime(),
1999
- isLoading: !0
2000
- };
2001
- const d = [...r, o];
2002
- this.setState({
2003
- messages: d,
2004
- message: "",
2005
- isSending: !0
2006
- });
2007
- const p = {
2008
- query: t,
2009
- default_language: i ? i.value : "KR",
2010
- original_email: s,
2011
- debug_grpc: !0
2012
- };
2013
- c && (p.conversation_id = c), await Ae(p, {
2014
- setContent: (y) => {
2015
- this.setState((S) => ({ messages: S.messages.map(
2016
- (v) => v.id === l ? {
2017
- ...v,
2018
- subject: "Some thing not used",
2019
- body: y,
2020
- isLoading: !1,
2021
- created_at: (/* @__PURE__ */ new Date()).getTime()
2022
- } : v
2023
- ) }));
2024
- },
2025
- setIsLoading: (y) => {
2026
- this.setState((S) => ({ messages: S.messages.map(
2027
- (v) => v.id === l ? { ...v, isLoading: y } : v
2028
- ) }));
2029
- },
2030
- setConversationId: (y) => {
2031
- this.setState({ conversationId: y });
2032
- },
2033
- signer: a,
2034
- baseUrl: h
2035
- }), this.setState({ isSending: !1 });
2036
- });
2037
- g(this, "handleKeyDown", (t) => {
2038
- !t.shiftKey && t.key === "Enter" && !this.state.isSending && (t.preventDefault(), this.handleSubmit());
2039
- });
2040
- g(this, "setLang", (t) => {
2041
- this.setState({ lang: t });
2042
- });
2043
- g(this, "setOriginalEmail", (t) => {
2044
- this.setState({ originalEmail: t });
2045
- });
2046
- this.state = {
2047
- message: "",
2048
- messages: [],
2049
- isSending: !1,
2050
- lang: W[0],
2051
- conversationId: "",
2052
- originalEmail: ""
2053
- };
2054
- }
2055
- render() {
2056
- const { onApply: t, getEditorContent: r } = this.props, { message: i, messages: s, isSending: c, lang: a, originalEmail: h } = this.state;
2057
- return /* @__PURE__ */ u.createElement(
2058
- "div",
2059
- {
2060
- style: {
2061
- display: "flex",
2062
- height: "100%",
2063
- padding: 16,
2064
- flexDirection: "column",
2065
- background: "#fff",
2066
- fontFamily: "inherit",
2067
- boxSizing: "border-box"
2068
- }
2069
- },
2070
- s.length > 0 ? /* @__PURE__ */ u.createElement(
2071
- gt,
2072
- {
2073
- items: s,
2074
- onApply: t,
2075
- getEditorContent: r
2076
- }
2077
- ) : /* @__PURE__ */ u.createElement(
2078
- "div",
2079
- {
2080
- style: {
2081
- flex: 1,
2082
- minHeight: 0,
2083
- display: "flex",
2084
- flexDirection: "column",
2085
- alignItems: "center",
2086
- justifyContent: "center",
2087
- color: "var(--grey-light)"
2088
- }
2089
- },
2090
- /* @__PURE__ */ u.createElement(ze, { size: 46 }),
2091
- /* @__PURE__ */ u.createElement(
2092
- "h2",
2093
- {
2094
- style: {
2095
- marginTop: 16,
2096
- fontWeight: 600,
2097
- color: "inherit",
2098
- fontSize: 18
2099
- }
2100
- },
2101
- "Build with Agent"
2102
- )
2103
- ),
2104
- /* @__PURE__ */ u.createElement(
2105
- "div",
2106
- {
2107
- style: {
2108
- width: "100%",
2109
- border: "1px solid #ddd",
2110
- borderRadius: 4,
2111
- // overflow: "hidden",
2112
- background: c ? "var(--background-lightGrey)" : "#fff",
2113
- display: "flex",
2114
- flexDirection: "column"
2115
- }
2116
- },
2117
- /* @__PURE__ */ u.createElement(
2118
- "textarea",
2119
- {
2120
- value: i,
2121
- onChange: this.handleMessageChange,
2122
- placeholder: "Describe your email",
2123
- name: "ai-content",
2124
- onKeyDown: this.handleKeyDown,
2125
- disabled: c,
2126
- style: {
2127
- flex: 1,
2128
- minWidth: 0,
2129
- borderRadius: 4,
2130
- padding: 12,
2131
- fontSize: 13,
2132
- border: "none",
2133
- resize: "none",
2134
- outline: "none",
2135
- minHeight: 60,
2136
- fontFamily: "inherit"
2137
- }
2138
- }
2139
- ),
2140
- /* @__PURE__ */ u.createElement(
2141
- "div",
2142
- {
2143
- style: {
2144
- display: "flex",
2145
- flexDirection: "row",
2146
- alignItems: "center",
2147
- justifyContent: "space-between",
2148
- width: "100%",
2149
- padding: "8px",
2150
- boxSizing: "border-box"
2151
- }
2152
- },
2153
- /* @__PURE__ */ u.createElement(
2154
- dt,
2155
- {
2156
- lang: a,
2157
- setLang: this.setLang,
2158
- originalEmail: h,
2159
- setOriginalEmail: this.setOriginalEmail,
2160
- getEditorContent: r
2161
- }
2162
- ),
2163
- /* @__PURE__ */ u.createElement(
2164
- "button",
2165
- {
2166
- disabled: !i.trim() || c,
2167
- onClick: this.handleSubmit,
2168
- className: "icon-button",
2169
- color: "primary"
2170
- },
2171
- /* @__PURE__ */ u.createElement(Ce, null)
2172
- )
2173
- )
2174
- )
2175
- );
2176
- }
2177
- }
2178
- export {
2179
- bt as C
2180
- };