@asgard-js/react 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/templates/quick-replies/quick-replies.d.ts.map +1 -1
- package/dist/components/templates/text-template/bot-typing-box.d.ts.map +1 -1
- package/dist/components/templates/text-template/text-template.d.ts.map +1 -1
- package/dist/components/templates/text-template/use-markdown-renderer.d.ts +9 -0
- package/dist/components/templates/text-template/use-markdown-renderer.d.ts.map +1 -0
- package/dist/hooks/use-channel.d.ts +2 -2
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/index.js +2796 -648
- package/dist/style.css +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var Lr = Object.defineProperty;
|
|
2
|
+
var Ir = (o, e, t) => e in o ? Lr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var S = (o, e, t) => Ir(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { jsx as d, jsxs as R, Fragment as Nr } from "react/jsx-runtime";
|
|
5
|
+
import * as L from "react";
|
|
6
|
+
import { createContext as Dt, useMemo as $, useContext as Pt, useRef as ce, useEffect as O, useState as V, useCallback as I, useLayoutEffect as qn, memo as Mr } from "react";
|
|
7
|
+
import { AsgardServiceClient as Or, EventType as Ie, Conversation as Dr, Channel as Pr, MessageTemplateType as He } from "@asgard-js/core";
|
|
8
|
+
function kn(o) {
|
|
9
|
+
return o !== null && typeof o == "object" && !Array.isArray(o);
|
|
10
|
+
}
|
|
11
|
+
function Gn(o, e) {
|
|
12
|
+
const t = { ...o };
|
|
13
|
+
if (!e) return t;
|
|
14
|
+
for (const [n, s] of Object.entries(e)) {
|
|
15
|
+
if (!kn(s)) {
|
|
16
|
+
t[n] = s;
|
|
14
17
|
continue;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
t[n] = Gn(kn(t[n]) ? t[n] : {}, s);
|
|
17
20
|
}
|
|
18
|
-
return
|
|
21
|
+
return t;
|
|
19
22
|
}
|
|
20
|
-
const
|
|
23
|
+
const Wn = {
|
|
21
24
|
chatbot: {
|
|
22
25
|
width: "375px",
|
|
23
26
|
height: "640px",
|
|
@@ -34,231 +37,231 @@ const ct = {
|
|
|
34
37
|
color: "var(--asg-color-text)",
|
|
35
38
|
backgroundColor: "var(--asg-color-primary)"
|
|
36
39
|
}
|
|
37
|
-
},
|
|
38
|
-
|
|
40
|
+
}, Zn = Dt(
|
|
41
|
+
Wn
|
|
39
42
|
);
|
|
40
|
-
function
|
|
41
|
-
const { children:
|
|
42
|
-
() =>
|
|
43
|
-
[
|
|
43
|
+
function zr(o) {
|
|
44
|
+
const { children: e, theme: t = {} } = o, n = $(
|
|
45
|
+
() => Gn(Wn, t),
|
|
46
|
+
[t]
|
|
44
47
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ d(Zn.Provider, { value: n, children: e });
|
|
46
49
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
50
|
+
function ge() {
|
|
51
|
+
return Pt(Zn);
|
|
49
52
|
}
|
|
50
|
-
function
|
|
51
|
-
const { config:
|
|
52
|
-
return i.current || (i.current = new
|
|
53
|
+
function $r(o) {
|
|
54
|
+
const { config: e } = o, { onRunInit: t, onProcess: n, onMessage: s, onRunDone: r, onRunError: a } = e, i = ce(null);
|
|
55
|
+
return i.current || (i.current = new Or(e)), O(() => () => {
|
|
53
56
|
i.current && (i.current.close(), i.current = null);
|
|
54
|
-
}, []),
|
|
55
|
-
!i.current || !
|
|
56
|
-
}, [
|
|
57
|
-
!i.current || !
|
|
58
|
-
}, [
|
|
59
|
-
!i.current || !
|
|
60
|
-
}, [
|
|
61
|
-
!i.current || !
|
|
62
|
-
}, [
|
|
63
|
-
!i.current || !a || i.current.on(
|
|
57
|
+
}, []), O(() => {
|
|
58
|
+
!i.current || !t || i.current.on(Ie.INIT, t);
|
|
59
|
+
}, [t]), O(() => {
|
|
60
|
+
!i.current || !n || i.current.on(Ie.PROCESS, n);
|
|
61
|
+
}, [n]), O(() => {
|
|
62
|
+
!i.current || !s || i.current.on(Ie.MESSAGE, s);
|
|
63
|
+
}, [s]), O(() => {
|
|
64
|
+
!i.current || !r || i.current.on(Ie.DONE, r);
|
|
65
|
+
}, [r]), O(() => {
|
|
66
|
+
!i.current || !a || i.current.on(Ie.ERROR, a);
|
|
64
67
|
}, [a]), i.current;
|
|
65
68
|
}
|
|
66
|
-
function
|
|
67
|
-
const { client:
|
|
68
|
-
if (!
|
|
69
|
+
function Br(o) {
|
|
70
|
+
const { client: e, customChannelId: t, customMessageId: n, initMessages: s } = o;
|
|
71
|
+
if (!e)
|
|
69
72
|
throw new Error("Client instance is required");
|
|
70
|
-
if (!
|
|
73
|
+
if (!t)
|
|
71
74
|
throw new Error("Custom channel id is required");
|
|
72
|
-
const [
|
|
73
|
-
const
|
|
75
|
+
const [r, a] = V(null), [i, p] = V(!0), [c, u] = V(!1), [m, f] = V(!1), [g, x] = V(null), k = I(async () => {
|
|
76
|
+
const D = new Dr({
|
|
74
77
|
messages: new Map(
|
|
75
|
-
|
|
78
|
+
s == null ? void 0 : s.map((E) => [E.messageId, E])
|
|
76
79
|
)
|
|
77
80
|
});
|
|
78
|
-
|
|
79
|
-
const
|
|
81
|
+
u(!0), f(!0), x(D);
|
|
82
|
+
const K = await Pr.reset(
|
|
80
83
|
{
|
|
81
|
-
client:
|
|
82
|
-
customChannelId:
|
|
83
|
-
customMessageId:
|
|
84
|
-
conversation:
|
|
85
|
-
statesObserver: (
|
|
86
|
-
|
|
84
|
+
client: e,
|
|
85
|
+
customChannelId: t,
|
|
86
|
+
customMessageId: n,
|
|
87
|
+
conversation: D,
|
|
88
|
+
statesObserver: (E) => {
|
|
89
|
+
f(E.isConnecting), x(E.conversation);
|
|
87
90
|
}
|
|
88
91
|
},
|
|
89
92
|
{
|
|
90
93
|
onSseCompleted() {
|
|
91
|
-
|
|
94
|
+
u(!1);
|
|
92
95
|
},
|
|
93
96
|
onSseError() {
|
|
94
|
-
|
|
97
|
+
u(!1);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
);
|
|
98
|
-
a(
|
|
99
|
-
}, [
|
|
100
|
-
a((
|
|
101
|
-
}, []),
|
|
102
|
-
(
|
|
103
|
-
[
|
|
101
|
+
a(K);
|
|
102
|
+
}, [e, t, n, s]), T = I(() => {
|
|
103
|
+
a((D) => (D == null || D.close(), null)), p(!1), u(!1), f(!1), x(null);
|
|
104
|
+
}, []), Y = I(
|
|
105
|
+
(D) => r == null ? void 0 : r.sendMessage(D),
|
|
106
|
+
[r]
|
|
104
107
|
);
|
|
105
|
-
return
|
|
106
|
-
!
|
|
107
|
-
}, [
|
|
108
|
+
return O(() => {
|
|
109
|
+
!r && i && k();
|
|
110
|
+
}, [r, i, k]), O(() => () => T(), [T]), $(
|
|
108
111
|
() => ({
|
|
109
112
|
isOpen: i,
|
|
110
|
-
isResetting:
|
|
111
|
-
isConnecting:
|
|
112
|
-
conversation:
|
|
113
|
-
sendMessage:
|
|
114
|
-
resetChannel:
|
|
115
|
-
closeChannel:
|
|
113
|
+
isResetting: c,
|
|
114
|
+
isConnecting: m,
|
|
115
|
+
conversation: g,
|
|
116
|
+
sendMessage: Y,
|
|
117
|
+
resetChannel: k,
|
|
118
|
+
closeChannel: T
|
|
116
119
|
}),
|
|
117
120
|
[
|
|
118
121
|
i,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
c,
|
|
123
|
+
m,
|
|
124
|
+
g,
|
|
125
|
+
Y,
|
|
126
|
+
k,
|
|
127
|
+
T
|
|
125
128
|
]
|
|
126
129
|
);
|
|
127
130
|
}
|
|
128
|
-
function
|
|
129
|
-
const [
|
|
130
|
-
return
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
},
|
|
134
|
-
return () => clearTimeout(
|
|
135
|
-
}, [
|
|
136
|
-
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
131
|
+
function Hr(o, e) {
|
|
132
|
+
const [t, n] = V(o);
|
|
133
|
+
return O(() => {
|
|
134
|
+
const s = window.setTimeout(() => {
|
|
135
|
+
n(o);
|
|
136
|
+
}, e ?? 300);
|
|
137
|
+
return () => clearTimeout(s);
|
|
138
|
+
}, [o, e]), t;
|
|
139
|
+
}
|
|
140
|
+
const Ct = typeof window < "u" ? qn : null;
|
|
141
|
+
function Ur() {
|
|
139
142
|
return window.visualViewport ? [window.visualViewport.width, window.visualViewport.height] : [window.innerWidth, window.innerHeight];
|
|
140
143
|
}
|
|
141
|
-
function
|
|
142
|
-
const [
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
(
|
|
144
|
+
function Fr() {
|
|
145
|
+
const [o, e] = V(), t = I(() => {
|
|
146
|
+
const n = Ur();
|
|
147
|
+
e(
|
|
148
|
+
(s) => s && s[0] === n[0] && s[1] === n[1] ? s : n
|
|
146
149
|
);
|
|
147
150
|
}, []);
|
|
148
|
-
return
|
|
149
|
-
var
|
|
150
|
-
function
|
|
151
|
-
|
|
151
|
+
return Ct == null || Ct(t, [t]), O(() => {
|
|
152
|
+
var s;
|
|
153
|
+
function n() {
|
|
154
|
+
t(), setTimeout(t, 1e3);
|
|
152
155
|
}
|
|
153
|
-
return window.addEventListener("resize",
|
|
154
|
-
var
|
|
155
|
-
window.removeEventListener("resize",
|
|
156
|
+
return window.addEventListener("resize", n), window.addEventListener("orientationchange", n), (s = window.visualViewport) == null || s.addEventListener("resize", n), () => {
|
|
157
|
+
var r;
|
|
158
|
+
window.removeEventListener("resize", n), window.removeEventListener("orientationchange", n), (r = window.visualViewport) == null || r.removeEventListener("resize", n);
|
|
156
159
|
};
|
|
157
|
-
}, [
|
|
158
|
-
}
|
|
159
|
-
function
|
|
160
|
-
return ["INPUT", "TEXTAREA"].includes(
|
|
161
|
-
|
|
162
|
-
) ||
|
|
163
|
-
}
|
|
164
|
-
function
|
|
165
|
-
const [
|
|
166
|
-
return
|
|
167
|
-
function
|
|
168
|
-
if (!
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
function
|
|
173
|
-
if (!
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
return document.addEventListener("focusin",
|
|
178
|
-
document.removeEventListener("focusin",
|
|
160
|
+
}, [t]), o;
|
|
161
|
+
}
|
|
162
|
+
function wn(o) {
|
|
163
|
+
return ["INPUT", "TEXTAREA"].includes(o.tagName) && !["button", "submit", "checkbox", "file", "image"].includes(
|
|
164
|
+
o.type
|
|
165
|
+
) || o.hasAttribute("contenteditable");
|
|
166
|
+
}
|
|
167
|
+
function qr() {
|
|
168
|
+
const [o, e] = V(!1);
|
|
169
|
+
return O(() => {
|
|
170
|
+
function t(s) {
|
|
171
|
+
if (!s.target) return;
|
|
172
|
+
const r = s.target;
|
|
173
|
+
wn(r) && e(!0);
|
|
174
|
+
}
|
|
175
|
+
function n(s) {
|
|
176
|
+
if (!s.target) return;
|
|
177
|
+
const r = s.target;
|
|
178
|
+
wn(r) && e(!1);
|
|
179
|
+
}
|
|
180
|
+
return document.addEventListener("focusin", t), document.addEventListener("focusout", n), () => {
|
|
181
|
+
document.removeEventListener("focusin", t), document.removeEventListener("focusout", n);
|
|
179
182
|
};
|
|
180
|
-
}, []),
|
|
183
|
+
}, []), o;
|
|
181
184
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
function
|
|
185
|
+
function Gr() {
|
|
186
|
+
O(() => {
|
|
187
|
+
function o() {
|
|
185
188
|
window.scrollTo(0, 0);
|
|
186
189
|
}
|
|
187
|
-
return window.addEventListener("scroll",
|
|
188
|
-
window.removeEventListener("scroll",
|
|
190
|
+
return window.addEventListener("scroll", o), () => {
|
|
191
|
+
window.removeEventListener("scroll", o);
|
|
189
192
|
};
|
|
190
193
|
}, []);
|
|
191
194
|
}
|
|
192
|
-
function
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
function
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
203
|
-
let
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
function r
|
|
208
|
-
if (
|
|
209
|
-
const a =
|
|
195
|
+
function Vn(o) {
|
|
196
|
+
if (o.scrollHeight > o.offsetHeight)
|
|
197
|
+
return o;
|
|
198
|
+
const e = o.parentElement;
|
|
199
|
+
if (e)
|
|
200
|
+
return Vn(e);
|
|
201
|
+
}
|
|
202
|
+
function Wr(o) {
|
|
203
|
+
O(() => {
|
|
204
|
+
const e = o.current;
|
|
205
|
+
if (!e) return;
|
|
206
|
+
let t;
|
|
207
|
+
function n(r) {
|
|
208
|
+
r.touches.length === 1 && (t = r.touches[0]);
|
|
209
|
+
}
|
|
210
|
+
function s(r) {
|
|
211
|
+
if (r.touches.length !== 1 || !t) return;
|
|
212
|
+
const a = t.pageY - r.targetTouches[0].pageY, i = t.pageX - r.targetTouches[0].pageX;
|
|
210
213
|
if (Math.abs(i) > Math.abs(a)) return;
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
213
|
-
|
|
214
|
+
const p = r.target, c = Vn(p);
|
|
215
|
+
if (!c) {
|
|
216
|
+
r.preventDefault();
|
|
214
217
|
return;
|
|
215
218
|
}
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
+
const u = a < 0, m = c.scrollTop === 0;
|
|
220
|
+
if (u && m) {
|
|
221
|
+
r.preventDefault();
|
|
219
222
|
return;
|
|
220
223
|
}
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
|
|
224
|
+
const f = c.scrollTop === c.scrollHeight - c.clientHeight;
|
|
225
|
+
if (!u && f) {
|
|
226
|
+
r.preventDefault();
|
|
224
227
|
return;
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
|
-
return
|
|
228
|
-
|
|
230
|
+
return e.addEventListener("touchstart", n), e.addEventListener("touchmove", s), () => {
|
|
231
|
+
e.removeEventListener("touchstart", n), e.removeEventListener("touchmove", s);
|
|
229
232
|
};
|
|
230
|
-
}, [
|
|
233
|
+
}, [o]);
|
|
231
234
|
}
|
|
232
|
-
const
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
}, [
|
|
238
|
-
|
|
239
|
-
function
|
|
240
|
-
|
|
235
|
+
const Et = typeof window < "u" ? qn : null;
|
|
236
|
+
function Zr(o) {
|
|
237
|
+
const e = I(() => {
|
|
238
|
+
const t = window.innerHeight * 0.01;
|
|
239
|
+
o.current && o.current.style.setProperty("--vh", `${t}px`);
|
|
240
|
+
}, [o]);
|
|
241
|
+
Et == null || Et(e, [e]), O(() => {
|
|
242
|
+
function t() {
|
|
243
|
+
e(), setTimeout(e, 1e3);
|
|
241
244
|
}
|
|
242
|
-
return
|
|
243
|
-
window.removeEventListener("resize",
|
|
245
|
+
return e(), window.addEventListener("resize", t), () => {
|
|
246
|
+
window.removeEventListener("resize", t);
|
|
244
247
|
};
|
|
245
|
-
}, [
|
|
248
|
+
}, [e]);
|
|
246
249
|
}
|
|
247
|
-
function
|
|
248
|
-
const { ref:
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
for (const
|
|
252
|
-
const { width: a, height: i } =
|
|
253
|
-
|
|
250
|
+
function Vr(o) {
|
|
251
|
+
const { ref: e, onResize: t } = o;
|
|
252
|
+
O(() => {
|
|
253
|
+
const n = new ResizeObserver((s) => {
|
|
254
|
+
for (const r of s) {
|
|
255
|
+
const { width: a, height: i } = r.contentRect;
|
|
256
|
+
t(a, i);
|
|
254
257
|
}
|
|
255
258
|
});
|
|
256
|
-
return
|
|
257
|
-
|
|
259
|
+
return e.current && n.observe(e.current), () => {
|
|
260
|
+
n.disconnect();
|
|
258
261
|
};
|
|
259
|
-
}, [
|
|
262
|
+
}, [e, t]);
|
|
260
263
|
}
|
|
261
|
-
const
|
|
264
|
+
const jn = Dt({
|
|
262
265
|
avatar: void 0,
|
|
263
266
|
client: null,
|
|
264
267
|
isOpen: !1,
|
|
@@ -268,84 +271,84 @@ const lt = F({
|
|
|
268
271
|
messageBoxBottomRef: { current: null },
|
|
269
272
|
botTypingPlaceholder: void 0
|
|
270
273
|
});
|
|
271
|
-
function
|
|
274
|
+
function jr(o) {
|
|
272
275
|
const {
|
|
273
|
-
avatar:
|
|
274
|
-
children:
|
|
275
|
-
config:
|
|
276
|
-
botTypingPlaceholder:
|
|
277
|
-
customChannelId:
|
|
276
|
+
avatar: e,
|
|
277
|
+
children: t,
|
|
278
|
+
config: n,
|
|
279
|
+
botTypingPlaceholder: s,
|
|
280
|
+
customChannelId: r,
|
|
278
281
|
initMessages: a
|
|
279
|
-
} =
|
|
280
|
-
isOpen:
|
|
281
|
-
isResetting:
|
|
282
|
-
isConnecting:
|
|
283
|
-
conversation:
|
|
284
|
-
sendMessage:
|
|
285
|
-
resetChannel:
|
|
286
|
-
closeChannel:
|
|
287
|
-
} =
|
|
288
|
-
client:
|
|
289
|
-
customChannelId:
|
|
282
|
+
} = o, i = ce(null), p = $r({ config: n }), {
|
|
283
|
+
isOpen: c,
|
|
284
|
+
isResetting: u,
|
|
285
|
+
isConnecting: m,
|
|
286
|
+
conversation: f,
|
|
287
|
+
sendMessage: g,
|
|
288
|
+
resetChannel: x,
|
|
289
|
+
closeChannel: k
|
|
290
|
+
} = Br({
|
|
291
|
+
client: p,
|
|
292
|
+
customChannelId: r,
|
|
290
293
|
initMessages: a
|
|
291
|
-
}),
|
|
294
|
+
}), T = $(
|
|
292
295
|
() => ({
|
|
293
|
-
avatar:
|
|
294
|
-
client:
|
|
295
|
-
isOpen:
|
|
296
|
-
isResetting:
|
|
297
|
-
isConnecting:
|
|
298
|
-
messages: (
|
|
299
|
-
sendMessage:
|
|
300
|
-
resetChannel:
|
|
301
|
-
closeChannel:
|
|
302
|
-
botTypingPlaceholder:
|
|
296
|
+
avatar: e,
|
|
297
|
+
client: p,
|
|
298
|
+
isOpen: c,
|
|
299
|
+
isResetting: u,
|
|
300
|
+
isConnecting: m,
|
|
301
|
+
messages: (f == null ? void 0 : f.messages) ?? null,
|
|
302
|
+
sendMessage: g,
|
|
303
|
+
resetChannel: x,
|
|
304
|
+
closeChannel: k,
|
|
305
|
+
botTypingPlaceholder: s,
|
|
303
306
|
messageBoxBottomRef: i
|
|
304
307
|
}),
|
|
305
308
|
[
|
|
306
|
-
|
|
307
|
-
u,
|
|
308
|
-
d,
|
|
309
|
-
h,
|
|
310
|
-
_,
|
|
311
|
-
l == null ? void 0 : l.messages,
|
|
309
|
+
e,
|
|
312
310
|
p,
|
|
313
|
-
|
|
311
|
+
c,
|
|
312
|
+
u,
|
|
313
|
+
m,
|
|
314
|
+
f == null ? void 0 : f.messages,
|
|
315
|
+
g,
|
|
314
316
|
x,
|
|
315
|
-
|
|
317
|
+
k,
|
|
318
|
+
s
|
|
316
319
|
]
|
|
317
320
|
);
|
|
318
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ d(jn.Provider, { value: T, children: t });
|
|
319
322
|
}
|
|
320
|
-
function
|
|
321
|
-
return
|
|
323
|
+
function se() {
|
|
324
|
+
return Pt(jn);
|
|
322
325
|
}
|
|
323
|
-
const
|
|
326
|
+
const Yn = Dt({
|
|
324
327
|
onErrorClick: void 0,
|
|
325
328
|
errorMessageRenderer: void 0
|
|
326
329
|
});
|
|
327
|
-
function
|
|
328
|
-
const { children:
|
|
329
|
-
() => ({ onErrorClick:
|
|
330
|
-
[
|
|
330
|
+
function Yr(o) {
|
|
331
|
+
const { children: e, onErrorClick: t, errorMessageRenderer: n } = o, s = $(
|
|
332
|
+
() => ({ onErrorClick: t, errorMessageRenderer: n }),
|
|
333
|
+
[n, t]
|
|
331
334
|
);
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
}
|
|
334
|
-
function
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
const
|
|
338
|
-
chatbot_header:
|
|
339
|
-
chatbot_header__content:
|
|
340
|
-
chatbot_header__title:
|
|
341
|
-
chatbot_header__extra:
|
|
342
|
-
},
|
|
343
|
-
function
|
|
344
|
-
const { avatar:
|
|
345
|
-
return
|
|
335
|
+
return /* @__PURE__ */ d(Yn.Provider, { value: s, children: e });
|
|
336
|
+
}
|
|
337
|
+
function Xr() {
|
|
338
|
+
return Pt(Yn);
|
|
339
|
+
}
|
|
340
|
+
const Qr = "_chatbot_header_luxt4_1", Kr = "_chatbot_header__content_luxt4_4", Jr = "_chatbot_header__title_luxt4_12", es = "_chatbot_header__extra_luxt4_23", Je = {
|
|
341
|
+
chatbot_header: Qr,
|
|
342
|
+
chatbot_header__content: Kr,
|
|
343
|
+
chatbot_header__title: Jr,
|
|
344
|
+
chatbot_header__extra: es
|
|
345
|
+
}, ts = (o) => /* @__PURE__ */ L.createElement("svg", { width: 33, height: 32, viewBox: "0 0 33 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("g", { clipPath: "url(#clip0_3084_29383)" }, /* @__PURE__ */ L.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "#333333" }), /* @__PURE__ */ L.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.5788 6.33398C19.8925 6.33398 22.5788 9.02028 22.5788 12.334C22.5788 14.2211 21.7075 15.9048 20.3453 17.0047C23.6487 18.3735 26.0607 21.6974 26.4106 25.6673H24.4569C24.0206 21.6274 20.9742 18.4911 17.2591 18.3397L16.9776 18.334H16.5788H15.8437C12.0019 18.334 8.81164 21.5258 8.36437 25.6673H6.41064C6.76857 21.607 9.28344 18.2225 12.7029 16.9143C11.4036 15.8137 10.5788 14.1701 10.5788 12.334C10.5788 9.02028 13.265 6.33398 16.5788 6.33398ZM16.5788 16.334C18.7879 16.334 20.5788 14.5431 20.5788 12.334C20.5788 10.1248 18.7879 8.33398 16.5788 8.33398C14.3696 8.33398 12.5788 10.1248 12.5788 12.334C12.5788 14.5431 14.3696 16.334 16.5788 16.334Z", fill: "#8C8C8C" })), /* @__PURE__ */ L.createElement("defs", null, /* @__PURE__ */ L.createElement("clipPath", { id: "clip0_3084_29383" }, /* @__PURE__ */ L.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "white" }))));
|
|
346
|
+
function ns(o) {
|
|
347
|
+
const { avatar: e } = o;
|
|
348
|
+
return e ? /* @__PURE__ */ d(
|
|
346
349
|
"img",
|
|
347
350
|
{
|
|
348
|
-
src:
|
|
351
|
+
src: e,
|
|
349
352
|
alt: "avatar",
|
|
350
353
|
style: {
|
|
351
354
|
width: 33,
|
|
@@ -353,630 +356,2775 @@ function Pt(n) {
|
|
|
353
356
|
borderRadius: "50%"
|
|
354
357
|
}
|
|
355
358
|
}
|
|
356
|
-
) : /* @__PURE__ */
|
|
359
|
+
) : /* @__PURE__ */ d(ts, {});
|
|
357
360
|
}
|
|
358
|
-
const
|
|
359
|
-
function
|
|
360
|
-
const { title:
|
|
361
|
+
const rs = (o) => /* @__PURE__ */ L.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.49453 2.3352C6.44049 -0.226723 10.9105 -0.106316 13.7142 2.69633C16.6428 5.62613 16.6428 10.3739 13.7144 13.3035C10.7846 16.2322 6.03581 16.2322 3.1073 13.3036C2.30873 12.505 1.71132 11.5536 1.34188 10.5109L1.78892 10.3525L1.34171 10.5106L1.22791 10.162C1.01752 9.46018 0.910643 8.73159 0.910643 7.9997H2.4542L2.46382 8.33865C2.49584 8.9024 2.60763 9.46037 2.79674 9.99539L2.7968 9.99536L2.90116 10.2683C3.19714 10.9887 3.63414 11.6475 4.19876 12.2121C6.52451 14.5379 10.2961 14.5379 12.6229 12.212C14.9486 9.88539 14.9486 6.11464 12.6227 3.78781C10.3306 1.49653 6.63579 1.46263 4.30292 3.68622L6.68087 3.68698V5.22954H3.49394H1.95141V3.68698V0.5H3.49394L3.49453 2.3352Z", fill: "#8C8C8C" })), ss = (o) => /* @__PURE__ */ L.createElement("svg", { width: 15, height: 14, viewBox: "0 0 15 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.3496 0L7.41062 5.938L1.47162 0L0.411621 1.06L6.34962 6.999L0.411621 12.938L1.47162 13.999L7.41062 8.059L13.3496 13.999L14.4096 12.938L8.47162 6.999L14.4096 1.06L13.3496 0Z", fill: "#8C8C8C" }));
|
|
362
|
+
function os(o) {
|
|
363
|
+
const { title: e, onReset: t, onClose: n } = o, { chatbot: s } = ge(), { avatar: r, isResetting: a, resetChannel: i, closeChannel: p } = se(), c = $(
|
|
361
364
|
() => ({
|
|
362
|
-
maxWidth: (
|
|
363
|
-
borderBottomColor:
|
|
365
|
+
maxWidth: (s == null ? void 0 : s.contentMaxWidth) ?? "1200px",
|
|
366
|
+
borderBottomColor: s == null ? void 0 : s.borderColor
|
|
364
367
|
}),
|
|
365
|
-
[
|
|
366
|
-
),
|
|
367
|
-
(
|
|
368
|
-
a || (
|
|
368
|
+
[s]
|
|
369
|
+
), u = I(
|
|
370
|
+
(f) => {
|
|
371
|
+
a || (f.stopPropagation(), t == null || t(), i == null || i());
|
|
369
372
|
},
|
|
370
|
-
[a,
|
|
371
|
-
),
|
|
372
|
-
(
|
|
373
|
-
a || (
|
|
373
|
+
[a, t, i]
|
|
374
|
+
), m = I(
|
|
375
|
+
(f) => {
|
|
376
|
+
a || (f.stopPropagation(), n == null || n(), p == null || p());
|
|
374
377
|
},
|
|
375
|
-
[a,
|
|
378
|
+
[a, n, p]
|
|
376
379
|
);
|
|
377
|
-
return /* @__PURE__ */
|
|
378
|
-
/* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */
|
|
380
|
-
/* @__PURE__ */
|
|
380
|
+
return /* @__PURE__ */ d("div", { className: Je.chatbot_header, children: /* @__PURE__ */ R("div", { className: Je.chatbot_header__content, style: c, children: [
|
|
381
|
+
/* @__PURE__ */ R("div", { className: Je.chatbot_header__title, children: [
|
|
382
|
+
/* @__PURE__ */ d(ns, { avatar: r }),
|
|
383
|
+
/* @__PURE__ */ d("h4", { children: e })
|
|
381
384
|
] }),
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
+
/* @__PURE__ */ R("div", { className: Je.chatbot_header__extra, children: [
|
|
386
|
+
/* @__PURE__ */ d("div", { onClick: u, children: /* @__PURE__ */ d(rs, {}) }),
|
|
387
|
+
/* @__PURE__ */ d("div", { onClick: m, children: /* @__PURE__ */ d(ss, {}) })
|
|
385
388
|
] })
|
|
386
389
|
] }) });
|
|
387
390
|
}
|
|
388
|
-
const
|
|
389
|
-
chatbot_body:
|
|
390
|
-
chatbot_body__content:
|
|
391
|
-
},
|
|
392
|
-
template_box:
|
|
391
|
+
const is = "_chatbot_body_f6sqm_1", as = "_chatbot_body__content_f6sqm_5", Tn = {
|
|
392
|
+
chatbot_body: is,
|
|
393
|
+
chatbot_body__content: as
|
|
394
|
+
}, ls = "_template_box_1ozig_1", ye = {
|
|
395
|
+
template_box: ls,
|
|
393
396
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
394
397
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
395
398
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
396
399
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
397
400
|
};
|
|
398
|
-
function
|
|
399
|
-
var
|
|
400
|
-
if (typeof
|
|
401
|
-
else if (typeof
|
|
402
|
-
var
|
|
403
|
-
for (
|
|
404
|
-
} else for (
|
|
405
|
-
return
|
|
401
|
+
function Xn(o) {
|
|
402
|
+
var e, t, n = "";
|
|
403
|
+
if (typeof o == "string" || typeof o == "number") n += o;
|
|
404
|
+
else if (typeof o == "object") if (Array.isArray(o)) {
|
|
405
|
+
var s = o.length;
|
|
406
|
+
for (e = 0; e < s; e++) o[e] && (t = Xn(o[e])) && (n && (n += " "), n += t);
|
|
407
|
+
} else for (t in o) o[t] && (n && (n += " "), n += t);
|
|
408
|
+
return n;
|
|
406
409
|
}
|
|
407
|
-
function
|
|
408
|
-
for (var
|
|
409
|
-
return
|
|
410
|
+
function ae() {
|
|
411
|
+
for (var o, e, t = 0, n = "", s = arguments.length; t < s; t++) (o = arguments[t]) && (e = Xn(o)) && (n && (n += " "), n += e);
|
|
412
|
+
return n;
|
|
410
413
|
}
|
|
411
|
-
function
|
|
412
|
-
const { type:
|
|
413
|
-
switch (
|
|
414
|
+
function Ge(o) {
|
|
415
|
+
const { type: e, direction: t = "horizontal", children: n } = o, s = $(() => {
|
|
416
|
+
switch (e) {
|
|
414
417
|
case "user":
|
|
415
|
-
return
|
|
418
|
+
return ae(ye.template_box, ye["template_box--user"]);
|
|
416
419
|
case "bot":
|
|
417
420
|
default:
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
421
|
+
return ae(
|
|
422
|
+
ye.template_box,
|
|
423
|
+
ye["template_box--bot"],
|
|
424
|
+
t === "horizontal" ? ye["template_box--horizontal"] : ye["template_box--vertical"]
|
|
422
425
|
);
|
|
423
426
|
}
|
|
424
|
-
}, [
|
|
425
|
-
return /* @__PURE__ */
|
|
427
|
+
}, [t, e]);
|
|
428
|
+
return /* @__PURE__ */ d("div", { className: s, children: n });
|
|
426
429
|
}
|
|
427
|
-
const
|
|
428
|
-
template_box_content:
|
|
429
|
-
content:
|
|
430
|
-
},
|
|
431
|
-
quick_replies_box:
|
|
432
|
-
quick_reply:
|
|
430
|
+
const cs = "_template_box_content_fs2wk_1", us = "_content_fs2wk_8", yn = {
|
|
431
|
+
template_box_content: cs,
|
|
432
|
+
content: us
|
|
433
|
+
}, ps = "_quick_replies_box_zoq7y_1", hs = "_quick_reply_zoq7y_7", Cn = {
|
|
434
|
+
quick_replies_box: ps,
|
|
435
|
+
quick_reply: hs
|
|
433
436
|
};
|
|
434
|
-
function
|
|
435
|
-
const { quickReplies:
|
|
436
|
-
(
|
|
437
|
-
|
|
438
|
-
},
|
|
439
|
-
[o]
|
|
437
|
+
function fs(o) {
|
|
438
|
+
const { quickReplies: e } = o, { sendMessage: t, isConnecting: n } = se(), s = I(
|
|
439
|
+
(r) => t == null ? void 0 : t({ text: r }),
|
|
440
|
+
[t]
|
|
440
441
|
);
|
|
441
|
-
return
|
|
442
|
+
return e != null && e.length ? /* @__PURE__ */ d("div", { className: Cn.quick_replies_box, children: e.map((r) => /* @__PURE__ */ d(
|
|
442
443
|
"button",
|
|
443
444
|
{
|
|
444
|
-
className:
|
|
445
|
-
disabled:
|
|
446
|
-
onClick: () => r
|
|
447
|
-
children:
|
|
445
|
+
className: Cn.quick_reply,
|
|
446
|
+
disabled: n,
|
|
447
|
+
onClick: () => s(r.text),
|
|
448
|
+
children: r.text
|
|
448
449
|
},
|
|
449
|
-
|
|
450
|
+
r.text
|
|
450
451
|
)) }) : null;
|
|
451
452
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
453
|
+
function It(o) {
|
|
454
|
+
return o.toLocaleTimeString("zh-TW", {
|
|
454
455
|
timeZone: "Asia/Taipei",
|
|
455
456
|
hour: "2-digit",
|
|
456
457
|
minute: "2-digit",
|
|
457
458
|
hour12: !1
|
|
458
459
|
});
|
|
459
460
|
}
|
|
460
|
-
const
|
|
461
|
-
time:
|
|
461
|
+
const ds = "_time_rgg92_1", gs = {
|
|
462
|
+
time: ds
|
|
462
463
|
};
|
|
463
|
-
function
|
|
464
|
-
const { time:
|
|
465
|
-
return
|
|
466
|
-
}
|
|
467
|
-
function
|
|
468
|
-
const { quickReplies:
|
|
469
|
-
return /* @__PURE__ */
|
|
470
|
-
/* @__PURE__ */
|
|
471
|
-
|
|
472
|
-
/* @__PURE__ */
|
|
464
|
+
function zt(o) {
|
|
465
|
+
const { time: e, className: t } = o;
|
|
466
|
+
return e ? /* @__PURE__ */ d("div", { className: ae(gs.time, t), children: It(e) }) : null;
|
|
467
|
+
}
|
|
468
|
+
function $t(o) {
|
|
469
|
+
const { quickReplies: e, time: t, children: n } = o;
|
|
470
|
+
return /* @__PURE__ */ R("div", { className: yn.template_box_content, children: [
|
|
471
|
+
/* @__PURE__ */ R("div", { className: yn.content, children: [
|
|
472
|
+
n,
|
|
473
|
+
/* @__PURE__ */ d(zt, { time: t })
|
|
473
474
|
] }),
|
|
474
|
-
!!(
|
|
475
|
+
!!(e != null && e.length) && /* @__PURE__ */ d(fs, { quickReplies: e })
|
|
475
476
|
] });
|
|
476
477
|
}
|
|
477
|
-
const
|
|
478
|
-
bot_avatar:
|
|
479
|
-
},
|
|
480
|
-
const { avatar:
|
|
481
|
-
return
|
|
482
|
-
}),
|
|
483
|
-
card_root:
|
|
484
|
-
card_content:
|
|
485
|
-
card_title:
|
|
486
|
-
card_description:
|
|
487
|
-
card_actions:
|
|
478
|
+
const ms = "_bot_avatar_xrs9x_1", En = {
|
|
479
|
+
bot_avatar: ms
|
|
480
|
+
}, _s = (o) => /* @__PURE__ */ L.createElement("svg", { viewBox: "0 0 25 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("path", { d: "M0.40625 12C0.40625 5.37258 5.77883 0 12.4062 0C19.0337 0 24.4062 5.37258 24.4062 12C24.4062 18.6274 19.0337 24 12.4062 24C5.77883 24 0.40625 18.6274 0.40625 12Z", fill: "#585858" }), /* @__PURE__ */ L.createElement("path", { d: "M6.40625 18.75V15C6.40625 14.5875 6.55313 14.2344 6.84688 13.9406C7.14063 13.6469 7.49375 13.5 7.90625 13.5H16.9062C17.3188 13.5 17.6719 13.6469 17.9656 13.9406C18.2594 14.2344 18.4062 14.5875 18.4062 15V18.75H6.40625ZM10.1562 12.75C9.11875 12.75 8.23438 12.3844 7.50312 11.6531C6.77187 10.9219 6.40625 10.0375 6.40625 9C6.40625 7.9625 6.77187 7.07812 7.50312 6.34687C8.23438 5.61562 9.11875 5.25 10.1562 5.25H14.6562C15.6938 5.25 16.5781 5.61562 17.3094 6.34687C18.0406 7.07812 18.4062 7.9625 18.4062 9C18.4062 10.0375 18.0406 10.9219 17.3094 11.6531C16.5781 12.3844 15.6938 12.75 14.6562 12.75H10.1562ZM7.90625 17.25H16.9062V15H7.90625V17.25ZM10.1562 11.25H14.6562C15.2812 11.25 15.8125 11.0312 16.25 10.5938C16.6875 10.1562 16.9062 9.625 16.9062 9C16.9062 8.375 16.6875 7.84375 16.25 7.40625C15.8125 6.96875 15.2812 6.75 14.6562 6.75H10.1562C9.53125 6.75 9 6.96875 8.5625 7.40625C8.125 7.84375 7.90625 8.375 7.90625 9C7.90625 9.625 8.125 10.1562 8.5625 10.5938C9 11.0312 9.53125 11.25 10.1562 11.25ZM10.1562 9.75C10.3688 9.75 10.5469 9.67812 10.6906 9.53438C10.8344 9.39062 10.9062 9.2125 10.9062 9C10.9062 8.7875 10.8344 8.60938 10.6906 8.46562C10.5469 8.32187 10.3688 8.25 10.1562 8.25C9.94375 8.25 9.76562 8.32187 9.62187 8.46562C9.47812 8.60938 9.40625 8.7875 9.40625 9C9.40625 9.2125 9.47812 9.39062 9.62187 9.53438C9.76562 9.67812 9.94375 9.75 10.1562 9.75ZM14.6562 9.75C14.8687 9.75 15.0469 9.67812 15.1906 9.53438C15.3344 9.39062 15.4062 9.2125 15.4062 9C15.4062 8.7875 15.3344 8.60938 15.1906 8.46562C15.0469 8.32187 14.8687 8.25 14.6562 8.25C14.4438 8.25 14.2656 8.32187 14.1219 8.46562C13.9781 8.60938 13.9062 8.7875 13.9062 9C13.9062 9.2125 13.9781 9.39062 14.1219 9.53438C14.2656 9.67812 14.4438 9.75 14.6562 9.75Z", fill: "white" })), at = Mr((o) => {
|
|
481
|
+
const { avatar: e } = o;
|
|
482
|
+
return e ? /* @__PURE__ */ d("img", { src: e, alt: "Bot Avatar", className: En.bot_avatar }) : /* @__PURE__ */ d("div", { className: En.bot_avatar, children: /* @__PURE__ */ d(_s, {}) });
|
|
483
|
+
}), bs = "_card_root_1qjc0_1", xs = "_card_content_1qjc0_12", ks = "_card_title_1qjc0_20", ws = "_card_description_1qjc0_26", Ts = "_card_actions_1qjc0_41", Ne = {
|
|
484
|
+
card_root: bs,
|
|
485
|
+
card_content: xs,
|
|
486
|
+
card_title: ks,
|
|
487
|
+
card_description: ws,
|
|
488
|
+
card_actions: Ts
|
|
488
489
|
};
|
|
489
|
-
function
|
|
490
|
+
function Qn(o) {
|
|
490
491
|
var a;
|
|
491
|
-
const { template:
|
|
492
|
-
switch (
|
|
492
|
+
const { template: e } = o, { sendMessage: t } = se(), n = $(() => (e == null ? void 0 : e.thumbnailImageUrl.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee", [e]), s = $(() => {
|
|
493
|
+
switch (e == null ? void 0 : e.imageAspectRatio) {
|
|
493
494
|
case "square":
|
|
494
495
|
return "1 / 1";
|
|
495
496
|
case "rectangle":
|
|
496
497
|
default:
|
|
497
498
|
return "1.51 / 1";
|
|
498
499
|
}
|
|
499
|
-
}, [
|
|
500
|
+
}, [e]), r = I(
|
|
500
501
|
(i) => function() {
|
|
501
502
|
switch (i.type) {
|
|
502
503
|
case "message":
|
|
503
|
-
|
|
504
|
+
t == null || t({ text: i.text });
|
|
504
505
|
return;
|
|
505
506
|
case "uri":
|
|
506
507
|
window.open(i.uri, "_blank");
|
|
507
508
|
return;
|
|
508
509
|
}
|
|
509
510
|
},
|
|
510
|
-
[
|
|
511
|
+
[t]
|
|
511
512
|
);
|
|
512
|
-
return /* @__PURE__ */
|
|
513
|
-
(
|
|
513
|
+
return /* @__PURE__ */ R("div", { className: Ne.card_root, children: [
|
|
514
|
+
(e == null ? void 0 : e.thumbnailImageUrl) && /* @__PURE__ */ d(
|
|
514
515
|
"img",
|
|
515
516
|
{
|
|
516
|
-
alt:
|
|
517
|
-
src:
|
|
517
|
+
alt: e == null ? void 0 : e.title,
|
|
518
|
+
src: n,
|
|
518
519
|
style: {
|
|
519
520
|
display: "block",
|
|
520
521
|
width: "100%",
|
|
521
522
|
maxHeight: "170px",
|
|
522
|
-
objectFit:
|
|
523
|
-
aspectRatio:
|
|
523
|
+
objectFit: e == null ? void 0 : e.imageSize,
|
|
524
|
+
aspectRatio: s
|
|
524
525
|
}
|
|
525
526
|
}
|
|
526
527
|
),
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
528
|
+
/* @__PURE__ */ R("div", { className: Ne.card_content, children: [
|
|
529
|
+
/* @__PURE__ */ d("h5", { className: Ne.card_title, children: e == null ? void 0 : e.title }),
|
|
530
|
+
/* @__PURE__ */ d("div", { className: Ne.card_description, children: e == null ? void 0 : e.text }),
|
|
531
|
+
/* @__PURE__ */ d("div", { className: Ne.card_actions, children: (a = e == null ? void 0 : e.buttons) == null ? void 0 : a.map((i, p) => /* @__PURE__ */ d("button", { onClick: r(i.action), children: i.label }, p)) })
|
|
531
532
|
] })
|
|
532
533
|
] });
|
|
533
534
|
}
|
|
534
|
-
function
|
|
535
|
-
const { message:
|
|
536
|
-
return /* @__PURE__ */
|
|
537
|
-
/* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
|
|
535
|
+
function ys(o) {
|
|
536
|
+
const { message: e } = o, { avatar: t } = se(), n = e.message.template;
|
|
537
|
+
return /* @__PURE__ */ R(Ge, { type: "bot", direction: "horizontal", children: [
|
|
538
|
+
/* @__PURE__ */ d(at, { avatar: t }),
|
|
539
|
+
/* @__PURE__ */ d(
|
|
540
|
+
$t,
|
|
540
541
|
{
|
|
541
|
-
time:
|
|
542
|
-
quickReplies:
|
|
543
|
-
children: /* @__PURE__ */
|
|
542
|
+
time: e.time,
|
|
543
|
+
quickReplies: n == null ? void 0 : n.quickReplies,
|
|
544
|
+
children: /* @__PURE__ */ d(Qn, { template: n })
|
|
544
545
|
}
|
|
545
546
|
)
|
|
546
547
|
] });
|
|
547
548
|
}
|
|
548
|
-
const
|
|
549
|
-
text:
|
|
550
|
-
|
|
551
|
-
"text--
|
|
552
|
-
"
|
|
553
|
-
|
|
549
|
+
const Cs = "_text_1afu9_1", Es = "_md_container_1afu9_11", Ss = "_dot_1afu9_41", ee = {
|
|
550
|
+
text: Cs,
|
|
551
|
+
md_container: Es,
|
|
552
|
+
"text--user": "_text--user_1afu9_18",
|
|
553
|
+
"text--bot": "_text--bot_1afu9_24",
|
|
554
|
+
"typing-indicator": "_typing-indicator_1afu9_36",
|
|
555
|
+
dot: Ss
|
|
554
556
|
};
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
557
|
+
function Bt() {
|
|
558
|
+
return {
|
|
559
|
+
async: !1,
|
|
560
|
+
breaks: !1,
|
|
561
|
+
extensions: null,
|
|
562
|
+
gfm: !0,
|
|
563
|
+
hooks: null,
|
|
564
|
+
pedantic: !1,
|
|
565
|
+
renderer: null,
|
|
566
|
+
silent: !1,
|
|
567
|
+
tokenizer: null,
|
|
568
|
+
walkTokens: null
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
let me = Bt();
|
|
572
|
+
function Kn(o) {
|
|
573
|
+
me = o;
|
|
574
|
+
}
|
|
575
|
+
const Ue = { exec: () => null };
|
|
576
|
+
function y(o, e = "") {
|
|
577
|
+
let t = typeof o == "string" ? o : o.source;
|
|
578
|
+
const n = {
|
|
579
|
+
replace: (s, r) => {
|
|
580
|
+
let a = typeof r == "string" ? r : r.source;
|
|
581
|
+
return a = a.replace(q.caret, "$1"), t = t.replace(s, a), n;
|
|
582
|
+
},
|
|
583
|
+
getRegex: () => new RegExp(t, e)
|
|
584
|
+
};
|
|
585
|
+
return n;
|
|
586
|
+
}
|
|
587
|
+
const q = {
|
|
588
|
+
codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
|
|
589
|
+
outputLinkReplace: /\\([\[\]])/g,
|
|
590
|
+
indentCodeCompensation: /^(\s+)(?:```)/,
|
|
591
|
+
beginningSpace: /^\s+/,
|
|
592
|
+
endingHash: /#$/,
|
|
593
|
+
startingSpaceChar: /^ /,
|
|
594
|
+
endingSpaceChar: / $/,
|
|
595
|
+
nonSpaceChar: /[^ ]/,
|
|
596
|
+
newLineCharGlobal: /\n/g,
|
|
597
|
+
tabCharGlobal: /\t/g,
|
|
598
|
+
multipleSpaceGlobal: /\s+/g,
|
|
599
|
+
blankLine: /^[ \t]*$/,
|
|
600
|
+
doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
|
|
601
|
+
blockquoteStart: /^ {0,3}>/,
|
|
602
|
+
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
|
|
603
|
+
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
|
|
604
|
+
listReplaceTabs: /^\t+/,
|
|
605
|
+
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
|
|
606
|
+
listIsTask: /^\[[ xX]\] /,
|
|
607
|
+
listReplaceTask: /^\[[ xX]\] +/,
|
|
608
|
+
anyLine: /\n.*\n/,
|
|
609
|
+
hrefBrackets: /^<(.*)>$/,
|
|
610
|
+
tableDelimiter: /[:|]/,
|
|
611
|
+
tableAlignChars: /^\||\| *$/g,
|
|
612
|
+
tableRowBlankLine: /\n[ \t]*$/,
|
|
613
|
+
tableAlignRight: /^ *-+: *$/,
|
|
614
|
+
tableAlignCenter: /^ *:-+: *$/,
|
|
615
|
+
tableAlignLeft: /^ *:-+ *$/,
|
|
616
|
+
startATag: /^<a /i,
|
|
617
|
+
endATag: /^<\/a>/i,
|
|
618
|
+
startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
|
|
619
|
+
endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
|
|
620
|
+
startAngleBracket: /^</,
|
|
621
|
+
endAngleBracket: />$/,
|
|
622
|
+
pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
|
|
623
|
+
unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
|
|
624
|
+
escapeTest: /[&<>"']/,
|
|
625
|
+
escapeReplace: /[&<>"']/g,
|
|
626
|
+
escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
|
|
627
|
+
escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
|
|
628
|
+
unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
|
|
629
|
+
caret: /(^|[^\[])\^/g,
|
|
630
|
+
percentDecode: /%25/g,
|
|
631
|
+
findPipe: /\|/g,
|
|
632
|
+
splitPipe: / \|/,
|
|
633
|
+
slashPipe: /\\\|/g,
|
|
634
|
+
carriageReturn: /\r\n|\r/g,
|
|
635
|
+
spaceLine: /^ +$/gm,
|
|
636
|
+
notSpaceStart: /^\S*/,
|
|
637
|
+
endingNewline: /\n$/,
|
|
638
|
+
listItemRegex: (o) => new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
639
|
+
nextBulletRegex: (o) => new RegExp(`^ {0,${Math.min(3, o - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
|
|
640
|
+
hrRegex: (o) => new RegExp(`^ {0,${Math.min(3, o - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
|
|
641
|
+
fencesBeginRegex: (o) => new RegExp(`^ {0,${Math.min(3, o - 1)}}(?:\`\`\`|~~~)`),
|
|
642
|
+
headingBeginRegex: (o) => new RegExp(`^ {0,${Math.min(3, o - 1)}}#`),
|
|
643
|
+
htmlBeginRegex: (o) => new RegExp(`^ {0,${Math.min(3, o - 1)}}<(?:[a-z].*>|!--)`, "i")
|
|
644
|
+
}, As = /^(?:[ \t]*(?:\n|$))+/, Rs = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, vs = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, We = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Ls = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Ht = /(?:[*+-]|\d{1,9}[.)])/, Jn = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, er = y(Jn).replace(/bull/g, Ht).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(), Is = y(Jn).replace(/bull/g, Ht).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(), Ut = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ns = /^[^\n]+/, Ft = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Ms = y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Ft).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Os = y(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Ht).getRegex(), lt = "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", qt = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Ds = y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", qt).replace("tag", lt).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), tr = y(Ut).replace("hr", We).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", lt).getRegex(), Ps = y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", tr).getRegex(), Gt = {
|
|
645
|
+
blockquote: Ps,
|
|
646
|
+
code: Rs,
|
|
647
|
+
def: Ms,
|
|
648
|
+
fences: vs,
|
|
649
|
+
heading: Ls,
|
|
650
|
+
hr: We,
|
|
651
|
+
html: Ds,
|
|
652
|
+
lheading: er,
|
|
653
|
+
list: Os,
|
|
654
|
+
newline: As,
|
|
655
|
+
paragraph: tr,
|
|
656
|
+
table: Ue,
|
|
657
|
+
text: Ns
|
|
658
|
+
}, Sn = y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", We).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", lt).getRegex(), zs = {
|
|
659
|
+
...Gt,
|
|
660
|
+
lheading: Is,
|
|
661
|
+
table: Sn,
|
|
662
|
+
paragraph: y(Ut).replace("hr", We).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Sn).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", lt).getRegex()
|
|
663
|
+
}, $s = {
|
|
664
|
+
...Gt,
|
|
665
|
+
html: y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", qt).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(),
|
|
666
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
667
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
668
|
+
fences: Ue,
|
|
669
|
+
// fences not supported
|
|
670
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
671
|
+
paragraph: y(Ut).replace("hr", We).replace("heading", ` *#{1,6} *[^
|
|
672
|
+
]`).replace("lheading", er).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
673
|
+
}, Bs = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Hs = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, nr = /^( {2,}|\\)\n(?!\s*$)/, Us = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, ct = /[\p{P}\p{S}]/u, Wt = /[\s\p{P}\p{S}]/u, rr = /[^\s\p{P}\p{S}]/u, Fs = y(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Wt).getRegex(), sr = /(?!~)[\p{P}\p{S}]/u, qs = /(?!~)[\s\p{P}\p{S}]/u, Gs = /(?:[^\s\p{P}\p{S}]|~)/u, Ws = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, or = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Zs = y(or, "u").replace(/punct/g, ct).getRegex(), Vs = y(or, "u").replace(/punct/g, sr).getRegex(), ir = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", js = y(ir, "gu").replace(/notPunctSpace/g, rr).replace(/punctSpace/g, Wt).replace(/punct/g, ct).getRegex(), Ys = y(ir, "gu").replace(/notPunctSpace/g, Gs).replace(/punctSpace/g, qs).replace(/punct/g, sr).getRegex(), Xs = y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, rr).replace(/punctSpace/g, Wt).replace(/punct/g, ct).getRegex(), Qs = y(/\\(punct)/, "gu").replace(/punct/g, ct).getRegex(), Ks = y(/^<(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(), Js = y(qt).replace("(?:-->|$)", "-->").getRegex(), eo = y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Js).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), st = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, to = y(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", st).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ar = y(/^!?\[(label)\]\[(ref)\]/).replace("label", st).replace("ref", Ft).getRegex(), lr = y(/^!?\[(ref)\](?:\[\])?/).replace("ref", Ft).getRegex(), no = y("reflink|nolink(?!\\()", "g").replace("reflink", ar).replace("nolink", lr).getRegex(), Zt = {
|
|
674
|
+
_backpedal: Ue,
|
|
675
|
+
// only used for GFM url
|
|
676
|
+
anyPunctuation: Qs,
|
|
677
|
+
autolink: Ks,
|
|
678
|
+
blockSkip: Ws,
|
|
679
|
+
br: nr,
|
|
680
|
+
code: Hs,
|
|
681
|
+
del: Ue,
|
|
682
|
+
emStrongLDelim: Zs,
|
|
683
|
+
emStrongRDelimAst: js,
|
|
684
|
+
emStrongRDelimUnd: Xs,
|
|
685
|
+
escape: Bs,
|
|
686
|
+
link: to,
|
|
687
|
+
nolink: lr,
|
|
688
|
+
punctuation: Fs,
|
|
689
|
+
reflink: ar,
|
|
690
|
+
reflinkSearch: no,
|
|
691
|
+
tag: eo,
|
|
692
|
+
text: Us,
|
|
693
|
+
url: Ue
|
|
694
|
+
}, ro = {
|
|
695
|
+
...Zt,
|
|
696
|
+
link: y(/^!?\[(label)\]\((.*?)\)/).replace("label", st).getRegex(),
|
|
697
|
+
reflink: y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", st).getRegex()
|
|
698
|
+
}, Nt = {
|
|
699
|
+
...Zt,
|
|
700
|
+
emStrongRDelimAst: Ys,
|
|
701
|
+
emStrongLDelim: Vs,
|
|
702
|
+
url: y(/^((?: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(),
|
|
703
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
704
|
+
del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
|
|
705
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
706
|
+
}, so = {
|
|
707
|
+
...Nt,
|
|
708
|
+
br: y(nr).replace("{2,}", "*").getRegex(),
|
|
709
|
+
text: y(Nt.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
710
|
+
}, et = {
|
|
711
|
+
normal: Gt,
|
|
712
|
+
gfm: zs,
|
|
713
|
+
pedantic: $s
|
|
714
|
+
}, Me = {
|
|
715
|
+
normal: Zt,
|
|
716
|
+
gfm: Nt,
|
|
717
|
+
breaks: so,
|
|
718
|
+
pedantic: ro
|
|
719
|
+
}, oo = {
|
|
720
|
+
"&": "&",
|
|
721
|
+
"<": "<",
|
|
722
|
+
">": ">",
|
|
723
|
+
'"': """,
|
|
724
|
+
"'": "'"
|
|
725
|
+
}, An = (o) => oo[o];
|
|
726
|
+
function re(o, e) {
|
|
727
|
+
if (e) {
|
|
728
|
+
if (q.escapeTest.test(o))
|
|
729
|
+
return o.replace(q.escapeReplace, An);
|
|
730
|
+
} else if (q.escapeTestNoEncode.test(o))
|
|
731
|
+
return o.replace(q.escapeReplaceNoEncode, An);
|
|
732
|
+
return o;
|
|
733
|
+
}
|
|
734
|
+
function Rn(o) {
|
|
735
|
+
try {
|
|
736
|
+
o = encodeURI(o).replace(q.percentDecode, "%");
|
|
737
|
+
} catch {
|
|
738
|
+
return null;
|
|
739
|
+
}
|
|
740
|
+
return o;
|
|
741
|
+
}
|
|
742
|
+
function vn(o, e) {
|
|
743
|
+
var r;
|
|
744
|
+
const t = o.replace(q.findPipe, (a, i, p) => {
|
|
745
|
+
let c = !1, u = i;
|
|
746
|
+
for (; --u >= 0 && p[u] === "\\"; )
|
|
747
|
+
c = !c;
|
|
748
|
+
return c ? "|" : " |";
|
|
749
|
+
}), n = t.split(q.splitPipe);
|
|
750
|
+
let s = 0;
|
|
751
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !((r = n.at(-1)) != null && r.trim()) && n.pop(), e)
|
|
752
|
+
if (n.length > e)
|
|
753
|
+
n.splice(e);
|
|
754
|
+
else
|
|
755
|
+
for (; n.length < e; )
|
|
756
|
+
n.push("");
|
|
757
|
+
for (; s < n.length; s++)
|
|
758
|
+
n[s] = n[s].trim().replace(q.slashPipe, "|");
|
|
759
|
+
return n;
|
|
760
|
+
}
|
|
761
|
+
function Oe(o, e, t) {
|
|
762
|
+
const n = o.length;
|
|
763
|
+
if (n === 0)
|
|
764
|
+
return "";
|
|
765
|
+
let s = 0;
|
|
766
|
+
for (; s < n && o.charAt(n - s - 1) === e; )
|
|
767
|
+
s++;
|
|
768
|
+
return o.slice(0, n - s);
|
|
769
|
+
}
|
|
770
|
+
function io(o, e) {
|
|
771
|
+
if (o.indexOf(e[1]) === -1)
|
|
772
|
+
return -1;
|
|
773
|
+
let t = 0;
|
|
774
|
+
for (let n = 0; n < o.length; n++)
|
|
775
|
+
if (o[n] === "\\")
|
|
776
|
+
n++;
|
|
777
|
+
else if (o[n] === e[0])
|
|
778
|
+
t++;
|
|
779
|
+
else if (o[n] === e[1] && (t--, t < 0))
|
|
780
|
+
return n;
|
|
781
|
+
return -1;
|
|
782
|
+
}
|
|
783
|
+
function Ln(o, e, t, n, s) {
|
|
784
|
+
const r = e.href, a = e.title || null, i = o[1].replace(s.other.outputLinkReplace, "$1");
|
|
785
|
+
if (o[0].charAt(0) !== "!") {
|
|
786
|
+
n.state.inLink = !0;
|
|
787
|
+
const p = {
|
|
788
|
+
type: "link",
|
|
789
|
+
raw: t,
|
|
790
|
+
href: r,
|
|
791
|
+
title: a,
|
|
792
|
+
text: i,
|
|
793
|
+
tokens: n.inlineTokens(i)
|
|
794
|
+
};
|
|
795
|
+
return n.state.inLink = !1, p;
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
type: "image",
|
|
799
|
+
raw: t,
|
|
800
|
+
href: r,
|
|
801
|
+
title: a,
|
|
802
|
+
text: i
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function ao(o, e, t) {
|
|
806
|
+
const n = o.match(t.other.indentCodeCompensation);
|
|
807
|
+
if (n === null)
|
|
808
|
+
return e;
|
|
809
|
+
const s = n[1];
|
|
810
|
+
return e.split(`
|
|
811
|
+
`).map((r) => {
|
|
812
|
+
const a = r.match(t.other.beginningSpace);
|
|
813
|
+
if (a === null)
|
|
814
|
+
return r;
|
|
815
|
+
const [i] = a;
|
|
816
|
+
return i.length >= s.length ? r.slice(s.length) : r;
|
|
817
|
+
}).join(`
|
|
818
|
+
`);
|
|
819
|
+
}
|
|
820
|
+
class ot {
|
|
821
|
+
// set by the lexer
|
|
822
|
+
constructor(e) {
|
|
823
|
+
S(this, "options");
|
|
824
|
+
S(this, "rules");
|
|
825
|
+
// set by the lexer
|
|
826
|
+
S(this, "lexer");
|
|
827
|
+
this.options = e || me;
|
|
828
|
+
}
|
|
829
|
+
space(e) {
|
|
830
|
+
const t = this.rules.block.newline.exec(e);
|
|
831
|
+
if (t && t[0].length > 0)
|
|
832
|
+
return {
|
|
833
|
+
type: "space",
|
|
834
|
+
raw: t[0]
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
code(e) {
|
|
838
|
+
const t = this.rules.block.code.exec(e);
|
|
839
|
+
if (t) {
|
|
840
|
+
const n = t[0].replace(this.rules.other.codeRemoveIndent, "");
|
|
841
|
+
return {
|
|
842
|
+
type: "code",
|
|
843
|
+
raw: t[0],
|
|
844
|
+
codeBlockStyle: "indented",
|
|
845
|
+
text: this.options.pedantic ? n : Oe(n, `
|
|
846
|
+
`)
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
fences(e) {
|
|
851
|
+
const t = this.rules.block.fences.exec(e);
|
|
852
|
+
if (t) {
|
|
853
|
+
const n = t[0], s = ao(n, t[3] || "", this.rules);
|
|
854
|
+
return {
|
|
855
|
+
type: "code",
|
|
856
|
+
raw: n,
|
|
857
|
+
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
858
|
+
text: s
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
heading(e) {
|
|
863
|
+
const t = this.rules.block.heading.exec(e);
|
|
864
|
+
if (t) {
|
|
865
|
+
let n = t[2].trim();
|
|
866
|
+
if (this.rules.other.endingHash.test(n)) {
|
|
867
|
+
const s = Oe(n, "#");
|
|
868
|
+
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
|
|
869
|
+
}
|
|
870
|
+
return {
|
|
871
|
+
type: "heading",
|
|
872
|
+
raw: t[0],
|
|
873
|
+
depth: t[1].length,
|
|
874
|
+
text: n,
|
|
875
|
+
tokens: this.lexer.inline(n)
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
hr(e) {
|
|
880
|
+
const t = this.rules.block.hr.exec(e);
|
|
881
|
+
if (t)
|
|
882
|
+
return {
|
|
883
|
+
type: "hr",
|
|
884
|
+
raw: Oe(t[0], `
|
|
885
|
+
`)
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
blockquote(e) {
|
|
889
|
+
const t = this.rules.block.blockquote.exec(e);
|
|
890
|
+
if (t) {
|
|
891
|
+
let n = Oe(t[0], `
|
|
892
|
+
`).split(`
|
|
893
|
+
`), s = "", r = "";
|
|
894
|
+
const a = [];
|
|
895
|
+
for (; n.length > 0; ) {
|
|
896
|
+
let i = !1;
|
|
897
|
+
const p = [];
|
|
898
|
+
let c;
|
|
899
|
+
for (c = 0; c < n.length; c++)
|
|
900
|
+
if (this.rules.other.blockquoteStart.test(n[c]))
|
|
901
|
+
p.push(n[c]), i = !0;
|
|
902
|
+
else if (!i)
|
|
903
|
+
p.push(n[c]);
|
|
904
|
+
else
|
|
905
|
+
break;
|
|
906
|
+
n = n.slice(c);
|
|
907
|
+
const u = p.join(`
|
|
908
|
+
`), m = u.replace(this.rules.other.blockquoteSetextReplace, `
|
|
909
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
|
|
910
|
+
s = s ? `${s}
|
|
911
|
+
${u}` : u, r = r ? `${r}
|
|
912
|
+
${m}` : m;
|
|
913
|
+
const f = this.lexer.state.top;
|
|
914
|
+
if (this.lexer.state.top = !0, this.lexer.blockTokens(m, a, !0), this.lexer.state.top = f, n.length === 0)
|
|
915
|
+
break;
|
|
916
|
+
const g = a.at(-1);
|
|
917
|
+
if ((g == null ? void 0 : g.type) === "code")
|
|
918
|
+
break;
|
|
919
|
+
if ((g == null ? void 0 : g.type) === "blockquote") {
|
|
920
|
+
const x = g, k = x.raw + `
|
|
921
|
+
` + n.join(`
|
|
922
|
+
`), T = this.blockquote(k);
|
|
923
|
+
a[a.length - 1] = T, s = s.substring(0, s.length - x.raw.length) + T.raw, r = r.substring(0, r.length - x.text.length) + T.text;
|
|
924
|
+
break;
|
|
925
|
+
} else if ((g == null ? void 0 : g.type) === "list") {
|
|
926
|
+
const x = g, k = x.raw + `
|
|
927
|
+
` + n.join(`
|
|
928
|
+
`), T = this.list(k);
|
|
929
|
+
a[a.length - 1] = T, s = s.substring(0, s.length - g.raw.length) + T.raw, r = r.substring(0, r.length - x.raw.length) + T.raw, n = k.substring(a.at(-1).raw.length).split(`
|
|
930
|
+
`);
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return {
|
|
935
|
+
type: "blockquote",
|
|
936
|
+
raw: s,
|
|
937
|
+
tokens: a,
|
|
938
|
+
text: r
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
list(e) {
|
|
943
|
+
let t = this.rules.block.list.exec(e);
|
|
944
|
+
if (t) {
|
|
945
|
+
let n = t[1].trim();
|
|
946
|
+
const s = n.length > 1, r = {
|
|
947
|
+
type: "list",
|
|
948
|
+
raw: "",
|
|
949
|
+
ordered: s,
|
|
950
|
+
start: s ? +n.slice(0, -1) : "",
|
|
951
|
+
loose: !1,
|
|
952
|
+
items: []
|
|
953
|
+
};
|
|
954
|
+
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
|
|
955
|
+
const a = this.rules.other.listItemRegex(n);
|
|
956
|
+
let i = !1;
|
|
957
|
+
for (; e; ) {
|
|
958
|
+
let c = !1, u = "", m = "";
|
|
959
|
+
if (!(t = a.exec(e)) || this.rules.block.hr.test(e))
|
|
960
|
+
break;
|
|
961
|
+
u = t[0], e = e.substring(u.length);
|
|
962
|
+
let f = t[2].split(`
|
|
963
|
+
`, 1)[0].replace(this.rules.other.listReplaceTabs, (D) => " ".repeat(3 * D.length)), g = e.split(`
|
|
964
|
+
`, 1)[0], x = !f.trim(), k = 0;
|
|
965
|
+
if (this.options.pedantic ? (k = 2, m = f.trimStart()) : x ? k = t[1].length + 1 : (k = t[2].search(this.rules.other.nonSpaceChar), k = k > 4 ? 1 : k, m = f.slice(k), k += t[1].length), x && this.rules.other.blankLine.test(g) && (u += g + `
|
|
966
|
+
`, e = e.substring(g.length + 1), c = !0), !c) {
|
|
967
|
+
const D = this.rules.other.nextBulletRegex(k), K = this.rules.other.hrRegex(k), E = this.rules.other.fencesBeginRegex(k), le = this.rules.other.headingBeginRegex(k), Ee = this.rules.other.htmlBeginRegex(k);
|
|
968
|
+
for (; e; ) {
|
|
969
|
+
const Se = e.split(`
|
|
970
|
+
`, 1)[0];
|
|
971
|
+
let ue;
|
|
972
|
+
if (g = Se, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), ue = g) : ue = g.replace(this.rules.other.tabCharGlobal, " "), E.test(g) || le.test(g) || Ee.test(g) || D.test(g) || K.test(g))
|
|
973
|
+
break;
|
|
974
|
+
if (ue.search(this.rules.other.nonSpaceChar) >= k || !g.trim())
|
|
975
|
+
m += `
|
|
976
|
+
` + ue.slice(k);
|
|
977
|
+
else {
|
|
978
|
+
if (x || f.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || E.test(f) || le.test(f) || K.test(f))
|
|
979
|
+
break;
|
|
980
|
+
m += `
|
|
981
|
+
` + g;
|
|
982
|
+
}
|
|
983
|
+
!x && !g.trim() && (x = !0), u += Se + `
|
|
984
|
+
`, e = e.substring(Se.length + 1), f = ue.slice(k);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
r.loose || (i ? r.loose = !0 : this.rules.other.doubleBlankLine.test(u) && (i = !0));
|
|
988
|
+
let T = null, Y;
|
|
989
|
+
this.options.gfm && (T = this.rules.other.listIsTask.exec(m), T && (Y = T[0] !== "[ ] ", m = m.replace(this.rules.other.listReplaceTask, ""))), r.items.push({
|
|
990
|
+
type: "list_item",
|
|
991
|
+
raw: u,
|
|
992
|
+
task: !!T,
|
|
993
|
+
checked: Y,
|
|
994
|
+
loose: !1,
|
|
995
|
+
text: m,
|
|
996
|
+
tokens: []
|
|
997
|
+
}), r.raw += u;
|
|
998
|
+
}
|
|
999
|
+
const p = r.items.at(-1);
|
|
1000
|
+
if (p)
|
|
1001
|
+
p.raw = p.raw.trimEnd(), p.text = p.text.trimEnd();
|
|
1002
|
+
else
|
|
1003
|
+
return;
|
|
1004
|
+
r.raw = r.raw.trimEnd();
|
|
1005
|
+
for (let c = 0; c < r.items.length; c++)
|
|
1006
|
+
if (this.lexer.state.top = !1, r.items[c].tokens = this.lexer.blockTokens(r.items[c].text, []), !r.loose) {
|
|
1007
|
+
const u = r.items[c].tokens.filter((f) => f.type === "space"), m = u.length > 0 && u.some((f) => this.rules.other.anyLine.test(f.raw));
|
|
1008
|
+
r.loose = m;
|
|
1009
|
+
}
|
|
1010
|
+
if (r.loose)
|
|
1011
|
+
for (let c = 0; c < r.items.length; c++)
|
|
1012
|
+
r.items[c].loose = !0;
|
|
1013
|
+
return r;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
html(e) {
|
|
1017
|
+
const t = this.rules.block.html.exec(e);
|
|
1018
|
+
if (t)
|
|
1019
|
+
return {
|
|
1020
|
+
type: "html",
|
|
1021
|
+
block: !0,
|
|
1022
|
+
raw: t[0],
|
|
1023
|
+
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
|
|
1024
|
+
text: t[0]
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
def(e) {
|
|
1028
|
+
const t = this.rules.block.def.exec(e);
|
|
1029
|
+
if (t) {
|
|
1030
|
+
const n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
1031
|
+
return {
|
|
1032
|
+
type: "def",
|
|
1033
|
+
tag: n,
|
|
1034
|
+
raw: t[0],
|
|
1035
|
+
href: s,
|
|
1036
|
+
title: r
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
table(e) {
|
|
1041
|
+
var i;
|
|
1042
|
+
const t = this.rules.block.table.exec(e);
|
|
1043
|
+
if (!t || !this.rules.other.tableDelimiter.test(t[2]))
|
|
1044
|
+
return;
|
|
1045
|
+
const n = vn(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = (i = t[3]) != null && i.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
|
|
1046
|
+
`) : [], a = {
|
|
1047
|
+
type: "table",
|
|
1048
|
+
raw: t[0],
|
|
1049
|
+
header: [],
|
|
1050
|
+
align: [],
|
|
1051
|
+
rows: []
|
|
1052
|
+
};
|
|
1053
|
+
if (n.length === s.length) {
|
|
1054
|
+
for (const p of s)
|
|
1055
|
+
this.rules.other.tableAlignRight.test(p) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(p) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(p) ? a.align.push("left") : a.align.push(null);
|
|
1056
|
+
for (let p = 0; p < n.length; p++)
|
|
1057
|
+
a.header.push({
|
|
1058
|
+
text: n[p],
|
|
1059
|
+
tokens: this.lexer.inline(n[p]),
|
|
1060
|
+
header: !0,
|
|
1061
|
+
align: a.align[p]
|
|
1062
|
+
});
|
|
1063
|
+
for (const p of r)
|
|
1064
|
+
a.rows.push(vn(p, a.header.length).map((c, u) => ({
|
|
1065
|
+
text: c,
|
|
1066
|
+
tokens: this.lexer.inline(c),
|
|
1067
|
+
header: !1,
|
|
1068
|
+
align: a.align[u]
|
|
1069
|
+
})));
|
|
1070
|
+
return a;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
lheading(e) {
|
|
1074
|
+
const t = this.rules.block.lheading.exec(e);
|
|
1075
|
+
if (t)
|
|
1076
|
+
return {
|
|
1077
|
+
type: "heading",
|
|
1078
|
+
raw: t[0],
|
|
1079
|
+
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
1080
|
+
text: t[1],
|
|
1081
|
+
tokens: this.lexer.inline(t[1])
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
paragraph(e) {
|
|
1085
|
+
const t = this.rules.block.paragraph.exec(e);
|
|
1086
|
+
if (t) {
|
|
1087
|
+
const n = t[1].charAt(t[1].length - 1) === `
|
|
1088
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
1089
|
+
return {
|
|
1090
|
+
type: "paragraph",
|
|
1091
|
+
raw: t[0],
|
|
1092
|
+
text: n,
|
|
1093
|
+
tokens: this.lexer.inline(n)
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
text(e) {
|
|
1098
|
+
const t = this.rules.block.text.exec(e);
|
|
1099
|
+
if (t)
|
|
1100
|
+
return {
|
|
1101
|
+
type: "text",
|
|
1102
|
+
raw: t[0],
|
|
1103
|
+
text: t[0],
|
|
1104
|
+
tokens: this.lexer.inline(t[0])
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
escape(e) {
|
|
1108
|
+
const t = this.rules.inline.escape.exec(e);
|
|
1109
|
+
if (t)
|
|
1110
|
+
return {
|
|
1111
|
+
type: "escape",
|
|
1112
|
+
raw: t[0],
|
|
1113
|
+
text: t[1]
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
tag(e) {
|
|
1117
|
+
const t = this.rules.inline.tag.exec(e);
|
|
1118
|
+
if (t)
|
|
1119
|
+
return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
|
|
1120
|
+
type: "html",
|
|
1121
|
+
raw: t[0],
|
|
1122
|
+
inLink: this.lexer.state.inLink,
|
|
1123
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
1124
|
+
block: !1,
|
|
1125
|
+
text: t[0]
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
link(e) {
|
|
1129
|
+
const t = this.rules.inline.link.exec(e);
|
|
1130
|
+
if (t) {
|
|
1131
|
+
const n = t[2].trim();
|
|
1132
|
+
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
|
|
1133
|
+
if (!this.rules.other.endAngleBracket.test(n))
|
|
1134
|
+
return;
|
|
1135
|
+
const a = Oe(n.slice(0, -1), "\\");
|
|
1136
|
+
if ((n.length - a.length) % 2 === 0)
|
|
1137
|
+
return;
|
|
1138
|
+
} else {
|
|
1139
|
+
const a = io(t[2], "()");
|
|
1140
|
+
if (a > -1) {
|
|
1141
|
+
const p = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + a;
|
|
1142
|
+
t[2] = t[2].substring(0, a), t[0] = t[0].substring(0, p).trim(), t[3] = "";
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
let s = t[2], r = "";
|
|
1146
|
+
if (this.options.pedantic) {
|
|
1147
|
+
const a = this.rules.other.pedanticHrefTitle.exec(s);
|
|
1148
|
+
a && (s = a[1], r = a[3]);
|
|
1149
|
+
} else
|
|
1150
|
+
r = t[3] ? t[3].slice(1, -1) : "";
|
|
1151
|
+
return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), Ln(t, {
|
|
1152
|
+
href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
1153
|
+
title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
|
|
1154
|
+
}, t[0], this.lexer, this.rules);
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
reflink(e, t) {
|
|
1158
|
+
let n;
|
|
1159
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
1160
|
+
const s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
|
|
1161
|
+
if (!r) {
|
|
1162
|
+
const a = n[0].charAt(0);
|
|
1163
|
+
return {
|
|
1164
|
+
type: "text",
|
|
1165
|
+
raw: a,
|
|
1166
|
+
text: a
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
return Ln(n, r, n[0], this.lexer, this.rules);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
emStrong(e, t, n = "") {
|
|
1173
|
+
let s = this.rules.inline.emStrongLDelim.exec(e);
|
|
1174
|
+
if (!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric))
|
|
1175
|
+
return;
|
|
1176
|
+
if (!(s[1] || s[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
1177
|
+
const a = [...s[0]].length - 1;
|
|
1178
|
+
let i, p, c = a, u = 0;
|
|
1179
|
+
const m = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
1180
|
+
for (m.lastIndex = 0, t = t.slice(-1 * e.length + a); (s = m.exec(t)) != null; ) {
|
|
1181
|
+
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i)
|
|
1182
|
+
continue;
|
|
1183
|
+
if (p = [...i].length, s[3] || s[4]) {
|
|
1184
|
+
c += p;
|
|
1185
|
+
continue;
|
|
1186
|
+
} else if ((s[5] || s[6]) && a % 3 && !((a + p) % 3)) {
|
|
1187
|
+
u += p;
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
if (c -= p, c > 0)
|
|
1191
|
+
continue;
|
|
1192
|
+
p = Math.min(p, p + c + u);
|
|
1193
|
+
const f = [...s[0]][0].length, g = e.slice(0, a + s.index + f + p);
|
|
1194
|
+
if (Math.min(a, p) % 2) {
|
|
1195
|
+
const k = g.slice(1, -1);
|
|
1196
|
+
return {
|
|
1197
|
+
type: "em",
|
|
1198
|
+
raw: g,
|
|
1199
|
+
text: k,
|
|
1200
|
+
tokens: this.lexer.inlineTokens(k)
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
const x = g.slice(2, -2);
|
|
1204
|
+
return {
|
|
1205
|
+
type: "strong",
|
|
1206
|
+
raw: g,
|
|
1207
|
+
text: x,
|
|
1208
|
+
tokens: this.lexer.inlineTokens(x)
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
codespan(e) {
|
|
1214
|
+
const t = this.rules.inline.code.exec(e);
|
|
1215
|
+
if (t) {
|
|
1216
|
+
let n = t[2].replace(this.rules.other.newLineCharGlobal, " ");
|
|
1217
|
+
const s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
|
|
1218
|
+
return s && r && (n = n.substring(1, n.length - 1)), {
|
|
1219
|
+
type: "codespan",
|
|
1220
|
+
raw: t[0],
|
|
1221
|
+
text: n
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
br(e) {
|
|
1226
|
+
const t = this.rules.inline.br.exec(e);
|
|
1227
|
+
if (t)
|
|
1228
|
+
return {
|
|
1229
|
+
type: "br",
|
|
1230
|
+
raw: t[0]
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
del(e) {
|
|
1234
|
+
const t = this.rules.inline.del.exec(e);
|
|
1235
|
+
if (t)
|
|
1236
|
+
return {
|
|
1237
|
+
type: "del",
|
|
1238
|
+
raw: t[0],
|
|
1239
|
+
text: t[2],
|
|
1240
|
+
tokens: this.lexer.inlineTokens(t[2])
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
autolink(e) {
|
|
1244
|
+
const t = this.rules.inline.autolink.exec(e);
|
|
1245
|
+
if (t) {
|
|
1246
|
+
let n, s;
|
|
1247
|
+
return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), {
|
|
1248
|
+
type: "link",
|
|
1249
|
+
raw: t[0],
|
|
1250
|
+
text: n,
|
|
1251
|
+
href: s,
|
|
1252
|
+
tokens: [
|
|
1253
|
+
{
|
|
1254
|
+
type: "text",
|
|
1255
|
+
raw: n,
|
|
1256
|
+
text: n
|
|
1257
|
+
}
|
|
1258
|
+
]
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
url(e) {
|
|
1263
|
+
var n;
|
|
1264
|
+
let t;
|
|
1265
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
1266
|
+
let s, r;
|
|
1267
|
+
if (t[2] === "@")
|
|
1268
|
+
s = t[0], r = "mailto:" + s;
|
|
1269
|
+
else {
|
|
1270
|
+
let a;
|
|
1271
|
+
do
|
|
1272
|
+
a = t[0], t[0] = ((n = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : n[0]) ?? "";
|
|
1273
|
+
while (a !== t[0]);
|
|
1274
|
+
s = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
|
|
1275
|
+
}
|
|
1276
|
+
return {
|
|
1277
|
+
type: "link",
|
|
1278
|
+
raw: t[0],
|
|
1279
|
+
text: s,
|
|
1280
|
+
href: r,
|
|
1281
|
+
tokens: [
|
|
1282
|
+
{
|
|
1283
|
+
type: "text",
|
|
1284
|
+
raw: s,
|
|
1285
|
+
text: s
|
|
1286
|
+
}
|
|
1287
|
+
]
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
inlineText(e) {
|
|
1292
|
+
const t = this.rules.inline.text.exec(e);
|
|
1293
|
+
if (t) {
|
|
1294
|
+
const n = this.lexer.state.inRawBlock;
|
|
1295
|
+
return {
|
|
1296
|
+
type: "text",
|
|
1297
|
+
raw: t[0],
|
|
1298
|
+
text: t[0],
|
|
1299
|
+
escaped: n
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
class j {
|
|
1305
|
+
constructor(e) {
|
|
1306
|
+
S(this, "tokens");
|
|
1307
|
+
S(this, "options");
|
|
1308
|
+
S(this, "state");
|
|
1309
|
+
S(this, "tokenizer");
|
|
1310
|
+
S(this, "inlineQueue");
|
|
1311
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || me, this.options.tokenizer = this.options.tokenizer || new ot(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
1312
|
+
inLink: !1,
|
|
1313
|
+
inRawBlock: !1,
|
|
1314
|
+
top: !0
|
|
1315
|
+
};
|
|
1316
|
+
const t = {
|
|
1317
|
+
other: q,
|
|
1318
|
+
block: et.normal,
|
|
1319
|
+
inline: Me.normal
|
|
1320
|
+
};
|
|
1321
|
+
this.options.pedantic ? (t.block = et.pedantic, t.inline = Me.pedantic) : this.options.gfm && (t.block = et.gfm, this.options.breaks ? t.inline = Me.breaks : t.inline = Me.gfm), this.tokenizer.rules = t;
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Expose Rules
|
|
1325
|
+
*/
|
|
1326
|
+
static get rules() {
|
|
1327
|
+
return {
|
|
1328
|
+
block: et,
|
|
1329
|
+
inline: Me
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Static Lex Method
|
|
1334
|
+
*/
|
|
1335
|
+
static lex(e, t) {
|
|
1336
|
+
return new j(t).lex(e);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Static Lex Inline Method
|
|
1340
|
+
*/
|
|
1341
|
+
static lexInline(e, t) {
|
|
1342
|
+
return new j(t).inlineTokens(e);
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Preprocessing
|
|
1346
|
+
*/
|
|
1347
|
+
lex(e) {
|
|
1348
|
+
e = e.replace(q.carriageReturn, `
|
|
1349
|
+
`), this.blockTokens(e, this.tokens);
|
|
1350
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
1351
|
+
const n = this.inlineQueue[t];
|
|
1352
|
+
this.inlineTokens(n.src, n.tokens);
|
|
1353
|
+
}
|
|
1354
|
+
return this.inlineQueue = [], this.tokens;
|
|
1355
|
+
}
|
|
1356
|
+
blockTokens(e, t = [], n = !1) {
|
|
1357
|
+
var s, r, a;
|
|
1358
|
+
for (this.options.pedantic && (e = e.replace(q.tabCharGlobal, " ").replace(q.spaceLine, "")); e; ) {
|
|
1359
|
+
let i;
|
|
1360
|
+
if ((r = (s = this.options.extensions) == null ? void 0 : s.block) != null && r.some((c) => (i = c.call({ lexer: this }, e, t)) ? (e = e.substring(i.raw.length), t.push(i), !0) : !1))
|
|
1361
|
+
continue;
|
|
1362
|
+
if (i = this.tokenizer.space(e)) {
|
|
1363
|
+
e = e.substring(i.raw.length);
|
|
1364
|
+
const c = t.at(-1);
|
|
1365
|
+
i.raw.length === 1 && c !== void 0 ? c.raw += `
|
|
1366
|
+
` : t.push(i);
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
if (i = this.tokenizer.code(e)) {
|
|
1370
|
+
e = e.substring(i.raw.length);
|
|
1371
|
+
const c = t.at(-1);
|
|
1372
|
+
(c == null ? void 0 : c.type) === "paragraph" || (c == null ? void 0 : c.type) === "text" ? (c.raw += `
|
|
1373
|
+
` + i.raw, c.text += `
|
|
1374
|
+
` + i.text, this.inlineQueue.at(-1).src = c.text) : t.push(i);
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
if (i = this.tokenizer.fences(e)) {
|
|
1378
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1379
|
+
continue;
|
|
1380
|
+
}
|
|
1381
|
+
if (i = this.tokenizer.heading(e)) {
|
|
1382
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if (i = this.tokenizer.hr(e)) {
|
|
1386
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
if (i = this.tokenizer.blockquote(e)) {
|
|
1390
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
if (i = this.tokenizer.list(e)) {
|
|
1394
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
if (i = this.tokenizer.html(e)) {
|
|
1398
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
if (i = this.tokenizer.def(e)) {
|
|
1402
|
+
e = e.substring(i.raw.length);
|
|
1403
|
+
const c = t.at(-1);
|
|
1404
|
+
(c == null ? void 0 : c.type) === "paragraph" || (c == null ? void 0 : c.type) === "text" ? (c.raw += `
|
|
1405
|
+
` + i.raw, c.text += `
|
|
1406
|
+
` + i.raw, this.inlineQueue.at(-1).src = c.text) : this.tokens.links[i.tag] || (this.tokens.links[i.tag] = {
|
|
1407
|
+
href: i.href,
|
|
1408
|
+
title: i.title
|
|
1409
|
+
});
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1412
|
+
if (i = this.tokenizer.table(e)) {
|
|
1413
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
if (i = this.tokenizer.lheading(e)) {
|
|
1417
|
+
e = e.substring(i.raw.length), t.push(i);
|
|
1418
|
+
continue;
|
|
1419
|
+
}
|
|
1420
|
+
let p = e;
|
|
1421
|
+
if ((a = this.options.extensions) != null && a.startBlock) {
|
|
1422
|
+
let c = 1 / 0;
|
|
1423
|
+
const u = e.slice(1);
|
|
1424
|
+
let m;
|
|
1425
|
+
this.options.extensions.startBlock.forEach((f) => {
|
|
1426
|
+
m = f.call({ lexer: this }, u), typeof m == "number" && m >= 0 && (c = Math.min(c, m));
|
|
1427
|
+
}), c < 1 / 0 && c >= 0 && (p = e.substring(0, c + 1));
|
|
1428
|
+
}
|
|
1429
|
+
if (this.state.top && (i = this.tokenizer.paragraph(p))) {
|
|
1430
|
+
const c = t.at(-1);
|
|
1431
|
+
n && (c == null ? void 0 : c.type) === "paragraph" ? (c.raw += `
|
|
1432
|
+
` + i.raw, c.text += `
|
|
1433
|
+
` + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = c.text) : t.push(i), n = p.length !== e.length, e = e.substring(i.raw.length);
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
if (i = this.tokenizer.text(e)) {
|
|
1437
|
+
e = e.substring(i.raw.length);
|
|
1438
|
+
const c = t.at(-1);
|
|
1439
|
+
(c == null ? void 0 : c.type) === "text" ? (c.raw += `
|
|
1440
|
+
` + i.raw, c.text += `
|
|
1441
|
+
` + i.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = c.text) : t.push(i);
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
if (e) {
|
|
1445
|
+
const c = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1446
|
+
if (this.options.silent) {
|
|
1447
|
+
console.error(c);
|
|
1448
|
+
break;
|
|
1449
|
+
} else
|
|
1450
|
+
throw new Error(c);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
return this.state.top = !0, t;
|
|
1454
|
+
}
|
|
1455
|
+
inline(e, t = []) {
|
|
1456
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Lexing/Compiling
|
|
1460
|
+
*/
|
|
1461
|
+
inlineTokens(e, t = []) {
|
|
1462
|
+
var i, p, c;
|
|
1463
|
+
let n = e, s = null;
|
|
1464
|
+
if (this.tokens.links) {
|
|
1465
|
+
const u = Object.keys(this.tokens.links);
|
|
1466
|
+
if (u.length > 0)
|
|
1467
|
+
for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; )
|
|
1468
|
+
u.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1469
|
+
}
|
|
1470
|
+
for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; )
|
|
1471
|
+
n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1472
|
+
for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; )
|
|
1473
|
+
n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1474
|
+
let r = !1, a = "";
|
|
1475
|
+
for (; e; ) {
|
|
1476
|
+
r || (a = ""), r = !1;
|
|
1477
|
+
let u;
|
|
1478
|
+
if ((p = (i = this.options.extensions) == null ? void 0 : i.inline) != null && p.some((f) => (u = f.call({ lexer: this }, e, t)) ? (e = e.substring(u.raw.length), t.push(u), !0) : !1))
|
|
1479
|
+
continue;
|
|
1480
|
+
if (u = this.tokenizer.escape(e)) {
|
|
1481
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
if (u = this.tokenizer.tag(e)) {
|
|
1485
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1486
|
+
continue;
|
|
1487
|
+
}
|
|
1488
|
+
if (u = this.tokenizer.link(e)) {
|
|
1489
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1490
|
+
continue;
|
|
1491
|
+
}
|
|
1492
|
+
if (u = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1493
|
+
e = e.substring(u.raw.length);
|
|
1494
|
+
const f = t.at(-1);
|
|
1495
|
+
u.type === "text" && (f == null ? void 0 : f.type) === "text" ? (f.raw += u.raw, f.text += u.text) : t.push(u);
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1498
|
+
if (u = this.tokenizer.emStrong(e, n, a)) {
|
|
1499
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
if (u = this.tokenizer.codespan(e)) {
|
|
1503
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1504
|
+
continue;
|
|
1505
|
+
}
|
|
1506
|
+
if (u = this.tokenizer.br(e)) {
|
|
1507
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1508
|
+
continue;
|
|
1509
|
+
}
|
|
1510
|
+
if (u = this.tokenizer.del(e)) {
|
|
1511
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1512
|
+
continue;
|
|
1513
|
+
}
|
|
1514
|
+
if (u = this.tokenizer.autolink(e)) {
|
|
1515
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1516
|
+
continue;
|
|
1517
|
+
}
|
|
1518
|
+
if (!this.state.inLink && (u = this.tokenizer.url(e))) {
|
|
1519
|
+
e = e.substring(u.raw.length), t.push(u);
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
let m = e;
|
|
1523
|
+
if ((c = this.options.extensions) != null && c.startInline) {
|
|
1524
|
+
let f = 1 / 0;
|
|
1525
|
+
const g = e.slice(1);
|
|
1526
|
+
let x;
|
|
1527
|
+
this.options.extensions.startInline.forEach((k) => {
|
|
1528
|
+
x = k.call({ lexer: this }, g), typeof x == "number" && x >= 0 && (f = Math.min(f, x));
|
|
1529
|
+
}), f < 1 / 0 && f >= 0 && (m = e.substring(0, f + 1));
|
|
1530
|
+
}
|
|
1531
|
+
if (u = this.tokenizer.inlineText(m)) {
|
|
1532
|
+
e = e.substring(u.raw.length), u.raw.slice(-1) !== "_" && (a = u.raw.slice(-1)), r = !0;
|
|
1533
|
+
const f = t.at(-1);
|
|
1534
|
+
(f == null ? void 0 : f.type) === "text" ? (f.raw += u.raw, f.text += u.text) : t.push(u);
|
|
1535
|
+
continue;
|
|
1536
|
+
}
|
|
1537
|
+
if (e) {
|
|
1538
|
+
const f = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1539
|
+
if (this.options.silent) {
|
|
1540
|
+
console.error(f);
|
|
1541
|
+
break;
|
|
1542
|
+
} else
|
|
1543
|
+
throw new Error(f);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
return t;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
class it {
|
|
1550
|
+
// set by the parser
|
|
1551
|
+
constructor(e) {
|
|
1552
|
+
S(this, "options");
|
|
1553
|
+
S(this, "parser");
|
|
1554
|
+
this.options = e || me;
|
|
1555
|
+
}
|
|
1556
|
+
space(e) {
|
|
1557
|
+
return "";
|
|
1558
|
+
}
|
|
1559
|
+
code({ text: e, lang: t, escaped: n }) {
|
|
1560
|
+
var a;
|
|
1561
|
+
const s = (a = (t || "").match(q.notSpaceStart)) == null ? void 0 : a[0], r = e.replace(q.endingNewline, "") + `
|
|
1562
|
+
`;
|
|
1563
|
+
return s ? '<pre><code class="language-' + re(s) + '">' + (n ? r : re(r, !0)) + `</code></pre>
|
|
1564
|
+
` : "<pre><code>" + (n ? r : re(r, !0)) + `</code></pre>
|
|
1565
|
+
`;
|
|
1566
|
+
}
|
|
1567
|
+
blockquote({ tokens: e }) {
|
|
1568
|
+
return `<blockquote>
|
|
1569
|
+
${this.parser.parse(e)}</blockquote>
|
|
1570
|
+
`;
|
|
1571
|
+
}
|
|
1572
|
+
html({ text: e }) {
|
|
1573
|
+
return e;
|
|
1574
|
+
}
|
|
1575
|
+
heading({ tokens: e, depth: t }) {
|
|
1576
|
+
return `<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
1577
|
+
`;
|
|
1578
|
+
}
|
|
1579
|
+
hr(e) {
|
|
1580
|
+
return `<hr>
|
|
1581
|
+
`;
|
|
1582
|
+
}
|
|
1583
|
+
list(e) {
|
|
1584
|
+
const t = e.ordered, n = e.start;
|
|
1585
|
+
let s = "";
|
|
1586
|
+
for (let i = 0; i < e.items.length; i++) {
|
|
1587
|
+
const p = e.items[i];
|
|
1588
|
+
s += this.listitem(p);
|
|
1589
|
+
}
|
|
1590
|
+
const r = t ? "ol" : "ul", a = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1591
|
+
return "<" + r + a + `>
|
|
1592
|
+
` + s + "</" + r + `>
|
|
1593
|
+
`;
|
|
1594
|
+
}
|
|
1595
|
+
listitem(e) {
|
|
1596
|
+
var n;
|
|
1597
|
+
let t = "";
|
|
1598
|
+
if (e.task) {
|
|
1599
|
+
const s = this.checkbox({ checked: !!e.checked });
|
|
1600
|
+
e.loose ? ((n = e.tokens[0]) == null ? void 0 : n.type) === "paragraph" ? (e.tokens[0].text = s + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = s + " " + re(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = !0)) : e.tokens.unshift({
|
|
1601
|
+
type: "text",
|
|
1602
|
+
raw: s + " ",
|
|
1603
|
+
text: s + " ",
|
|
1604
|
+
escaped: !0
|
|
1605
|
+
}) : t += s + " ";
|
|
1606
|
+
}
|
|
1607
|
+
return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
|
|
1608
|
+
`;
|
|
1609
|
+
}
|
|
1610
|
+
checkbox({ checked: e }) {
|
|
1611
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
1612
|
+
}
|
|
1613
|
+
paragraph({ tokens: e }) {
|
|
1614
|
+
return `<p>${this.parser.parseInline(e)}</p>
|
|
1615
|
+
`;
|
|
1616
|
+
}
|
|
1617
|
+
table(e) {
|
|
1618
|
+
let t = "", n = "";
|
|
1619
|
+
for (let r = 0; r < e.header.length; r++)
|
|
1620
|
+
n += this.tablecell(e.header[r]);
|
|
1621
|
+
t += this.tablerow({ text: n });
|
|
1622
|
+
let s = "";
|
|
1623
|
+
for (let r = 0; r < e.rows.length; r++) {
|
|
1624
|
+
const a = e.rows[r];
|
|
1625
|
+
n = "";
|
|
1626
|
+
for (let i = 0; i < a.length; i++)
|
|
1627
|
+
n += this.tablecell(a[i]);
|
|
1628
|
+
s += this.tablerow({ text: n });
|
|
1629
|
+
}
|
|
1630
|
+
return s && (s = `<tbody>${s}</tbody>`), `<table>
|
|
1631
|
+
<thead>
|
|
1632
|
+
` + t + `</thead>
|
|
1633
|
+
` + s + `</table>
|
|
1634
|
+
`;
|
|
1635
|
+
}
|
|
1636
|
+
tablerow({ text: e }) {
|
|
1637
|
+
return `<tr>
|
|
1638
|
+
${e}</tr>
|
|
1639
|
+
`;
|
|
1640
|
+
}
|
|
1641
|
+
tablecell(e) {
|
|
1642
|
+
const t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
|
|
1643
|
+
return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
|
|
1644
|
+
`;
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* span level renderer
|
|
1648
|
+
*/
|
|
1649
|
+
strong({ tokens: e }) {
|
|
1650
|
+
return `<strong>${this.parser.parseInline(e)}</strong>`;
|
|
1651
|
+
}
|
|
1652
|
+
em({ tokens: e }) {
|
|
1653
|
+
return `<em>${this.parser.parseInline(e)}</em>`;
|
|
1654
|
+
}
|
|
1655
|
+
codespan({ text: e }) {
|
|
1656
|
+
return `<code>${re(e, !0)}</code>`;
|
|
1657
|
+
}
|
|
1658
|
+
br(e) {
|
|
1659
|
+
return "<br>";
|
|
1660
|
+
}
|
|
1661
|
+
del({ tokens: e }) {
|
|
1662
|
+
return `<del>${this.parser.parseInline(e)}</del>`;
|
|
1663
|
+
}
|
|
1664
|
+
link({ href: e, title: t, tokens: n }) {
|
|
1665
|
+
const s = this.parser.parseInline(n), r = Rn(e);
|
|
1666
|
+
if (r === null)
|
|
1667
|
+
return s;
|
|
1668
|
+
e = r;
|
|
1669
|
+
let a = '<a href="' + e + '"';
|
|
1670
|
+
return t && (a += ' title="' + re(t) + '"'), a += ">" + s + "</a>", a;
|
|
1671
|
+
}
|
|
1672
|
+
image({ href: e, title: t, text: n }) {
|
|
1673
|
+
const s = Rn(e);
|
|
1674
|
+
if (s === null)
|
|
1675
|
+
return re(n);
|
|
1676
|
+
e = s;
|
|
1677
|
+
let r = `<img src="${e}" alt="${n}"`;
|
|
1678
|
+
return t && (r += ` title="${re(t)}"`), r += ">", r;
|
|
1679
|
+
}
|
|
1680
|
+
text(e) {
|
|
1681
|
+
return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : re(e.text);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
class Vt {
|
|
1685
|
+
// no need for block level renderers
|
|
1686
|
+
strong({ text: e }) {
|
|
1687
|
+
return e;
|
|
1688
|
+
}
|
|
1689
|
+
em({ text: e }) {
|
|
1690
|
+
return e;
|
|
1691
|
+
}
|
|
1692
|
+
codespan({ text: e }) {
|
|
1693
|
+
return e;
|
|
1694
|
+
}
|
|
1695
|
+
del({ text: e }) {
|
|
1696
|
+
return e;
|
|
1697
|
+
}
|
|
1698
|
+
html({ text: e }) {
|
|
1699
|
+
return e;
|
|
1700
|
+
}
|
|
1701
|
+
text({ text: e }) {
|
|
1702
|
+
return e;
|
|
1703
|
+
}
|
|
1704
|
+
link({ text: e }) {
|
|
1705
|
+
return "" + e;
|
|
1706
|
+
}
|
|
1707
|
+
image({ text: e }) {
|
|
1708
|
+
return "" + e;
|
|
1709
|
+
}
|
|
1710
|
+
br() {
|
|
1711
|
+
return "";
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
class X {
|
|
1715
|
+
constructor(e) {
|
|
1716
|
+
S(this, "options");
|
|
1717
|
+
S(this, "renderer");
|
|
1718
|
+
S(this, "textRenderer");
|
|
1719
|
+
this.options = e || me, this.options.renderer = this.options.renderer || new it(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Vt();
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Static Parse Method
|
|
1723
|
+
*/
|
|
1724
|
+
static parse(e, t) {
|
|
1725
|
+
return new X(t).parse(e);
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Static Parse Inline Method
|
|
1729
|
+
*/
|
|
1730
|
+
static parseInline(e, t) {
|
|
1731
|
+
return new X(t).parseInline(e);
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Parse Loop
|
|
1735
|
+
*/
|
|
1736
|
+
parse(e, t = !0) {
|
|
1737
|
+
var s, r;
|
|
1738
|
+
let n = "";
|
|
1739
|
+
for (let a = 0; a < e.length; a++) {
|
|
1740
|
+
const i = e[a];
|
|
1741
|
+
if ((r = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && r[i.type]) {
|
|
1742
|
+
const c = i, u = this.options.extensions.renderers[c.type].call({ parser: this }, c);
|
|
1743
|
+
if (u !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(c.type)) {
|
|
1744
|
+
n += u || "";
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
const p = i;
|
|
1749
|
+
switch (p.type) {
|
|
1750
|
+
case "space": {
|
|
1751
|
+
n += this.renderer.space(p);
|
|
1752
|
+
continue;
|
|
1753
|
+
}
|
|
1754
|
+
case "hr": {
|
|
1755
|
+
n += this.renderer.hr(p);
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
case "heading": {
|
|
1759
|
+
n += this.renderer.heading(p);
|
|
1760
|
+
continue;
|
|
1761
|
+
}
|
|
1762
|
+
case "code": {
|
|
1763
|
+
n += this.renderer.code(p);
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
case "table": {
|
|
1767
|
+
n += this.renderer.table(p);
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
case "blockquote": {
|
|
1771
|
+
n += this.renderer.blockquote(p);
|
|
1772
|
+
continue;
|
|
1773
|
+
}
|
|
1774
|
+
case "list": {
|
|
1775
|
+
n += this.renderer.list(p);
|
|
1776
|
+
continue;
|
|
1777
|
+
}
|
|
1778
|
+
case "html": {
|
|
1779
|
+
n += this.renderer.html(p);
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1782
|
+
case "paragraph": {
|
|
1783
|
+
n += this.renderer.paragraph(p);
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
case "text": {
|
|
1787
|
+
let c = p, u = this.renderer.text(c);
|
|
1788
|
+
for (; a + 1 < e.length && e[a + 1].type === "text"; )
|
|
1789
|
+
c = e[++a], u += `
|
|
1790
|
+
` + this.renderer.text(c);
|
|
1791
|
+
t ? n += this.renderer.paragraph({
|
|
1792
|
+
type: "paragraph",
|
|
1793
|
+
raw: u,
|
|
1794
|
+
text: u,
|
|
1795
|
+
tokens: [{ type: "text", raw: u, text: u, escaped: !0 }]
|
|
1796
|
+
}) : n += u;
|
|
1797
|
+
continue;
|
|
1798
|
+
}
|
|
1799
|
+
default: {
|
|
1800
|
+
const c = 'Token with "' + p.type + '" type was not found.';
|
|
1801
|
+
if (this.options.silent)
|
|
1802
|
+
return console.error(c), "";
|
|
1803
|
+
throw new Error(c);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
return n;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Parse Inline Tokens
|
|
1811
|
+
*/
|
|
1812
|
+
parseInline(e, t = this.renderer) {
|
|
1813
|
+
var s, r;
|
|
1814
|
+
let n = "";
|
|
1815
|
+
for (let a = 0; a < e.length; a++) {
|
|
1816
|
+
const i = e[a];
|
|
1817
|
+
if ((r = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && r[i.type]) {
|
|
1818
|
+
const c = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
1819
|
+
if (c !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
|
|
1820
|
+
n += c || "";
|
|
1821
|
+
continue;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
const p = i;
|
|
1825
|
+
switch (p.type) {
|
|
1826
|
+
case "escape": {
|
|
1827
|
+
n += t.text(p);
|
|
1828
|
+
break;
|
|
1829
|
+
}
|
|
1830
|
+
case "html": {
|
|
1831
|
+
n += t.html(p);
|
|
1832
|
+
break;
|
|
1833
|
+
}
|
|
1834
|
+
case "link": {
|
|
1835
|
+
n += t.link(p);
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
case "image": {
|
|
1839
|
+
n += t.image(p);
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
case "strong": {
|
|
1843
|
+
n += t.strong(p);
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
case "em": {
|
|
1847
|
+
n += t.em(p);
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
case "codespan": {
|
|
1851
|
+
n += t.codespan(p);
|
|
1852
|
+
break;
|
|
1853
|
+
}
|
|
1854
|
+
case "br": {
|
|
1855
|
+
n += t.br(p);
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
case "del": {
|
|
1859
|
+
n += t.del(p);
|
|
1860
|
+
break;
|
|
1861
|
+
}
|
|
1862
|
+
case "text": {
|
|
1863
|
+
n += t.text(p);
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
default: {
|
|
1867
|
+
const c = 'Token with "' + p.type + '" type was not found.';
|
|
1868
|
+
if (this.options.silent)
|
|
1869
|
+
return console.error(c), "";
|
|
1870
|
+
throw new Error(c);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
return n;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
class Fe {
|
|
1878
|
+
constructor(e) {
|
|
1879
|
+
S(this, "options");
|
|
1880
|
+
S(this, "block");
|
|
1881
|
+
this.options = e || me;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* Process markdown before marked
|
|
1885
|
+
*/
|
|
1886
|
+
preprocess(e) {
|
|
1887
|
+
return e;
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Process HTML after marked is finished
|
|
1891
|
+
*/
|
|
1892
|
+
postprocess(e) {
|
|
1893
|
+
return e;
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Process all tokens before walk tokens
|
|
1897
|
+
*/
|
|
1898
|
+
processAllTokens(e) {
|
|
1899
|
+
return e;
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Provide function to tokenize markdown
|
|
1903
|
+
*/
|
|
1904
|
+
provideLexer() {
|
|
1905
|
+
return this.block ? j.lex : j.lexInline;
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Provide function to parse tokens
|
|
1909
|
+
*/
|
|
1910
|
+
provideParser() {
|
|
1911
|
+
return this.block ? X.parse : X.parseInline;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
S(Fe, "passThroughHooks", /* @__PURE__ */ new Set([
|
|
1915
|
+
"preprocess",
|
|
1916
|
+
"postprocess",
|
|
1917
|
+
"processAllTokens"
|
|
1918
|
+
]));
|
|
1919
|
+
class lo {
|
|
1920
|
+
constructor(...e) {
|
|
1921
|
+
S(this, "defaults", Bt());
|
|
1922
|
+
S(this, "options", this.setOptions);
|
|
1923
|
+
S(this, "parse", this.parseMarkdown(!0));
|
|
1924
|
+
S(this, "parseInline", this.parseMarkdown(!1));
|
|
1925
|
+
S(this, "Parser", X);
|
|
1926
|
+
S(this, "Renderer", it);
|
|
1927
|
+
S(this, "TextRenderer", Vt);
|
|
1928
|
+
S(this, "Lexer", j);
|
|
1929
|
+
S(this, "Tokenizer", ot);
|
|
1930
|
+
S(this, "Hooks", Fe);
|
|
1931
|
+
this.use(...e);
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Run callback for every token
|
|
1935
|
+
*/
|
|
1936
|
+
walkTokens(e, t) {
|
|
1937
|
+
var s, r;
|
|
1938
|
+
let n = [];
|
|
1939
|
+
for (const a of e)
|
|
1940
|
+
switch (n = n.concat(t.call(this, a)), a.type) {
|
|
1941
|
+
case "table": {
|
|
1942
|
+
const i = a;
|
|
1943
|
+
for (const p of i.header)
|
|
1944
|
+
n = n.concat(this.walkTokens(p.tokens, t));
|
|
1945
|
+
for (const p of i.rows)
|
|
1946
|
+
for (const c of p)
|
|
1947
|
+
n = n.concat(this.walkTokens(c.tokens, t));
|
|
1948
|
+
break;
|
|
1949
|
+
}
|
|
1950
|
+
case "list": {
|
|
1951
|
+
const i = a;
|
|
1952
|
+
n = n.concat(this.walkTokens(i.items, t));
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
default: {
|
|
1956
|
+
const i = a;
|
|
1957
|
+
(r = (s = this.defaults.extensions) == null ? void 0 : s.childTokens) != null && r[i.type] ? this.defaults.extensions.childTokens[i.type].forEach((p) => {
|
|
1958
|
+
const c = i[p].flat(1 / 0);
|
|
1959
|
+
n = n.concat(this.walkTokens(c, t));
|
|
1960
|
+
}) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
return n;
|
|
1964
|
+
}
|
|
1965
|
+
use(...e) {
|
|
1966
|
+
const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1967
|
+
return e.forEach((n) => {
|
|
1968
|
+
const s = { ...n };
|
|
1969
|
+
if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((r) => {
|
|
1970
|
+
if (!r.name)
|
|
1971
|
+
throw new Error("extension name required");
|
|
1972
|
+
if ("renderer" in r) {
|
|
1973
|
+
const a = t.renderers[r.name];
|
|
1974
|
+
a ? t.renderers[r.name] = function(...i) {
|
|
1975
|
+
let p = r.renderer.apply(this, i);
|
|
1976
|
+
return p === !1 && (p = a.apply(this, i)), p;
|
|
1977
|
+
} : t.renderers[r.name] = r.renderer;
|
|
1978
|
+
}
|
|
1979
|
+
if ("tokenizer" in r) {
|
|
1980
|
+
if (!r.level || r.level !== "block" && r.level !== "inline")
|
|
1981
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
1982
|
+
const a = t[r.level];
|
|
1983
|
+
a ? a.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
|
|
1984
|
+
}
|
|
1985
|
+
"childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
|
|
1986
|
+
}), s.extensions = t), n.renderer) {
|
|
1987
|
+
const r = this.defaults.renderer || new it(this.defaults);
|
|
1988
|
+
for (const a in n.renderer) {
|
|
1989
|
+
if (!(a in r))
|
|
1990
|
+
throw new Error(`renderer '${a}' does not exist`);
|
|
1991
|
+
if (["options", "parser"].includes(a))
|
|
1992
|
+
continue;
|
|
1993
|
+
const i = a, p = n.renderer[i], c = r[i];
|
|
1994
|
+
r[i] = (...u) => {
|
|
1995
|
+
let m = p.apply(r, u);
|
|
1996
|
+
return m === !1 && (m = c.apply(r, u)), m || "";
|
|
1997
|
+
};
|
|
1998
|
+
}
|
|
1999
|
+
s.renderer = r;
|
|
2000
|
+
}
|
|
2001
|
+
if (n.tokenizer) {
|
|
2002
|
+
const r = this.defaults.tokenizer || new ot(this.defaults);
|
|
2003
|
+
for (const a in n.tokenizer) {
|
|
2004
|
+
if (!(a in r))
|
|
2005
|
+
throw new Error(`tokenizer '${a}' does not exist`);
|
|
2006
|
+
if (["options", "rules", "lexer"].includes(a))
|
|
2007
|
+
continue;
|
|
2008
|
+
const i = a, p = n.tokenizer[i], c = r[i];
|
|
2009
|
+
r[i] = (...u) => {
|
|
2010
|
+
let m = p.apply(r, u);
|
|
2011
|
+
return m === !1 && (m = c.apply(r, u)), m;
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
s.tokenizer = r;
|
|
2015
|
+
}
|
|
2016
|
+
if (n.hooks) {
|
|
2017
|
+
const r = this.defaults.hooks || new Fe();
|
|
2018
|
+
for (const a in n.hooks) {
|
|
2019
|
+
if (!(a in r))
|
|
2020
|
+
throw new Error(`hook '${a}' does not exist`);
|
|
2021
|
+
if (["options", "block"].includes(a))
|
|
2022
|
+
continue;
|
|
2023
|
+
const i = a, p = n.hooks[i], c = r[i];
|
|
2024
|
+
Fe.passThroughHooks.has(a) ? r[i] = (u) => {
|
|
2025
|
+
if (this.defaults.async)
|
|
2026
|
+
return Promise.resolve(p.call(r, u)).then((f) => c.call(r, f));
|
|
2027
|
+
const m = p.call(r, u);
|
|
2028
|
+
return c.call(r, m);
|
|
2029
|
+
} : r[i] = (...u) => {
|
|
2030
|
+
let m = p.apply(r, u);
|
|
2031
|
+
return m === !1 && (m = c.apply(r, u)), m;
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
s.hooks = r;
|
|
2035
|
+
}
|
|
2036
|
+
if (n.walkTokens) {
|
|
2037
|
+
const r = this.defaults.walkTokens, a = n.walkTokens;
|
|
2038
|
+
s.walkTokens = function(i) {
|
|
2039
|
+
let p = [];
|
|
2040
|
+
return p.push(a.call(this, i)), r && (p = p.concat(r.call(this, i))), p;
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
this.defaults = { ...this.defaults, ...s };
|
|
2044
|
+
}), this;
|
|
2045
|
+
}
|
|
2046
|
+
setOptions(e) {
|
|
2047
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
2048
|
+
}
|
|
2049
|
+
lexer(e, t) {
|
|
2050
|
+
return j.lex(e, t ?? this.defaults);
|
|
2051
|
+
}
|
|
2052
|
+
parser(e, t) {
|
|
2053
|
+
return X.parse(e, t ?? this.defaults);
|
|
2054
|
+
}
|
|
2055
|
+
parseMarkdown(e) {
|
|
2056
|
+
return (n, s) => {
|
|
2057
|
+
const r = { ...s }, a = { ...this.defaults, ...r }, i = this.onError(!!a.silent, !!a.async);
|
|
2058
|
+
if (this.defaults.async === !0 && r.async === !1)
|
|
2059
|
+
return i(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."));
|
|
2060
|
+
if (typeof n > "u" || n === null)
|
|
2061
|
+
return i(new Error("marked(): input parameter is undefined or null"));
|
|
2062
|
+
if (typeof n != "string")
|
|
2063
|
+
return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
2064
|
+
a.hooks && (a.hooks.options = a, a.hooks.block = e);
|
|
2065
|
+
const p = a.hooks ? a.hooks.provideLexer() : e ? j.lex : j.lexInline, c = a.hooks ? a.hooks.provideParser() : e ? X.parse : X.parseInline;
|
|
2066
|
+
if (a.async)
|
|
2067
|
+
return Promise.resolve(a.hooks ? a.hooks.preprocess(n) : n).then((u) => p(u, a)).then((u) => a.hooks ? a.hooks.processAllTokens(u) : u).then((u) => a.walkTokens ? Promise.all(this.walkTokens(u, a.walkTokens)).then(() => u) : u).then((u) => c(u, a)).then((u) => a.hooks ? a.hooks.postprocess(u) : u).catch(i);
|
|
2068
|
+
try {
|
|
2069
|
+
a.hooks && (n = a.hooks.preprocess(n));
|
|
2070
|
+
let u = p(n, a);
|
|
2071
|
+
a.hooks && (u = a.hooks.processAllTokens(u)), a.walkTokens && this.walkTokens(u, a.walkTokens);
|
|
2072
|
+
let m = c(u, a);
|
|
2073
|
+
return a.hooks && (m = a.hooks.postprocess(m)), m;
|
|
2074
|
+
} catch (u) {
|
|
2075
|
+
return i(u);
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
onError(e, t) {
|
|
2080
|
+
return (n) => {
|
|
2081
|
+
if (n.message += `
|
|
2082
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
2083
|
+
const s = "<p>An error occurred:</p><pre>" + re(n.message + "", !0) + "</pre>";
|
|
2084
|
+
return t ? Promise.resolve(s) : s;
|
|
2085
|
+
}
|
|
2086
|
+
if (t)
|
|
2087
|
+
return Promise.reject(n);
|
|
2088
|
+
throw n;
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
const de = new lo();
|
|
2093
|
+
function C(o, e) {
|
|
2094
|
+
return de.parse(o, e);
|
|
2095
|
+
}
|
|
2096
|
+
C.options = C.setOptions = function(o) {
|
|
2097
|
+
return de.setOptions(o), C.defaults = de.defaults, Kn(C.defaults), C;
|
|
2098
|
+
};
|
|
2099
|
+
C.getDefaults = Bt;
|
|
2100
|
+
C.defaults = me;
|
|
2101
|
+
C.use = function(...o) {
|
|
2102
|
+
return de.use(...o), C.defaults = de.defaults, Kn(C.defaults), C;
|
|
2103
|
+
};
|
|
2104
|
+
C.walkTokens = function(o, e) {
|
|
2105
|
+
return de.walkTokens(o, e);
|
|
2106
|
+
};
|
|
2107
|
+
C.parseInline = de.parseInline;
|
|
2108
|
+
C.Parser = X;
|
|
2109
|
+
C.parser = X.parse;
|
|
2110
|
+
C.Renderer = it;
|
|
2111
|
+
C.TextRenderer = Vt;
|
|
2112
|
+
C.Lexer = j;
|
|
2113
|
+
C.lexer = j.lex;
|
|
2114
|
+
C.Tokenizer = ot;
|
|
2115
|
+
C.Hooks = Fe;
|
|
2116
|
+
C.parse = C;
|
|
2117
|
+
C.options;
|
|
2118
|
+
C.setOptions;
|
|
2119
|
+
C.use;
|
|
2120
|
+
C.walkTokens;
|
|
2121
|
+
C.parseInline;
|
|
2122
|
+
X.parse;
|
|
2123
|
+
j.lex;
|
|
2124
|
+
/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */
|
|
2125
|
+
const {
|
|
2126
|
+
entries: cr,
|
|
2127
|
+
setPrototypeOf: In,
|
|
2128
|
+
isFrozen: co,
|
|
2129
|
+
getPrototypeOf: uo,
|
|
2130
|
+
getOwnPropertyDescriptor: po
|
|
2131
|
+
} = Object;
|
|
2132
|
+
let {
|
|
2133
|
+
freeze: G,
|
|
2134
|
+
seal: Q,
|
|
2135
|
+
create: ur
|
|
2136
|
+
} = Object, {
|
|
2137
|
+
apply: Mt,
|
|
2138
|
+
construct: Ot
|
|
2139
|
+
} = typeof Reflect < "u" && Reflect;
|
|
2140
|
+
G || (G = function(e) {
|
|
2141
|
+
return e;
|
|
2142
|
+
});
|
|
2143
|
+
Q || (Q = function(e) {
|
|
2144
|
+
return e;
|
|
2145
|
+
});
|
|
2146
|
+
Mt || (Mt = function(e, t, n) {
|
|
2147
|
+
return e.apply(t, n);
|
|
2148
|
+
});
|
|
2149
|
+
Ot || (Ot = function(e, t) {
|
|
2150
|
+
return new e(...t);
|
|
2151
|
+
});
|
|
2152
|
+
const tt = W(Array.prototype.forEach), ho = W(Array.prototype.lastIndexOf), Nn = W(Array.prototype.pop), De = W(Array.prototype.push), fo = W(Array.prototype.splice), rt = W(String.prototype.toLowerCase), St = W(String.prototype.toString), Mn = W(String.prototype.match), Pe = W(String.prototype.replace), go = W(String.prototype.indexOf), mo = W(String.prototype.trim), J = W(Object.prototype.hasOwnProperty), F = W(RegExp.prototype.test), ze = _o(TypeError);
|
|
2153
|
+
function W(o) {
|
|
2154
|
+
return function(e) {
|
|
2155
|
+
e instanceof RegExp && (e.lastIndex = 0);
|
|
2156
|
+
for (var t = arguments.length, n = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++)
|
|
2157
|
+
n[s - 1] = arguments[s];
|
|
2158
|
+
return Mt(o, e, n);
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
function _o(o) {
|
|
2162
|
+
return function() {
|
|
2163
|
+
for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
|
|
2164
|
+
t[n] = arguments[n];
|
|
2165
|
+
return Ot(o, t);
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
function w(o, e) {
|
|
2169
|
+
let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : rt;
|
|
2170
|
+
In && In(o, null);
|
|
2171
|
+
let n = e.length;
|
|
2172
|
+
for (; n--; ) {
|
|
2173
|
+
let s = e[n];
|
|
2174
|
+
if (typeof s == "string") {
|
|
2175
|
+
const r = t(s);
|
|
2176
|
+
r !== s && (co(e) || (e[n] = r), s = r);
|
|
2177
|
+
}
|
|
2178
|
+
o[s] = !0;
|
|
2179
|
+
}
|
|
2180
|
+
return o;
|
|
2181
|
+
}
|
|
2182
|
+
function bo(o) {
|
|
2183
|
+
for (let e = 0; e < o.length; e++)
|
|
2184
|
+
J(o, e) || (o[e] = null);
|
|
2185
|
+
return o;
|
|
2186
|
+
}
|
|
2187
|
+
function fe(o) {
|
|
2188
|
+
const e = ur(null);
|
|
2189
|
+
for (const [t, n] of cr(o))
|
|
2190
|
+
J(o, t) && (Array.isArray(n) ? e[t] = bo(n) : n && typeof n == "object" && n.constructor === Object ? e[t] = fe(n) : e[t] = n);
|
|
2191
|
+
return e;
|
|
2192
|
+
}
|
|
2193
|
+
function $e(o, e) {
|
|
2194
|
+
for (; o !== null; ) {
|
|
2195
|
+
const n = po(o, e);
|
|
2196
|
+
if (n) {
|
|
2197
|
+
if (n.get)
|
|
2198
|
+
return W(n.get);
|
|
2199
|
+
if (typeof n.value == "function")
|
|
2200
|
+
return W(n.value);
|
|
2201
|
+
}
|
|
2202
|
+
o = uo(o);
|
|
2203
|
+
}
|
|
2204
|
+
function t() {
|
|
2205
|
+
return null;
|
|
2206
|
+
}
|
|
2207
|
+
return t;
|
|
2208
|
+
}
|
|
2209
|
+
const On = G(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), At = G(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Rt = G(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), xo = G(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), vt = G(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), ko = G(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Dn = G(["#text"]), Pn = G(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Lt = G(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), zn = G(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), nt = G(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), wo = Q(/\{\{[\w\W]*|[\w\W]*\}\}/gm), To = Q(/<%[\w\W]*|[\w\W]*%>/gm), yo = Q(/\$\{[\w\W]*/gm), Co = Q(/^data-[\-\w.\u00B7-\uFFFF]+$/), Eo = Q(/^aria-[\-\w]+$/), pr = Q(
|
|
2210
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
2211
|
+
// eslint-disable-line no-useless-escape
|
|
2212
|
+
), So = Q(/^(?:\w+script|data):/i), Ao = Q(
|
|
2213
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
2214
|
+
// eslint-disable-line no-control-regex
|
|
2215
|
+
), hr = Q(/^html$/i), Ro = Q(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
2216
|
+
var $n = /* @__PURE__ */ Object.freeze({
|
|
2217
|
+
__proto__: null,
|
|
2218
|
+
ARIA_ATTR: Eo,
|
|
2219
|
+
ATTR_WHITESPACE: Ao,
|
|
2220
|
+
CUSTOM_ELEMENT: Ro,
|
|
2221
|
+
DATA_ATTR: Co,
|
|
2222
|
+
DOCTYPE_NAME: hr,
|
|
2223
|
+
ERB_EXPR: To,
|
|
2224
|
+
IS_ALLOWED_URI: pr,
|
|
2225
|
+
IS_SCRIPT_OR_DATA: So,
|
|
2226
|
+
MUSTACHE_EXPR: wo,
|
|
2227
|
+
TMPLIT_EXPR: yo
|
|
2228
|
+
});
|
|
2229
|
+
const Be = {
|
|
2230
|
+
element: 1,
|
|
2231
|
+
text: 3,
|
|
2232
|
+
// Deprecated
|
|
2233
|
+
progressingInstruction: 7,
|
|
2234
|
+
comment: 8,
|
|
2235
|
+
document: 9
|
|
2236
|
+
}, vo = function() {
|
|
2237
|
+
return typeof window > "u" ? null : window;
|
|
2238
|
+
}, Lo = function(e, t) {
|
|
2239
|
+
if (typeof e != "object" || typeof e.createPolicy != "function")
|
|
2240
|
+
return null;
|
|
2241
|
+
let n = null;
|
|
2242
|
+
const s = "data-tt-policy-suffix";
|
|
2243
|
+
t && t.hasAttribute(s) && (n = t.getAttribute(s));
|
|
2244
|
+
const r = "dompurify" + (n ? "#" + n : "");
|
|
2245
|
+
try {
|
|
2246
|
+
return e.createPolicy(r, {
|
|
2247
|
+
createHTML(a) {
|
|
2248
|
+
return a;
|
|
2249
|
+
},
|
|
2250
|
+
createScriptURL(a) {
|
|
2251
|
+
return a;
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
} catch {
|
|
2255
|
+
return console.warn("TrustedTypes policy " + r + " could not be created."), null;
|
|
2256
|
+
}
|
|
2257
|
+
}, Bn = function() {
|
|
2258
|
+
return {
|
|
2259
|
+
afterSanitizeAttributes: [],
|
|
2260
|
+
afterSanitizeElements: [],
|
|
2261
|
+
afterSanitizeShadowDOM: [],
|
|
2262
|
+
beforeSanitizeAttributes: [],
|
|
2263
|
+
beforeSanitizeElements: [],
|
|
2264
|
+
beforeSanitizeShadowDOM: [],
|
|
2265
|
+
uponSanitizeAttribute: [],
|
|
2266
|
+
uponSanitizeElement: [],
|
|
2267
|
+
uponSanitizeShadowNode: []
|
|
2268
|
+
};
|
|
2269
|
+
};
|
|
2270
|
+
function fr() {
|
|
2271
|
+
let o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : vo();
|
|
2272
|
+
const e = (b) => fr(b);
|
|
2273
|
+
if (e.version = "3.2.5", e.removed = [], !o || !o.document || o.document.nodeType !== Be.document || !o.Element)
|
|
2274
|
+
return e.isSupported = !1, e;
|
|
2275
|
+
let {
|
|
2276
|
+
document: t
|
|
2277
|
+
} = o;
|
|
2278
|
+
const n = t, s = n.currentScript, {
|
|
2279
|
+
DocumentFragment: r,
|
|
2280
|
+
HTMLTemplateElement: a,
|
|
2281
|
+
Node: i,
|
|
2282
|
+
Element: p,
|
|
2283
|
+
NodeFilter: c,
|
|
2284
|
+
NamedNodeMap: u = o.NamedNodeMap || o.MozNamedAttrMap,
|
|
2285
|
+
HTMLFormElement: m,
|
|
2286
|
+
DOMParser: f,
|
|
2287
|
+
trustedTypes: g
|
|
2288
|
+
} = o, x = p.prototype, k = $e(x, "cloneNode"), T = $e(x, "remove"), Y = $e(x, "nextSibling"), D = $e(x, "childNodes"), K = $e(x, "parentNode");
|
|
2289
|
+
if (typeof a == "function") {
|
|
2290
|
+
const b = t.createElement("template");
|
|
2291
|
+
b.content && b.content.ownerDocument && (t = b.content.ownerDocument);
|
|
2292
|
+
}
|
|
2293
|
+
let E, le = "";
|
|
2294
|
+
const {
|
|
2295
|
+
implementation: Ee,
|
|
2296
|
+
createNodeIterator: Se,
|
|
2297
|
+
createDocumentFragment: ue,
|
|
2298
|
+
getElementsByTagName: mr
|
|
2299
|
+
} = t, {
|
|
2300
|
+
importNode: _r
|
|
2301
|
+
} = n;
|
|
2302
|
+
let H = Bn();
|
|
2303
|
+
e.isSupported = typeof cr == "function" && typeof K == "function" && Ee && Ee.createHTMLDocument !== void 0;
|
|
2304
|
+
const {
|
|
2305
|
+
MUSTACHE_EXPR: ut,
|
|
2306
|
+
ERB_EXPR: pt,
|
|
2307
|
+
TMPLIT_EXPR: ht,
|
|
2308
|
+
DATA_ATTR: br,
|
|
2309
|
+
ARIA_ATTR: xr,
|
|
2310
|
+
IS_SCRIPT_OR_DATA: kr,
|
|
2311
|
+
ATTR_WHITESPACE: jt,
|
|
2312
|
+
CUSTOM_ELEMENT: wr
|
|
2313
|
+
} = $n;
|
|
2314
|
+
let {
|
|
2315
|
+
IS_ALLOWED_URI: Yt
|
|
2316
|
+
} = $n, N = null;
|
|
2317
|
+
const Xt = w({}, [...On, ...At, ...Rt, ...vt, ...Dn]);
|
|
2318
|
+
let P = null;
|
|
2319
|
+
const Qt = w({}, [...Pn, ...Lt, ...zn, ...nt]);
|
|
2320
|
+
let v = Object.seal(ur(null, {
|
|
2321
|
+
tagNameCheck: {
|
|
2322
|
+
writable: !0,
|
|
2323
|
+
configurable: !1,
|
|
2324
|
+
enumerable: !0,
|
|
2325
|
+
value: null
|
|
2326
|
+
},
|
|
2327
|
+
attributeNameCheck: {
|
|
2328
|
+
writable: !0,
|
|
2329
|
+
configurable: !1,
|
|
2330
|
+
enumerable: !0,
|
|
2331
|
+
value: null
|
|
2332
|
+
},
|
|
2333
|
+
allowCustomizedBuiltInElements: {
|
|
2334
|
+
writable: !0,
|
|
2335
|
+
configurable: !1,
|
|
2336
|
+
enumerable: !0,
|
|
2337
|
+
value: !1
|
|
2338
|
+
}
|
|
2339
|
+
})), Ae = null, ft = null, Kt = !0, dt = !0, Jt = !1, en = !0, _e = !1, gt = !0, pe = !1, mt = !1, _t = !1, be = !1, Ze = !1, Ve = !1, tn = !0, nn = !1;
|
|
2340
|
+
const Tr = "user-content-";
|
|
2341
|
+
let bt = !0, Re = !1, xe = {}, ke = null;
|
|
2342
|
+
const rn = w({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
2343
|
+
let sn = null;
|
|
2344
|
+
const on = w({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
2345
|
+
let xt = null;
|
|
2346
|
+
const an = w({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), je = "http://www.w3.org/1998/Math/MathML", Ye = "http://www.w3.org/2000/svg", oe = "http://www.w3.org/1999/xhtml";
|
|
2347
|
+
let we = oe, kt = !1, wt = null;
|
|
2348
|
+
const yr = w({}, [je, Ye, oe], St);
|
|
2349
|
+
let Xe = w({}, ["mi", "mo", "mn", "ms", "mtext"]), Qe = w({}, ["annotation-xml"]);
|
|
2350
|
+
const Cr = w({}, ["title", "style", "font", "a", "script"]);
|
|
2351
|
+
let ve = null;
|
|
2352
|
+
const Er = ["application/xhtml+xml", "text/html"], Sr = "text/html";
|
|
2353
|
+
let M = null, Te = null;
|
|
2354
|
+
const Ar = t.createElement("form"), ln = function(l) {
|
|
2355
|
+
return l instanceof RegExp || l instanceof Function;
|
|
2356
|
+
}, Tt = function() {
|
|
2357
|
+
let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2358
|
+
if (!(Te && Te === l)) {
|
|
2359
|
+
if ((!l || typeof l != "object") && (l = {}), l = fe(l), ve = // eslint-disable-next-line unicorn/prefer-includes
|
|
2360
|
+
Er.indexOf(l.PARSER_MEDIA_TYPE) === -1 ? Sr : l.PARSER_MEDIA_TYPE, M = ve === "application/xhtml+xml" ? St : rt, N = J(l, "ALLOWED_TAGS") ? w({}, l.ALLOWED_TAGS, M) : Xt, P = J(l, "ALLOWED_ATTR") ? w({}, l.ALLOWED_ATTR, M) : Qt, wt = J(l, "ALLOWED_NAMESPACES") ? w({}, l.ALLOWED_NAMESPACES, St) : yr, xt = J(l, "ADD_URI_SAFE_ATTR") ? w(fe(an), l.ADD_URI_SAFE_ATTR, M) : an, sn = J(l, "ADD_DATA_URI_TAGS") ? w(fe(on), l.ADD_DATA_URI_TAGS, M) : on, ke = J(l, "FORBID_CONTENTS") ? w({}, l.FORBID_CONTENTS, M) : rn, Ae = J(l, "FORBID_TAGS") ? w({}, l.FORBID_TAGS, M) : {}, ft = J(l, "FORBID_ATTR") ? w({}, l.FORBID_ATTR, M) : {}, xe = J(l, "USE_PROFILES") ? l.USE_PROFILES : !1, Kt = l.ALLOW_ARIA_ATTR !== !1, dt = l.ALLOW_DATA_ATTR !== !1, Jt = l.ALLOW_UNKNOWN_PROTOCOLS || !1, en = l.ALLOW_SELF_CLOSE_IN_ATTR !== !1, _e = l.SAFE_FOR_TEMPLATES || !1, gt = l.SAFE_FOR_XML !== !1, pe = l.WHOLE_DOCUMENT || !1, be = l.RETURN_DOM || !1, Ze = l.RETURN_DOM_FRAGMENT || !1, Ve = l.RETURN_TRUSTED_TYPE || !1, _t = l.FORCE_BODY || !1, tn = l.SANITIZE_DOM !== !1, nn = l.SANITIZE_NAMED_PROPS || !1, bt = l.KEEP_CONTENT !== !1, Re = l.IN_PLACE || !1, Yt = l.ALLOWED_URI_REGEXP || pr, we = l.NAMESPACE || oe, Xe = l.MATHML_TEXT_INTEGRATION_POINTS || Xe, Qe = l.HTML_INTEGRATION_POINTS || Qe, v = l.CUSTOM_ELEMENT_HANDLING || {}, l.CUSTOM_ELEMENT_HANDLING && ln(l.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (v.tagNameCheck = l.CUSTOM_ELEMENT_HANDLING.tagNameCheck), l.CUSTOM_ELEMENT_HANDLING && ln(l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (v.attributeNameCheck = l.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), l.CUSTOM_ELEMENT_HANDLING && typeof l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (v.allowCustomizedBuiltInElements = l.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), _e && (dt = !1), Ze && (be = !0), xe && (N = w({}, Dn), P = [], xe.html === !0 && (w(N, On), w(P, Pn)), xe.svg === !0 && (w(N, At), w(P, Lt), w(P, nt)), xe.svgFilters === !0 && (w(N, Rt), w(P, Lt), w(P, nt)), xe.mathMl === !0 && (w(N, vt), w(P, zn), w(P, nt))), l.ADD_TAGS && (N === Xt && (N = fe(N)), w(N, l.ADD_TAGS, M)), l.ADD_ATTR && (P === Qt && (P = fe(P)), w(P, l.ADD_ATTR, M)), l.ADD_URI_SAFE_ATTR && w(xt, l.ADD_URI_SAFE_ATTR, M), l.FORBID_CONTENTS && (ke === rn && (ke = fe(ke)), w(ke, l.FORBID_CONTENTS, M)), bt && (N["#text"] = !0), pe && w(N, ["html", "head", "body"]), N.table && (w(N, ["tbody"]), delete Ae.tbody), l.TRUSTED_TYPES_POLICY) {
|
|
2361
|
+
if (typeof l.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
2362
|
+
throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
2363
|
+
if (typeof l.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
2364
|
+
throw ze('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
2365
|
+
E = l.TRUSTED_TYPES_POLICY, le = E.createHTML("");
|
|
2366
|
+
} else
|
|
2367
|
+
E === void 0 && (E = Lo(g, s)), E !== null && typeof le == "string" && (le = E.createHTML(""));
|
|
2368
|
+
G && G(l), Te = l;
|
|
2369
|
+
}
|
|
2370
|
+
}, cn = w({}, [...At, ...Rt, ...xo]), un = w({}, [...vt, ...ko]), Rr = function(l) {
|
|
2371
|
+
let h = K(l);
|
|
2372
|
+
(!h || !h.tagName) && (h = {
|
|
2373
|
+
namespaceURI: we,
|
|
2374
|
+
tagName: "template"
|
|
2375
|
+
});
|
|
2376
|
+
const _ = rt(l.tagName), A = rt(h.tagName);
|
|
2377
|
+
return wt[l.namespaceURI] ? l.namespaceURI === Ye ? h.namespaceURI === oe ? _ === "svg" : h.namespaceURI === je ? _ === "svg" && (A === "annotation-xml" || Xe[A]) : !!cn[_] : l.namespaceURI === je ? h.namespaceURI === oe ? _ === "math" : h.namespaceURI === Ye ? _ === "math" && Qe[A] : !!un[_] : l.namespaceURI === oe ? h.namespaceURI === Ye && !Qe[A] || h.namespaceURI === je && !Xe[A] ? !1 : !un[_] && (Cr[_] || !cn[_]) : !!(ve === "application/xhtml+xml" && wt[l.namespaceURI]) : !1;
|
|
2378
|
+
}, te = function(l) {
|
|
2379
|
+
De(e.removed, {
|
|
2380
|
+
element: l
|
|
2381
|
+
});
|
|
2382
|
+
try {
|
|
2383
|
+
K(l).removeChild(l);
|
|
2384
|
+
} catch {
|
|
2385
|
+
T(l);
|
|
2386
|
+
}
|
|
2387
|
+
}, Ke = function(l, h) {
|
|
2388
|
+
try {
|
|
2389
|
+
De(e.removed, {
|
|
2390
|
+
attribute: h.getAttributeNode(l),
|
|
2391
|
+
from: h
|
|
2392
|
+
});
|
|
2393
|
+
} catch {
|
|
2394
|
+
De(e.removed, {
|
|
2395
|
+
attribute: null,
|
|
2396
|
+
from: h
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
if (h.removeAttribute(l), l === "is")
|
|
2400
|
+
if (be || Ze)
|
|
2401
|
+
try {
|
|
2402
|
+
te(h);
|
|
2403
|
+
} catch {
|
|
2404
|
+
}
|
|
2405
|
+
else
|
|
2406
|
+
try {
|
|
2407
|
+
h.setAttribute(l, "");
|
|
2408
|
+
} catch {
|
|
2409
|
+
}
|
|
2410
|
+
}, pn = function(l) {
|
|
2411
|
+
let h = null, _ = null;
|
|
2412
|
+
if (_t)
|
|
2413
|
+
l = "<remove></remove>" + l;
|
|
2414
|
+
else {
|
|
2415
|
+
const z = Mn(l, /^[\r\n\t ]+/);
|
|
2416
|
+
_ = z && z[0];
|
|
2417
|
+
}
|
|
2418
|
+
ve === "application/xhtml+xml" && we === oe && (l = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + l + "</body></html>");
|
|
2419
|
+
const A = E ? E.createHTML(l) : l;
|
|
2420
|
+
if (we === oe)
|
|
2421
|
+
try {
|
|
2422
|
+
h = new f().parseFromString(A, ve);
|
|
2423
|
+
} catch {
|
|
2424
|
+
}
|
|
2425
|
+
if (!h || !h.documentElement) {
|
|
2426
|
+
h = Ee.createDocument(we, "template", null);
|
|
2427
|
+
try {
|
|
2428
|
+
h.documentElement.innerHTML = kt ? le : A;
|
|
2429
|
+
} catch {
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
const B = h.body || h.documentElement;
|
|
2433
|
+
return l && _ && B.insertBefore(t.createTextNode(_), B.childNodes[0] || null), we === oe ? mr.call(h, pe ? "html" : "body")[0] : pe ? h.documentElement : B;
|
|
2434
|
+
}, hn = function(l) {
|
|
2435
|
+
return Se.call(
|
|
2436
|
+
l.ownerDocument || l,
|
|
2437
|
+
l,
|
|
2438
|
+
// eslint-disable-next-line no-bitwise
|
|
2439
|
+
c.SHOW_ELEMENT | c.SHOW_COMMENT | c.SHOW_TEXT | c.SHOW_PROCESSING_INSTRUCTION | c.SHOW_CDATA_SECTION,
|
|
2440
|
+
null
|
|
2441
|
+
);
|
|
2442
|
+
}, yt = function(l) {
|
|
2443
|
+
return l instanceof m && (typeof l.nodeName != "string" || typeof l.textContent != "string" || typeof l.removeChild != "function" || !(l.attributes instanceof u) || typeof l.removeAttribute != "function" || typeof l.setAttribute != "function" || typeof l.namespaceURI != "string" || typeof l.insertBefore != "function" || typeof l.hasChildNodes != "function");
|
|
2444
|
+
}, fn = function(l) {
|
|
2445
|
+
return typeof i == "function" && l instanceof i;
|
|
2446
|
+
};
|
|
2447
|
+
function ie(b, l, h) {
|
|
2448
|
+
tt(b, (_) => {
|
|
2449
|
+
_.call(e, l, h, Te);
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
const dn = function(l) {
|
|
2453
|
+
let h = null;
|
|
2454
|
+
if (ie(H.beforeSanitizeElements, l, null), yt(l))
|
|
2455
|
+
return te(l), !0;
|
|
2456
|
+
const _ = M(l.nodeName);
|
|
2457
|
+
if (ie(H.uponSanitizeElement, l, {
|
|
2458
|
+
tagName: _,
|
|
2459
|
+
allowedTags: N
|
|
2460
|
+
}), l.hasChildNodes() && !fn(l.firstElementChild) && F(/<[/\w!]/g, l.innerHTML) && F(/<[/\w!]/g, l.textContent) || l.nodeType === Be.progressingInstruction || gt && l.nodeType === Be.comment && F(/<[/\w]/g, l.data))
|
|
2461
|
+
return te(l), !0;
|
|
2462
|
+
if (!N[_] || Ae[_]) {
|
|
2463
|
+
if (!Ae[_] && mn(_) && (v.tagNameCheck instanceof RegExp && F(v.tagNameCheck, _) || v.tagNameCheck instanceof Function && v.tagNameCheck(_)))
|
|
2464
|
+
return !1;
|
|
2465
|
+
if (bt && !ke[_]) {
|
|
2466
|
+
const A = K(l) || l.parentNode, B = D(l) || l.childNodes;
|
|
2467
|
+
if (B && A) {
|
|
2468
|
+
const z = B.length;
|
|
2469
|
+
for (let Z = z - 1; Z >= 0; --Z) {
|
|
2470
|
+
const ne = k(B[Z], !0);
|
|
2471
|
+
ne.__removalCount = (l.__removalCount || 0) + 1, A.insertBefore(ne, Y(l));
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
return te(l), !0;
|
|
2476
|
+
}
|
|
2477
|
+
return l instanceof p && !Rr(l) || (_ === "noscript" || _ === "noembed" || _ === "noframes") && F(/<\/no(script|embed|frames)/i, l.innerHTML) ? (te(l), !0) : (_e && l.nodeType === Be.text && (h = l.textContent, tt([ut, pt, ht], (A) => {
|
|
2478
|
+
h = Pe(h, A, " ");
|
|
2479
|
+
}), l.textContent !== h && (De(e.removed, {
|
|
2480
|
+
element: l.cloneNode()
|
|
2481
|
+
}), l.textContent = h)), ie(H.afterSanitizeElements, l, null), !1);
|
|
2482
|
+
}, gn = function(l, h, _) {
|
|
2483
|
+
if (tn && (h === "id" || h === "name") && (_ in t || _ in Ar))
|
|
2484
|
+
return !1;
|
|
2485
|
+
if (!(dt && !ft[h] && F(br, h))) {
|
|
2486
|
+
if (!(Kt && F(xr, h))) {
|
|
2487
|
+
if (!P[h] || ft[h]) {
|
|
2488
|
+
if (
|
|
2489
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
2490
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2491
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
2492
|
+
!(mn(l) && (v.tagNameCheck instanceof RegExp && F(v.tagNameCheck, l) || v.tagNameCheck instanceof Function && v.tagNameCheck(l)) && (v.attributeNameCheck instanceof RegExp && F(v.attributeNameCheck, h) || v.attributeNameCheck instanceof Function && v.attributeNameCheck(h)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
2493
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
2494
|
+
h === "is" && v.allowCustomizedBuiltInElements && (v.tagNameCheck instanceof RegExp && F(v.tagNameCheck, _) || v.tagNameCheck instanceof Function && v.tagNameCheck(_)))
|
|
2495
|
+
) return !1;
|
|
2496
|
+
} else if (!xt[h]) {
|
|
2497
|
+
if (!F(Yt, Pe(_, jt, ""))) {
|
|
2498
|
+
if (!((h === "src" || h === "xlink:href" || h === "href") && l !== "script" && go(_, "data:") === 0 && sn[l])) {
|
|
2499
|
+
if (!(Jt && !F(kr, Pe(_, jt, "")))) {
|
|
2500
|
+
if (_)
|
|
2501
|
+
return !1;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return !0;
|
|
2509
|
+
}, mn = function(l) {
|
|
2510
|
+
return l !== "annotation-xml" && Mn(l, wr);
|
|
2511
|
+
}, _n = function(l) {
|
|
2512
|
+
ie(H.beforeSanitizeAttributes, l, null);
|
|
2513
|
+
const {
|
|
2514
|
+
attributes: h
|
|
2515
|
+
} = l;
|
|
2516
|
+
if (!h || yt(l))
|
|
2517
|
+
return;
|
|
2518
|
+
const _ = {
|
|
2519
|
+
attrName: "",
|
|
2520
|
+
attrValue: "",
|
|
2521
|
+
keepAttr: !0,
|
|
2522
|
+
allowedAttributes: P,
|
|
2523
|
+
forceKeepAttr: void 0
|
|
2524
|
+
};
|
|
2525
|
+
let A = h.length;
|
|
2526
|
+
for (; A--; ) {
|
|
2527
|
+
const B = h[A], {
|
|
2528
|
+
name: z,
|
|
2529
|
+
namespaceURI: Z,
|
|
2530
|
+
value: ne
|
|
2531
|
+
} = B, Le = M(z);
|
|
2532
|
+
let U = z === "value" ? ne : mo(ne);
|
|
2533
|
+
if (_.attrName = Le, _.attrValue = U, _.keepAttr = !0, _.forceKeepAttr = void 0, ie(H.uponSanitizeAttribute, l, _), U = _.attrValue, nn && (Le === "id" || Le === "name") && (Ke(z, l), U = Tr + U), gt && F(/((--!?|])>)|<\/(style|title)/i, U)) {
|
|
2534
|
+
Ke(z, l);
|
|
2535
|
+
continue;
|
|
2536
|
+
}
|
|
2537
|
+
if (_.forceKeepAttr || (Ke(z, l), !_.keepAttr))
|
|
2538
|
+
continue;
|
|
2539
|
+
if (!en && F(/\/>/i, U)) {
|
|
2540
|
+
Ke(z, l);
|
|
2541
|
+
continue;
|
|
2542
|
+
}
|
|
2543
|
+
_e && tt([ut, pt, ht], (xn) => {
|
|
2544
|
+
U = Pe(U, xn, " ");
|
|
2545
|
+
});
|
|
2546
|
+
const bn = M(l.nodeName);
|
|
2547
|
+
if (gn(bn, Le, U)) {
|
|
2548
|
+
if (E && typeof g == "object" && typeof g.getAttributeType == "function" && !Z)
|
|
2549
|
+
switch (g.getAttributeType(bn, Le)) {
|
|
2550
|
+
case "TrustedHTML": {
|
|
2551
|
+
U = E.createHTML(U);
|
|
2552
|
+
break;
|
|
2553
|
+
}
|
|
2554
|
+
case "TrustedScriptURL": {
|
|
2555
|
+
U = E.createScriptURL(U);
|
|
2556
|
+
break;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
try {
|
|
2560
|
+
Z ? l.setAttributeNS(Z, z, U) : l.setAttribute(z, U), yt(l) ? te(l) : Nn(e.removed);
|
|
2561
|
+
} catch {
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
ie(H.afterSanitizeAttributes, l, null);
|
|
2566
|
+
}, vr = function b(l) {
|
|
2567
|
+
let h = null;
|
|
2568
|
+
const _ = hn(l);
|
|
2569
|
+
for (ie(H.beforeSanitizeShadowDOM, l, null); h = _.nextNode(); )
|
|
2570
|
+
ie(H.uponSanitizeShadowNode, h, null), dn(h), _n(h), h.content instanceof r && b(h.content);
|
|
2571
|
+
ie(H.afterSanitizeShadowDOM, l, null);
|
|
2572
|
+
};
|
|
2573
|
+
return e.sanitize = function(b) {
|
|
2574
|
+
let l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, h = null, _ = null, A = null, B = null;
|
|
2575
|
+
if (kt = !b, kt && (b = "<!-->"), typeof b != "string" && !fn(b))
|
|
2576
|
+
if (typeof b.toString == "function") {
|
|
2577
|
+
if (b = b.toString(), typeof b != "string")
|
|
2578
|
+
throw ze("dirty is not a string, aborting");
|
|
2579
|
+
} else
|
|
2580
|
+
throw ze("toString is not a function");
|
|
2581
|
+
if (!e.isSupported)
|
|
2582
|
+
return b;
|
|
2583
|
+
if (mt || Tt(l), e.removed = [], typeof b == "string" && (Re = !1), Re) {
|
|
2584
|
+
if (b.nodeName) {
|
|
2585
|
+
const ne = M(b.nodeName);
|
|
2586
|
+
if (!N[ne] || Ae[ne])
|
|
2587
|
+
throw ze("root node is forbidden and cannot be sanitized in-place");
|
|
2588
|
+
}
|
|
2589
|
+
} else if (b instanceof i)
|
|
2590
|
+
h = pn("<!---->"), _ = h.ownerDocument.importNode(b, !0), _.nodeType === Be.element && _.nodeName === "BODY" || _.nodeName === "HTML" ? h = _ : h.appendChild(_);
|
|
2591
|
+
else {
|
|
2592
|
+
if (!be && !_e && !pe && // eslint-disable-next-line unicorn/prefer-includes
|
|
2593
|
+
b.indexOf("<") === -1)
|
|
2594
|
+
return E && Ve ? E.createHTML(b) : b;
|
|
2595
|
+
if (h = pn(b), !h)
|
|
2596
|
+
return be ? null : Ve ? le : "";
|
|
2597
|
+
}
|
|
2598
|
+
h && _t && te(h.firstChild);
|
|
2599
|
+
const z = hn(Re ? b : h);
|
|
2600
|
+
for (; A = z.nextNode(); )
|
|
2601
|
+
dn(A), _n(A), A.content instanceof r && vr(A.content);
|
|
2602
|
+
if (Re)
|
|
2603
|
+
return b;
|
|
2604
|
+
if (be) {
|
|
2605
|
+
if (Ze)
|
|
2606
|
+
for (B = ue.call(h.ownerDocument); h.firstChild; )
|
|
2607
|
+
B.appendChild(h.firstChild);
|
|
2608
|
+
else
|
|
2609
|
+
B = h;
|
|
2610
|
+
return (P.shadowroot || P.shadowrootmode) && (B = _r.call(n, B, !0)), B;
|
|
2611
|
+
}
|
|
2612
|
+
let Z = pe ? h.outerHTML : h.innerHTML;
|
|
2613
|
+
return pe && N["!doctype"] && h.ownerDocument && h.ownerDocument.doctype && h.ownerDocument.doctype.name && F(hr, h.ownerDocument.doctype.name) && (Z = "<!DOCTYPE " + h.ownerDocument.doctype.name + `>
|
|
2614
|
+
` + Z), _e && tt([ut, pt, ht], (ne) => {
|
|
2615
|
+
Z = Pe(Z, ne, " ");
|
|
2616
|
+
}), E && Ve ? E.createHTML(Z) : Z;
|
|
2617
|
+
}, e.setConfig = function() {
|
|
2618
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2619
|
+
Tt(b), mt = !0;
|
|
2620
|
+
}, e.clearConfig = function() {
|
|
2621
|
+
Te = null, mt = !1;
|
|
2622
|
+
}, e.isValidAttribute = function(b, l, h) {
|
|
2623
|
+
Te || Tt({});
|
|
2624
|
+
const _ = M(b), A = M(l);
|
|
2625
|
+
return gn(_, A, h);
|
|
2626
|
+
}, e.addHook = function(b, l) {
|
|
2627
|
+
typeof l == "function" && De(H[b], l);
|
|
2628
|
+
}, e.removeHook = function(b, l) {
|
|
2629
|
+
if (l !== void 0) {
|
|
2630
|
+
const h = ho(H[b], l);
|
|
2631
|
+
return h === -1 ? void 0 : fo(H[b], h, 1)[0];
|
|
2632
|
+
}
|
|
2633
|
+
return Nn(H[b]);
|
|
2634
|
+
}, e.removeHooks = function(b) {
|
|
2635
|
+
H[b] = [];
|
|
2636
|
+
}, e.removeAllHooks = function() {
|
|
2637
|
+
H = Bn();
|
|
2638
|
+
}, e;
|
|
2639
|
+
}
|
|
2640
|
+
var Io = fr();
|
|
2641
|
+
function No(o) {
|
|
2642
|
+
return o.trim().endsWith(`
|
|
2643
|
+
|
|
2644
|
+
`) || o.trim().endsWith(".") || o.trim().endsWith("。");
|
|
2645
|
+
}
|
|
2646
|
+
function dr(o, e = 100) {
|
|
2647
|
+
const [t, n] = V([]), [s, r] = V(""), a = ce(/* @__PURE__ */ new Map()), i = I((c) => (c == null ? void 0 : c.raw) || c.text || "", []);
|
|
2648
|
+
return O(() => {
|
|
2649
|
+
if (!o) {
|
|
2650
|
+
n([]), r(""), a.current.clear();
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
const c = setTimeout(() => {
|
|
2654
|
+
const u = j.lex(o);
|
|
2655
|
+
if (u.length === 0) {
|
|
2656
|
+
n([]), r("");
|
|
2657
|
+
return;
|
|
2658
|
+
}
|
|
2659
|
+
let m = u.length - 1;
|
|
2660
|
+
for (let T = u.length - 1; T >= 0; T--) {
|
|
2661
|
+
const Y = i(u[T]);
|
|
2662
|
+
if (No(Y)) {
|
|
2663
|
+
m = T;
|
|
2664
|
+
break;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
const f = u.slice(0, m + 1), g = u.slice(m + 1), x = [];
|
|
2668
|
+
for (const T of f) {
|
|
2669
|
+
const Y = i(T), D = a.current.get(Y);
|
|
2670
|
+
if (D)
|
|
2671
|
+
x.push(D);
|
|
2672
|
+
else {
|
|
2673
|
+
const K = C.parser([T]), E = Io.sanitize(K);
|
|
2674
|
+
a.current.set(Y, E), x.push(E);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
const k = g.map(i).join(`
|
|
2678
|
+
`);
|
|
2679
|
+
n(x), r(k);
|
|
2680
|
+
}, e);
|
|
2681
|
+
return () => clearTimeout(c);
|
|
2682
|
+
}, [o, e, i]), {
|
|
2683
|
+
htmlBlocks: $(() => /* @__PURE__ */ d(
|
|
2684
|
+
"div",
|
|
2685
|
+
{
|
|
2686
|
+
className: ee.md_container,
|
|
2687
|
+
dangerouslySetInnerHTML: { __html: t.join("") }
|
|
2688
|
+
}
|
|
2689
|
+
), [t]),
|
|
2690
|
+
lastTypingText: s
|
|
2691
|
+
};
|
|
2692
|
+
}
|
|
2693
|
+
function Hn(o) {
|
|
2694
|
+
var i, p;
|
|
2695
|
+
const { message: e } = o, { avatar: t } = se(), n = ge(), { htmlBlocks: s, lastTypingText: r } = dr(
|
|
2696
|
+
((i = e == null ? void 0 : e.message) == null ? void 0 : i.text) || "",
|
|
2697
|
+
20
|
|
2698
|
+
), a = $(() => {
|
|
2699
|
+
var c, u, m, f;
|
|
2700
|
+
switch (e.type) {
|
|
560
2701
|
case "user":
|
|
561
2702
|
return {
|
|
562
|
-
color: (
|
|
563
|
-
backgroundColor: (
|
|
2703
|
+
color: (c = n == null ? void 0 : n.userMessage) == null ? void 0 : c.color,
|
|
2704
|
+
backgroundColor: (u = n == null ? void 0 : n.userMessage) == null ? void 0 : u.backgroundColor
|
|
564
2705
|
};
|
|
565
2706
|
case "bot":
|
|
566
2707
|
return {
|
|
567
|
-
color: (
|
|
568
|
-
backgroundColor: (
|
|
2708
|
+
color: (m = n == null ? void 0 : n.botMessage) == null ? void 0 : m.color,
|
|
2709
|
+
backgroundColor: (f = n == null ? void 0 : n.botMessage) == null ? void 0 : f.backgroundColor
|
|
569
2710
|
};
|
|
570
2711
|
default:
|
|
571
2712
|
return {};
|
|
572
2713
|
}
|
|
573
|
-
}, [
|
|
574
|
-
return
|
|
575
|
-
/* @__PURE__ */
|
|
2714
|
+
}, [e, n]);
|
|
2715
|
+
return e.type === "error" ? null : e.type === "user" ? /* @__PURE__ */ R(Ge, { type: "user", direction: "horizontal", children: [
|
|
2716
|
+
/* @__PURE__ */ d(
|
|
576
2717
|
"div",
|
|
577
2718
|
{
|
|
578
|
-
className:
|
|
579
|
-
style:
|
|
580
|
-
children:
|
|
2719
|
+
className: ae(ee.text, ee["text--user"]),
|
|
2720
|
+
style: a,
|
|
2721
|
+
children: e.text
|
|
581
2722
|
}
|
|
582
2723
|
),
|
|
583
|
-
/* @__PURE__ */
|
|
584
|
-
] }) : /* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
|
|
2724
|
+
/* @__PURE__ */ d(zt, { time: e.time })
|
|
2725
|
+
] }) : /* @__PURE__ */ R(Ge, { type: "bot", direction: "horizontal", children: [
|
|
2726
|
+
/* @__PURE__ */ d(at, { avatar: t }),
|
|
2727
|
+
/* @__PURE__ */ d(
|
|
2728
|
+
$t,
|
|
588
2729
|
{
|
|
589
|
-
time:
|
|
590
|
-
quickReplies: (
|
|
591
|
-
children: /* @__PURE__ */
|
|
2730
|
+
time: e.time,
|
|
2731
|
+
quickReplies: (p = e.message.template) == null ? void 0 : p.quickReplies,
|
|
2732
|
+
children: /* @__PURE__ */ R(
|
|
592
2733
|
"div",
|
|
593
2734
|
{
|
|
594
|
-
className:
|
|
595
|
-
style:
|
|
596
|
-
children:
|
|
2735
|
+
className: ae(ee.text, ee["text--bot"]),
|
|
2736
|
+
style: a,
|
|
2737
|
+
children: [
|
|
2738
|
+
s,
|
|
2739
|
+
r ?? ""
|
|
2740
|
+
]
|
|
597
2741
|
}
|
|
598
2742
|
)
|
|
599
2743
|
}
|
|
600
2744
|
)
|
|
601
2745
|
] });
|
|
602
2746
|
}
|
|
603
|
-
function
|
|
604
|
-
const { isTyping:
|
|
605
|
-
var
|
|
606
|
-
(
|
|
607
|
-
}, [
|
|
608
|
-
|
|
609
|
-
const
|
|
2747
|
+
function gr(o) {
|
|
2748
|
+
const { isTyping: e, typingText: t } = o, { messageBoxBottomRef: n, avatar: s } = se(), r = ge(), a = ce(null), i = I(() => {
|
|
2749
|
+
var g;
|
|
2750
|
+
(g = n.current) == null || g.scrollIntoView({ behavior: "smooth" });
|
|
2751
|
+
}, [n]);
|
|
2752
|
+
Vr({ ref: a, onResize: i });
|
|
2753
|
+
const p = Hr(e, 500), { htmlBlocks: c, lastTypingText: u } = dr(
|
|
2754
|
+
t || "",
|
|
2755
|
+
20
|
|
2756
|
+
), m = $(
|
|
610
2757
|
() => {
|
|
611
|
-
var
|
|
2758
|
+
var g, x;
|
|
612
2759
|
return {
|
|
613
|
-
color: (
|
|
614
|
-
backgroundColor: (
|
|
2760
|
+
color: (g = r == null ? void 0 : r.botMessage) == null ? void 0 : g.color,
|
|
2761
|
+
backgroundColor: (x = r == null ? void 0 : r.botMessage) == null ? void 0 : x.backgroundColor
|
|
615
2762
|
};
|
|
616
2763
|
},
|
|
617
|
-
[
|
|
618
|
-
),
|
|
2764
|
+
[r]
|
|
2765
|
+
), f = $(
|
|
619
2766
|
() => {
|
|
620
|
-
var
|
|
2767
|
+
var g;
|
|
621
2768
|
return {
|
|
622
|
-
backgroundColor: (
|
|
2769
|
+
backgroundColor: (g = r == null ? void 0 : r.botMessage) == null ? void 0 : g.color
|
|
623
2770
|
};
|
|
624
2771
|
},
|
|
625
|
-
[
|
|
2772
|
+
[r]
|
|
626
2773
|
);
|
|
627
|
-
return
|
|
628
|
-
/* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
2774
|
+
return p ? /* @__PURE__ */ R(Ge, { type: "bot", direction: "horizontal", children: [
|
|
2775
|
+
/* @__PURE__ */ d(at, { avatar: s }),
|
|
2776
|
+
/* @__PURE__ */ d($t, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ d(
|
|
630
2777
|
"div",
|
|
631
2778
|
{
|
|
632
2779
|
ref: a,
|
|
633
|
-
className:
|
|
634
|
-
style:
|
|
635
|
-
children: /* @__PURE__ */
|
|
636
|
-
|
|
637
|
-
u
|
|
638
|
-
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
2780
|
+
className: ae(ee.text, ee["text--bot"]),
|
|
2781
|
+
style: m,
|
|
2782
|
+
children: /* @__PURE__ */ R("span", { children: [
|
|
2783
|
+
c,
|
|
2784
|
+
u ?? "",
|
|
2785
|
+
p && /* @__PURE__ */ R("span", { className: ee["typing-indicator"], children: [
|
|
2786
|
+
/* @__PURE__ */ d("div", { className: ee.dot, style: f }),
|
|
2787
|
+
/* @__PURE__ */ d("div", { className: ee.dot, style: f }),
|
|
2788
|
+
/* @__PURE__ */ d("div", { className: ee.dot, style: f })
|
|
641
2789
|
] })
|
|
642
2790
|
] })
|
|
643
2791
|
}
|
|
644
2792
|
) })
|
|
645
2793
|
] }) : null;
|
|
646
2794
|
}
|
|
647
|
-
function
|
|
648
|
-
const { placeholder:
|
|
649
|
-
() => Array.from((
|
|
650
|
-
(
|
|
2795
|
+
function Mo(o) {
|
|
2796
|
+
const { placeholder: e } = o, { isConnecting: t, messages: n } = se(), s = $(
|
|
2797
|
+
() => Array.from((n == null ? void 0 : n.values()) ?? []).some(
|
|
2798
|
+
(r) => r.type === "bot" && r.isTyping
|
|
651
2799
|
),
|
|
652
|
-
[
|
|
2800
|
+
[n]
|
|
653
2801
|
);
|
|
654
|
-
return
|
|
2802
|
+
return t && !s ? /* @__PURE__ */ d(gr, { isTyping: !0, typingText: e }) : null;
|
|
655
2803
|
}
|
|
656
|
-
const
|
|
657
|
-
carousel_root:
|
|
658
|
-
carousel_time:
|
|
2804
|
+
const Oo = "_carousel_root_sv1hc_1", Do = "_carousel_time_sv1hc_12", Un = {
|
|
2805
|
+
carousel_root: Oo,
|
|
2806
|
+
carousel_time: Do
|
|
659
2807
|
};
|
|
660
|
-
function
|
|
661
|
-
var
|
|
662
|
-
const { message:
|
|
663
|
-
return /* @__PURE__ */
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
666
|
-
/* @__PURE__ */
|
|
2808
|
+
function Po(o) {
|
|
2809
|
+
var s;
|
|
2810
|
+
const { message: e } = o, { avatar: t } = se(), n = e.message.template;
|
|
2811
|
+
return /* @__PURE__ */ R(Ge, { type: "bot", direction: "vertical", children: [
|
|
2812
|
+
/* @__PURE__ */ d(at, { avatar: t }),
|
|
2813
|
+
/* @__PURE__ */ d("div", { className: Un.carousel_root, children: (s = n.columns) == null ? void 0 : s.map((r, a) => /* @__PURE__ */ d(Qn, { template: r }, a)) }),
|
|
2814
|
+
/* @__PURE__ */ d(zt, { className: Un.carousel_time, time: e.time })
|
|
667
2815
|
] });
|
|
668
2816
|
}
|
|
669
|
-
const
|
|
670
|
-
hint_root:
|
|
671
|
-
error_hint_title:
|
|
672
|
-
error_hint_message:
|
|
673
|
-
time:
|
|
2817
|
+
const zo = "_hint_root_iy66i_1", $o = "_error_hint_title_iy66i_17", Bo = "_error_hint_message_iy66i_23", Ho = "_time_iy66i_32", Ce = {
|
|
2818
|
+
hint_root: zo,
|
|
2819
|
+
error_hint_title: $o,
|
|
2820
|
+
error_hint_message: Bo,
|
|
2821
|
+
time: Ho
|
|
674
2822
|
};
|
|
675
|
-
function
|
|
676
|
-
const { message:
|
|
677
|
-
|
|
678
|
-
}, [
|
|
679
|
-
if (
|
|
680
|
-
if (
|
|
681
|
-
return /* @__PURE__ */
|
|
682
|
-
/* @__PURE__ */
|
|
683
|
-
/* @__PURE__ */
|
|
684
|
-
/* @__PURE__ */
|
|
2823
|
+
function Fn(o) {
|
|
2824
|
+
const { message: e } = o, { onErrorClick: t, errorMessageRenderer: n } = Xr(), s = I(() => {
|
|
2825
|
+
t == null || t(e);
|
|
2826
|
+
}, [e, t]);
|
|
2827
|
+
if (e.type === "user") return null;
|
|
2828
|
+
if (e.type === "error")
|
|
2829
|
+
return /* @__PURE__ */ d("div", { className: Ce.hint_root, children: (n == null ? void 0 : n(e)) ?? /* @__PURE__ */ R(Nr, { children: [
|
|
2830
|
+
/* @__PURE__ */ R("div", { className: Ce.error_hint_title, children: [
|
|
2831
|
+
/* @__PURE__ */ d("span", { className: Ce.time, children: It(e.time) }),
|
|
2832
|
+
/* @__PURE__ */ d("span", { children: "Unexpected error" })
|
|
685
2833
|
] }),
|
|
686
|
-
|
|
2834
|
+
t && /* @__PURE__ */ R(
|
|
687
2835
|
"div",
|
|
688
2836
|
{
|
|
689
|
-
className:
|
|
690
|
-
onClick:
|
|
2837
|
+
className: Ce.error_hint_message,
|
|
2838
|
+
onClick: s,
|
|
691
2839
|
children: [
|
|
692
2840
|
"Click ",
|
|
693
|
-
/* @__PURE__ */
|
|
2841
|
+
/* @__PURE__ */ d("span", { children: "here" }),
|
|
694
2842
|
" to view the report."
|
|
695
2843
|
]
|
|
696
2844
|
}
|
|
697
2845
|
)
|
|
698
2846
|
] }) });
|
|
699
|
-
const
|
|
700
|
-
return
|
|
701
|
-
/* @__PURE__ */
|
|
702
|
-
|
|
2847
|
+
const r = e.message.template;
|
|
2848
|
+
return r.type !== He.HINT ? null : /* @__PURE__ */ R("div", { className: Ce.hint_root, children: [
|
|
2849
|
+
/* @__PURE__ */ d("div", { className: Ce.time, children: It(e.time) }),
|
|
2850
|
+
r.text
|
|
703
2851
|
] });
|
|
704
2852
|
}
|
|
705
|
-
function
|
|
706
|
-
var
|
|
707
|
-
const { message:
|
|
708
|
-
if (
|
|
709
|
-
return /* @__PURE__ */
|
|
710
|
-
if (
|
|
711
|
-
return /* @__PURE__ */
|
|
712
|
-
if (
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
|
|
2853
|
+
function Uo(o) {
|
|
2854
|
+
var t;
|
|
2855
|
+
const { message: e } = o;
|
|
2856
|
+
if (e.type === "user")
|
|
2857
|
+
return /* @__PURE__ */ d(Hn, { message: e });
|
|
2858
|
+
if (e.type === "error")
|
|
2859
|
+
return /* @__PURE__ */ d(Fn, { message: e });
|
|
2860
|
+
if (e.isTyping)
|
|
2861
|
+
return /* @__PURE__ */ d(
|
|
2862
|
+
gr,
|
|
715
2863
|
{
|
|
716
|
-
isTyping:
|
|
717
|
-
typingText:
|
|
2864
|
+
isTyping: e.isTyping,
|
|
2865
|
+
typingText: e.typingText
|
|
718
2866
|
}
|
|
719
2867
|
);
|
|
720
|
-
switch ((
|
|
721
|
-
case
|
|
722
|
-
return /* @__PURE__ */
|
|
723
|
-
case
|
|
724
|
-
return /* @__PURE__ */
|
|
725
|
-
case
|
|
726
|
-
return /* @__PURE__ */
|
|
727
|
-
case
|
|
728
|
-
return /* @__PURE__ */
|
|
2868
|
+
switch ((t = e.message.template) == null ? void 0 : t.type) {
|
|
2869
|
+
case He.TEXT:
|
|
2870
|
+
return /* @__PURE__ */ d(Hn, { message: e });
|
|
2871
|
+
case He.HINT:
|
|
2872
|
+
return /* @__PURE__ */ d(Fn, { message: e });
|
|
2873
|
+
case He.BUTTON:
|
|
2874
|
+
return /* @__PURE__ */ d(ys, { message: e });
|
|
2875
|
+
case He.CAROUSEL:
|
|
2876
|
+
return /* @__PURE__ */ d(Po, { message: e });
|
|
729
2877
|
default:
|
|
730
|
-
return /* @__PURE__ */
|
|
2878
|
+
return /* @__PURE__ */ d("div", {});
|
|
731
2879
|
}
|
|
732
2880
|
}
|
|
733
|
-
function
|
|
734
|
-
const { chatbot:
|
|
735
|
-
|
|
736
|
-
var
|
|
737
|
-
(
|
|
738
|
-
}, [
|
|
739
|
-
const
|
|
2881
|
+
function Fo() {
|
|
2882
|
+
const { chatbot: o } = ge(), { messages: e, messageBoxBottomRef: t, botTypingPlaceholder: n } = se();
|
|
2883
|
+
O(() => {
|
|
2884
|
+
var r;
|
|
2885
|
+
(r = t.current) == null || r.scrollIntoView({ behavior: "smooth" });
|
|
2886
|
+
}, [e, t]);
|
|
2887
|
+
const s = $(
|
|
740
2888
|
() => ({
|
|
741
|
-
maxWidth: (
|
|
2889
|
+
maxWidth: (o == null ? void 0 : o.contentMaxWidth) ?? "1200px"
|
|
742
2890
|
}),
|
|
743
|
-
[
|
|
2891
|
+
[o]
|
|
744
2892
|
);
|
|
745
|
-
return /* @__PURE__ */
|
|
746
|
-
Array.from((
|
|
747
|
-
|
|
2893
|
+
return /* @__PURE__ */ d("div", { className: Tn.chatbot_body, children: /* @__PURE__ */ R("div", { className: Tn.chatbot_body__content, style: s, children: [
|
|
2894
|
+
Array.from((e == null ? void 0 : e.values()) ?? []).map((r) => /* @__PURE__ */ d(
|
|
2895
|
+
Uo,
|
|
748
2896
|
{
|
|
749
|
-
message:
|
|
2897
|
+
message: r
|
|
750
2898
|
},
|
|
751
|
-
|
|
2899
|
+
r.messageId
|
|
752
2900
|
)),
|
|
753
|
-
/* @__PURE__ */
|
|
754
|
-
|
|
2901
|
+
/* @__PURE__ */ d(
|
|
2902
|
+
Mo,
|
|
755
2903
|
{
|
|
756
|
-
placeholder:
|
|
2904
|
+
placeholder: n ?? "正在輸入訊息"
|
|
757
2905
|
}
|
|
758
2906
|
),
|
|
759
|
-
/* @__PURE__ */
|
|
2907
|
+
/* @__PURE__ */ d("div", { ref: t })
|
|
760
2908
|
] }) });
|
|
761
2909
|
}
|
|
762
|
-
const
|
|
763
|
-
chatbot_footer:
|
|
764
|
-
chatbot_footer__content:
|
|
765
|
-
chatbot_textarea:
|
|
766
|
-
chatbot_submit_button:
|
|
767
|
-
chatbot_submit_button__disabled:
|
|
768
|
-
},
|
|
769
|
-
function
|
|
770
|
-
const { setValue:
|
|
771
|
-
|
|
772
|
-
const
|
|
773
|
-
if (!
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
for (let
|
|
777
|
-
|
|
778
|
-
},
|
|
779
|
-
alert(`語音識別錯誤: ${JSON.stringify(
|
|
780
|
-
},
|
|
781
|
-
|
|
782
|
-
},
|
|
783
|
-
}, [
|
|
784
|
-
const a =
|
|
785
|
-
if (!
|
|
2910
|
+
const qo = "_chatbot_footer_1slg7_1", Go = "_chatbot_footer__content_1slg7_4", Wo = "_chatbot_textarea_1slg7_14", Zo = "_chatbot_submit_button_1slg7_29", Vo = "_chatbot_submit_button__disabled_1slg7_54", he = {
|
|
2911
|
+
chatbot_footer: qo,
|
|
2912
|
+
chatbot_footer__content: Go,
|
|
2913
|
+
chatbot_textarea: Wo,
|
|
2914
|
+
chatbot_submit_button: Zo,
|
|
2915
|
+
chatbot_submit_button__disabled: Vo
|
|
2916
|
+
}, jo = (o) => /* @__PURE__ */ L.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("path", { d: "M0.823242 11.6953V0.945312L14.3328 6.32031L0.823242 11.6953ZM1.90658 10.0911L11.3649 6.32031L1.90658 2.54948V4.98052L5.92574 6.32031L1.90658 7.6601V10.0911Z", fill: "white" })), Yo = (o) => /* @__PURE__ */ L.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("path", { d: "M5.40658 9.90397C4.82435 9.90397 4.33158 9.7023 3.92824 9.29897C3.52491 8.89564 3.32324 8.40286 3.32324 7.82064V2.82064C3.32324 2.23842 3.52491 1.74564 3.92824 1.3423C4.33158 0.938971 4.82435 0.737305 5.40658 0.737305C5.9888 0.737305 6.48158 0.938971 6.88491 1.3423C7.28824 1.74564 7.48991 2.23842 7.48991 2.82064V7.82064C7.48991 8.40286 7.28824 8.89564 6.88491 9.29897C6.48158 9.7023 5.9888 9.90397 5.40658 9.90397ZM4.86491 15.1123V12.8654C3.56213 12.7208 2.47949 12.1724 1.61699 11.2202C0.754492 10.2679 0.323242 9.13467 0.323242 7.82064H1.40658C1.40658 8.92731 1.79706 9.87064 2.57803 10.6506C3.35887 11.4306 4.30331 11.8206 5.41137 11.8206C6.51928 11.8206 7.46213 11.4306 8.23991 10.6506C9.01769 9.87064 9.40658 8.92731 9.40658 7.82064H10.4899C10.4899 9.13467 10.0587 10.2679 9.19616 11.2202C8.33366 12.1724 7.25102 12.7208 5.94824 12.8654V15.1123H4.86491ZM5.40658 8.82064C5.68991 8.82064 5.92741 8.7248 6.11908 8.53314C6.31074 8.34147 6.40658 8.10397 6.40658 7.82064V2.82064C6.40658 2.5373 6.31074 2.2998 6.11908 2.10814C5.92741 1.91647 5.68991 1.82064 5.40658 1.82064C5.12324 1.82064 4.88574 1.91647 4.69408 2.10814C4.50241 2.2998 4.40658 2.5373 4.40658 2.82064V7.82064C4.40658 8.10397 4.50241 8.34147 4.69408 8.53314C4.88574 8.7248 5.12324 8.82064 5.40658 8.82064Z", fill: "white" })), Xo = (o) => /* @__PURE__ */ L.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...o }, /* @__PURE__ */ L.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ L.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
|
|
2917
|
+
function Qo(o) {
|
|
2918
|
+
const { setValue: e, className: t } = o, [n, s] = V(!1), r = ce(null);
|
|
2919
|
+
O(() => {
|
|
2920
|
+
const f = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
2921
|
+
if (!f) return;
|
|
2922
|
+
const g = new f();
|
|
2923
|
+
g.lang = "zh-TW", g.continuous = !0, g.interimResults = !0, g.onresult = (x) => {
|
|
2924
|
+
for (let k = x.resultIndex; k < x.results.length; k++)
|
|
2925
|
+
x.results[k].isFinal && e((T) => T + x.results[k][0].transcript);
|
|
2926
|
+
}, g.onerror = (x) => {
|
|
2927
|
+
alert(`語音識別錯誤: ${JSON.stringify(x.error)}`);
|
|
2928
|
+
}, g.onend = () => {
|
|
2929
|
+
s(!1);
|
|
2930
|
+
}, r.current = g;
|
|
2931
|
+
}, [e]);
|
|
2932
|
+
const a = I(() => {
|
|
2933
|
+
if (!r.current) {
|
|
786
2934
|
alert("無法開始辨識: 語音識別器未初始化,請檢查是否有授權使用麥克風");
|
|
787
2935
|
return;
|
|
788
2936
|
}
|
|
789
2937
|
try {
|
|
790
|
-
|
|
791
|
-
} catch (
|
|
792
|
-
alert(`無法開始辨識: ${JSON.stringify(
|
|
793
|
-
}
|
|
794
|
-
}, []), i =
|
|
795
|
-
|
|
796
|
-
}, []),
|
|
797
|
-
(
|
|
798
|
-
|
|
2938
|
+
r.current.start(), s(!0);
|
|
2939
|
+
} catch (f) {
|
|
2940
|
+
alert(`無法開始辨識: ${JSON.stringify(f)}`);
|
|
2941
|
+
}
|
|
2942
|
+
}, []), i = I(() => {
|
|
2943
|
+
r.current && (r.current.stop(), s(!1));
|
|
2944
|
+
}, []), p = I(
|
|
2945
|
+
(f) => {
|
|
2946
|
+
n || (f.preventDefault(), a());
|
|
799
2947
|
},
|
|
800
|
-
[
|
|
801
|
-
),
|
|
802
|
-
(
|
|
803
|
-
|
|
2948
|
+
[n, a]
|
|
2949
|
+
), c = I(
|
|
2950
|
+
(f) => {
|
|
2951
|
+
n && (f.preventDefault(), i());
|
|
804
2952
|
},
|
|
805
|
-
[
|
|
806
|
-
),
|
|
807
|
-
(
|
|
808
|
-
|
|
2953
|
+
[n, i]
|
|
2954
|
+
), u = I(
|
|
2955
|
+
(f) => {
|
|
2956
|
+
n || (f.preventDefault(), a());
|
|
809
2957
|
},
|
|
810
|
-
[
|
|
811
|
-
),
|
|
812
|
-
(
|
|
813
|
-
|
|
2958
|
+
[n, a]
|
|
2959
|
+
), m = I(
|
|
2960
|
+
(f) => {
|
|
2961
|
+
n && (f.preventDefault(), i());
|
|
814
2962
|
},
|
|
815
|
-
[
|
|
2963
|
+
[n, i]
|
|
816
2964
|
);
|
|
817
|
-
return /* @__PURE__ */
|
|
2965
|
+
return /* @__PURE__ */ d(
|
|
818
2966
|
"div",
|
|
819
2967
|
{
|
|
820
|
-
className:
|
|
821
|
-
onMouseDown:
|
|
822
|
-
onMouseUp:
|
|
823
|
-
onTouchStart:
|
|
824
|
-
onTouchEnd:
|
|
825
|
-
children:
|
|
2968
|
+
className: t,
|
|
2969
|
+
onMouseDown: p,
|
|
2970
|
+
onMouseUp: c,
|
|
2971
|
+
onTouchStart: u,
|
|
2972
|
+
onTouchEnd: m,
|
|
2973
|
+
children: n ? /* @__PURE__ */ d(Xo, {}) : /* @__PURE__ */ d(Yo, {})
|
|
826
2974
|
}
|
|
827
2975
|
);
|
|
828
2976
|
}
|
|
829
|
-
function
|
|
830
|
-
const { sendMessage:
|
|
831
|
-
() =>
|
|
832
|
-
[
|
|
833
|
-
),
|
|
2977
|
+
function Ko() {
|
|
2978
|
+
const { sendMessage: o, isConnecting: e } = se(), { chatbot: t } = ge(), [n, s] = V(""), [r, a] = V(!1), i = ce(null), p = $(
|
|
2979
|
+
() => e || !n.trim(),
|
|
2980
|
+
[e, n]
|
|
2981
|
+
), c = $(
|
|
834
2982
|
() => ({
|
|
835
|
-
maxWidth: (
|
|
836
|
-
borderTopColor:
|
|
2983
|
+
maxWidth: (t == null ? void 0 : t.contentMaxWidth) ?? "1200px",
|
|
2984
|
+
borderTopColor: t == null ? void 0 : t.borderColor
|
|
837
2985
|
}),
|
|
838
|
-
[
|
|
839
|
-
),
|
|
840
|
-
(
|
|
841
|
-
const
|
|
842
|
-
|
|
2986
|
+
[t]
|
|
2987
|
+
), u = I(
|
|
2988
|
+
(g) => {
|
|
2989
|
+
const x = g.target, k = x.value;
|
|
2990
|
+
x.style.height = "36px", k && (x.style.height = `${x.scrollHeight}px`), s(g.target.value);
|
|
843
2991
|
},
|
|
844
2992
|
[]
|
|
845
|
-
),
|
|
846
|
-
!
|
|
847
|
-
}, [
|
|
848
|
-
(
|
|
849
|
-
if (
|
|
850
|
-
|
|
851
|
-
const
|
|
852
|
-
|
|
2993
|
+
), m = I(() => {
|
|
2994
|
+
!r && !e && (o == null || o({ text: n }), s(""), i.current && (i.current.style.height = "36px"));
|
|
2995
|
+
}, [r, e, o, n]), f = I(
|
|
2996
|
+
(g) => {
|
|
2997
|
+
if (g.key === "Enter" && !r && !e && n.trim()) {
|
|
2998
|
+
o == null || o({ text: n }), s("");
|
|
2999
|
+
const x = g.target;
|
|
3000
|
+
x.style.height = "36px";
|
|
853
3001
|
}
|
|
854
3002
|
},
|
|
855
|
-
[
|
|
3003
|
+
[r, e, o, n]
|
|
856
3004
|
);
|
|
857
|
-
return /* @__PURE__ */
|
|
858
|
-
/* @__PURE__ */
|
|
3005
|
+
return /* @__PURE__ */ d("div", { className: he.chatbot_footer, children: /* @__PURE__ */ R("div", { className: he.chatbot_footer__content, style: c, children: [
|
|
3006
|
+
/* @__PURE__ */ d(
|
|
859
3007
|
"textarea",
|
|
860
3008
|
{
|
|
861
3009
|
ref: i,
|
|
862
|
-
className:
|
|
863
|
-
disabled:
|
|
3010
|
+
className: he.chatbot_textarea,
|
|
3011
|
+
disabled: e,
|
|
864
3012
|
cols: 40,
|
|
865
|
-
value:
|
|
3013
|
+
value: n,
|
|
866
3014
|
placeholder: "Enter message",
|
|
867
|
-
onChange:
|
|
868
|
-
onKeyDown:
|
|
3015
|
+
onChange: u,
|
|
3016
|
+
onKeyDown: f,
|
|
869
3017
|
onCompositionStart: () => a(!0),
|
|
870
3018
|
onCompositionEnd: () => a(!1)
|
|
871
3019
|
}
|
|
872
3020
|
),
|
|
873
|
-
|
|
3021
|
+
n ? /* @__PURE__ */ d(
|
|
874
3022
|
"button",
|
|
875
3023
|
{
|
|
876
|
-
className:
|
|
877
|
-
|
|
878
|
-
|
|
3024
|
+
className: ae(
|
|
3025
|
+
he.chatbot_submit_button,
|
|
3026
|
+
p && he.chatbot_submit_button__disabled
|
|
879
3027
|
),
|
|
880
|
-
disabled:
|
|
881
|
-
onClick:
|
|
882
|
-
children: /* @__PURE__ */
|
|
3028
|
+
disabled: p,
|
|
3029
|
+
onClick: m,
|
|
3030
|
+
children: /* @__PURE__ */ d(jo, {})
|
|
883
3031
|
}
|
|
884
|
-
) : /* @__PURE__ */
|
|
885
|
-
|
|
3032
|
+
) : /* @__PURE__ */ d(
|
|
3033
|
+
Qo,
|
|
886
3034
|
{
|
|
887
|
-
setValue:
|
|
888
|
-
className:
|
|
889
|
-
|
|
890
|
-
|
|
3035
|
+
setValue: s,
|
|
3036
|
+
className: ae(
|
|
3037
|
+
he.chatbot_submit_button,
|
|
3038
|
+
e && he.chatbot_submit_button__disabled
|
|
891
3039
|
)
|
|
892
3040
|
}
|
|
893
3041
|
)
|
|
894
3042
|
] }) });
|
|
895
3043
|
}
|
|
896
|
-
const
|
|
897
|
-
chatbot_root:
|
|
898
|
-
full_screen:
|
|
899
|
-
chatbot_container:
|
|
900
|
-
screen_keyboard_open:
|
|
3044
|
+
const Jo = "_chatbot_root_lao40_1", ei = "_full_screen_lao40_135", ti = "_chatbot_container_lao40_143", ni = "_screen_keyboard_open_lao40_148", qe = {
|
|
3045
|
+
chatbot_root: Jo,
|
|
3046
|
+
full_screen: ei,
|
|
3047
|
+
chatbot_container: ti,
|
|
3048
|
+
screen_keyboard_open: ni
|
|
901
3049
|
};
|
|
902
|
-
function
|
|
903
|
-
const { children:
|
|
904
|
-
|
|
905
|
-
const [,
|
|
906
|
-
var i,
|
|
3050
|
+
function ri(o) {
|
|
3051
|
+
const { children: e } = o, t = ce(null), n = ge();
|
|
3052
|
+
Wr(t), Gr();
|
|
3053
|
+
const [, s] = Fr() ?? [], r = qr(), a = $(() => {
|
|
3054
|
+
var i, p;
|
|
907
3055
|
return Object.assign(
|
|
908
|
-
(i =
|
|
909
|
-
backgroundColor: (
|
|
3056
|
+
(i = n == null ? void 0 : n.chatbot) != null && i.backgroundColor ? {
|
|
3057
|
+
backgroundColor: (p = n.chatbot) == null ? void 0 : p.backgroundColor
|
|
910
3058
|
} : {},
|
|
911
|
-
|
|
3059
|
+
r ? { height: s } : {}
|
|
912
3060
|
);
|
|
913
|
-
}, [
|
|
914
|
-
return /* @__PURE__ */
|
|
3061
|
+
}, [s, r, n]);
|
|
3062
|
+
return /* @__PURE__ */ d("div", { className: qe.full_screen, children: /* @__PURE__ */ d(
|
|
915
3063
|
"div",
|
|
916
3064
|
{
|
|
917
|
-
ref:
|
|
918
|
-
className:
|
|
919
|
-
|
|
920
|
-
|
|
3065
|
+
ref: t,
|
|
3066
|
+
className: ae(
|
|
3067
|
+
qe.chatbot_container,
|
|
3068
|
+
r && qe.screen_keyboard_open
|
|
921
3069
|
),
|
|
922
3070
|
style: a,
|
|
923
|
-
children:
|
|
3071
|
+
children: e
|
|
924
3072
|
}
|
|
925
3073
|
) });
|
|
926
3074
|
}
|
|
927
|
-
function
|
|
928
|
-
const { fullScreen:
|
|
929
|
-
|
|
930
|
-
const
|
|
931
|
-
return /* @__PURE__ */
|
|
3075
|
+
function si(o) {
|
|
3076
|
+
const { fullScreen: e, children: t } = o, n = ce(null);
|
|
3077
|
+
Zr(n);
|
|
3078
|
+
const s = ge();
|
|
3079
|
+
return /* @__PURE__ */ d("div", { ref: n, className: qe.chatbot_root, children: e ? /* @__PURE__ */ d(ri, { children: t }) : /* @__PURE__ */ d("div", { className: qe.chatbot_container, style: s == null ? void 0 : s.chatbot, children: t }) });
|
|
932
3080
|
}
|
|
933
|
-
function
|
|
3081
|
+
function ci(o) {
|
|
934
3082
|
const {
|
|
935
|
-
title:
|
|
936
|
-
theme:
|
|
937
|
-
config:
|
|
938
|
-
customChannelId:
|
|
939
|
-
initMessages:
|
|
3083
|
+
title: e,
|
|
3084
|
+
theme: t,
|
|
3085
|
+
config: n,
|
|
3086
|
+
customChannelId: s,
|
|
3087
|
+
initMessages: r,
|
|
940
3088
|
fullScreen: a = !1,
|
|
941
3089
|
avatar: i,
|
|
942
|
-
botTypingPlaceholder:
|
|
943
|
-
onReset:
|
|
944
|
-
onClose:
|
|
945
|
-
onErrorClick:
|
|
946
|
-
errorMessageRenderer:
|
|
947
|
-
} =
|
|
948
|
-
return /* @__PURE__ */
|
|
949
|
-
|
|
3090
|
+
botTypingPlaceholder: p,
|
|
3091
|
+
onReset: c,
|
|
3092
|
+
onClose: u,
|
|
3093
|
+
onErrorClick: m,
|
|
3094
|
+
errorMessageRenderer: f
|
|
3095
|
+
} = o;
|
|
3096
|
+
return /* @__PURE__ */ d(zr, { theme: t, children: /* @__PURE__ */ d(
|
|
3097
|
+
jr,
|
|
950
3098
|
{
|
|
951
3099
|
avatar: i,
|
|
952
|
-
config:
|
|
953
|
-
customChannelId:
|
|
954
|
-
initMessages:
|
|
955
|
-
botTypingPlaceholder:
|
|
956
|
-
children: /* @__PURE__ */
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
/* @__PURE__ */
|
|
959
|
-
|
|
3100
|
+
config: n,
|
|
3101
|
+
customChannelId: s,
|
|
3102
|
+
initMessages: r,
|
|
3103
|
+
botTypingPlaceholder: p,
|
|
3104
|
+
children: /* @__PURE__ */ R(si, { fullScreen: a, children: [
|
|
3105
|
+
/* @__PURE__ */ d(os, { title: e, onReset: c, onClose: u }),
|
|
3106
|
+
/* @__PURE__ */ d(
|
|
3107
|
+
Yr,
|
|
960
3108
|
{
|
|
961
|
-
onErrorClick:
|
|
962
|
-
errorMessageRenderer:
|
|
963
|
-
children: /* @__PURE__ */
|
|
3109
|
+
onErrorClick: m,
|
|
3110
|
+
errorMessageRenderer: f,
|
|
3111
|
+
children: /* @__PURE__ */ d(Fo, {})
|
|
964
3112
|
}
|
|
965
3113
|
),
|
|
966
|
-
/* @__PURE__ */
|
|
3114
|
+
/* @__PURE__ */ d(Ko, {})
|
|
967
3115
|
] })
|
|
968
3116
|
}
|
|
969
3117
|
) });
|
|
970
3118
|
}
|
|
971
3119
|
export {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
3120
|
+
ci as Chatbot,
|
|
3121
|
+
$r as useAsgardServiceClient,
|
|
3122
|
+
Br as useChannel,
|
|
3123
|
+
Hr as useDebounce,
|
|
3124
|
+
qr as useIsOnScreenKeyboardOpen,
|
|
3125
|
+
Gr as useOnScreenKeyboardScrollFix,
|
|
3126
|
+
Wr as usePreventOverScrolling,
|
|
3127
|
+
Vr as useResizeObserver,
|
|
3128
|
+
Zr as useUpdateVh,
|
|
3129
|
+
Fr as useViewportSize
|
|
982
3130
|
};
|