hanbiro-react16-sdk 1.0.3 → 1.0.5

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