blueeyebot-widget 0.1.0
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/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/ChatWidget.d.ts +5 -0
- package/dist/api.d.ts +37 -0
- package/dist/audio.d.ts +18 -0
- package/dist/blueeyebot.es.js +14 -0
- package/dist/blueeyebot.iife.js +53 -0
- package/dist/bob.d.ts +24 -0
- package/dist/config.d.ts +18 -0
- package/dist/icons.d.ts +19 -0
- package/dist/index.d.ts +14 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +24 -0
- package/dist/storage.d.ts +5 -0
- package/dist/toast.d.ts +17 -0
- package/dist/types.d.ts +80 -0
- package/dist/web-component-DZRPaCAI.js +2602 -0
- package/dist/web-component.d.ts +25 -0
- package/package.json +58 -0
|
@@ -0,0 +1,2602 @@
|
|
|
1
|
+
var Be, S, Ut, q, bt, jt, Wt, Oe, we, le, qt, Xe, Ve, Qe, Te = {}, Ce = [], $n = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Ae = Array.isArray;
|
|
2
|
+
function W(r, e) {
|
|
3
|
+
for (var t in e) r[t] = e[t];
|
|
4
|
+
return r;
|
|
5
|
+
}
|
|
6
|
+
function et(r) {
|
|
7
|
+
r && r.parentNode && r.parentNode.removeChild(r);
|
|
8
|
+
}
|
|
9
|
+
function Ft(r, e, t) {
|
|
10
|
+
var n, o, s, i = {};
|
|
11
|
+
for (s in e) s == "key" ? n = e[s] : s == "ref" ? o = e[s] : i[s] = e[s];
|
|
12
|
+
if (arguments.length > 2 && (i.children = arguments.length > 3 ? Be.call(arguments, 2) : t), typeof r == "function" && r.defaultProps != null) for (s in r.defaultProps) i[s] === void 0 && (i[s] = r.defaultProps[s]);
|
|
13
|
+
return ye(r, i, n, o, null);
|
|
14
|
+
}
|
|
15
|
+
function ye(r, e, t, n, o) {
|
|
16
|
+
var s = { type: r, props: e, key: t, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: o ?? ++Ut, __i: -1, __u: 0 };
|
|
17
|
+
return o == null && S.vnode != null && S.vnode(s), s;
|
|
18
|
+
}
|
|
19
|
+
function ee(r) {
|
|
20
|
+
return r.children;
|
|
21
|
+
}
|
|
22
|
+
function ve(r, e) {
|
|
23
|
+
this.props = r, this.context = e;
|
|
24
|
+
}
|
|
25
|
+
function te(r, e) {
|
|
26
|
+
if (e == null) return r.__ ? te(r.__, r.__i + 1) : null;
|
|
27
|
+
for (var t; e < r.__k.length; e++) if ((t = r.__k[e]) != null && t.__e != null) return t.__e;
|
|
28
|
+
return typeof r.type == "function" ? te(r) : null;
|
|
29
|
+
}
|
|
30
|
+
function Tn(r) {
|
|
31
|
+
if (r.__P && r.__d) {
|
|
32
|
+
var e = r.__v, t = e.__e, n = [], o = [], s = W({}, e);
|
|
33
|
+
s.__v = e.__v + 1, S.vnode && S.vnode(s), tt(r.__P, s, e, r.__n, r.__P.namespaceURI, 32 & e.__u ? [t] : null, n, t ?? te(e), !!(32 & e.__u), o), s.__v = e.__v, s.__.__k[s.__i] = s, Yt(n, s, o), e.__e = e.__ = null, s.__e != t && Zt(s);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function Zt(r) {
|
|
37
|
+
if ((r = r.__) != null && r.__c != null) return r.__e = r.__c.base = null, r.__k.some(function(e) {
|
|
38
|
+
if (e != null && e.__e != null) return r.__e = r.__c.base = e.__e;
|
|
39
|
+
}), Zt(r);
|
|
40
|
+
}
|
|
41
|
+
function xt(r) {
|
|
42
|
+
(!r.__d && (r.__d = !0) && q.push(r) && !Ie.__r++ || bt != S.debounceRendering) && ((bt = S.debounceRendering) || jt)(Ie);
|
|
43
|
+
}
|
|
44
|
+
function Ie() {
|
|
45
|
+
try {
|
|
46
|
+
for (var r, e = 1; q.length; ) q.length > e && q.sort(Wt), r = q.shift(), e = q.length, Tn(r);
|
|
47
|
+
} finally {
|
|
48
|
+
q.length = Ie.__r = 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function Vt(r, e, t, n, o, s, i, a, c, d, u) {
|
|
52
|
+
var l, h, f, x, v, w, b, m = n && n.__k || Ce, I = e.length;
|
|
53
|
+
for (c = Cn(t, e, m, c, I), l = 0; l < I; l++) (f = t.__k[l]) != null && (h = f.__i != -1 && m[f.__i] || Te, f.__i = l, w = tt(r, f, h, o, s, i, a, c, d, u), x = f.__e, f.ref && h.ref != f.ref && (h.ref && nt(h.ref, null, f), u.push(f.ref, f.__c || x, f)), v == null && x != null && (v = x), (b = !!(4 & f.__u)) || h.__k === f.__k ? (c = Qt(f, c, r, b), b && h.__e && (h.__e = null)) : typeof f.type == "function" && w !== void 0 ? c = w : x && (c = x.nextSibling), f.__u &= -7);
|
|
54
|
+
return t.__e = v, c;
|
|
55
|
+
}
|
|
56
|
+
function Cn(r, e, t, n, o) {
|
|
57
|
+
var s, i, a, c, d, u = t.length, l = u, h = 0;
|
|
58
|
+
for (r.__k = new Array(o), s = 0; s < o; s++) (i = e[s]) != null && typeof i != "boolean" && typeof i != "function" ? (typeof i == "string" || typeof i == "number" || typeof i == "bigint" || i.constructor == String ? i = r.__k[s] = ye(null, i, null, null, null) : Ae(i) ? i = r.__k[s] = ye(ee, { children: i }, null, null, null) : i.constructor === void 0 && i.__b > 0 ? i = r.__k[s] = ye(i.type, i.props, i.key, i.ref ? i.ref : null, i.__v) : r.__k[s] = i, c = s + h, i.__ = r, i.__b = r.__b + 1, a = null, (d = i.__i = In(i, t, c, l)) != -1 && (l--, (a = t[d]) && (a.__u |= 2)), a == null || a.__v == null ? (d == -1 && (o > u ? h-- : o < u && h++), typeof i.type != "function" && (i.__u |= 4)) : d != c && (d == c - 1 ? h-- : d == c + 1 ? h++ : (d > c ? h-- : h++, i.__u |= 4))) : r.__k[s] = null;
|
|
59
|
+
if (l) for (s = 0; s < u; s++) (a = t[s]) != null && (2 & a.__u) == 0 && (a.__e == n && (n = te(a)), Jt(a, a));
|
|
60
|
+
return n;
|
|
61
|
+
}
|
|
62
|
+
function Qt(r, e, t, n) {
|
|
63
|
+
var o, s;
|
|
64
|
+
if (typeof r.type == "function") {
|
|
65
|
+
for (o = r.__k, s = 0; o && s < o.length; s++) o[s] && (o[s].__ = r, e = Qt(o[s], e, t, n));
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
r.__e != e && (n && (e && r.type && !e.parentNode && (e = te(r)), t.insertBefore(r.__e, e || null)), e = r.__e);
|
|
69
|
+
do
|
|
70
|
+
e = e && e.nextSibling;
|
|
71
|
+
while (e != null && e.nodeType == 8);
|
|
72
|
+
return e;
|
|
73
|
+
}
|
|
74
|
+
function In(r, e, t, n) {
|
|
75
|
+
var o, s, i, a = r.key, c = r.type, d = e[t], u = d != null && (2 & d.__u) == 0;
|
|
76
|
+
if (d === null && a == null || u && a == d.key && c == d.type) return t;
|
|
77
|
+
if (n > (u ? 1 : 0)) {
|
|
78
|
+
for (o = t - 1, s = t + 1; o >= 0 || s < e.length; ) if ((d = e[i = o >= 0 ? o-- : s++]) != null && (2 & d.__u) == 0 && a == d.key && c == d.type) return i;
|
|
79
|
+
}
|
|
80
|
+
return -1;
|
|
81
|
+
}
|
|
82
|
+
function kt(r, e, t) {
|
|
83
|
+
e[0] == "-" ? r.setProperty(e, t ?? "") : r[e] = t == null ? "" : typeof t != "number" || $n.test(e) ? t : t + "px";
|
|
84
|
+
}
|
|
85
|
+
function _e(r, e, t, n, o) {
|
|
86
|
+
var s, i;
|
|
87
|
+
e: if (e == "style") if (typeof t == "string") r.style.cssText = t;
|
|
88
|
+
else {
|
|
89
|
+
if (typeof n == "string" && (r.style.cssText = n = ""), n) for (e in n) t && e in t || kt(r.style, e, "");
|
|
90
|
+
if (t) for (e in t) n && t[e] == n[e] || kt(r.style, e, t[e]);
|
|
91
|
+
}
|
|
92
|
+
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(qt, "$1")), i = e.toLowerCase(), e = i in r || e == "onFocusOut" || e == "onFocusIn" ? i.slice(2) : e.slice(2), r.l || (r.l = {}), r.l[e + s] = t, t ? n ? t[le] = n[le] : (t[le] = Xe, r.addEventListener(e, s ? Qe : Ve, s)) : r.removeEventListener(e, s ? Qe : Ve, s);
|
|
93
|
+
else {
|
|
94
|
+
if (o == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
95
|
+
else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in r) try {
|
|
96
|
+
r[e] = t ?? "";
|
|
97
|
+
break e;
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
typeof t == "function" || (t == null || t === !1 && e[4] != "-" ? r.removeAttribute(e) : r.setAttribute(e, e == "popover" && t == 1 ? "" : t));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function wt(r) {
|
|
104
|
+
return function(e) {
|
|
105
|
+
if (this.l) {
|
|
106
|
+
var t = this.l[e.type + r];
|
|
107
|
+
if (e[we] == null) e[we] = Xe++;
|
|
108
|
+
else if (e[we] < t[le]) return;
|
|
109
|
+
return t(S.event ? S.event(e) : e);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function tt(r, e, t, n, o, s, i, a, c, d) {
|
|
114
|
+
var u, l, h, f, x, v, w, b, m, I, R, B, fe, J, K, z = e.type;
|
|
115
|
+
if (e.constructor !== void 0) return null;
|
|
116
|
+
128 & t.__u && (c = !!(32 & t.__u), s = [a = e.__e = t.__e]), (u = S.__b) && u(e);
|
|
117
|
+
e: if (typeof z == "function") try {
|
|
118
|
+
if (b = e.props, m = z.prototype && z.prototype.render, I = (u = z.contextType) && n[u.__c], R = u ? I ? I.props.value : u.__ : n, t.__c ? w = (l = e.__c = t.__c).__ = l.__E : (m ? e.__c = l = new z(b, R) : (e.__c = l = new ve(b, R), l.constructor = z, l.render = Rn), I && I.sub(l), l.state || (l.state = {}), l.__n = n, h = l.__d = !0, l.__h = [], l._sb = []), m && l.__s == null && (l.__s = l.state), m && z.getDerivedStateFromProps != null && (l.__s == l.state && (l.__s = W({}, l.__s)), W(l.__s, z.getDerivedStateFromProps(b, l.__s))), f = l.props, x = l.state, l.__v = e, h) m && z.getDerivedStateFromProps == null && l.componentWillMount != null && l.componentWillMount(), m && l.componentDidMount != null && l.__h.push(l.componentDidMount);
|
|
119
|
+
else {
|
|
120
|
+
if (m && z.getDerivedStateFromProps == null && b !== f && l.componentWillReceiveProps != null && l.componentWillReceiveProps(b, R), e.__v == t.__v || !l.__e && l.shouldComponentUpdate != null && l.shouldComponentUpdate(b, l.__s, R) === !1) {
|
|
121
|
+
e.__v != t.__v && (l.props = b, l.state = l.__s, l.__d = !1), e.__e = t.__e, e.__k = t.__k, e.__k.some(function(D) {
|
|
122
|
+
D && (D.__ = e);
|
|
123
|
+
}), Ce.push.apply(l.__h, l._sb), l._sb = [], l.__h.length && i.push(l);
|
|
124
|
+
break e;
|
|
125
|
+
}
|
|
126
|
+
l.componentWillUpdate != null && l.componentWillUpdate(b, l.__s, R), m && l.componentDidUpdate != null && l.__h.push(function() {
|
|
127
|
+
l.componentDidUpdate(f, x, v);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (l.context = R, l.props = b, l.__P = r, l.__e = !1, B = S.__r, fe = 0, m) l.state = l.__s, l.__d = !1, B && B(e), u = l.render(l.props, l.state, l.context), Ce.push.apply(l.__h, l._sb), l._sb = [];
|
|
131
|
+
else do
|
|
132
|
+
l.__d = !1, B && B(e), u = l.render(l.props, l.state, l.context), l.state = l.__s;
|
|
133
|
+
while (l.__d && ++fe < 25);
|
|
134
|
+
l.state = l.__s, l.getChildContext != null && (n = W(W({}, n), l.getChildContext())), m && !h && l.getSnapshotBeforeUpdate != null && (v = l.getSnapshotBeforeUpdate(f, x)), J = u != null && u.type === ee && u.key == null ? Gt(u.props.children) : u, a = Vt(r, Ae(J) ? J : [J], e, t, n, o, s, i, a, c, d), l.base = e.__e, e.__u &= -161, l.__h.length && i.push(l), w && (l.__E = l.__ = null);
|
|
135
|
+
} catch (D) {
|
|
136
|
+
if (e.__v = null, c || s != null) if (D.then) {
|
|
137
|
+
for (e.__u |= c ? 160 : 128; a && a.nodeType == 8 && a.nextSibling; ) a = a.nextSibling;
|
|
138
|
+
s[s.indexOf(a)] = null, e.__e = a;
|
|
139
|
+
} else {
|
|
140
|
+
for (K = s.length; K--; ) et(s[K]);
|
|
141
|
+
Ye(e);
|
|
142
|
+
}
|
|
143
|
+
else e.__e = t.__e, e.__k = t.__k, D.then || Ye(e);
|
|
144
|
+
S.__e(D, e, t);
|
|
145
|
+
}
|
|
146
|
+
else s == null && e.__v == t.__v ? (e.__k = t.__k, e.__e = t.__e) : a = e.__e = zn(t.__e, e, t, n, o, s, i, c, d);
|
|
147
|
+
return (u = S.diffed) && u(e), 128 & e.__u ? void 0 : a;
|
|
148
|
+
}
|
|
149
|
+
function Ye(r) {
|
|
150
|
+
r && (r.__c && (r.__c.__e = !0), r.__k && r.__k.some(Ye));
|
|
151
|
+
}
|
|
152
|
+
function Yt(r, e, t) {
|
|
153
|
+
for (var n = 0; n < t.length; n++) nt(t[n], t[++n], t[++n]);
|
|
154
|
+
S.__c && S.__c(e, r), r.some(function(o) {
|
|
155
|
+
try {
|
|
156
|
+
r = o.__h, o.__h = [], r.some(function(s) {
|
|
157
|
+
s.call(o);
|
|
158
|
+
});
|
|
159
|
+
} catch (s) {
|
|
160
|
+
S.__e(s, o.__v);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function Gt(r) {
|
|
165
|
+
return typeof r != "object" || r == null || r.__b > 0 ? r : Ae(r) ? r.map(Gt) : r.constructor !== void 0 ? null : W({}, r);
|
|
166
|
+
}
|
|
167
|
+
function zn(r, e, t, n, o, s, i, a, c) {
|
|
168
|
+
var d, u, l, h, f, x, v, w = t.props || Te, b = e.props, m = e.type;
|
|
169
|
+
if (m == "svg" ? o = "http://www.w3.org/2000/svg" : m == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o || (o = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
170
|
+
for (d = 0; d < s.length; d++) if ((f = s[d]) && "setAttribute" in f == !!m && (m ? f.localName == m : f.nodeType == 3)) {
|
|
171
|
+
r = f, s[d] = null;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (r == null) {
|
|
176
|
+
if (m == null) return document.createTextNode(b);
|
|
177
|
+
r = document.createElementNS(o, m, b.is && b), a && (S.__m && S.__m(e, s), a = !1), s = null;
|
|
178
|
+
}
|
|
179
|
+
if (m == null) w === b || a && r.data == b || (r.data = b);
|
|
180
|
+
else {
|
|
181
|
+
if (s = m == "textarea" && b.defaultValue != null ? null : s && Be.call(r.childNodes), !a && s != null) for (w = {}, d = 0; d < r.attributes.length; d++) w[(f = r.attributes[d]).name] = f.value;
|
|
182
|
+
for (d in w) f = w[d], d == "dangerouslySetInnerHTML" ? l = f : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || _e(r, d, null, f, o);
|
|
183
|
+
for (d in b) f = b[d], d == "children" ? h = f : d == "dangerouslySetInnerHTML" ? u = f : d == "value" ? x = f : d == "checked" ? v = f : a && typeof f != "function" || w[d] === f || _e(r, d, f, w[d], o);
|
|
184
|
+
if (u) a || l && (u.__html == l.__html || u.__html == r.innerHTML) || (r.innerHTML = u.__html), e.__k = [];
|
|
185
|
+
else if (l && (r.innerHTML = ""), Vt(e.type == "template" ? r.content : r, Ae(h) ? h : [h], e, t, n, m == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, i, s ? s[0] : t.__k && te(t, 0), a, c), s != null) for (d = s.length; d--; ) et(s[d]);
|
|
186
|
+
a && m != "textarea" || (d = "value", m == "progress" && x == null ? r.removeAttribute("value") : x != null && (x !== r[d] || m == "progress" && !x || m == "option" && x != w[d]) && _e(r, d, x, w[d], o), d = "checked", v != null && v != r[d] && _e(r, d, v, w[d], o));
|
|
187
|
+
}
|
|
188
|
+
return r;
|
|
189
|
+
}
|
|
190
|
+
function nt(r, e, t) {
|
|
191
|
+
try {
|
|
192
|
+
if (typeof r == "function") {
|
|
193
|
+
var n = typeof r.__u == "function";
|
|
194
|
+
n && r.__u(), n && e == null || (r.__u = r(e));
|
|
195
|
+
} else r.current = e;
|
|
196
|
+
} catch (o) {
|
|
197
|
+
S.__e(o, t);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function Jt(r, e, t) {
|
|
201
|
+
var n, o;
|
|
202
|
+
if (S.unmount && S.unmount(r), (n = r.ref) && (n.current && n.current != r.__e || nt(n, null, e)), (n = r.__c) != null) {
|
|
203
|
+
if (n.componentWillUnmount) try {
|
|
204
|
+
n.componentWillUnmount();
|
|
205
|
+
} catch (s) {
|
|
206
|
+
S.__e(s, e);
|
|
207
|
+
}
|
|
208
|
+
n.base = n.__P = null;
|
|
209
|
+
}
|
|
210
|
+
if (n = r.__k) for (o = 0; o < n.length; o++) n[o] && Jt(n[o], e, t || typeof r.type != "function");
|
|
211
|
+
t || et(r.__e), r.__c = r.__ = r.__e = void 0;
|
|
212
|
+
}
|
|
213
|
+
function Rn(r, e, t) {
|
|
214
|
+
return this.constructor(r, t);
|
|
215
|
+
}
|
|
216
|
+
function Ue(r, e, t) {
|
|
217
|
+
var n, o, s, i;
|
|
218
|
+
e == document && (e = document.documentElement), S.__ && S.__(r, e), o = (n = !1) ? null : e.__k, s = [], i = [], tt(e, r = e.__k = Ft(ee, null, [r]), o || Te, Te, e.namespaceURI, o ? null : e.firstChild ? Be.call(e.childNodes) : null, s, o ? o.__e : e.firstChild, n, i), Yt(s, r, i);
|
|
219
|
+
}
|
|
220
|
+
Be = Ce.slice, S = { __e: function(r, e, t, n) {
|
|
221
|
+
for (var o, s, i; e = e.__; ) if ((o = e.__c) && !o.__) try {
|
|
222
|
+
if ((s = o.constructor) && s.getDerivedStateFromError != null && (o.setState(s.getDerivedStateFromError(r)), i = o.__d), o.componentDidCatch != null && (o.componentDidCatch(r, n || {}), i = o.__d), i) return o.__E = o;
|
|
223
|
+
} catch (a) {
|
|
224
|
+
r = a;
|
|
225
|
+
}
|
|
226
|
+
throw r;
|
|
227
|
+
} }, Ut = 0, ve.prototype.setState = function(r, e) {
|
|
228
|
+
var t;
|
|
229
|
+
t = this.__s != null && this.__s != this.state ? this.__s : this.__s = W({}, this.state), typeof r == "function" && (r = r(W({}, t), this.props)), r && W(t, r), r != null && this.__v && (e && this._sb.push(e), xt(this));
|
|
230
|
+
}, ve.prototype.forceUpdate = function(r) {
|
|
231
|
+
this.__v && (this.__e = !0, r && this.__h.push(r), xt(this));
|
|
232
|
+
}, ve.prototype.render = ee, q = [], jt = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Wt = function(r, e) {
|
|
233
|
+
return r.__v.__b - e.__v.__b;
|
|
234
|
+
}, Ie.__r = 0, Oe = Math.random().toString(8), we = "__d" + Oe, le = "__a" + Oe, qt = /(PointerCapture)$|Capture$/i, Xe = 0, Ve = wt(!1), Qe = wt(!0);
|
|
235
|
+
const En = ':host{--cw-primary: #0083ff;--cw-secondary: #0070eb;--cw-accent: var(--cw-primary);--cw-accent-strong: var(--cw-secondary);--cw-gradient: linear-gradient(135deg, var(--cw-primary), var(--cw-secondary));--cw-bg: #0a0c10;--cw-surface: #13171d;--cw-surface-2: #1b212a;--cw-border: rgba(255, 255, 255, .08);--cw-header-text: #ffffff;--cw-text: #e6edf3;--cw-text-secondary: #c9d1d9;--cw-text-muted: #5b6268;--cw-danger: #ff5c5c;--cw-radius: 18px;--cw-font-family: "Inter", system-ui, Avenir, Helvetica, Arial, sans-serif;--cw-panel-width: 400px;--cw-panel-height: 600px;--cw-z-index: 9999;position:fixed;bottom:2rem;z-index:var(--cw-z-index);font-family:var(--cw-font-family);line-height:1.5}:host([data-position="bottom-right"]),:host(:not([data-position])){right:2rem}:host([data-position="bottom-left"]){left:2rem}*,*:before,*:after{box-sizing:border-box}.bob{color:var(--cw-accent);display:block}.bobGlow{filter:drop-shadow(0 0 5px rgba(0,131,255,.75)) drop-shadow(0 0 12px rgba(0,131,255,.4))}.bobHead{opacity:.95}.bobEyes{transform-origin:52px 30px;animation:bobBlink 4.5s infinite}.bobEyesTyping{animation:bobBlink 1.8s infinite}@keyframes bobBlink{0%,90%,to{transform:scaleY(1)}93%,96%{transform:scaleY(.08)}}.bobSpinner{fill:none;stroke-dasharray:18 44;stroke-linecap:round;transform-box:fill-box;transform-origin:center;animation:bobSpin .8s linear infinite}@keyframes bobSpin{to{transform:rotate(360deg)}}.bob[data-state=error]{color:var(--cw-danger)}.bobX{transform-origin:52px 30px;animation:bobShake .4s ease-in-out 2}@keyframes bobShake{0%,to{transform:translate(0)}25%{transform:translate(-2px)}75%{transform:translate(2px)}}.bobHearts{transform-origin:52px 30px;animation:bobPulse .6s ease-in-out 2}@keyframes bobPulse{0%,to{transform:scale(1)}50%{transform:scale(1.18)}}.fabButton{background:radial-gradient(circle at 50% 40%,#161b22,#0a0c10);border:1px solid rgba(0,131,255,.25);border-radius:18px;padding:12px 16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 0 22px #0083ff47,0 10px 28px #00000080;transition:transform .3s cubic-bezier(.175,.885,.32,1.275),box-shadow .3s}.fabButton:hover{transform:scale(1.07);box-shadow:0 0 30px #0083ff8c,0 12px 32px #0000008c}.fabButton:active{transform:scale(.95)}.backdrop{position:fixed;inset:0;background:#0009;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);animation:fadeIn .2s ease forwards}.chatWindow{position:absolute;bottom:0;right:0;width:var(--cw-panel-width);max-width:calc(100vw - 4rem);height:var(--cw-panel-height);max-height:calc(100vh - 4rem);background:var(--cw-bg);border:1px solid var(--cw-border);border-radius:var(--cw-radius);box-shadow:0 24px 48px #0000008c,0 0 0 1px #0006;display:flex;overflow:hidden;transform-origin:bottom right;animation:scaleIn .3s cubic-bezier(.175,.885,.32,1.275) forwards;opacity:0}:host([data-position="bottom-left"]) .chatWindow{right:auto;left:0;transform-origin:bottom left}.chatWindow.maximized{position:fixed;inset:50% auto auto 50%;transform:translate(-50%,-50%);width:min(1200px,calc(100vw - 48px));height:calc(100vh - 48px);max-width:none;max-height:none;animation:fadeIn .2s ease forwards}.mainCol{position:relative;flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--cw-bg)}@keyframes scaleIn{0%{opacity:0;transform:scale(.8) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.sidebar{width:288px;flex-shrink:0;background:var(--cw-surface);border-right:1px solid var(--cw-border);display:flex;flex-direction:column;overflow:hidden;transition:width .25s ease}.sidebar.collapsed{width:72px}.sidebarTop{display:flex;align-items:center;justify-content:space-between;padding:18px 16px}.sidebar.collapsed .sidebarTop{flex-direction:column;justify-content:center;gap:12px}.sidebarBrand{display:flex;align-items:center}.railToggle{flex-shrink:0}.sidebar.collapsed .railToggle{transform:rotate(180deg)}.sidebarScroll{flex:1;overflow-y:auto;overflow-x:hidden;padding:8px 12px 16px}.sidebarSection{margin-bottom:22px}.sidebarLabel{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;color:var(--cw-text-muted);padding:0 8px 8px}.sidebar.collapsed .sidebarLabel,.sidebar.collapsed .chatItem,.sidebar.collapsed .sidebarEmpty,.sidebar.collapsed .sidebarItemText{display:none}.sidebarItem{width:100%;display:flex;align-items:center;gap:12px;padding:9px 10px;border:none;background:transparent;color:var(--cw-text-secondary);font-family:inherit;font-size:14px;border-radius:10px;cursor:pointer;text-align:left;transition:background .15s,color .15s}.sidebarItem:hover{background:var(--cw-surface-2);color:var(--cw-text)}.sidebar.collapsed .sidebarItem{justify-content:center;padding:9px 0}.chatItem{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:9px 12px;border-radius:10px;border:1px solid transparent;color:var(--cw-text-secondary);font-size:14px;cursor:pointer;transition:background .15s,color .15s,border-color .15s}.chatItem:hover{background:var(--cw-surface-2);color:var(--cw-text)}.chatItem.active{border-color:#0083ff99;background:#0083ff1a;color:var(--cw-accent)}.chatItemTitle{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chatItemDelete{flex-shrink:0;width:24px;height:24px;border:none;background:transparent;color:var(--cw-danger);border-radius:6px;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:.6;transition:opacity .15s,background .15s,color .15s}.chatItemDelete:hover{background:#ff5c5c26;color:var(--cw-danger)}.sidebarEmpty{padding:4px 10px;font-size:13px;color:var(--cw-text-muted)}.chatHeader{background:var(--cw-surface);color:var(--cw-text);padding:14px 18px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--cw-border)}.chatWindow.maximized .chatHeader{background:var(--cw-bg)}.headerTitle{display:flex;align-items:center;gap:10px;font-weight:600;font-size:16px}.breadcrumb{color:var(--cw-text)}.breadcrumbSep{color:var(--cw-text-muted);margin-left:8px}.headerActions{display:flex;gap:6px}.iconButton{background:transparent;border:none;color:var(--cw-text-secondary);cursor:pointer;width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;transition:background .2s,color .2s}.iconButton:hover{background:var(--cw-surface-2);color:var(--cw-text)}.chatBody{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:16px;background:var(--cw-bg)}.chatBody::-webkit-scrollbar,.historyPanel::-webkit-scrollbar,.sidebarScroll::-webkit-scrollbar{width:6px}.chatBody::-webkit-scrollbar-track,.historyPanel::-webkit-scrollbar-track,.sidebarScroll::-webkit-scrollbar-track{background:transparent}.chatBody::-webkit-scrollbar-thumb,.historyPanel::-webkit-scrollbar-thumb,.sidebarScroll::-webkit-scrollbar-thumb{background-color:#2a323d;border-radius:10px}.chatWindow.maximized .chatBody>*{max-width:820px;width:100%;margin-inline:auto}.message{max-width:85%;animation:msgIn .3s ease}@keyframes msgIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.message.user{align-self:flex-end}.message.assistant{align-self:flex-start}.chatWindow.maximized .message.user{align-self:flex-end;margin-right:0}.messageContent{padding:12px 16px;border-radius:16px;font-size:14.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word}.message.user .messageContent{background:var(--cw-gradient);color:#fff;border-bottom-right-radius:4px}.message.assistant .messageContent{background:var(--cw-surface);color:var(--cw-text);border:1px solid var(--cw-border);border-bottom-left-radius:4px}.messageContent code{background:#ffffff14;padding:2px 6px;border-radius:4px;font-family:monospace;font-size:.9em}.message.user .messageContent code{background:#fff3}.markdownBody{white-space:normal}.markdownBody p{margin:0 0 .6em}.markdownBody p:last-child{margin-bottom:0}.markdownBody ul,.markdownBody ol{margin:.4em 0 .6em 1.4em;padding:0}.markdownBody li{margin-bottom:.2em}.markdownBody strong{font-weight:700;color:var(--cw-text)}.markdownBody em{font-style:italic}.markdownBody h1,.markdownBody h2,.markdownBody h3{margin:.6em 0 .3em;font-weight:700;line-height:1.3;color:var(--cw-text)}.markdownBody h1{font-size:1.15em}.markdownBody h2{font-size:1.05em}.markdownBody h3{font-size:.97em}.markdownBody pre{background:#ffffff0f;border:1px solid var(--cw-border);border-radius:8px;padding:10px 12px;overflow-x:auto;margin:.5em 0}.markdownBody pre code{background:transparent;padding:0;font-size:.88em}.markdownBody blockquote{border-left:3px solid var(--cw-accent);margin:.4em 0;padding:.2em .8em;color:var(--cw-text-secondary);font-style:italic}.markdownBody a{color:var(--cw-accent);text-decoration:underline;text-underline-offset:2px}.markdownBody hr{border:none;border-top:1px solid var(--cw-border);margin:.8em 0}.typingIndicator{display:flex;gap:4px;padding:4px}.typingDot{width:8px;height:8px;background:var(--cw-accent);border-radius:50%;animation:typing 1.4s infinite ease-in-out both}.typingDot:nth-child(1){animation-delay:-.32s}.typingDot:nth-child(2){animation-delay:-.16s}@keyframes typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatFooter{padding:16px;background:var(--cw-bg);border-top:1px solid var(--cw-border)}.chatWindow.maximized .chatFooter{padding:16px 20px 20px}.chatWindow.maximized .inputWrapper{max-width:820px;margin-inline:auto}.inputWrapper{display:flex;gap:10px;align-items:flex-end;background:var(--cw-surface);padding:8px 12px;border-radius:16px;border:1px solid var(--cw-border);transition:border-color .2s,box-shadow .2s}.inputWrapper:focus-within{border-color:#0083ff80;box-shadow:0 0 0 3px #0083ff1f}.addButton{flex-shrink:0;width:32px;height:32px;border-radius:10px;border:none;background:transparent;color:var(--cw-text-secondary);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s,color .2s}.addButton:hover{background:var(--cw-surface-2);color:var(--cw-text)}.micButton{flex-shrink:0;width:32px;height:32px;border-radius:10px;border:none;background:transparent;color:var(--cw-text-secondary);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s,color .2s,box-shadow .2s}.micButton:hover:not(:disabled){background:var(--cw-surface-2);color:var(--cw-text)}.micButton:disabled{color:var(--cw-text-muted);cursor:not-allowed}.micButton.recording{color:#fff;background:#e5484d;animation:cw-mic-pulse 1.4s ease-in-out infinite}@keyframes cw-mic-pulse{0%,to{box-shadow:0 0 #e5484d80}50%{box-shadow:0 0 0 6px #e5484d00}}.textarea{flex:1;background:transparent;border:none;resize:none;padding:6px 0;font-family:inherit;font-size:14px;line-height:1.5;color:var(--cw-text);max-height:120px;outline:none}.textarea::placeholder{color:var(--cw-text-muted)}.sendButton{background:var(--cw-gradient);color:#fff;border:none;width:36px;height:36px;border-radius:12px;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .2s,background .2s,opacity .2s;flex-shrink:0}.sendButton:hover:not(:disabled){transform:scale(1.05)}.sendButton:active:not(:disabled){transform:scale(.95)}.sendButton:disabled{background:var(--cw-surface-2);color:var(--cw-text-muted);cursor:not-allowed;transform:none}.footerInfo{display:flex;justify-content:space-between;padding:8px 4px 0;font-size:11px;color:var(--cw-text-muted)}.chatWindow.maximized .footerInfo{max-width:820px;margin-inline:auto}.errorMessage{background:#ff5c5c1f;color:#ff8585;padding:10px 16px;border-radius:12px;font-size:13px;align-self:center;margin:10px 0;display:flex;align-items:center;gap:8px;border:1px solid rgba(255,92,92,.3)}.historyPanel{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px;background:var(--cw-bg)}.historyItem{background:var(--cw-surface);border:1px solid var(--cw-border);border-radius:12px;padding:12px 16px;display:flex;justify-content:space-between;align-items:center;cursor:pointer;transition:all .2s ease}.historyItem:hover{border-color:#0083ff66;transform:translateY(-1px)}.historyItemContent{flex:1;overflow:hidden}.historyTitle{font-size:14px;font-weight:500;color:var(--cw-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:4px}.historyDate{font-size:11px;color:var(--cw-text-muted)}.deleteBtn{background:transparent;border:none;color:var(--cw-danger);width:32px;height:32px;border-radius:8px;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:.6;transition:all .2s;flex-shrink:0;margin-left:12px}.deleteBtn:hover{opacity:1;background:#ff5c5c26}.emptyHistory{text-align:center;color:var(--cw-text-muted);font-size:14px;margin-top:40px}.toastContainer{position:absolute;top:12px;left:50%;transform:translate(-50%);display:flex;flex-direction:column;gap:8px;z-index:2;pointer-events:none}.toast{background:var(--cw-surface-2);color:var(--cw-text);padding:8px 16px;border-radius:20px;font-size:12px;border:1px solid var(--cw-border);box-shadow:0 4px 12px #0006;animation:fadeIn .2s ease forwards}.toast-success{background:#16a34a;border-color:transparent;color:#fff}.toast-error{background:#dc2626;border-color:transparent;color:#fff}@media(max-width:480px){.chatWindow{width:calc(100vw - 2rem);height:calc(100vh - 100px)}.chatWindow.maximized{width:100vw;height:100vh;border-radius:0;inset:0;transform:none}.sidebar{width:240px}.sidebar.collapsed{width:64px}}';
|
|
236
|
+
var Bn = 0;
|
|
237
|
+
function p(r, e, t, n, o, s) {
|
|
238
|
+
e || (e = {});
|
|
239
|
+
var i, a, c = e;
|
|
240
|
+
if ("ref" in c) for (a in c = {}, e) a == "ref" ? i = e[a] : c[a] = e[a];
|
|
241
|
+
var d = { type: r, props: c, key: t, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Bn, __i: -1, __u: 0, __source: o, __self: s };
|
|
242
|
+
if (typeof r == "function" && (i = r.defaultProps)) for (a in i) c[a] === void 0 && (c[a] = i[a]);
|
|
243
|
+
return S.vnode && S.vnode(d), d;
|
|
244
|
+
}
|
|
245
|
+
var pe, T, je, yt, de = 0, Kt = [], C = S, vt = C.__b, St = C.__r, $t = C.diffed, Tt = C.__c, Ct = C.unmount, It = C.__;
|
|
246
|
+
function rt(r, e) {
|
|
247
|
+
C.__h && C.__h(T, r, de || e), de = 0;
|
|
248
|
+
var t = T.__H || (T.__H = { __: [], __h: [] });
|
|
249
|
+
return r >= t.__.length && t.__.push({}), t.__[r];
|
|
250
|
+
}
|
|
251
|
+
function A(r) {
|
|
252
|
+
return de = 1, An(tn, r);
|
|
253
|
+
}
|
|
254
|
+
function An(r, e, t) {
|
|
255
|
+
var n = rt(pe++, 2);
|
|
256
|
+
if (n.t = r, !n.__c && (n.__ = [tn(void 0, e), function(a) {
|
|
257
|
+
var c = n.__N ? n.__N[0] : n.__[0], d = n.t(c, a);
|
|
258
|
+
c !== d && (n.__N = [d, n.__[1]], n.__c.setState({}));
|
|
259
|
+
}], n.__c = T, !T.__f)) {
|
|
260
|
+
var o = function(a, c, d) {
|
|
261
|
+
if (!n.__c.__H) return !0;
|
|
262
|
+
var u = n.__c.__H.__.filter(function(h) {
|
|
263
|
+
return h.__c;
|
|
264
|
+
});
|
|
265
|
+
if (u.every(function(h) {
|
|
266
|
+
return !h.__N;
|
|
267
|
+
})) return !s || s.call(this, a, c, d);
|
|
268
|
+
var l = n.__c.props !== a;
|
|
269
|
+
return u.some(function(h) {
|
|
270
|
+
if (h.__N) {
|
|
271
|
+
var f = h.__[0];
|
|
272
|
+
h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (l = !0);
|
|
273
|
+
}
|
|
274
|
+
}), s && s.call(this, a, c, d) || l;
|
|
275
|
+
};
|
|
276
|
+
T.__f = !0;
|
|
277
|
+
var s = T.shouldComponentUpdate, i = T.componentWillUpdate;
|
|
278
|
+
T.componentWillUpdate = function(a, c, d) {
|
|
279
|
+
if (this.__e) {
|
|
280
|
+
var u = s;
|
|
281
|
+
s = void 0, o(a, c, d), s = u;
|
|
282
|
+
}
|
|
283
|
+
i && i.call(this, a, c, d);
|
|
284
|
+
}, T.shouldComponentUpdate = o;
|
|
285
|
+
}
|
|
286
|
+
return n.__N || n.__;
|
|
287
|
+
}
|
|
288
|
+
function We(r, e) {
|
|
289
|
+
var t = rt(pe++, 3);
|
|
290
|
+
!C.__s && en(t.__H, e) && (t.__ = r, t.u = e, T.__H.__h.push(t));
|
|
291
|
+
}
|
|
292
|
+
function me(r) {
|
|
293
|
+
return de = 5, Xt(function() {
|
|
294
|
+
return { current: r };
|
|
295
|
+
}, []);
|
|
296
|
+
}
|
|
297
|
+
function Xt(r, e) {
|
|
298
|
+
var t = rt(pe++, 7);
|
|
299
|
+
return en(t.__H, e) && (t.__ = r(), t.__H = e, t.__h = r), t.__;
|
|
300
|
+
}
|
|
301
|
+
function zt(r, e) {
|
|
302
|
+
return de = 8, Xt(function() {
|
|
303
|
+
return r;
|
|
304
|
+
}, e);
|
|
305
|
+
}
|
|
306
|
+
function Pn() {
|
|
307
|
+
for (var r; r = Kt.shift(); ) {
|
|
308
|
+
var e = r.__H;
|
|
309
|
+
if (r.__P && e) try {
|
|
310
|
+
e.__h.some(Se), e.__h.some(Ge), e.__h = [];
|
|
311
|
+
} catch (t) {
|
|
312
|
+
e.__h = [], C.__e(t, r.__v);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
C.__b = function(r) {
|
|
317
|
+
T = null, vt && vt(r);
|
|
318
|
+
}, C.__ = function(r, e) {
|
|
319
|
+
r && e.__k && e.__k.__m && (r.__m = e.__k.__m), It && It(r, e);
|
|
320
|
+
}, C.__r = function(r) {
|
|
321
|
+
St && St(r), pe = 0;
|
|
322
|
+
var e = (T = r.__c).__H;
|
|
323
|
+
e && (je === T ? (e.__h = [], T.__h = [], e.__.some(function(t) {
|
|
324
|
+
t.__N && (t.__ = t.__N), t.u = t.__N = void 0;
|
|
325
|
+
})) : (e.__h.some(Se), e.__h.some(Ge), e.__h = [], pe = 0)), je = T;
|
|
326
|
+
}, C.diffed = function(r) {
|
|
327
|
+
$t && $t(r);
|
|
328
|
+
var e = r.__c;
|
|
329
|
+
e && e.__H && (e.__H.__h.length && (Kt.push(e) !== 1 && yt === C.requestAnimationFrame || ((yt = C.requestAnimationFrame) || Mn)(Pn)), e.__H.__.some(function(t) {
|
|
330
|
+
t.u && (t.__H = t.u), t.u = void 0;
|
|
331
|
+
})), je = T = null;
|
|
332
|
+
}, C.__c = function(r, e) {
|
|
333
|
+
e.some(function(t) {
|
|
334
|
+
try {
|
|
335
|
+
t.__h.some(Se), t.__h = t.__h.filter(function(n) {
|
|
336
|
+
return !n.__ || Ge(n);
|
|
337
|
+
});
|
|
338
|
+
} catch (n) {
|
|
339
|
+
e.some(function(o) {
|
|
340
|
+
o.__h && (o.__h = []);
|
|
341
|
+
}), e = [], C.__e(n, t.__v);
|
|
342
|
+
}
|
|
343
|
+
}), Tt && Tt(r, e);
|
|
344
|
+
}, C.unmount = function(r) {
|
|
345
|
+
Ct && Ct(r);
|
|
346
|
+
var e, t = r.__c;
|
|
347
|
+
t && t.__H && (t.__H.__.some(function(n) {
|
|
348
|
+
try {
|
|
349
|
+
Se(n);
|
|
350
|
+
} catch (o) {
|
|
351
|
+
e = o;
|
|
352
|
+
}
|
|
353
|
+
}), t.__H = void 0, e && C.__e(e, t.__v));
|
|
354
|
+
};
|
|
355
|
+
var Rt = typeof requestAnimationFrame == "function";
|
|
356
|
+
function Mn(r) {
|
|
357
|
+
var e, t = function() {
|
|
358
|
+
clearTimeout(n), Rt && cancelAnimationFrame(e), setTimeout(r);
|
|
359
|
+
}, n = setTimeout(t, 35);
|
|
360
|
+
Rt && (e = requestAnimationFrame(t));
|
|
361
|
+
}
|
|
362
|
+
function Se(r) {
|
|
363
|
+
var e = T, t = r.__c;
|
|
364
|
+
typeof t == "function" && (r.__c = void 0, t()), T = e;
|
|
365
|
+
}
|
|
366
|
+
function Ge(r) {
|
|
367
|
+
var e = T;
|
|
368
|
+
r.__c = r.__(), T = e;
|
|
369
|
+
}
|
|
370
|
+
function en(r, e) {
|
|
371
|
+
return !r || r.length !== e.length || e.some(function(t, n) {
|
|
372
|
+
return t !== r[n];
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function tn(r, e) {
|
|
376
|
+
return typeof e == "function" ? e(r) : e;
|
|
377
|
+
}
|
|
378
|
+
function st() {
|
|
379
|
+
return {
|
|
380
|
+
async: !1,
|
|
381
|
+
breaks: !1,
|
|
382
|
+
extensions: null,
|
|
383
|
+
gfm: !0,
|
|
384
|
+
hooks: null,
|
|
385
|
+
pedantic: !1,
|
|
386
|
+
renderer: null,
|
|
387
|
+
silent: !1,
|
|
388
|
+
tokenizer: null,
|
|
389
|
+
walkTokens: null
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
let G = st();
|
|
393
|
+
function nn(r) {
|
|
394
|
+
G = r;
|
|
395
|
+
}
|
|
396
|
+
const rn = /[&<>"']/, Ln = new RegExp(rn.source, "g"), sn = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, Hn = new RegExp(sn.source, "g"), Dn = {
|
|
397
|
+
"&": "&",
|
|
398
|
+
"<": "<",
|
|
399
|
+
">": ">",
|
|
400
|
+
'"': """,
|
|
401
|
+
"'": "'"
|
|
402
|
+
}, Et = (r) => Dn[r];
|
|
403
|
+
function P(r, e) {
|
|
404
|
+
if (e) {
|
|
405
|
+
if (rn.test(r))
|
|
406
|
+
return r.replace(Ln, Et);
|
|
407
|
+
} else if (sn.test(r))
|
|
408
|
+
return r.replace(Hn, Et);
|
|
409
|
+
return r;
|
|
410
|
+
}
|
|
411
|
+
const Nn = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
412
|
+
function On(r) {
|
|
413
|
+
return r.replace(Nn, (e, t) => (t = t.toLowerCase(), t === "colon" ? ":" : t.charAt(0) === "#" ? t.charAt(1) === "x" ? String.fromCharCode(parseInt(t.substring(2), 16)) : String.fromCharCode(+t.substring(1)) : ""));
|
|
414
|
+
}
|
|
415
|
+
const Un = /(^|[^\[])\^/g;
|
|
416
|
+
function y(r, e) {
|
|
417
|
+
let t = typeof r == "string" ? r : r.source;
|
|
418
|
+
e = e || "";
|
|
419
|
+
const n = {
|
|
420
|
+
replace: (o, s) => {
|
|
421
|
+
let i = typeof s == "string" ? s : s.source;
|
|
422
|
+
return i = i.replace(Un, "$1"), t = t.replace(o, i), n;
|
|
423
|
+
},
|
|
424
|
+
getRegex: () => new RegExp(t, e)
|
|
425
|
+
};
|
|
426
|
+
return n;
|
|
427
|
+
}
|
|
428
|
+
function Bt(r) {
|
|
429
|
+
try {
|
|
430
|
+
r = encodeURI(r).replace(/%25/g, "%");
|
|
431
|
+
} catch {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
return r;
|
|
435
|
+
}
|
|
436
|
+
const ce = { exec: () => null };
|
|
437
|
+
function At(r, e) {
|
|
438
|
+
const t = r.replace(/\|/g, (s, i, a) => {
|
|
439
|
+
let c = !1, d = i;
|
|
440
|
+
for (; --d >= 0 && a[d] === "\\"; )
|
|
441
|
+
c = !c;
|
|
442
|
+
return c ? "|" : " |";
|
|
443
|
+
}), n = t.split(/ \|/);
|
|
444
|
+
let o = 0;
|
|
445
|
+
if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), e)
|
|
446
|
+
if (n.length > e)
|
|
447
|
+
n.splice(e);
|
|
448
|
+
else
|
|
449
|
+
for (; n.length < e; )
|
|
450
|
+
n.push("");
|
|
451
|
+
for (; o < n.length; o++)
|
|
452
|
+
n[o] = n[o].trim().replace(/\\\|/g, "|");
|
|
453
|
+
return n;
|
|
454
|
+
}
|
|
455
|
+
function be(r, e, t) {
|
|
456
|
+
const n = r.length;
|
|
457
|
+
if (n === 0)
|
|
458
|
+
return "";
|
|
459
|
+
let o = 0;
|
|
460
|
+
for (; o < n && r.charAt(n - o - 1) === e; )
|
|
461
|
+
o++;
|
|
462
|
+
return r.slice(0, n - o);
|
|
463
|
+
}
|
|
464
|
+
function jn(r, e) {
|
|
465
|
+
if (r.indexOf(e[1]) === -1)
|
|
466
|
+
return -1;
|
|
467
|
+
let t = 0;
|
|
468
|
+
for (let n = 0; n < r.length; n++)
|
|
469
|
+
if (r[n] === "\\")
|
|
470
|
+
n++;
|
|
471
|
+
else if (r[n] === e[0])
|
|
472
|
+
t++;
|
|
473
|
+
else if (r[n] === e[1] && (t--, t < 0))
|
|
474
|
+
return n;
|
|
475
|
+
return -1;
|
|
476
|
+
}
|
|
477
|
+
function Pt(r, e, t, n) {
|
|
478
|
+
const o = e.href, s = e.title ? P(e.title) : null, i = r[1].replace(/\\([\[\]])/g, "$1");
|
|
479
|
+
if (r[0].charAt(0) !== "!") {
|
|
480
|
+
n.state.inLink = !0;
|
|
481
|
+
const a = {
|
|
482
|
+
type: "link",
|
|
483
|
+
raw: t,
|
|
484
|
+
href: o,
|
|
485
|
+
title: s,
|
|
486
|
+
text: i,
|
|
487
|
+
tokens: n.inlineTokens(i)
|
|
488
|
+
};
|
|
489
|
+
return n.state.inLink = !1, a;
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
type: "image",
|
|
493
|
+
raw: t,
|
|
494
|
+
href: o,
|
|
495
|
+
title: s,
|
|
496
|
+
text: P(i)
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function Wn(r, e) {
|
|
500
|
+
const t = r.match(/^(\s+)(?:```)/);
|
|
501
|
+
if (t === null)
|
|
502
|
+
return e;
|
|
503
|
+
const n = t[1];
|
|
504
|
+
return e.split(`
|
|
505
|
+
`).map((o) => {
|
|
506
|
+
const s = o.match(/^\s+/);
|
|
507
|
+
if (s === null)
|
|
508
|
+
return o;
|
|
509
|
+
const [i] = s;
|
|
510
|
+
return i.length >= n.length ? o.slice(n.length) : o;
|
|
511
|
+
}).join(`
|
|
512
|
+
`);
|
|
513
|
+
}
|
|
514
|
+
class ze {
|
|
515
|
+
options;
|
|
516
|
+
rules;
|
|
517
|
+
// set by the lexer
|
|
518
|
+
lexer;
|
|
519
|
+
// set by the lexer
|
|
520
|
+
constructor(e) {
|
|
521
|
+
this.options = e || G;
|
|
522
|
+
}
|
|
523
|
+
space(e) {
|
|
524
|
+
const t = this.rules.block.newline.exec(e);
|
|
525
|
+
if (t && t[0].length > 0)
|
|
526
|
+
return {
|
|
527
|
+
type: "space",
|
|
528
|
+
raw: t[0]
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
code(e) {
|
|
532
|
+
const t = this.rules.block.code.exec(e);
|
|
533
|
+
if (t) {
|
|
534
|
+
const n = t[0].replace(/^ {1,4}/gm, "");
|
|
535
|
+
return {
|
|
536
|
+
type: "code",
|
|
537
|
+
raw: t[0],
|
|
538
|
+
codeBlockStyle: "indented",
|
|
539
|
+
text: this.options.pedantic ? n : be(n, `
|
|
540
|
+
`)
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
fences(e) {
|
|
545
|
+
const t = this.rules.block.fences.exec(e);
|
|
546
|
+
if (t) {
|
|
547
|
+
const n = t[0], o = Wn(n, t[3] || "");
|
|
548
|
+
return {
|
|
549
|
+
type: "code",
|
|
550
|
+
raw: n,
|
|
551
|
+
lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
|
|
552
|
+
text: o
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
heading(e) {
|
|
557
|
+
const t = this.rules.block.heading.exec(e);
|
|
558
|
+
if (t) {
|
|
559
|
+
let n = t[2].trim();
|
|
560
|
+
if (/#$/.test(n)) {
|
|
561
|
+
const o = be(n, "#");
|
|
562
|
+
(this.options.pedantic || !o || / $/.test(o)) && (n = o.trim());
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
type: "heading",
|
|
566
|
+
raw: t[0],
|
|
567
|
+
depth: t[1].length,
|
|
568
|
+
text: n,
|
|
569
|
+
tokens: this.lexer.inline(n)
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
hr(e) {
|
|
574
|
+
const t = this.rules.block.hr.exec(e);
|
|
575
|
+
if (t)
|
|
576
|
+
return {
|
|
577
|
+
type: "hr",
|
|
578
|
+
raw: t[0]
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
blockquote(e) {
|
|
582
|
+
const t = this.rules.block.blockquote.exec(e);
|
|
583
|
+
if (t) {
|
|
584
|
+
let n = t[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, `
|
|
585
|
+
$1`);
|
|
586
|
+
n = be(n.replace(/^ *>[ \t]?/gm, ""), `
|
|
587
|
+
`);
|
|
588
|
+
const o = this.lexer.state.top;
|
|
589
|
+
this.lexer.state.top = !0;
|
|
590
|
+
const s = this.lexer.blockTokens(n);
|
|
591
|
+
return this.lexer.state.top = o, {
|
|
592
|
+
type: "blockquote",
|
|
593
|
+
raw: t[0],
|
|
594
|
+
tokens: s,
|
|
595
|
+
text: n
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
list(e) {
|
|
600
|
+
let t = this.rules.block.list.exec(e);
|
|
601
|
+
if (t) {
|
|
602
|
+
let n = t[1].trim();
|
|
603
|
+
const o = n.length > 1, s = {
|
|
604
|
+
type: "list",
|
|
605
|
+
raw: "",
|
|
606
|
+
ordered: o,
|
|
607
|
+
start: o ? +n.slice(0, -1) : "",
|
|
608
|
+
loose: !1,
|
|
609
|
+
items: []
|
|
610
|
+
};
|
|
611
|
+
n = o ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = o ? n : "[*+-]");
|
|
612
|
+
const i = new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);
|
|
613
|
+
let a = "", c = "", d = !1;
|
|
614
|
+
for (; e; ) {
|
|
615
|
+
let u = !1;
|
|
616
|
+
if (!(t = i.exec(e)) || this.rules.block.hr.test(e))
|
|
617
|
+
break;
|
|
618
|
+
a = t[0], e = e.substring(a.length);
|
|
619
|
+
let l = t[2].split(`
|
|
620
|
+
`, 1)[0].replace(/^\t+/, (b) => " ".repeat(3 * b.length)), h = e.split(`
|
|
621
|
+
`, 1)[0], f = 0;
|
|
622
|
+
this.options.pedantic ? (f = 2, c = l.trimStart()) : (f = t[2].search(/[^ ]/), f = f > 4 ? 1 : f, c = l.slice(f), f += t[1].length);
|
|
623
|
+
let x = !1;
|
|
624
|
+
if (!l && /^ *$/.test(h) && (a += h + `
|
|
625
|
+
`, e = e.substring(h.length + 1), u = !0), !u) {
|
|
626
|
+
const b = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), m = new RegExp(`^ {0,${Math.min(3, f - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), I = new RegExp(`^ {0,${Math.min(3, f - 1)}}(?:\`\`\`|~~~)`), R = new RegExp(`^ {0,${Math.min(3, f - 1)}}#`);
|
|
627
|
+
for (; e; ) {
|
|
628
|
+
const B = e.split(`
|
|
629
|
+
`, 1)[0];
|
|
630
|
+
if (h = B, this.options.pedantic && (h = h.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), I.test(h) || R.test(h) || b.test(h) || m.test(e))
|
|
631
|
+
break;
|
|
632
|
+
if (h.search(/[^ ]/) >= f || !h.trim())
|
|
633
|
+
c += `
|
|
634
|
+
` + h.slice(f);
|
|
635
|
+
else {
|
|
636
|
+
if (x || l.search(/[^ ]/) >= 4 || I.test(l) || R.test(l) || m.test(l))
|
|
637
|
+
break;
|
|
638
|
+
c += `
|
|
639
|
+
` + h;
|
|
640
|
+
}
|
|
641
|
+
!x && !h.trim() && (x = !0), a += B + `
|
|
642
|
+
`, e = e.substring(B.length + 1), l = h.slice(f);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
s.loose || (d ? s.loose = !0 : /\n *\n *$/.test(a) && (d = !0));
|
|
646
|
+
let v = null, w;
|
|
647
|
+
this.options.gfm && (v = /^\[[ xX]\] /.exec(c), v && (w = v[0] !== "[ ] ", c = c.replace(/^\[[ xX]\] +/, ""))), s.items.push({
|
|
648
|
+
type: "list_item",
|
|
649
|
+
raw: a,
|
|
650
|
+
task: !!v,
|
|
651
|
+
checked: w,
|
|
652
|
+
loose: !1,
|
|
653
|
+
text: c,
|
|
654
|
+
tokens: []
|
|
655
|
+
}), s.raw += a;
|
|
656
|
+
}
|
|
657
|
+
s.items[s.items.length - 1].raw = a.trimEnd(), s.items[s.items.length - 1].text = c.trimEnd(), s.raw = s.raw.trimEnd();
|
|
658
|
+
for (let u = 0; u < s.items.length; u++)
|
|
659
|
+
if (this.lexer.state.top = !1, s.items[u].tokens = this.lexer.blockTokens(s.items[u].text, []), !s.loose) {
|
|
660
|
+
const l = s.items[u].tokens.filter((f) => f.type === "space"), h = l.length > 0 && l.some((f) => /\n.*\n/.test(f.raw));
|
|
661
|
+
s.loose = h;
|
|
662
|
+
}
|
|
663
|
+
if (s.loose)
|
|
664
|
+
for (let u = 0; u < s.items.length; u++)
|
|
665
|
+
s.items[u].loose = !0;
|
|
666
|
+
return s;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
html(e) {
|
|
670
|
+
const t = this.rules.block.html.exec(e);
|
|
671
|
+
if (t)
|
|
672
|
+
return {
|
|
673
|
+
type: "html",
|
|
674
|
+
block: !0,
|
|
675
|
+
raw: t[0],
|
|
676
|
+
pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
|
|
677
|
+
text: t[0]
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
def(e) {
|
|
681
|
+
const t = this.rules.block.def.exec(e);
|
|
682
|
+
if (t) {
|
|
683
|
+
const n = t[1].toLowerCase().replace(/\s+/g, " "), o = t[2] ? t[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", s = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
|
|
684
|
+
return {
|
|
685
|
+
type: "def",
|
|
686
|
+
tag: n,
|
|
687
|
+
raw: t[0],
|
|
688
|
+
href: o,
|
|
689
|
+
title: s
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
table(e) {
|
|
694
|
+
const t = this.rules.block.table.exec(e);
|
|
695
|
+
if (!t || !/[:|]/.test(t[2]))
|
|
696
|
+
return;
|
|
697
|
+
const n = At(t[1]), o = t[2].replace(/^\||\| *$/g, "").split("|"), s = t[3] && t[3].trim() ? t[3].replace(/\n[ \t]*$/, "").split(`
|
|
698
|
+
`) : [], i = {
|
|
699
|
+
type: "table",
|
|
700
|
+
raw: t[0],
|
|
701
|
+
header: [],
|
|
702
|
+
align: [],
|
|
703
|
+
rows: []
|
|
704
|
+
};
|
|
705
|
+
if (n.length === o.length) {
|
|
706
|
+
for (const a of o)
|
|
707
|
+
/^ *-+: *$/.test(a) ? i.align.push("right") : /^ *:-+: *$/.test(a) ? i.align.push("center") : /^ *:-+ *$/.test(a) ? i.align.push("left") : i.align.push(null);
|
|
708
|
+
for (const a of n)
|
|
709
|
+
i.header.push({
|
|
710
|
+
text: a,
|
|
711
|
+
tokens: this.lexer.inline(a)
|
|
712
|
+
});
|
|
713
|
+
for (const a of s)
|
|
714
|
+
i.rows.push(At(a, i.header.length).map((c) => ({
|
|
715
|
+
text: c,
|
|
716
|
+
tokens: this.lexer.inline(c)
|
|
717
|
+
})));
|
|
718
|
+
return i;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
lheading(e) {
|
|
722
|
+
const t = this.rules.block.lheading.exec(e);
|
|
723
|
+
if (t)
|
|
724
|
+
return {
|
|
725
|
+
type: "heading",
|
|
726
|
+
raw: t[0],
|
|
727
|
+
depth: t[2].charAt(0) === "=" ? 1 : 2,
|
|
728
|
+
text: t[1],
|
|
729
|
+
tokens: this.lexer.inline(t[1])
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
paragraph(e) {
|
|
733
|
+
const t = this.rules.block.paragraph.exec(e);
|
|
734
|
+
if (t) {
|
|
735
|
+
const n = t[1].charAt(t[1].length - 1) === `
|
|
736
|
+
` ? t[1].slice(0, -1) : t[1];
|
|
737
|
+
return {
|
|
738
|
+
type: "paragraph",
|
|
739
|
+
raw: t[0],
|
|
740
|
+
text: n,
|
|
741
|
+
tokens: this.lexer.inline(n)
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
text(e) {
|
|
746
|
+
const t = this.rules.block.text.exec(e);
|
|
747
|
+
if (t)
|
|
748
|
+
return {
|
|
749
|
+
type: "text",
|
|
750
|
+
raw: t[0],
|
|
751
|
+
text: t[0],
|
|
752
|
+
tokens: this.lexer.inline(t[0])
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
escape(e) {
|
|
756
|
+
const t = this.rules.inline.escape.exec(e);
|
|
757
|
+
if (t)
|
|
758
|
+
return {
|
|
759
|
+
type: "escape",
|
|
760
|
+
raw: t[0],
|
|
761
|
+
text: P(t[1])
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
tag(e) {
|
|
765
|
+
const t = this.rules.inline.tag.exec(e);
|
|
766
|
+
if (t)
|
|
767
|
+
return !this.lexer.state.inLink && /^<a /i.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
|
|
768
|
+
type: "html",
|
|
769
|
+
raw: t[0],
|
|
770
|
+
inLink: this.lexer.state.inLink,
|
|
771
|
+
inRawBlock: this.lexer.state.inRawBlock,
|
|
772
|
+
block: !1,
|
|
773
|
+
text: t[0]
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
link(e) {
|
|
777
|
+
const t = this.rules.inline.link.exec(e);
|
|
778
|
+
if (t) {
|
|
779
|
+
const n = t[2].trim();
|
|
780
|
+
if (!this.options.pedantic && /^</.test(n)) {
|
|
781
|
+
if (!/>$/.test(n))
|
|
782
|
+
return;
|
|
783
|
+
const i = be(n.slice(0, -1), "\\");
|
|
784
|
+
if ((n.length - i.length) % 2 === 0)
|
|
785
|
+
return;
|
|
786
|
+
} else {
|
|
787
|
+
const i = jn(t[2], "()");
|
|
788
|
+
if (i > -1) {
|
|
789
|
+
const c = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
|
|
790
|
+
t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, c).trim(), t[3] = "";
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
let o = t[2], s = "";
|
|
794
|
+
if (this.options.pedantic) {
|
|
795
|
+
const i = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);
|
|
796
|
+
i && (o = i[1], s = i[3]);
|
|
797
|
+
} else
|
|
798
|
+
s = t[3] ? t[3].slice(1, -1) : "";
|
|
799
|
+
return o = o.trim(), /^</.test(o) && (this.options.pedantic && !/>$/.test(n) ? o = o.slice(1) : o = o.slice(1, -1)), Pt(t, {
|
|
800
|
+
href: o && o.replace(this.rules.inline.anyPunctuation, "$1"),
|
|
801
|
+
title: s && s.replace(this.rules.inline.anyPunctuation, "$1")
|
|
802
|
+
}, t[0], this.lexer);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
reflink(e, t) {
|
|
806
|
+
let n;
|
|
807
|
+
if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
|
|
808
|
+
const o = (n[2] || n[1]).replace(/\s+/g, " "), s = t[o.toLowerCase()];
|
|
809
|
+
if (!s) {
|
|
810
|
+
const i = n[0].charAt(0);
|
|
811
|
+
return {
|
|
812
|
+
type: "text",
|
|
813
|
+
raw: i,
|
|
814
|
+
text: i
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
return Pt(n, s, n[0], this.lexer);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
emStrong(e, t, n = "") {
|
|
821
|
+
let o = this.rules.inline.emStrongLDelim.exec(e);
|
|
822
|
+
if (!o || o[3] && n.match(/[\p{L}\p{N}]/u))
|
|
823
|
+
return;
|
|
824
|
+
if (!(o[1] || o[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
|
|
825
|
+
const i = [...o[0]].length - 1;
|
|
826
|
+
let a, c, d = i, u = 0;
|
|
827
|
+
const l = o[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
|
|
828
|
+
for (l.lastIndex = 0, t = t.slice(-1 * e.length + i); (o = l.exec(t)) != null; ) {
|
|
829
|
+
if (a = o[1] || o[2] || o[3] || o[4] || o[5] || o[6], !a)
|
|
830
|
+
continue;
|
|
831
|
+
if (c = [...a].length, o[3] || o[4]) {
|
|
832
|
+
d += c;
|
|
833
|
+
continue;
|
|
834
|
+
} else if ((o[5] || o[6]) && i % 3 && !((i + c) % 3)) {
|
|
835
|
+
u += c;
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
if (d -= c, d > 0)
|
|
839
|
+
continue;
|
|
840
|
+
c = Math.min(c, c + d + u);
|
|
841
|
+
const h = [...o[0]][0].length, f = e.slice(0, i + o.index + h + c);
|
|
842
|
+
if (Math.min(i, c) % 2) {
|
|
843
|
+
const v = f.slice(1, -1);
|
|
844
|
+
return {
|
|
845
|
+
type: "em",
|
|
846
|
+
raw: f,
|
|
847
|
+
text: v,
|
|
848
|
+
tokens: this.lexer.inlineTokens(v)
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
const x = f.slice(2, -2);
|
|
852
|
+
return {
|
|
853
|
+
type: "strong",
|
|
854
|
+
raw: f,
|
|
855
|
+
text: x,
|
|
856
|
+
tokens: this.lexer.inlineTokens(x)
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
codespan(e) {
|
|
862
|
+
const t = this.rules.inline.code.exec(e);
|
|
863
|
+
if (t) {
|
|
864
|
+
let n = t[2].replace(/\n/g, " ");
|
|
865
|
+
const o = /[^ ]/.test(n), s = /^ /.test(n) && / $/.test(n);
|
|
866
|
+
return o && s && (n = n.substring(1, n.length - 1)), n = P(n, !0), {
|
|
867
|
+
type: "codespan",
|
|
868
|
+
raw: t[0],
|
|
869
|
+
text: n
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
br(e) {
|
|
874
|
+
const t = this.rules.inline.br.exec(e);
|
|
875
|
+
if (t)
|
|
876
|
+
return {
|
|
877
|
+
type: "br",
|
|
878
|
+
raw: t[0]
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
del(e) {
|
|
882
|
+
const t = this.rules.inline.del.exec(e);
|
|
883
|
+
if (t)
|
|
884
|
+
return {
|
|
885
|
+
type: "del",
|
|
886
|
+
raw: t[0],
|
|
887
|
+
text: t[2],
|
|
888
|
+
tokens: this.lexer.inlineTokens(t[2])
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
autolink(e) {
|
|
892
|
+
const t = this.rules.inline.autolink.exec(e);
|
|
893
|
+
if (t) {
|
|
894
|
+
let n, o;
|
|
895
|
+
return t[2] === "@" ? (n = P(t[1]), o = "mailto:" + n) : (n = P(t[1]), o = n), {
|
|
896
|
+
type: "link",
|
|
897
|
+
raw: t[0],
|
|
898
|
+
text: n,
|
|
899
|
+
href: o,
|
|
900
|
+
tokens: [
|
|
901
|
+
{
|
|
902
|
+
type: "text",
|
|
903
|
+
raw: n,
|
|
904
|
+
text: n
|
|
905
|
+
}
|
|
906
|
+
]
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
url(e) {
|
|
911
|
+
let t;
|
|
912
|
+
if (t = this.rules.inline.url.exec(e)) {
|
|
913
|
+
let n, o;
|
|
914
|
+
if (t[2] === "@")
|
|
915
|
+
n = P(t[0]), o = "mailto:" + n;
|
|
916
|
+
else {
|
|
917
|
+
let s;
|
|
918
|
+
do
|
|
919
|
+
s = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
|
|
920
|
+
while (s !== t[0]);
|
|
921
|
+
n = P(t[0]), t[1] === "www." ? o = "http://" + t[0] : o = t[0];
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
type: "link",
|
|
925
|
+
raw: t[0],
|
|
926
|
+
text: n,
|
|
927
|
+
href: o,
|
|
928
|
+
tokens: [
|
|
929
|
+
{
|
|
930
|
+
type: "text",
|
|
931
|
+
raw: n,
|
|
932
|
+
text: n
|
|
933
|
+
}
|
|
934
|
+
]
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
inlineText(e) {
|
|
939
|
+
const t = this.rules.inline.text.exec(e);
|
|
940
|
+
if (t) {
|
|
941
|
+
let n;
|
|
942
|
+
return this.lexer.state.inRawBlock ? n = t[0] : n = P(t[0]), {
|
|
943
|
+
type: "text",
|
|
944
|
+
raw: t[0],
|
|
945
|
+
text: n
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const qn = /^(?: *(?:\n|$))+/, Fn = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, Zn = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, ue = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Vn = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, on = /(?:[*+-]|\d{1,9}[.)])/, an = y(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, on).replace(/blockCode/g, / {4}/).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/).getRegex(), ot = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Qn = /^[^\n]+/, it = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Yn = y(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", it).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Gn = y(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, on).getRegex(), Pe = "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", at = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Jn = 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", at).replace("tag", Pe).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ln = y(ot).replace("hr", ue).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", Pe).getRegex(), Kn = y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ln).getRegex(), lt = {
|
|
951
|
+
blockquote: Kn,
|
|
952
|
+
code: Fn,
|
|
953
|
+
def: Yn,
|
|
954
|
+
fences: Zn,
|
|
955
|
+
heading: Vn,
|
|
956
|
+
hr: ue,
|
|
957
|
+
html: Jn,
|
|
958
|
+
lheading: an,
|
|
959
|
+
list: Gn,
|
|
960
|
+
newline: qn,
|
|
961
|
+
paragraph: ln,
|
|
962
|
+
table: ce,
|
|
963
|
+
text: Qn
|
|
964
|
+
}, Mt = y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", ue).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\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", Pe).getRegex(), Xn = {
|
|
965
|
+
...lt,
|
|
966
|
+
table: Mt,
|
|
967
|
+
paragraph: y(ot).replace("hr", ue).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Mt).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", Pe).getRegex()
|
|
968
|
+
}, er = {
|
|
969
|
+
...lt,
|
|
970
|
+
html: y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", at).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(),
|
|
971
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
972
|
+
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
973
|
+
fences: ce,
|
|
974
|
+
// fences not supported
|
|
975
|
+
lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
976
|
+
paragraph: y(ot).replace("hr", ue).replace("heading", ` *#{1,6} *[^
|
|
977
|
+
]`).replace("lheading", an).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
|
|
978
|
+
}, cn = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, tr = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, pn = /^( {2,}|\\)\n(?!\s*$)/, nr = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, he = "\\p{P}\\p{S}", rr = y(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, he).getRegex(), sr = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g, or = y(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, he).getRegex(), ir = y("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, he).getRegex(), ar = y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, he).getRegex(), lr = y(/\\([punct])/, "gu").replace(/punct/g, he).getRegex(), cr = 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(), pr = y(at).replace("(?:-->|$)", "-->").getRegex(), dr = 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", pr).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Re = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, ur = y(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", Re).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), dn = y(/^!?\[(label)\]\[(ref)\]/).replace("label", Re).replace("ref", it).getRegex(), un = y(/^!?\[(ref)\](?:\[\])?/).replace("ref", it).getRegex(), hr = y("reflink|nolink(?!\\()", "g").replace("reflink", dn).replace("nolink", un).getRegex(), ct = {
|
|
979
|
+
_backpedal: ce,
|
|
980
|
+
// only used for GFM url
|
|
981
|
+
anyPunctuation: lr,
|
|
982
|
+
autolink: cr,
|
|
983
|
+
blockSkip: sr,
|
|
984
|
+
br: pn,
|
|
985
|
+
code: tr,
|
|
986
|
+
del: ce,
|
|
987
|
+
emStrongLDelim: or,
|
|
988
|
+
emStrongRDelimAst: ir,
|
|
989
|
+
emStrongRDelimUnd: ar,
|
|
990
|
+
escape: cn,
|
|
991
|
+
link: ur,
|
|
992
|
+
nolink: un,
|
|
993
|
+
punctuation: rr,
|
|
994
|
+
reflink: dn,
|
|
995
|
+
reflinkSearch: hr,
|
|
996
|
+
tag: dr,
|
|
997
|
+
text: nr,
|
|
998
|
+
url: ce
|
|
999
|
+
}, fr = {
|
|
1000
|
+
...ct,
|
|
1001
|
+
link: y(/^!?\[(label)\]\((.*?)\)/).replace("label", Re).getRegex(),
|
|
1002
|
+
reflink: y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Re).getRegex()
|
|
1003
|
+
}, Je = {
|
|
1004
|
+
...ct,
|
|
1005
|
+
escape: y(cn).replace("])", "~|])").getRegex(),
|
|
1006
|
+
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(),
|
|
1007
|
+
_backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
|
|
1008
|
+
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
1009
|
+
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
1010
|
+
}, gr = {
|
|
1011
|
+
...Je,
|
|
1012
|
+
br: y(pn).replace("{2,}", "*").getRegex(),
|
|
1013
|
+
text: y(Je.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
|
|
1014
|
+
}, xe = {
|
|
1015
|
+
normal: lt,
|
|
1016
|
+
gfm: Xn,
|
|
1017
|
+
pedantic: er
|
|
1018
|
+
}, se = {
|
|
1019
|
+
normal: ct,
|
|
1020
|
+
gfm: Je,
|
|
1021
|
+
breaks: gr,
|
|
1022
|
+
pedantic: fr
|
|
1023
|
+
};
|
|
1024
|
+
class O {
|
|
1025
|
+
tokens;
|
|
1026
|
+
options;
|
|
1027
|
+
state;
|
|
1028
|
+
tokenizer;
|
|
1029
|
+
inlineQueue;
|
|
1030
|
+
constructor(e) {
|
|
1031
|
+
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || G, this.options.tokenizer = this.options.tokenizer || new ze(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
|
|
1032
|
+
inLink: !1,
|
|
1033
|
+
inRawBlock: !1,
|
|
1034
|
+
top: !0
|
|
1035
|
+
};
|
|
1036
|
+
const t = {
|
|
1037
|
+
block: xe.normal,
|
|
1038
|
+
inline: se.normal
|
|
1039
|
+
};
|
|
1040
|
+
this.options.pedantic ? (t.block = xe.pedantic, t.inline = se.pedantic) : this.options.gfm && (t.block = xe.gfm, this.options.breaks ? t.inline = se.breaks : t.inline = se.gfm), this.tokenizer.rules = t;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Expose Rules
|
|
1044
|
+
*/
|
|
1045
|
+
static get rules() {
|
|
1046
|
+
return {
|
|
1047
|
+
block: xe,
|
|
1048
|
+
inline: se
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Static Lex Method
|
|
1053
|
+
*/
|
|
1054
|
+
static lex(e, t) {
|
|
1055
|
+
return new O(t).lex(e);
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Static Lex Inline Method
|
|
1059
|
+
*/
|
|
1060
|
+
static lexInline(e, t) {
|
|
1061
|
+
return new O(t).inlineTokens(e);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Preprocessing
|
|
1065
|
+
*/
|
|
1066
|
+
lex(e) {
|
|
1067
|
+
e = e.replace(/\r\n|\r/g, `
|
|
1068
|
+
`), this.blockTokens(e, this.tokens);
|
|
1069
|
+
for (let t = 0; t < this.inlineQueue.length; t++) {
|
|
1070
|
+
const n = this.inlineQueue[t];
|
|
1071
|
+
this.inlineTokens(n.src, n.tokens);
|
|
1072
|
+
}
|
|
1073
|
+
return this.inlineQueue = [], this.tokens;
|
|
1074
|
+
}
|
|
1075
|
+
blockTokens(e, t = []) {
|
|
1076
|
+
this.options.pedantic ? e = e.replace(/\t/g, " ").replace(/^ +$/gm, "") : e = e.replace(/^( *)(\t+)/gm, (a, c, d) => c + " ".repeat(d.length));
|
|
1077
|
+
let n, o, s, i;
|
|
1078
|
+
for (; e; )
|
|
1079
|
+
if (!(this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((a) => (n = a.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
|
|
1080
|
+
if (n = this.tokenizer.space(e)) {
|
|
1081
|
+
e = e.substring(n.raw.length), n.raw.length === 1 && t.length > 0 ? t[t.length - 1].raw += `
|
|
1082
|
+
` : t.push(n);
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
if (n = this.tokenizer.code(e)) {
|
|
1086
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && (o.type === "paragraph" || o.type === "text") ? (o.raw += `
|
|
1087
|
+
` + n.raw, o.text += `
|
|
1088
|
+
` + n.text, this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n);
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
if (n = this.tokenizer.fences(e)) {
|
|
1092
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
if (n = this.tokenizer.heading(e)) {
|
|
1096
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1097
|
+
continue;
|
|
1098
|
+
}
|
|
1099
|
+
if (n = this.tokenizer.hr(e)) {
|
|
1100
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
if (n = this.tokenizer.blockquote(e)) {
|
|
1104
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
if (n = this.tokenizer.list(e)) {
|
|
1108
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
if (n = this.tokenizer.html(e)) {
|
|
1112
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
if (n = this.tokenizer.def(e)) {
|
|
1116
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && (o.type === "paragraph" || o.type === "text") ? (o.raw += `
|
|
1117
|
+
` + n.raw, o.text += `
|
|
1118
|
+
` + n.raw, this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = {
|
|
1119
|
+
href: n.href,
|
|
1120
|
+
title: n.title
|
|
1121
|
+
});
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
if (n = this.tokenizer.table(e)) {
|
|
1125
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
if (n = this.tokenizer.lheading(e)) {
|
|
1129
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (s = e, this.options.extensions && this.options.extensions.startBlock) {
|
|
1133
|
+
let a = 1 / 0;
|
|
1134
|
+
const c = e.slice(1);
|
|
1135
|
+
let d;
|
|
1136
|
+
this.options.extensions.startBlock.forEach((u) => {
|
|
1137
|
+
d = u.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (a = Math.min(a, d));
|
|
1138
|
+
}), a < 1 / 0 && a >= 0 && (s = e.substring(0, a + 1));
|
|
1139
|
+
}
|
|
1140
|
+
if (this.state.top && (n = this.tokenizer.paragraph(s))) {
|
|
1141
|
+
o = t[t.length - 1], i && o.type === "paragraph" ? (o.raw += `
|
|
1142
|
+
` + n.raw, o.text += `
|
|
1143
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n), i = s.length !== e.length, e = e.substring(n.raw.length);
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if (n = this.tokenizer.text(e)) {
|
|
1147
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && o.type === "text" ? (o.raw += `
|
|
1148
|
+
` + n.raw, o.text += `
|
|
1149
|
+
` + n.text, this.inlineQueue.pop(), this.inlineQueue[this.inlineQueue.length - 1].src = o.text) : t.push(n);
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (e) {
|
|
1153
|
+
const a = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1154
|
+
if (this.options.silent) {
|
|
1155
|
+
console.error(a);
|
|
1156
|
+
break;
|
|
1157
|
+
} else
|
|
1158
|
+
throw new Error(a);
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
return this.state.top = !0, t;
|
|
1162
|
+
}
|
|
1163
|
+
inline(e, t = []) {
|
|
1164
|
+
return this.inlineQueue.push({ src: e, tokens: t }), t;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Lexing/Compiling
|
|
1168
|
+
*/
|
|
1169
|
+
inlineTokens(e, t = []) {
|
|
1170
|
+
let n, o, s, i = e, a, c, d;
|
|
1171
|
+
if (this.tokens.links) {
|
|
1172
|
+
const u = Object.keys(this.tokens.links);
|
|
1173
|
+
if (u.length > 0)
|
|
1174
|
+
for (; (a = this.tokenizer.rules.inline.reflinkSearch.exec(i)) != null; )
|
|
1175
|
+
u.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
|
|
1176
|
+
}
|
|
1177
|
+
for (; (a = this.tokenizer.rules.inline.blockSkip.exec(i)) != null; )
|
|
1178
|
+
i = i.slice(0, a.index) + "[" + "a".repeat(a[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
1179
|
+
for (; (a = this.tokenizer.rules.inline.anyPunctuation.exec(i)) != null; )
|
|
1180
|
+
i = i.slice(0, a.index) + "++" + i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
|
|
1181
|
+
for (; e; )
|
|
1182
|
+
if (c || (d = ""), c = !1, !(this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((u) => (n = u.call({ lexer: this }, e, t)) ? (e = e.substring(n.raw.length), t.push(n), !0) : !1))) {
|
|
1183
|
+
if (n = this.tokenizer.escape(e)) {
|
|
1184
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1185
|
+
continue;
|
|
1186
|
+
}
|
|
1187
|
+
if (n = this.tokenizer.tag(e)) {
|
|
1188
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && n.type === "text" && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1189
|
+
continue;
|
|
1190
|
+
}
|
|
1191
|
+
if (n = this.tokenizer.link(e)) {
|
|
1192
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
if (n = this.tokenizer.reflink(e, this.tokens.links)) {
|
|
1196
|
+
e = e.substring(n.raw.length), o = t[t.length - 1], o && n.type === "text" && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1199
|
+
if (n = this.tokenizer.emStrong(e, i, d)) {
|
|
1200
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
if (n = this.tokenizer.codespan(e)) {
|
|
1204
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (n = this.tokenizer.br(e)) {
|
|
1208
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1209
|
+
continue;
|
|
1210
|
+
}
|
|
1211
|
+
if (n = this.tokenizer.del(e)) {
|
|
1212
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
if (n = this.tokenizer.autolink(e)) {
|
|
1216
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1219
|
+
if (!this.state.inLink && (n = this.tokenizer.url(e))) {
|
|
1220
|
+
e = e.substring(n.raw.length), t.push(n);
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
if (s = e, this.options.extensions && this.options.extensions.startInline) {
|
|
1224
|
+
let u = 1 / 0;
|
|
1225
|
+
const l = e.slice(1);
|
|
1226
|
+
let h;
|
|
1227
|
+
this.options.extensions.startInline.forEach((f) => {
|
|
1228
|
+
h = f.call({ lexer: this }, l), typeof h == "number" && h >= 0 && (u = Math.min(u, h));
|
|
1229
|
+
}), u < 1 / 0 && u >= 0 && (s = e.substring(0, u + 1));
|
|
1230
|
+
}
|
|
1231
|
+
if (n = this.tokenizer.inlineText(s)) {
|
|
1232
|
+
e = e.substring(n.raw.length), n.raw.slice(-1) !== "_" && (d = n.raw.slice(-1)), c = !0, o = t[t.length - 1], o && o.type === "text" ? (o.raw += n.raw, o.text += n.text) : t.push(n);
|
|
1233
|
+
continue;
|
|
1234
|
+
}
|
|
1235
|
+
if (e) {
|
|
1236
|
+
const u = "Infinite loop on byte: " + e.charCodeAt(0);
|
|
1237
|
+
if (this.options.silent) {
|
|
1238
|
+
console.error(u);
|
|
1239
|
+
break;
|
|
1240
|
+
} else
|
|
1241
|
+
throw new Error(u);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
return t;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
class Ee {
|
|
1248
|
+
options;
|
|
1249
|
+
constructor(e) {
|
|
1250
|
+
this.options = e || G;
|
|
1251
|
+
}
|
|
1252
|
+
code(e, t, n) {
|
|
1253
|
+
const o = (t || "").match(/^\S*/)?.[0];
|
|
1254
|
+
return e = e.replace(/\n$/, "") + `
|
|
1255
|
+
`, o ? '<pre><code class="language-' + P(o) + '">' + (n ? e : P(e, !0)) + `</code></pre>
|
|
1256
|
+
` : "<pre><code>" + (n ? e : P(e, !0)) + `</code></pre>
|
|
1257
|
+
`;
|
|
1258
|
+
}
|
|
1259
|
+
blockquote(e) {
|
|
1260
|
+
return `<blockquote>
|
|
1261
|
+
${e}</blockquote>
|
|
1262
|
+
`;
|
|
1263
|
+
}
|
|
1264
|
+
html(e, t) {
|
|
1265
|
+
return e;
|
|
1266
|
+
}
|
|
1267
|
+
heading(e, t, n) {
|
|
1268
|
+
return `<h${t}>${e}</h${t}>
|
|
1269
|
+
`;
|
|
1270
|
+
}
|
|
1271
|
+
hr() {
|
|
1272
|
+
return `<hr>
|
|
1273
|
+
`;
|
|
1274
|
+
}
|
|
1275
|
+
list(e, t, n) {
|
|
1276
|
+
const o = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
|
|
1277
|
+
return "<" + o + s + `>
|
|
1278
|
+
` + e + "</" + o + `>
|
|
1279
|
+
`;
|
|
1280
|
+
}
|
|
1281
|
+
listitem(e, t, n) {
|
|
1282
|
+
return `<li>${e}</li>
|
|
1283
|
+
`;
|
|
1284
|
+
}
|
|
1285
|
+
checkbox(e) {
|
|
1286
|
+
return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
|
|
1287
|
+
}
|
|
1288
|
+
paragraph(e) {
|
|
1289
|
+
return `<p>${e}</p>
|
|
1290
|
+
`;
|
|
1291
|
+
}
|
|
1292
|
+
table(e, t) {
|
|
1293
|
+
return t && (t = `<tbody>${t}</tbody>`), `<table>
|
|
1294
|
+
<thead>
|
|
1295
|
+
` + e + `</thead>
|
|
1296
|
+
` + t + `</table>
|
|
1297
|
+
`;
|
|
1298
|
+
}
|
|
1299
|
+
tablerow(e) {
|
|
1300
|
+
return `<tr>
|
|
1301
|
+
${e}</tr>
|
|
1302
|
+
`;
|
|
1303
|
+
}
|
|
1304
|
+
tablecell(e, t) {
|
|
1305
|
+
const n = t.header ? "th" : "td";
|
|
1306
|
+
return (t.align ? `<${n} align="${t.align}">` : `<${n}>`) + e + `</${n}>
|
|
1307
|
+
`;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* span level renderer
|
|
1311
|
+
*/
|
|
1312
|
+
strong(e) {
|
|
1313
|
+
return `<strong>${e}</strong>`;
|
|
1314
|
+
}
|
|
1315
|
+
em(e) {
|
|
1316
|
+
return `<em>${e}</em>`;
|
|
1317
|
+
}
|
|
1318
|
+
codespan(e) {
|
|
1319
|
+
return `<code>${e}</code>`;
|
|
1320
|
+
}
|
|
1321
|
+
br() {
|
|
1322
|
+
return "<br>";
|
|
1323
|
+
}
|
|
1324
|
+
del(e) {
|
|
1325
|
+
return `<del>${e}</del>`;
|
|
1326
|
+
}
|
|
1327
|
+
link(e, t, n) {
|
|
1328
|
+
const o = Bt(e);
|
|
1329
|
+
if (o === null)
|
|
1330
|
+
return n;
|
|
1331
|
+
e = o;
|
|
1332
|
+
let s = '<a href="' + e + '"';
|
|
1333
|
+
return t && (s += ' title="' + t + '"'), s += ">" + n + "</a>", s;
|
|
1334
|
+
}
|
|
1335
|
+
image(e, t, n) {
|
|
1336
|
+
const o = Bt(e);
|
|
1337
|
+
if (o === null)
|
|
1338
|
+
return n;
|
|
1339
|
+
e = o;
|
|
1340
|
+
let s = `<img src="${e}" alt="${n}"`;
|
|
1341
|
+
return t && (s += ` title="${t}"`), s += ">", s;
|
|
1342
|
+
}
|
|
1343
|
+
text(e) {
|
|
1344
|
+
return e;
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
class pt {
|
|
1348
|
+
// no need for block level renderers
|
|
1349
|
+
strong(e) {
|
|
1350
|
+
return e;
|
|
1351
|
+
}
|
|
1352
|
+
em(e) {
|
|
1353
|
+
return e;
|
|
1354
|
+
}
|
|
1355
|
+
codespan(e) {
|
|
1356
|
+
return e;
|
|
1357
|
+
}
|
|
1358
|
+
del(e) {
|
|
1359
|
+
return e;
|
|
1360
|
+
}
|
|
1361
|
+
html(e) {
|
|
1362
|
+
return e;
|
|
1363
|
+
}
|
|
1364
|
+
text(e) {
|
|
1365
|
+
return e;
|
|
1366
|
+
}
|
|
1367
|
+
link(e, t, n) {
|
|
1368
|
+
return "" + n;
|
|
1369
|
+
}
|
|
1370
|
+
image(e, t, n) {
|
|
1371
|
+
return "" + n;
|
|
1372
|
+
}
|
|
1373
|
+
br() {
|
|
1374
|
+
return "";
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
class U {
|
|
1378
|
+
options;
|
|
1379
|
+
renderer;
|
|
1380
|
+
textRenderer;
|
|
1381
|
+
constructor(e) {
|
|
1382
|
+
this.options = e || G, this.options.renderer = this.options.renderer || new Ee(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new pt();
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Static Parse Method
|
|
1386
|
+
*/
|
|
1387
|
+
static parse(e, t) {
|
|
1388
|
+
return new U(t).parse(e);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Static Parse Inline Method
|
|
1392
|
+
*/
|
|
1393
|
+
static parseInline(e, t) {
|
|
1394
|
+
return new U(t).parseInline(e);
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Parse Loop
|
|
1398
|
+
*/
|
|
1399
|
+
parse(e, t = !0) {
|
|
1400
|
+
let n = "";
|
|
1401
|
+
for (let o = 0; o < e.length; o++) {
|
|
1402
|
+
const s = e[o];
|
|
1403
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[s.type]) {
|
|
1404
|
+
const i = s, a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
|
|
1405
|
+
if (a !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(i.type)) {
|
|
1406
|
+
n += a || "";
|
|
1407
|
+
continue;
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
switch (s.type) {
|
|
1411
|
+
case "space":
|
|
1412
|
+
continue;
|
|
1413
|
+
case "hr": {
|
|
1414
|
+
n += this.renderer.hr();
|
|
1415
|
+
continue;
|
|
1416
|
+
}
|
|
1417
|
+
case "heading": {
|
|
1418
|
+
const i = s;
|
|
1419
|
+
n += this.renderer.heading(this.parseInline(i.tokens), i.depth, On(this.parseInline(i.tokens, this.textRenderer)));
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
case "code": {
|
|
1423
|
+
const i = s;
|
|
1424
|
+
n += this.renderer.code(i.text, i.lang, !!i.escaped);
|
|
1425
|
+
continue;
|
|
1426
|
+
}
|
|
1427
|
+
case "table": {
|
|
1428
|
+
const i = s;
|
|
1429
|
+
let a = "", c = "";
|
|
1430
|
+
for (let u = 0; u < i.header.length; u++)
|
|
1431
|
+
c += this.renderer.tablecell(this.parseInline(i.header[u].tokens), { header: !0, align: i.align[u] });
|
|
1432
|
+
a += this.renderer.tablerow(c);
|
|
1433
|
+
let d = "";
|
|
1434
|
+
for (let u = 0; u < i.rows.length; u++) {
|
|
1435
|
+
const l = i.rows[u];
|
|
1436
|
+
c = "";
|
|
1437
|
+
for (let h = 0; h < l.length; h++)
|
|
1438
|
+
c += this.renderer.tablecell(this.parseInline(l[h].tokens), { header: !1, align: i.align[h] });
|
|
1439
|
+
d += this.renderer.tablerow(c);
|
|
1440
|
+
}
|
|
1441
|
+
n += this.renderer.table(a, d);
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
case "blockquote": {
|
|
1445
|
+
const i = s, a = this.parse(i.tokens);
|
|
1446
|
+
n += this.renderer.blockquote(a);
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
case "list": {
|
|
1450
|
+
const i = s, a = i.ordered, c = i.start, d = i.loose;
|
|
1451
|
+
let u = "";
|
|
1452
|
+
for (let l = 0; l < i.items.length; l++) {
|
|
1453
|
+
const h = i.items[l], f = h.checked, x = h.task;
|
|
1454
|
+
let v = "";
|
|
1455
|
+
if (h.task) {
|
|
1456
|
+
const w = this.renderer.checkbox(!!f);
|
|
1457
|
+
d ? h.tokens.length > 0 && h.tokens[0].type === "paragraph" ? (h.tokens[0].text = w + " " + h.tokens[0].text, h.tokens[0].tokens && h.tokens[0].tokens.length > 0 && h.tokens[0].tokens[0].type === "text" && (h.tokens[0].tokens[0].text = w + " " + h.tokens[0].tokens[0].text)) : h.tokens.unshift({
|
|
1458
|
+
type: "text",
|
|
1459
|
+
text: w + " "
|
|
1460
|
+
}) : v += w + " ";
|
|
1461
|
+
}
|
|
1462
|
+
v += this.parse(h.tokens, d), u += this.renderer.listitem(v, x, !!f);
|
|
1463
|
+
}
|
|
1464
|
+
n += this.renderer.list(u, a, c);
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
case "html": {
|
|
1468
|
+
const i = s;
|
|
1469
|
+
n += this.renderer.html(i.text, i.block);
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
case "paragraph": {
|
|
1473
|
+
const i = s;
|
|
1474
|
+
n += this.renderer.paragraph(this.parseInline(i.tokens));
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1477
|
+
case "text": {
|
|
1478
|
+
let i = s, a = i.tokens ? this.parseInline(i.tokens) : i.text;
|
|
1479
|
+
for (; o + 1 < e.length && e[o + 1].type === "text"; )
|
|
1480
|
+
i = e[++o], a += `
|
|
1481
|
+
` + (i.tokens ? this.parseInline(i.tokens) : i.text);
|
|
1482
|
+
n += t ? this.renderer.paragraph(a) : a;
|
|
1483
|
+
continue;
|
|
1484
|
+
}
|
|
1485
|
+
default: {
|
|
1486
|
+
const i = 'Token with "' + s.type + '" type was not found.';
|
|
1487
|
+
if (this.options.silent)
|
|
1488
|
+
return console.error(i), "";
|
|
1489
|
+
throw new Error(i);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
return n;
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Parse Inline Tokens
|
|
1497
|
+
*/
|
|
1498
|
+
parseInline(e, t) {
|
|
1499
|
+
t = t || this.renderer;
|
|
1500
|
+
let n = "";
|
|
1501
|
+
for (let o = 0; o < e.length; o++) {
|
|
1502
|
+
const s = e[o];
|
|
1503
|
+
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[s.type]) {
|
|
1504
|
+
const i = this.options.extensions.renderers[s.type].call({ parser: this }, s);
|
|
1505
|
+
if (i !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(s.type)) {
|
|
1506
|
+
n += i || "";
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
switch (s.type) {
|
|
1511
|
+
case "escape": {
|
|
1512
|
+
const i = s;
|
|
1513
|
+
n += t.text(i.text);
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
case "html": {
|
|
1517
|
+
const i = s;
|
|
1518
|
+
n += t.html(i.text);
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
case "link": {
|
|
1522
|
+
const i = s;
|
|
1523
|
+
n += t.link(i.href, i.title, this.parseInline(i.tokens, t));
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
case "image": {
|
|
1527
|
+
const i = s;
|
|
1528
|
+
n += t.image(i.href, i.title, i.text);
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
case "strong": {
|
|
1532
|
+
const i = s;
|
|
1533
|
+
n += t.strong(this.parseInline(i.tokens, t));
|
|
1534
|
+
break;
|
|
1535
|
+
}
|
|
1536
|
+
case "em": {
|
|
1537
|
+
const i = s;
|
|
1538
|
+
n += t.em(this.parseInline(i.tokens, t));
|
|
1539
|
+
break;
|
|
1540
|
+
}
|
|
1541
|
+
case "codespan": {
|
|
1542
|
+
const i = s;
|
|
1543
|
+
n += t.codespan(i.text);
|
|
1544
|
+
break;
|
|
1545
|
+
}
|
|
1546
|
+
case "br": {
|
|
1547
|
+
n += t.br();
|
|
1548
|
+
break;
|
|
1549
|
+
}
|
|
1550
|
+
case "del": {
|
|
1551
|
+
const i = s;
|
|
1552
|
+
n += t.del(this.parseInline(i.tokens, t));
|
|
1553
|
+
break;
|
|
1554
|
+
}
|
|
1555
|
+
case "text": {
|
|
1556
|
+
const i = s;
|
|
1557
|
+
n += t.text(i.text);
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
default: {
|
|
1561
|
+
const i = 'Token with "' + s.type + '" type was not found.';
|
|
1562
|
+
if (this.options.silent)
|
|
1563
|
+
return console.error(i), "";
|
|
1564
|
+
throw new Error(i);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
return n;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
class $e {
|
|
1572
|
+
options;
|
|
1573
|
+
constructor(e) {
|
|
1574
|
+
this.options = e || G;
|
|
1575
|
+
}
|
|
1576
|
+
static passThroughHooks = /* @__PURE__ */ new Set([
|
|
1577
|
+
"preprocess",
|
|
1578
|
+
"postprocess",
|
|
1579
|
+
"processAllTokens"
|
|
1580
|
+
]);
|
|
1581
|
+
/**
|
|
1582
|
+
* Process markdown before marked
|
|
1583
|
+
*/
|
|
1584
|
+
preprocess(e) {
|
|
1585
|
+
return e;
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Process HTML after marked is finished
|
|
1589
|
+
*/
|
|
1590
|
+
postprocess(e) {
|
|
1591
|
+
return e;
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Process all tokens before walk tokens
|
|
1595
|
+
*/
|
|
1596
|
+
processAllTokens(e) {
|
|
1597
|
+
return e;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
class _r {
|
|
1601
|
+
defaults = st();
|
|
1602
|
+
options = this.setOptions;
|
|
1603
|
+
parse = this.#e(O.lex, U.parse);
|
|
1604
|
+
parseInline = this.#e(O.lexInline, U.parseInline);
|
|
1605
|
+
Parser = U;
|
|
1606
|
+
Renderer = Ee;
|
|
1607
|
+
TextRenderer = pt;
|
|
1608
|
+
Lexer = O;
|
|
1609
|
+
Tokenizer = ze;
|
|
1610
|
+
Hooks = $e;
|
|
1611
|
+
constructor(...e) {
|
|
1612
|
+
this.use(...e);
|
|
1613
|
+
}
|
|
1614
|
+
/**
|
|
1615
|
+
* Run callback for every token
|
|
1616
|
+
*/
|
|
1617
|
+
walkTokens(e, t) {
|
|
1618
|
+
let n = [];
|
|
1619
|
+
for (const o of e)
|
|
1620
|
+
switch (n = n.concat(t.call(this, o)), o.type) {
|
|
1621
|
+
case "table": {
|
|
1622
|
+
const s = o;
|
|
1623
|
+
for (const i of s.header)
|
|
1624
|
+
n = n.concat(this.walkTokens(i.tokens, t));
|
|
1625
|
+
for (const i of s.rows)
|
|
1626
|
+
for (const a of i)
|
|
1627
|
+
n = n.concat(this.walkTokens(a.tokens, t));
|
|
1628
|
+
break;
|
|
1629
|
+
}
|
|
1630
|
+
case "list": {
|
|
1631
|
+
const s = o;
|
|
1632
|
+
n = n.concat(this.walkTokens(s.items, t));
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1635
|
+
default: {
|
|
1636
|
+
const s = o;
|
|
1637
|
+
this.defaults.extensions?.childTokens?.[s.type] ? this.defaults.extensions.childTokens[s.type].forEach((i) => {
|
|
1638
|
+
const a = s[i].flat(1 / 0);
|
|
1639
|
+
n = n.concat(this.walkTokens(a, t));
|
|
1640
|
+
}) : s.tokens && (n = n.concat(this.walkTokens(s.tokens, t)));
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
return n;
|
|
1644
|
+
}
|
|
1645
|
+
use(...e) {
|
|
1646
|
+
const t = this.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
1647
|
+
return e.forEach((n) => {
|
|
1648
|
+
const o = { ...n };
|
|
1649
|
+
if (o.async = this.defaults.async || o.async || !1, n.extensions && (n.extensions.forEach((s) => {
|
|
1650
|
+
if (!s.name)
|
|
1651
|
+
throw new Error("extension name required");
|
|
1652
|
+
if ("renderer" in s) {
|
|
1653
|
+
const i = t.renderers[s.name];
|
|
1654
|
+
i ? t.renderers[s.name] = function(...a) {
|
|
1655
|
+
let c = s.renderer.apply(this, a);
|
|
1656
|
+
return c === !1 && (c = i.apply(this, a)), c;
|
|
1657
|
+
} : t.renderers[s.name] = s.renderer;
|
|
1658
|
+
}
|
|
1659
|
+
if ("tokenizer" in s) {
|
|
1660
|
+
if (!s.level || s.level !== "block" && s.level !== "inline")
|
|
1661
|
+
throw new Error("extension level must be 'block' or 'inline'");
|
|
1662
|
+
const i = t[s.level];
|
|
1663
|
+
i ? i.unshift(s.tokenizer) : t[s.level] = [s.tokenizer], s.start && (s.level === "block" ? t.startBlock ? t.startBlock.push(s.start) : t.startBlock = [s.start] : s.level === "inline" && (t.startInline ? t.startInline.push(s.start) : t.startInline = [s.start]));
|
|
1664
|
+
}
|
|
1665
|
+
"childTokens" in s && s.childTokens && (t.childTokens[s.name] = s.childTokens);
|
|
1666
|
+
}), o.extensions = t), n.renderer) {
|
|
1667
|
+
const s = this.defaults.renderer || new Ee(this.defaults);
|
|
1668
|
+
for (const i in n.renderer) {
|
|
1669
|
+
if (!(i in s))
|
|
1670
|
+
throw new Error(`renderer '${i}' does not exist`);
|
|
1671
|
+
if (i === "options")
|
|
1672
|
+
continue;
|
|
1673
|
+
const a = i, c = n.renderer[a], d = s[a];
|
|
1674
|
+
s[a] = (...u) => {
|
|
1675
|
+
let l = c.apply(s, u);
|
|
1676
|
+
return l === !1 && (l = d.apply(s, u)), l || "";
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
o.renderer = s;
|
|
1680
|
+
}
|
|
1681
|
+
if (n.tokenizer) {
|
|
1682
|
+
const s = this.defaults.tokenizer || new ze(this.defaults);
|
|
1683
|
+
for (const i in n.tokenizer) {
|
|
1684
|
+
if (!(i in s))
|
|
1685
|
+
throw new Error(`tokenizer '${i}' does not exist`);
|
|
1686
|
+
if (["options", "rules", "lexer"].includes(i))
|
|
1687
|
+
continue;
|
|
1688
|
+
const a = i, c = n.tokenizer[a], d = s[a];
|
|
1689
|
+
s[a] = (...u) => {
|
|
1690
|
+
let l = c.apply(s, u);
|
|
1691
|
+
return l === !1 && (l = d.apply(s, u)), l;
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
o.tokenizer = s;
|
|
1695
|
+
}
|
|
1696
|
+
if (n.hooks) {
|
|
1697
|
+
const s = this.defaults.hooks || new $e();
|
|
1698
|
+
for (const i in n.hooks) {
|
|
1699
|
+
if (!(i in s))
|
|
1700
|
+
throw new Error(`hook '${i}' does not exist`);
|
|
1701
|
+
if (i === "options")
|
|
1702
|
+
continue;
|
|
1703
|
+
const a = i, c = n.hooks[a], d = s[a];
|
|
1704
|
+
$e.passThroughHooks.has(i) ? s[a] = (u) => {
|
|
1705
|
+
if (this.defaults.async)
|
|
1706
|
+
return Promise.resolve(c.call(s, u)).then((h) => d.call(s, h));
|
|
1707
|
+
const l = c.call(s, u);
|
|
1708
|
+
return d.call(s, l);
|
|
1709
|
+
} : s[a] = (...u) => {
|
|
1710
|
+
let l = c.apply(s, u);
|
|
1711
|
+
return l === !1 && (l = d.apply(s, u)), l;
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
o.hooks = s;
|
|
1715
|
+
}
|
|
1716
|
+
if (n.walkTokens) {
|
|
1717
|
+
const s = this.defaults.walkTokens, i = n.walkTokens;
|
|
1718
|
+
o.walkTokens = function(a) {
|
|
1719
|
+
let c = [];
|
|
1720
|
+
return c.push(i.call(this, a)), s && (c = c.concat(s.call(this, a))), c;
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
this.defaults = { ...this.defaults, ...o };
|
|
1724
|
+
}), this;
|
|
1725
|
+
}
|
|
1726
|
+
setOptions(e) {
|
|
1727
|
+
return this.defaults = { ...this.defaults, ...e }, this;
|
|
1728
|
+
}
|
|
1729
|
+
lexer(e, t) {
|
|
1730
|
+
return O.lex(e, t ?? this.defaults);
|
|
1731
|
+
}
|
|
1732
|
+
parser(e, t) {
|
|
1733
|
+
return U.parse(e, t ?? this.defaults);
|
|
1734
|
+
}
|
|
1735
|
+
#e(e, t) {
|
|
1736
|
+
return (n, o) => {
|
|
1737
|
+
const s = { ...o }, i = { ...this.defaults, ...s };
|
|
1738
|
+
this.defaults.async === !0 && s.async === !1 && (i.silent || console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."), i.async = !0);
|
|
1739
|
+
const a = this.#t(!!i.silent, !!i.async);
|
|
1740
|
+
if (typeof n > "u" || n === null)
|
|
1741
|
+
return a(new Error("marked(): input parameter is undefined or null"));
|
|
1742
|
+
if (typeof n != "string")
|
|
1743
|
+
return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
|
|
1744
|
+
if (i.hooks && (i.hooks.options = i), i.async)
|
|
1745
|
+
return Promise.resolve(i.hooks ? i.hooks.preprocess(n) : n).then((c) => e(c, i)).then((c) => i.hooks ? i.hooks.processAllTokens(c) : c).then((c) => i.walkTokens ? Promise.all(this.walkTokens(c, i.walkTokens)).then(() => c) : c).then((c) => t(c, i)).then((c) => i.hooks ? i.hooks.postprocess(c) : c).catch(a);
|
|
1746
|
+
try {
|
|
1747
|
+
i.hooks && (n = i.hooks.preprocess(n));
|
|
1748
|
+
let c = e(n, i);
|
|
1749
|
+
i.hooks && (c = i.hooks.processAllTokens(c)), i.walkTokens && this.walkTokens(c, i.walkTokens);
|
|
1750
|
+
let d = t(c, i);
|
|
1751
|
+
return i.hooks && (d = i.hooks.postprocess(d)), d;
|
|
1752
|
+
} catch (c) {
|
|
1753
|
+
return a(c);
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
#t(e, t) {
|
|
1758
|
+
return (n) => {
|
|
1759
|
+
if (n.message += `
|
|
1760
|
+
Please report this to https://github.com/markedjs/marked.`, e) {
|
|
1761
|
+
const o = "<p>An error occurred:</p><pre>" + P(n.message + "", !0) + "</pre>";
|
|
1762
|
+
return t ? Promise.resolve(o) : o;
|
|
1763
|
+
}
|
|
1764
|
+
if (t)
|
|
1765
|
+
return Promise.reject(n);
|
|
1766
|
+
throw n;
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
const Y = new _r();
|
|
1771
|
+
function k(r, e) {
|
|
1772
|
+
return Y.parse(r, e);
|
|
1773
|
+
}
|
|
1774
|
+
k.options = k.setOptions = function(r) {
|
|
1775
|
+
return Y.setOptions(r), k.defaults = Y.defaults, nn(k.defaults), k;
|
|
1776
|
+
};
|
|
1777
|
+
k.getDefaults = st;
|
|
1778
|
+
k.defaults = G;
|
|
1779
|
+
k.use = function(...r) {
|
|
1780
|
+
return Y.use(...r), k.defaults = Y.defaults, nn(k.defaults), k;
|
|
1781
|
+
};
|
|
1782
|
+
k.walkTokens = function(r, e) {
|
|
1783
|
+
return Y.walkTokens(r, e);
|
|
1784
|
+
};
|
|
1785
|
+
k.parseInline = Y.parseInline;
|
|
1786
|
+
k.Parser = U;
|
|
1787
|
+
k.parser = U.parse;
|
|
1788
|
+
k.Renderer = Ee;
|
|
1789
|
+
k.TextRenderer = pt;
|
|
1790
|
+
k.Lexer = O;
|
|
1791
|
+
k.lexer = O.lex;
|
|
1792
|
+
k.Tokenizer = ze;
|
|
1793
|
+
k.Hooks = $e;
|
|
1794
|
+
k.parse = k;
|
|
1795
|
+
k.options;
|
|
1796
|
+
k.setOptions;
|
|
1797
|
+
k.use;
|
|
1798
|
+
k.walkTokens;
|
|
1799
|
+
k.parseInline;
|
|
1800
|
+
U.parse;
|
|
1801
|
+
O.lex;
|
|
1802
|
+
function Me(r, e, t) {
|
|
1803
|
+
const n = { ...r.headers };
|
|
1804
|
+
return t && (n["Content-Type"] = "application/json"), e && (n["X-Session-Id"] = e), n;
|
|
1805
|
+
}
|
|
1806
|
+
async function mr(r, e) {
|
|
1807
|
+
const t = await fetch(`${r.apiUrl}/chat`, {
|
|
1808
|
+
method: "POST",
|
|
1809
|
+
headers: Me(r, e.sessionId, !0),
|
|
1810
|
+
body: JSON.stringify({
|
|
1811
|
+
message: e.message,
|
|
1812
|
+
session_id: e.sessionId,
|
|
1813
|
+
user_role: e.userRole
|
|
1814
|
+
})
|
|
1815
|
+
}), n = await t.json();
|
|
1816
|
+
if (!t.ok)
|
|
1817
|
+
throw new Error(n?.error || "Something went wrong. Please try again.");
|
|
1818
|
+
return n;
|
|
1819
|
+
}
|
|
1820
|
+
async function Lt(r, e) {
|
|
1821
|
+
try {
|
|
1822
|
+
const t = await fetch(
|
|
1823
|
+
`${r.apiUrl}/history?session_id=${encodeURIComponent(e)}`,
|
|
1824
|
+
{ headers: Me(r, e, !1) }
|
|
1825
|
+
);
|
|
1826
|
+
if (!t.ok) return [];
|
|
1827
|
+
const n = await t.json();
|
|
1828
|
+
return Array.isArray(n?.messages) ? n.messages : [];
|
|
1829
|
+
} catch {
|
|
1830
|
+
return [];
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
function br(r, e) {
|
|
1834
|
+
return `${r.apiUrl.replace(/^http/i, "ws")}/ws/transcribe?lang=${encodeURIComponent(e)}`;
|
|
1835
|
+
}
|
|
1836
|
+
async function xr(r, e, t, n) {
|
|
1837
|
+
if (!("ReadableStream" in globalThis)) {
|
|
1838
|
+
const c = await mr(r, e);
|
|
1839
|
+
t(c.response ?? ""), n(c.session_id ?? e.sessionId, c.sources ?? []);
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
const o = await fetch(`${r.apiUrl}/chat/stream`, {
|
|
1843
|
+
method: "POST",
|
|
1844
|
+
headers: Me(r, e.sessionId, !0),
|
|
1845
|
+
body: JSON.stringify({
|
|
1846
|
+
message: e.message,
|
|
1847
|
+
session_id: e.sessionId,
|
|
1848
|
+
user_role: e.userRole
|
|
1849
|
+
})
|
|
1850
|
+
});
|
|
1851
|
+
if (!o.ok || !o.body)
|
|
1852
|
+
throw new Error(`Stream request failed: ${o.status}`);
|
|
1853
|
+
const s = o.body.getReader(), i = new TextDecoder();
|
|
1854
|
+
let a = "";
|
|
1855
|
+
for (; ; ) {
|
|
1856
|
+
const { done: c, value: d } = await s.read();
|
|
1857
|
+
if (c) break;
|
|
1858
|
+
a += i.decode(d, { stream: !0 });
|
|
1859
|
+
const u = a.split(`
|
|
1860
|
+
`);
|
|
1861
|
+
a = u.pop() ?? "";
|
|
1862
|
+
for (const l of u) {
|
|
1863
|
+
if (!l.startsWith("data:")) continue;
|
|
1864
|
+
const h = l.slice(5).trim();
|
|
1865
|
+
if (!h) continue;
|
|
1866
|
+
let f;
|
|
1867
|
+
try {
|
|
1868
|
+
f = JSON.parse(h);
|
|
1869
|
+
} catch {
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
if (typeof f.token == "string")
|
|
1873
|
+
t(f.token);
|
|
1874
|
+
else if (f.done === !0)
|
|
1875
|
+
n(
|
|
1876
|
+
typeof f.session_id == "string" ? f.session_id : e.sessionId,
|
|
1877
|
+
Array.isArray(f.sources) ? f.sources : []
|
|
1878
|
+
);
|
|
1879
|
+
else if (typeof f.error == "string")
|
|
1880
|
+
throw new Error(f.error);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
async function kr(r) {
|
|
1885
|
+
const e = await fetch(`${r.apiUrl}/sync`, {
|
|
1886
|
+
method: "POST",
|
|
1887
|
+
headers: Me(r, null, !0)
|
|
1888
|
+
});
|
|
1889
|
+
if (!e.ok) throw new Error("Sync failed");
|
|
1890
|
+
return (await e.json())?.status ?? "Sync completed";
|
|
1891
|
+
}
|
|
1892
|
+
const ke = /* @__PURE__ */ new Map();
|
|
1893
|
+
function qe() {
|
|
1894
|
+
try {
|
|
1895
|
+
return window.localStorage;
|
|
1896
|
+
} catch {
|
|
1897
|
+
return null;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
const L = {
|
|
1901
|
+
get(r) {
|
|
1902
|
+
try {
|
|
1903
|
+
const e = qe();
|
|
1904
|
+
return e ? e.getItem(r) : ke.get(r) ?? null;
|
|
1905
|
+
} catch {
|
|
1906
|
+
return ke.get(r) ?? null;
|
|
1907
|
+
}
|
|
1908
|
+
},
|
|
1909
|
+
set(r, e) {
|
|
1910
|
+
ke.set(r, e);
|
|
1911
|
+
try {
|
|
1912
|
+
qe()?.setItem(r, e);
|
|
1913
|
+
} catch {
|
|
1914
|
+
}
|
|
1915
|
+
},
|
|
1916
|
+
remove(r) {
|
|
1917
|
+
ke.delete(r);
|
|
1918
|
+
try {
|
|
1919
|
+
qe()?.removeItem(r);
|
|
1920
|
+
} catch {
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
let wr = 1;
|
|
1925
|
+
function yr() {
|
|
1926
|
+
const [r, e] = A([]), t = zt((o) => {
|
|
1927
|
+
e((s) => s.filter((i) => i.id !== o));
|
|
1928
|
+
}, []), n = zt(
|
|
1929
|
+
(o, s = "info", i = 3e3) => {
|
|
1930
|
+
const a = wr++;
|
|
1931
|
+
return e((c) => [...c, { id: a, message: o, type: s }]), i > 0 && setTimeout(() => t(a), i), a;
|
|
1932
|
+
},
|
|
1933
|
+
[t]
|
|
1934
|
+
);
|
|
1935
|
+
return { toasts: r, show: n, dismiss: t };
|
|
1936
|
+
}
|
|
1937
|
+
function vr({ toasts: r }) {
|
|
1938
|
+
return r.length === 0 ? null : /* @__PURE__ */ p("div", { class: "toastContainer", children: r.map((e) => /* @__PURE__ */ p("div", { class: `toast toast-${e.type}`, children: e.message }, e.id)) });
|
|
1939
|
+
}
|
|
1940
|
+
const Sr = 16e3;
|
|
1941
|
+
function $r() {
|
|
1942
|
+
return typeof navigator < "u" && !!navigator.mediaDevices?.getUserMedia && typeof WebSocket < "u" && !!(window.AudioContext || window.webkitAudioContext);
|
|
1943
|
+
}
|
|
1944
|
+
function Tr(r) {
|
|
1945
|
+
const e = new ArrayBuffer(r.length * 2), t = new DataView(e);
|
|
1946
|
+
for (let n = 0; n < r.length; n++) {
|
|
1947
|
+
const o = Math.max(-1, Math.min(1, r[n]));
|
|
1948
|
+
t.setInt16(n * 2, o < 0 ? o * 32768 : o * 32767, !0);
|
|
1949
|
+
}
|
|
1950
|
+
return e;
|
|
1951
|
+
}
|
|
1952
|
+
function Cr(r, e, t) {
|
|
1953
|
+
if (t >= e) return r;
|
|
1954
|
+
const n = e / t, o = Math.round(r.length / n), s = new Float32Array(o);
|
|
1955
|
+
let i = 0, a = 0;
|
|
1956
|
+
for (; i < s.length; ) {
|
|
1957
|
+
const c = Math.round((i + 1) * n);
|
|
1958
|
+
let d = 0, u = 0;
|
|
1959
|
+
for (let l = a; l < c && l < r.length; l++)
|
|
1960
|
+
d += r[l], u++;
|
|
1961
|
+
s[i] = u > 0 ? d / u : 0, i++, a = c;
|
|
1962
|
+
}
|
|
1963
|
+
return s;
|
|
1964
|
+
}
|
|
1965
|
+
async function Ir(r) {
|
|
1966
|
+
let e;
|
|
1967
|
+
try {
|
|
1968
|
+
e = await navigator.mediaDevices.getUserMedia({
|
|
1969
|
+
audio: { echoCancellation: !0, noiseSuppression: !0, autoGainControl: !0 }
|
|
1970
|
+
});
|
|
1971
|
+
} catch {
|
|
1972
|
+
throw new Error("Microphone access was denied or is unavailable.");
|
|
1973
|
+
}
|
|
1974
|
+
const t = window.AudioContext || window.webkitAudioContext, n = new t(), o = n.createMediaStreamSource(e), s = n.createScriptProcessor(4096, 1, 1), i = n.createGain();
|
|
1975
|
+
i.gain.value = 0;
|
|
1976
|
+
const a = new WebSocket(r.wsUrl);
|
|
1977
|
+
a.binaryType = "arraybuffer";
|
|
1978
|
+
let c = !1;
|
|
1979
|
+
const d = () => {
|
|
1980
|
+
try {
|
|
1981
|
+
s.disconnect();
|
|
1982
|
+
} catch {
|
|
1983
|
+
}
|
|
1984
|
+
try {
|
|
1985
|
+
o.disconnect();
|
|
1986
|
+
} catch {
|
|
1987
|
+
}
|
|
1988
|
+
try {
|
|
1989
|
+
i.disconnect();
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
try {
|
|
1993
|
+
n.close();
|
|
1994
|
+
} catch {
|
|
1995
|
+
}
|
|
1996
|
+
e.getTracks().forEach((u) => u.stop());
|
|
1997
|
+
};
|
|
1998
|
+
return a.onopen = () => {
|
|
1999
|
+
o.connect(s), s.connect(i), i.connect(n.destination), r.onStart?.();
|
|
2000
|
+
}, a.onmessage = (u) => {
|
|
2001
|
+
try {
|
|
2002
|
+
const l = JSON.parse(u.data);
|
|
2003
|
+
if (l.error) {
|
|
2004
|
+
r.onError(String(l.error));
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
typeof l.transcript == "string" && r.onTranscript({ transcript: l.transcript, isPartial: !!l.isPartial });
|
|
2008
|
+
} catch {
|
|
2009
|
+
}
|
|
2010
|
+
}, a.onerror = () => r.onError("Voice connection error."), a.onclose = () => d(), s.onaudioprocess = (u) => {
|
|
2011
|
+
if (a.readyState !== WebSocket.OPEN) return;
|
|
2012
|
+
const l = u.inputBuffer.getChannelData(0), h = Tr(Cr(l, n.sampleRate, Sr));
|
|
2013
|
+
a.send(h);
|
|
2014
|
+
}, {
|
|
2015
|
+
stop: () => {
|
|
2016
|
+
if (!c)
|
|
2017
|
+
if (c = !0, d(), a.readyState === WebSocket.OPEN) {
|
|
2018
|
+
try {
|
|
2019
|
+
a.send("STOP");
|
|
2020
|
+
} catch {
|
|
2021
|
+
}
|
|
2022
|
+
setTimeout(() => {
|
|
2023
|
+
try {
|
|
2024
|
+
a.close();
|
|
2025
|
+
} catch {
|
|
2026
|
+
}
|
|
2027
|
+
}, 800);
|
|
2028
|
+
} else
|
|
2029
|
+
try {
|
|
2030
|
+
a.close();
|
|
2031
|
+
} catch {
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
function H({ size: r = 18, children: e, ...t }) {
|
|
2037
|
+
return /* @__PURE__ */ p(
|
|
2038
|
+
"svg",
|
|
2039
|
+
{
|
|
2040
|
+
width: r,
|
|
2041
|
+
height: r,
|
|
2042
|
+
viewBox: "0 0 24 24",
|
|
2043
|
+
fill: "none",
|
|
2044
|
+
stroke: "currentColor",
|
|
2045
|
+
"stroke-width": "2",
|
|
2046
|
+
"stroke-linecap": "round",
|
|
2047
|
+
"stroke-linejoin": "round",
|
|
2048
|
+
...t,
|
|
2049
|
+
children: e
|
|
2050
|
+
}
|
|
2051
|
+
);
|
|
2052
|
+
}
|
|
2053
|
+
const zr = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2054
|
+
/* @__PURE__ */ p("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
2055
|
+
/* @__PURE__ */ p("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
2056
|
+
] }), Rr = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2057
|
+
/* @__PURE__ */ p("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
|
|
2058
|
+
/* @__PURE__ */ p("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
2059
|
+
] }), Ht = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2060
|
+
/* @__PURE__ */ p("polyline", { points: "23 4 23 10 17 10" }),
|
|
2061
|
+
/* @__PURE__ */ p("polyline", { points: "1 20 1 14 7 14" }),
|
|
2062
|
+
/* @__PURE__ */ p("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" })
|
|
2063
|
+
] }), Er = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2064
|
+
/* @__PURE__ */ p("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
2065
|
+
/* @__PURE__ */ p("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
2066
|
+
] }), Br = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2067
|
+
/* @__PURE__ */ p("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2068
|
+
/* @__PURE__ */ p("polyline", { points: "12 6 12 12 16 14" })
|
|
2069
|
+
] }), Dt = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2070
|
+
/* @__PURE__ */ p("polyline", { points: "3 6 5 6 21 6" }),
|
|
2071
|
+
/* @__PURE__ */ p("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
2072
|
+
] }), Ar = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2073
|
+
/* @__PURE__ */ p("polyline", { points: "15 3 21 3 21 9" }),
|
|
2074
|
+
/* @__PURE__ */ p("polyline", { points: "9 21 3 21 3 15" }),
|
|
2075
|
+
/* @__PURE__ */ p("line", { x1: "21", y1: "3", x2: "14", y2: "10" }),
|
|
2076
|
+
/* @__PURE__ */ p("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
|
|
2077
|
+
] }), Pr = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2078
|
+
/* @__PURE__ */ p("polyline", { points: "4 14 10 14 10 20" }),
|
|
2079
|
+
/* @__PURE__ */ p("polyline", { points: "20 10 14 10 14 4" }),
|
|
2080
|
+
/* @__PURE__ */ p("line", { x1: "14", y1: "10", x2: "21", y2: "3" }),
|
|
2081
|
+
/* @__PURE__ */ p("line", { x1: "3", y1: "21", x2: "10", y2: "14" })
|
|
2082
|
+
] }), Mr = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2083
|
+
/* @__PURE__ */ p("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
|
|
2084
|
+
/* @__PURE__ */ p("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
|
|
2085
|
+
] }), Lr = (r) => /* @__PURE__ */ p(H, { ...r, children: /* @__PURE__ */ p("polyline", { points: "15 18 9 12 15 6" }) }), Hr = (r) => /* @__PURE__ */ p(H, { ...r, children: [
|
|
2086
|
+
/* @__PURE__ */ p("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
|
|
2087
|
+
/* @__PURE__ */ p("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
|
|
2088
|
+
/* @__PURE__ */ p("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
|
|
2089
|
+
/* @__PURE__ */ p("line", { x1: "8", y1: "23", x2: "16", y2: "23" })
|
|
2090
|
+
] }), Z = 38, V = 66, E = 30, ae = 11;
|
|
2091
|
+
function Nt(r, e) {
|
|
2092
|
+
const t = ae / 8;
|
|
2093
|
+
return `M ${r} ${e + 5 * t} C ${r - 7 * t} ${e - 1 * t}, ${r - 6 * t} ${e - 7 * t}, ${r} ${e - 3 * t} C ${r + 6 * t} ${e - 7 * t}, ${r + 7 * t} ${e - 1 * t}, ${r} ${e + 5 * t} Z`;
|
|
2094
|
+
}
|
|
2095
|
+
function Fe({ size: r = 24, state: e = "idle", glow: t = !1, ...n }) {
|
|
2096
|
+
const o = ["bob", t ? "bobGlow" : ""].filter(Boolean).join(" ");
|
|
2097
|
+
return /* @__PURE__ */ p(
|
|
2098
|
+
"svg",
|
|
2099
|
+
{
|
|
2100
|
+
class: o,
|
|
2101
|
+
"data-state": e,
|
|
2102
|
+
width: r * 104 / 60,
|
|
2103
|
+
height: r,
|
|
2104
|
+
viewBox: "0 0 104 60",
|
|
2105
|
+
fill: "none",
|
|
2106
|
+
"aria-hidden": "true",
|
|
2107
|
+
...n,
|
|
2108
|
+
children: [
|
|
2109
|
+
/* @__PURE__ */ p(
|
|
2110
|
+
"rect",
|
|
2111
|
+
{
|
|
2112
|
+
class: "bobHead",
|
|
2113
|
+
x: "2.5",
|
|
2114
|
+
y: "2.5",
|
|
2115
|
+
width: "99",
|
|
2116
|
+
height: "55",
|
|
2117
|
+
rx: "27.5",
|
|
2118
|
+
stroke: "currentColor",
|
|
2119
|
+
"stroke-width": "3"
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
e === "loading" ? (
|
|
2123
|
+
// Spinner eyes: dashed rings that rotate.
|
|
2124
|
+
/* @__PURE__ */ p("g", { class: "bobSpinners", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round", children: [
|
|
2125
|
+
/* @__PURE__ */ p("circle", { class: "bobSpinner", cx: Z, cy: E, r: ae - 2 }),
|
|
2126
|
+
/* @__PURE__ */ p("circle", { class: "bobSpinner", cx: V, cy: E, r: ae - 2 })
|
|
2127
|
+
] })
|
|
2128
|
+
) : e === "error" ? (
|
|
2129
|
+
// X eyes.
|
|
2130
|
+
/* @__PURE__ */ p("g", { class: "bobX", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round", children: [
|
|
2131
|
+
/* @__PURE__ */ p("line", { x1: Z - 6, y1: E - 6, x2: Z + 6, y2: E + 6 }),
|
|
2132
|
+
/* @__PURE__ */ p("line", { x1: Z + 6, y1: E - 6, x2: Z - 6, y2: E + 6 }),
|
|
2133
|
+
/* @__PURE__ */ p("line", { x1: V - 6, y1: E - 6, x2: V + 6, y2: E + 6 }),
|
|
2134
|
+
/* @__PURE__ */ p("line", { x1: V + 6, y1: E - 6, x2: V - 6, y2: E + 6 })
|
|
2135
|
+
] })
|
|
2136
|
+
) : e === "success" ? (
|
|
2137
|
+
// Heart eyes.
|
|
2138
|
+
/* @__PURE__ */ p("g", { class: "bobHearts", fill: "currentColor", children: [
|
|
2139
|
+
/* @__PURE__ */ p("path", { d: Nt(Z, E) }),
|
|
2140
|
+
/* @__PURE__ */ p("path", { d: Nt(V, E) })
|
|
2141
|
+
] })
|
|
2142
|
+
) : (
|
|
2143
|
+
// idle / typing: open eyes that blink.
|
|
2144
|
+
/* @__PURE__ */ p("g", { class: `bobEyes${e === "typing" ? " bobEyesTyping" : ""}`, fill: "currentColor", children: [
|
|
2145
|
+
/* @__PURE__ */ p("circle", { cx: Z, cy: E, r: ae }),
|
|
2146
|
+
/* @__PURE__ */ p("circle", { cx: V, cy: E, r: ae })
|
|
2147
|
+
] })
|
|
2148
|
+
)
|
|
2149
|
+
]
|
|
2150
|
+
}
|
|
2151
|
+
);
|
|
2152
|
+
}
|
|
2153
|
+
k.setOptions({ async: !1 });
|
|
2154
|
+
const Q = "cw_session_id", oe = "cw_sessions";
|
|
2155
|
+
function Ze() {
|
|
2156
|
+
return "ses_" + Date.now().toString(36) + "_" + Math.random().toString(36).substring(2, 10);
|
|
2157
|
+
}
|
|
2158
|
+
function Dr({ config: r }) {
|
|
2159
|
+
const e = { apiUrl: r.apiUrl, headers: r.headers }, t = r.enableHistory, [n, o] = A(r.defaultOpen), [s, i] = A(!1), [a, c] = A(""), [d, u] = A([]), [l, h] = A(""), [f, x] = A(!1), [v, w] = A(null), [b, m] = A(!1), [I, R] = A([]), [B, fe] = A(!1), [J, K] = A(!1), [z, D] = A(!1), { toasts: fn, show: X, dismiss: gn } = yr(), dt = me(null), ne = me(null), ge = me(null), re = me(""), Le = () => ({ role: "assistant", content: r.welcomeMessage });
|
|
2160
|
+
We(() => {
|
|
2161
|
+
let g;
|
|
2162
|
+
if (t) {
|
|
2163
|
+
g = L.get(Q) || Ze(), L.set(Q, g);
|
|
2164
|
+
try {
|
|
2165
|
+
R(JSON.parse(L.get(oe) || "[]"));
|
|
2166
|
+
} catch {
|
|
2167
|
+
R([]);
|
|
2168
|
+
}
|
|
2169
|
+
} else
|
|
2170
|
+
g = Ze(), L.remove(Q);
|
|
2171
|
+
c(g), Lt(e, g).then((_) => {
|
|
2172
|
+
u(_.length > 0 ? _ : [Le()]);
|
|
2173
|
+
});
|
|
2174
|
+
}, [r.apiUrl, r.enableHistory]), We(() => {
|
|
2175
|
+
dt.current?.scrollIntoView({ behavior: "smooth" });
|
|
2176
|
+
}, [d, f]), We(() => () => ge.current?.stop(), []);
|
|
2177
|
+
const He = () => {
|
|
2178
|
+
const g = Ze();
|
|
2179
|
+
t ? L.set(Q, g) : L.remove(Q), c(g), u([Le()]), w(null), m(!1);
|
|
2180
|
+
}, _n = (g) => {
|
|
2181
|
+
if (!t) return;
|
|
2182
|
+
let _ = [];
|
|
2183
|
+
try {
|
|
2184
|
+
_ = JSON.parse(L.get(oe) || "[]");
|
|
2185
|
+
} catch {
|
|
2186
|
+
_ = [];
|
|
2187
|
+
}
|
|
2188
|
+
_.some(($) => $.id === a) || (_.unshift({
|
|
2189
|
+
id: a,
|
|
2190
|
+
title: g.substring(0, 50) + (g.length > 50 ? "…" : ""),
|
|
2191
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2192
|
+
}), _ = _.slice(0, 20), L.set(oe, JSON.stringify(_)), R(_));
|
|
2193
|
+
}, ut = (g) => {
|
|
2194
|
+
L.set(Q, g), c(g), Lt(e, g).then((_) => u(_.length ? _ : [Le()])), m(!1);
|
|
2195
|
+
}, ht = (g, _) => {
|
|
2196
|
+
g.stopPropagation();
|
|
2197
|
+
let $ = [];
|
|
2198
|
+
try {
|
|
2199
|
+
$ = JSON.parse(L.get(oe) || "[]");
|
|
2200
|
+
} catch {
|
|
2201
|
+
$ = [];
|
|
2202
|
+
}
|
|
2203
|
+
$ = $.filter((M) => M.id !== _), L.set(oe, JSON.stringify($)), R($), _ === a && He();
|
|
2204
|
+
}, ft = async () => {
|
|
2205
|
+
const g = X("Syncing with Confluence...", "info", 0);
|
|
2206
|
+
try {
|
|
2207
|
+
const _ = await kr(e);
|
|
2208
|
+
X(_, "success");
|
|
2209
|
+
} catch {
|
|
2210
|
+
X("Sync failed", "error");
|
|
2211
|
+
} finally {
|
|
2212
|
+
gn(g);
|
|
2213
|
+
}
|
|
2214
|
+
}, gt = async () => {
|
|
2215
|
+
z && De();
|
|
2216
|
+
const g = l.trim();
|
|
2217
|
+
if (!(!g || f)) {
|
|
2218
|
+
d.length <= 1 && _n(g), h(""), w(null), u((_) => [..._, { role: "user", content: g }]), x(!0), ne.current && (ne.current.style.height = "auto"), u((_) => [..._, { role: "assistant", content: "" }]);
|
|
2219
|
+
try {
|
|
2220
|
+
let _ = r.userRole;
|
|
2221
|
+
if (r.getUserRole)
|
|
2222
|
+
try {
|
|
2223
|
+
_ = await r.getUserRole();
|
|
2224
|
+
} catch {
|
|
2225
|
+
}
|
|
2226
|
+
await xr(
|
|
2227
|
+
e,
|
|
2228
|
+
{ message: g, sessionId: a, userRole: _ },
|
|
2229
|
+
($) => {
|
|
2230
|
+
u((M) => {
|
|
2231
|
+
const F = [...M], j = F[F.length - 1];
|
|
2232
|
+
return j?.role === "assistant" && (F[F.length - 1] = { ...j, content: j.content + $ }), F;
|
|
2233
|
+
});
|
|
2234
|
+
},
|
|
2235
|
+
($, M) => {
|
|
2236
|
+
u((F) => {
|
|
2237
|
+
const j = [...F], mt = j[j.length - 1];
|
|
2238
|
+
return mt?.role === "assistant" && (j[j.length - 1] = { ...mt, sources: M }), j;
|
|
2239
|
+
}), $ && $ !== a && (c($), t && L.set(Q, $)), K(!0), setTimeout(() => K(!1), 1800);
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
} catch (_) {
|
|
2243
|
+
u(($) => {
|
|
2244
|
+
const M = [...$];
|
|
2245
|
+
return M[M.length - 1]?.role === "assistant" && M[M.length - 1].content === "" && M.pop(), M;
|
|
2246
|
+
}), w(_ instanceof Error ? _.message : "Unable to connect to the server.");
|
|
2247
|
+
} finally {
|
|
2248
|
+
x(!1), setTimeout(() => ne.current?.focus(), 10);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}, mn = (g) => {
|
|
2252
|
+
g.key === "Enter" && !g.shiftKey && (g.preventDefault(), gt());
|
|
2253
|
+
}, bn = (g) => {
|
|
2254
|
+
const _ = g.currentTarget;
|
|
2255
|
+
h(_.value), _.style.height = "auto", _.style.height = Math.min(_.scrollHeight, 120) + "px";
|
|
2256
|
+
}, xn = () => {
|
|
2257
|
+
const g = ne.current;
|
|
2258
|
+
g && (g.style.height = "auto", g.style.height = Math.min(g.scrollHeight, 120) + "px");
|
|
2259
|
+
}, De = () => {
|
|
2260
|
+
ge.current?.stop(), ge.current = null, D(!1);
|
|
2261
|
+
}, kn = async () => {
|
|
2262
|
+
if (z) {
|
|
2263
|
+
De();
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (!$r()) {
|
|
2267
|
+
X("Voice input is not supported in this browser.", "error");
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
re.current = l ? l.replace(/\s+$/, "") + " " : "";
|
|
2271
|
+
try {
|
|
2272
|
+
const g = await Ir({
|
|
2273
|
+
wsUrl: br(e, r.voiceLanguage || "en-US"),
|
|
2274
|
+
onStart: () => D(!0),
|
|
2275
|
+
onError: (_) => {
|
|
2276
|
+
X(_, "error"), De();
|
|
2277
|
+
},
|
|
2278
|
+
onTranscript: ({ transcript: _, isPartial: $ }) => {
|
|
2279
|
+
$ ? h(re.current + _) : (re.current = re.current + _ + " ", h(re.current)), setTimeout(xn, 0);
|
|
2280
|
+
}
|
|
2281
|
+
});
|
|
2282
|
+
ge.current = g;
|
|
2283
|
+
} catch (g) {
|
|
2284
|
+
X(g instanceof Error ? g.message : "Could not start recording.", "error"), D(!1);
|
|
2285
|
+
}
|
|
2286
|
+
}, Ne = v ? "error" : f ? "loading" : J ? "success" : l.trim() ? "typing" : "idle";
|
|
2287
|
+
if (!n)
|
|
2288
|
+
return /* @__PURE__ */ p(
|
|
2289
|
+
"button",
|
|
2290
|
+
{
|
|
2291
|
+
class: "fabButton",
|
|
2292
|
+
onClick: () => o(!0),
|
|
2293
|
+
title: "Open Assistant",
|
|
2294
|
+
"aria-label": "Open chat",
|
|
2295
|
+
children: /* @__PURE__ */ p(Fe, { size: 34, state: Ne, glow: !0 })
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
const wn = I.find((g) => g.id === a)?.title || "New Chat", _t = I.some((g) => g.id === a), yn = /* @__PURE__ */ p("aside", { class: `sidebar${B ? " collapsed" : ""}`, children: [
|
|
2299
|
+
/* @__PURE__ */ p("div", { class: "sidebarTop", children: [
|
|
2300
|
+
/* @__PURE__ */ p("span", { class: "sidebarBrand", children: /* @__PURE__ */ p(Fe, { size: 30, state: Ne, glow: !0 }) }),
|
|
2301
|
+
/* @__PURE__ */ p(
|
|
2302
|
+
"button",
|
|
2303
|
+
{
|
|
2304
|
+
class: "iconButton railToggle",
|
|
2305
|
+
onClick: () => fe((g) => !g),
|
|
2306
|
+
title: B ? "Expand" : "Collapse",
|
|
2307
|
+
"aria-label": B ? "Expand sidebar" : "Collapse sidebar",
|
|
2308
|
+
children: /* @__PURE__ */ p(Lr, { size: 18 })
|
|
2309
|
+
}
|
|
2310
|
+
)
|
|
2311
|
+
] }),
|
|
2312
|
+
/* @__PURE__ */ p("div", { class: "sidebarScroll", children: [
|
|
2313
|
+
/* @__PURE__ */ p("div", { class: "sidebarSection", children: [
|
|
2314
|
+
/* @__PURE__ */ p("div", { class: "sidebarLabel", children: "Actions" }),
|
|
2315
|
+
/* @__PURE__ */ p("button", { class: "sidebarItem", onClick: He, title: "New Chat", children: [
|
|
2316
|
+
/* @__PURE__ */ p(Mr, { size: 18 }),
|
|
2317
|
+
/* @__PURE__ */ p("span", { class: "sidebarItemText", children: "New Chat" })
|
|
2318
|
+
] }),
|
|
2319
|
+
r.enableSync && /* @__PURE__ */ p("button", { class: "sidebarItem", onClick: ft, title: "Sync Documentation", children: [
|
|
2320
|
+
/* @__PURE__ */ p(Ht, { size: 18 }),
|
|
2321
|
+
/* @__PURE__ */ p("span", { class: "sidebarItemText", children: "Sync Documentation" })
|
|
2322
|
+
] })
|
|
2323
|
+
] }),
|
|
2324
|
+
t && /* @__PURE__ */ p("div", { class: "sidebarSection", children: [
|
|
2325
|
+
/* @__PURE__ */ p("div", { class: "sidebarLabel", children: "Chats" }),
|
|
2326
|
+
!_t && /* @__PURE__ */ p("div", { class: "chatItem active", title: "New Chat", children: /* @__PURE__ */ p("span", { class: "chatItemTitle", children: "New Chat" }) }),
|
|
2327
|
+
I.length === 0 && _t && /* @__PURE__ */ p("div", { class: "sidebarEmpty", children: "No chats yet" }),
|
|
2328
|
+
I.map((g) => /* @__PURE__ */ p(
|
|
2329
|
+
"div",
|
|
2330
|
+
{
|
|
2331
|
+
class: `chatItem${g.id === a ? " active" : ""}`,
|
|
2332
|
+
onClick: () => ut(g.id),
|
|
2333
|
+
title: g.title,
|
|
2334
|
+
children: [
|
|
2335
|
+
/* @__PURE__ */ p("span", { class: "chatItemTitle", children: g.title }),
|
|
2336
|
+
/* @__PURE__ */ p(
|
|
2337
|
+
"button",
|
|
2338
|
+
{
|
|
2339
|
+
class: "chatItemDelete",
|
|
2340
|
+
onClick: (_) => ht(_, g.id),
|
|
2341
|
+
title: "Delete chat",
|
|
2342
|
+
"aria-label": "Delete chat",
|
|
2343
|
+
children: /* @__PURE__ */ p(Dt, { size: 14 })
|
|
2344
|
+
}
|
|
2345
|
+
)
|
|
2346
|
+
]
|
|
2347
|
+
},
|
|
2348
|
+
g.id
|
|
2349
|
+
))
|
|
2350
|
+
] })
|
|
2351
|
+
] })
|
|
2352
|
+
] }), vn = /* @__PURE__ */ p("div", { class: "chatBody", children: [
|
|
2353
|
+
d.map((g, _) => {
|
|
2354
|
+
const $ = f && _ === d.length - 1 && g.role === "assistant" && g.content === "";
|
|
2355
|
+
return /* @__PURE__ */ p("div", { class: `message ${g.role}`, children: /* @__PURE__ */ p("div", { class: "messageContent", children: $ ? /* @__PURE__ */ p("div", { class: "typingIndicator", children: [
|
|
2356
|
+
/* @__PURE__ */ p("div", { class: "typingDot" }),
|
|
2357
|
+
/* @__PURE__ */ p("div", { class: "typingDot" }),
|
|
2358
|
+
/* @__PURE__ */ p("div", { class: "typingDot" })
|
|
2359
|
+
] }) : g.role === "assistant" ? /* @__PURE__ */ p(
|
|
2360
|
+
"div",
|
|
2361
|
+
{
|
|
2362
|
+
class: "markdownBody",
|
|
2363
|
+
dangerouslySetInnerHTML: { __html: k.parse(g.content) }
|
|
2364
|
+
}
|
|
2365
|
+
) : g.content }) }, _);
|
|
2366
|
+
}),
|
|
2367
|
+
v && /* @__PURE__ */ p("div", { class: "errorMessage", children: [
|
|
2368
|
+
"⚠️ ",
|
|
2369
|
+
v
|
|
2370
|
+
] }),
|
|
2371
|
+
/* @__PURE__ */ p("div", { ref: dt })
|
|
2372
|
+
] }), Sn = /* @__PURE__ */ p("div", { class: "chatFooter", children: [
|
|
2373
|
+
/* @__PURE__ */ p("div", { class: "inputWrapper", children: [
|
|
2374
|
+
/* @__PURE__ */ p(
|
|
2375
|
+
"textarea",
|
|
2376
|
+
{
|
|
2377
|
+
ref: ne,
|
|
2378
|
+
class: "textarea",
|
|
2379
|
+
value: l,
|
|
2380
|
+
onInput: bn,
|
|
2381
|
+
onKeyDown: mn,
|
|
2382
|
+
placeholder: r.placeholder,
|
|
2383
|
+
maxLength: r.maxMessageLength,
|
|
2384
|
+
rows: 1
|
|
2385
|
+
}
|
|
2386
|
+
),
|
|
2387
|
+
r.enableVoiceInput !== !1 && /* @__PURE__ */ p(
|
|
2388
|
+
"button",
|
|
2389
|
+
{
|
|
2390
|
+
class: `micButton${z ? " recording" : ""}`,
|
|
2391
|
+
onClick: kn,
|
|
2392
|
+
disabled: f,
|
|
2393
|
+
title: z ? "Stop recording" : "Voice input",
|
|
2394
|
+
"aria-label": z ? "Stop recording" : "Start voice input",
|
|
2395
|
+
children: /* @__PURE__ */ p(Hr, { size: 18 })
|
|
2396
|
+
}
|
|
2397
|
+
),
|
|
2398
|
+
/* @__PURE__ */ p(
|
|
2399
|
+
"button",
|
|
2400
|
+
{
|
|
2401
|
+
class: "sendButton",
|
|
2402
|
+
onClick: gt,
|
|
2403
|
+
disabled: !l.trim() || f,
|
|
2404
|
+
title: "Send",
|
|
2405
|
+
"aria-label": "Send message",
|
|
2406
|
+
children: /* @__PURE__ */ p(Rr, { size: 18 })
|
|
2407
|
+
}
|
|
2408
|
+
)
|
|
2409
|
+
] }),
|
|
2410
|
+
/* @__PURE__ */ p("div", { class: "footerInfo", children: [
|
|
2411
|
+
/* @__PURE__ */ p("span", { children: [
|
|
2412
|
+
l.length,
|
|
2413
|
+
"/",
|
|
2414
|
+
r.maxMessageLength
|
|
2415
|
+
] }),
|
|
2416
|
+
a && /* @__PURE__ */ p("span", { children: [
|
|
2417
|
+
"Session: ",
|
|
2418
|
+
a.substring(0, 8)
|
|
2419
|
+
] })
|
|
2420
|
+
] })
|
|
2421
|
+
] });
|
|
2422
|
+
return /* @__PURE__ */ p(ee, { children: [
|
|
2423
|
+
s && /* @__PURE__ */ p("div", { class: "backdrop", onClick: () => i(!1) }),
|
|
2424
|
+
/* @__PURE__ */ p("div", { class: `chatWindow${s ? " maximized" : ""}`, children: [
|
|
2425
|
+
s && yn,
|
|
2426
|
+
/* @__PURE__ */ p("div", { class: "mainCol", children: [
|
|
2427
|
+
/* @__PURE__ */ p(vr, { toasts: fn }),
|
|
2428
|
+
/* @__PURE__ */ p("div", { class: "chatHeader", children: [
|
|
2429
|
+
/* @__PURE__ */ p("div", { class: "headerTitle", children: s ? /* @__PURE__ */ p("span", { class: "breadcrumb", children: [
|
|
2430
|
+
wn,
|
|
2431
|
+
/* @__PURE__ */ p("span", { class: "breadcrumbSep", children: "/" })
|
|
2432
|
+
] }) : /* @__PURE__ */ p(ee, { children: [
|
|
2433
|
+
/* @__PURE__ */ p(Fe, { size: 22, state: Ne }),
|
|
2434
|
+
/* @__PURE__ */ p("span", { children: r.title })
|
|
2435
|
+
] }) }),
|
|
2436
|
+
/* @__PURE__ */ p("div", { class: "headerActions", children: [
|
|
2437
|
+
!s && t && /* @__PURE__ */ p(
|
|
2438
|
+
"button",
|
|
2439
|
+
{
|
|
2440
|
+
class: "iconButton",
|
|
2441
|
+
onClick: () => m((g) => !g),
|
|
2442
|
+
title: "History",
|
|
2443
|
+
"aria-label": "History",
|
|
2444
|
+
children: /* @__PURE__ */ p(Br, { size: 18 })
|
|
2445
|
+
}
|
|
2446
|
+
),
|
|
2447
|
+
!s && r.enableSync && /* @__PURE__ */ p("button", { class: "iconButton", onClick: ft, title: "Sync Docs", "aria-label": "Sync docs", children: /* @__PURE__ */ p(Ht, { size: 16 }) }),
|
|
2448
|
+
!s && /* @__PURE__ */ p(
|
|
2449
|
+
"button",
|
|
2450
|
+
{
|
|
2451
|
+
class: "iconButton",
|
|
2452
|
+
onClick: He,
|
|
2453
|
+
title: "New Chat",
|
|
2454
|
+
"aria-label": "New chat",
|
|
2455
|
+
children: /* @__PURE__ */ p(Er, { size: 18 })
|
|
2456
|
+
}
|
|
2457
|
+
),
|
|
2458
|
+
r.allowFullscreen && /* @__PURE__ */ p(
|
|
2459
|
+
"button",
|
|
2460
|
+
{
|
|
2461
|
+
class: "iconButton",
|
|
2462
|
+
onClick: () => i((g) => !g),
|
|
2463
|
+
title: s ? "Restore" : "Widescreen",
|
|
2464
|
+
"aria-label": s ? "Restore" : "Widescreen",
|
|
2465
|
+
children: s ? /* @__PURE__ */ p(Pr, { size: 16 }) : /* @__PURE__ */ p(Ar, { size: 16 })
|
|
2466
|
+
}
|
|
2467
|
+
),
|
|
2468
|
+
/* @__PURE__ */ p("button", { class: "iconButton", onClick: () => o(!1), title: "Close", "aria-label": "Close", children: /* @__PURE__ */ p(zr, { size: 20 }) })
|
|
2469
|
+
] })
|
|
2470
|
+
] }),
|
|
2471
|
+
!s && b ? /* @__PURE__ */ p("div", { class: "historyPanel", children: I.length === 0 ? /* @__PURE__ */ p("div", { class: "emptyHistory", children: "No chat history yet." }) : I.map((g) => /* @__PURE__ */ p("div", { class: "historyItem", onClick: () => ut(g.id), children: [
|
|
2472
|
+
/* @__PURE__ */ p("div", { class: "historyItemContent", children: [
|
|
2473
|
+
/* @__PURE__ */ p("div", { class: "historyTitle", children: g.title }),
|
|
2474
|
+
/* @__PURE__ */ p("div", { class: "historyDate", children: new Date(g.timestamp).toLocaleString() })
|
|
2475
|
+
] }),
|
|
2476
|
+
/* @__PURE__ */ p(
|
|
2477
|
+
"button",
|
|
2478
|
+
{
|
|
2479
|
+
class: "deleteBtn",
|
|
2480
|
+
onClick: (_) => ht(_, g.id),
|
|
2481
|
+
title: "Delete Session",
|
|
2482
|
+
"aria-label": "Delete session",
|
|
2483
|
+
children: /* @__PURE__ */ p(Dt, { size: 16 })
|
|
2484
|
+
}
|
|
2485
|
+
)
|
|
2486
|
+
] }, g.id)) }) : vn,
|
|
2487
|
+
(s || !b) && Sn
|
|
2488
|
+
] })
|
|
2489
|
+
] })
|
|
2490
|
+
] });
|
|
2491
|
+
}
|
|
2492
|
+
const Nr = `Hello! I'm your documentation assistant. I can help you with:
|
|
2493
|
+
- Feature explanations and how-to guides
|
|
2494
|
+
- Troubleshooting common issues
|
|
2495
|
+
- Configuration and setup questions
|
|
2496
|
+
- Best practices and recommendations
|
|
2497
|
+
|
|
2498
|
+
What would you like to know?`, Or = {
|
|
2499
|
+
title: "BlueEyeBot",
|
|
2500
|
+
welcomeMessage: Nr,
|
|
2501
|
+
placeholder: "Type your question...",
|
|
2502
|
+
userRole: "student/vizitator",
|
|
2503
|
+
position: "bottom-right",
|
|
2504
|
+
defaultOpen: !1,
|
|
2505
|
+
enableHistory: !1,
|
|
2506
|
+
enableSync: !1,
|
|
2507
|
+
allowFullscreen: !0,
|
|
2508
|
+
maxMessageLength: 2e3,
|
|
2509
|
+
enableVoiceInput: !0,
|
|
2510
|
+
voiceLanguage: "en-US",
|
|
2511
|
+
headers: {},
|
|
2512
|
+
zIndex: 9999
|
|
2513
|
+
};
|
|
2514
|
+
function Ur(r) {
|
|
2515
|
+
return { ...Or, ...r };
|
|
2516
|
+
}
|
|
2517
|
+
const N = (r) => r, Ot = (r) => {
|
|
2518
|
+
const e = Number(r);
|
|
2519
|
+
return Number.isNaN(e) ? void 0 : e;
|
|
2520
|
+
}, ie = (r) => r !== "false" && r !== "0", hn = {
|
|
2521
|
+
"api-url": { key: "apiUrl", parse: N },
|
|
2522
|
+
title: { key: "title", parse: N },
|
|
2523
|
+
"welcome-message": { key: "welcomeMessage", parse: N },
|
|
2524
|
+
placeholder: { key: "placeholder", parse: N },
|
|
2525
|
+
"user-role": { key: "userRole", parse: N },
|
|
2526
|
+
position: { key: "position", parse: N },
|
|
2527
|
+
"default-open": { key: "defaultOpen", parse: ie },
|
|
2528
|
+
"enable-history": { key: "enableHistory", parse: ie },
|
|
2529
|
+
"enable-sync": { key: "enableSync", parse: ie },
|
|
2530
|
+
"allow-fullscreen": { key: "allowFullscreen", parse: ie },
|
|
2531
|
+
"max-message-length": { key: "maxMessageLength", parse: Ot },
|
|
2532
|
+
"enable-voice-input": { key: "enableVoiceInput", parse: ie },
|
|
2533
|
+
"voice-language": { key: "voiceLanguage", parse: N },
|
|
2534
|
+
"z-index": { key: "zIndex", parse: Ot },
|
|
2535
|
+
"primary-color": { key: "primaryColor", parse: N },
|
|
2536
|
+
"secondary-color": { key: "secondaryColor", parse: N },
|
|
2537
|
+
"font-family": { key: "fontFamily", parse: N }
|
|
2538
|
+
}, jr = Object.keys(hn);
|
|
2539
|
+
function Wr(r) {
|
|
2540
|
+
const e = {};
|
|
2541
|
+
for (const [t, n] of Object.entries(hn))
|
|
2542
|
+
if (r.hasAttribute(t)) {
|
|
2543
|
+
const o = n.parse(r.getAttribute(t) ?? "");
|
|
2544
|
+
o !== void 0 && (e[n.key] = o);
|
|
2545
|
+
}
|
|
2546
|
+
return e;
|
|
2547
|
+
}
|
|
2548
|
+
const Ke = "blue-eye-bot";
|
|
2549
|
+
class qr extends HTMLElement {
|
|
2550
|
+
static get observedAttributes() {
|
|
2551
|
+
return jr;
|
|
2552
|
+
}
|
|
2553
|
+
mount;
|
|
2554
|
+
jsConfig = {};
|
|
2555
|
+
connected = !1;
|
|
2556
|
+
constructor() {
|
|
2557
|
+
super();
|
|
2558
|
+
const e = this.attachShadow({ mode: "open" }), t = document.createElement("style");
|
|
2559
|
+
t.textContent = En, this.mount = document.createElement("div"), e.append(t, this.mount);
|
|
2560
|
+
}
|
|
2561
|
+
connectedCallback() {
|
|
2562
|
+
this.connected = !0, this.update();
|
|
2563
|
+
}
|
|
2564
|
+
disconnectedCallback() {
|
|
2565
|
+
this.connected = !1, Ue(null, this.mount);
|
|
2566
|
+
}
|
|
2567
|
+
attributeChangedCallback() {
|
|
2568
|
+
this.connected && this.update();
|
|
2569
|
+
}
|
|
2570
|
+
/** Imperative configuration (objects/headers that can't be HTML attributes). */
|
|
2571
|
+
set config(e) {
|
|
2572
|
+
this.jsConfig = e || {}, this.connected && this.update();
|
|
2573
|
+
}
|
|
2574
|
+
get config() {
|
|
2575
|
+
return this.jsConfig;
|
|
2576
|
+
}
|
|
2577
|
+
resolve() {
|
|
2578
|
+
const e = { ...Wr(this), ...this.jsConfig };
|
|
2579
|
+
return e.apiUrl ? Ur(e) : (console.warn(`<${Ke}>: "api-url" is required and was not provided.`), null);
|
|
2580
|
+
}
|
|
2581
|
+
applyHostStyles(e) {
|
|
2582
|
+
const t = this.style;
|
|
2583
|
+
e.primaryColor && t.setProperty("--cw-primary", e.primaryColor), e.secondaryColor && t.setProperty("--cw-secondary", e.secondaryColor), e.fontFamily && t.setProperty("--cw-font-family", e.fontFamily), t.setProperty("--cw-z-index", String(e.zIndex)), this.setAttribute("data-position", e.position);
|
|
2584
|
+
}
|
|
2585
|
+
update() {
|
|
2586
|
+
const e = this.resolve();
|
|
2587
|
+
if (!e) {
|
|
2588
|
+
Ue(null, this.mount);
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
this.applyHostStyles(e), Ue(Ft(Dr, { config: e }), this.mount);
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
function Fr() {
|
|
2595
|
+
typeof customElements < "u" && !customElements.get(Ke) && customElements.define(Ke, qr);
|
|
2596
|
+
}
|
|
2597
|
+
export {
|
|
2598
|
+
hn as A,
|
|
2599
|
+
qr as C,
|
|
2600
|
+
Ke as T,
|
|
2601
|
+
Fr as d
|
|
2602
|
+
};
|