@useknest/widget-core 0.1.0-beta.12 → 0.1.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +317 -317
- package/dist/streaming.d.ts +3 -1
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,15 +8,15 @@ function Ie(n = W) {
|
|
|
8
8
|
function ye(n = W) {
|
|
9
9
|
return `${n}${X}/widget-config`;
|
|
10
10
|
}
|
|
11
|
-
const Re = "Sorry, I didn't get a response.", re = "Unknown error occurred", Oe = "This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.",
|
|
11
|
+
const Re = "Sorry, I didn't get a response.", re = "Unknown error occurred", Oe = "This domain is not authorized. Please add it to your allowed origins in the Knest dashboard.", Ne = "This chatbot has reached its usage limit. Please contact the site owner to upgrade their plan.", nt = "https://useknest.com/default-avatar.svg", at = "#3b82f6", rt = "Hi! I'm your AI assistant. I'm trained to answer questions about your documentation. How can I help you today?", st = [
|
|
12
12
|
"How do I get started?",
|
|
13
13
|
"What features are available?",
|
|
14
14
|
"How do I integrate this?"
|
|
15
|
-
], fe = ["image/jpeg", "image/png", "image/gif", "image/webp"],
|
|
15
|
+
], fe = ["image/jpeg", "image/png", "image/gif", "image/webp"], ve = [
|
|
16
16
|
"application/pdf",
|
|
17
17
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
18
|
"text/plain"
|
|
19
|
-
], Ee = [...fe, ...
|
|
19
|
+
], Ee = [...fe, ...ve], it = Ee.join(","), we = 10 * 1024 * 1024, ot = 5;
|
|
20
20
|
function Le(n = W) {
|
|
21
21
|
return `${n}${X}/chat-attachments/upload-url`;
|
|
22
22
|
}
|
|
@@ -30,26 +30,26 @@ const Ce = "knest-widget-config-", ke = 1440 * 60 * 1e3;
|
|
|
30
30
|
function J(n) {
|
|
31
31
|
return Ce + n;
|
|
32
32
|
}
|
|
33
|
-
function _e(n,
|
|
33
|
+
function _e(n, u) {
|
|
34
34
|
try {
|
|
35
35
|
const e = localStorage.getItem(J(n));
|
|
36
36
|
if (!e) return null;
|
|
37
37
|
const { config: l, cachedAt: c } = JSON.parse(e);
|
|
38
|
-
return Date.now() - c > ke ? (localStorage.removeItem(J(n)), null) : (
|
|
38
|
+
return Date.now() - c > ke ? (localStorage.removeItem(J(n)), null) : (u && l.updatedAt, l);
|
|
39
39
|
} catch {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function De(n,
|
|
43
|
+
function De(n, u) {
|
|
44
44
|
try {
|
|
45
|
-
const e = { config:
|
|
45
|
+
const e = { config: u, cachedAt: Date.now() };
|
|
46
46
|
localStorage.setItem(J(n), JSON.stringify(e));
|
|
47
47
|
} catch {
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
async function se(n,
|
|
50
|
+
async function se(n, u) {
|
|
51
51
|
try {
|
|
52
|
-
const e = await fetch(ye(
|
|
52
|
+
const e = await fetch(ye(u), {
|
|
53
53
|
method: "GET",
|
|
54
54
|
headers: {
|
|
55
55
|
"X-Api-Key": n
|
|
@@ -69,17 +69,17 @@ async function se(n, o) {
|
|
|
69
69
|
return console.error("Error fetching widget config:", e), { config: null, error: "network" };
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
async function lt(n,
|
|
72
|
+
async function lt(n, u, e) {
|
|
73
73
|
const l = _e(n);
|
|
74
|
-
return l ? (e && se(n,
|
|
74
|
+
return l ? (e && se(n, u).then((c) => {
|
|
75
75
|
c.config && c.config.updatedAt !== l.updatedAt && e(c.config);
|
|
76
|
-
}), { config: l, error: null }) : se(n,
|
|
76
|
+
}), { config: l, error: null }) : se(n, u);
|
|
77
77
|
}
|
|
78
78
|
let _ = null, H = !1, x = null;
|
|
79
|
-
async function ct(n,
|
|
79
|
+
async function ct(n, u) {
|
|
80
80
|
return x || (H && _ ? !0 : (x = (async () => {
|
|
81
81
|
try {
|
|
82
|
-
_ = be(n,
|
|
82
|
+
_ = be(n, u, {
|
|
83
83
|
auth: {
|
|
84
84
|
// Persist session in localStorage for cross-page persistence.
|
|
85
85
|
persistSession: !0,
|
|
@@ -116,69 +116,69 @@ function xe() {
|
|
|
116
116
|
return _;
|
|
117
117
|
}
|
|
118
118
|
async function dt(n) {
|
|
119
|
-
const { publishableApiKey:
|
|
119
|
+
const { publishableApiKey: u, content: e, threadId: l, callbacks: c, baseUrl: E, metadata: S, user: o } = n;
|
|
120
120
|
try {
|
|
121
121
|
if (!Pe())
|
|
122
122
|
throw new Error("Widget not authenticated. Call initWidgetAuth() first.");
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
123
|
+
const h = await Q();
|
|
124
|
+
if (!h)
|
|
125
125
|
throw new Error("No access token available. Please refresh and try again.");
|
|
126
|
-
const
|
|
127
|
-
l && (
|
|
128
|
-
const
|
|
126
|
+
const y = { content: e };
|
|
127
|
+
l && (y.threadId = l), S && (y.metadata = S), o && (!o.id && !o.email ? console.warn("[Knest] user prop ignored: at least id or email is required.") : (y.user = o, o.email && (y.email = o.email), o.fullName && (y.fullName = o.fullName)));
|
|
128
|
+
const R = await fetch(Ie(E), {
|
|
129
129
|
method: "POST",
|
|
130
130
|
headers: {
|
|
131
131
|
"Content-Type": "application/json",
|
|
132
|
-
"X-Api-Key":
|
|
133
|
-
Authorization: `Bearer ${
|
|
132
|
+
"X-Api-Key": u,
|
|
133
|
+
Authorization: `Bearer ${h}`
|
|
134
134
|
},
|
|
135
135
|
credentials: "include",
|
|
136
|
-
body: JSON.stringify(
|
|
136
|
+
body: JSON.stringify(y)
|
|
137
137
|
});
|
|
138
|
-
if (!
|
|
139
|
-
if (
|
|
138
|
+
if (!R.ok) {
|
|
139
|
+
if (R.status === 401 || R.status === 403)
|
|
140
140
|
throw new Error(Oe);
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
throw
|
|
141
|
+
if (R.status === 429) {
|
|
142
|
+
const f = await R.json();
|
|
143
|
+
throw f.code === "USAGE_LIMIT_EXCEEDED" ? new Error(Ne) : new Error(f.error || "Rate limited");
|
|
144
144
|
}
|
|
145
|
-
const
|
|
146
|
-
throw new Error(
|
|
145
|
+
const m = await R.json();
|
|
146
|
+
throw new Error(m.error || "Failed to send message");
|
|
147
147
|
}
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
148
|
+
const v = R.body?.getReader();
|
|
149
|
+
if (!v)
|
|
150
150
|
throw new Error("Response body is not readable");
|
|
151
|
-
const
|
|
152
|
-
let
|
|
151
|
+
const w = new TextDecoder();
|
|
152
|
+
let k = "", L = !1;
|
|
153
153
|
for (; ; ) {
|
|
154
|
-
const { done:
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
const
|
|
154
|
+
const { done: m, value: f } = await v.read();
|
|
155
|
+
if (m) break;
|
|
156
|
+
k += w.decode(f, { stream: !0 });
|
|
157
|
+
const T = k.split(`
|
|
158
158
|
`);
|
|
159
|
-
|
|
160
|
-
for (const
|
|
161
|
-
if (
|
|
159
|
+
k = T.pop() || "";
|
|
160
|
+
for (const a of T)
|
|
161
|
+
if (a.startsWith("data: "))
|
|
162
162
|
try {
|
|
163
|
-
const t = JSON.parse(
|
|
163
|
+
const t = JSON.parse(a.slice(6));
|
|
164
164
|
if (t.type === "init")
|
|
165
165
|
t.threadId && c.onInit && c.onInit(t.threadId);
|
|
166
166
|
else if (t.type === "content")
|
|
167
|
-
t.content && (
|
|
167
|
+
t.content && (L = !0, c.onContent(t.content));
|
|
168
168
|
else if (t.type === "complete")
|
|
169
169
|
c.onComplete && c.onComplete(t.sources || []);
|
|
170
170
|
else if (t.type === "done")
|
|
171
|
-
t.humanTakeover && (
|
|
171
|
+
t.humanTakeover && (L = !0), c.onDone && c.onDone({ humanTakeover: t.humanTakeover });
|
|
172
172
|
else if (t.type === "error")
|
|
173
173
|
throw new Error(t.error || re);
|
|
174
174
|
} catch (t) {
|
|
175
|
-
console.error("Error parsing SSE data:", t,
|
|
175
|
+
console.error("Error parsing SSE data:", t, a);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
} catch (
|
|
180
|
-
const
|
|
181
|
-
c.onError(
|
|
178
|
+
L || c.onError(Re);
|
|
179
|
+
} catch (h) {
|
|
180
|
+
const y = h instanceof Error ? h.message : re;
|
|
181
|
+
c.onError(y);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
var ie = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
@@ -188,7 +188,7 @@ function Ue(n) {
|
|
|
188
188
|
var V = { exports: {} }, oe;
|
|
189
189
|
function Me() {
|
|
190
190
|
return oe || (oe = 1, (function(n) {
|
|
191
|
-
var
|
|
191
|
+
var u = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
192
192
|
/**
|
|
193
193
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
194
194
|
*
|
|
@@ -198,7 +198,7 @@ function Me() {
|
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
200
|
var e = (function(l) {
|
|
201
|
-
var c = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, E = 0,
|
|
201
|
+
var c = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, E = 0, S = {}, o = {
|
|
202
202
|
/**
|
|
203
203
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
204
204
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -253,8 +253,8 @@ function Me() {
|
|
|
253
253
|
* @memberof Prism
|
|
254
254
|
*/
|
|
255
255
|
util: {
|
|
256
|
-
encode: function t
|
|
257
|
-
return
|
|
256
|
+
encode: function a(t) {
|
|
257
|
+
return t instanceof h ? new h(t.type, a(t.content), t.alias) : Array.isArray(t) ? t.map(a) : t.replace(/&/g, "&").replace(/</g, "<").replace(/\u00a0/g, " ");
|
|
258
258
|
},
|
|
259
259
|
/**
|
|
260
260
|
* Returns the name of the type of the given value.
|
|
@@ -272,8 +272,8 @@ function Me() {
|
|
|
272
272
|
* type(String) === 'Function'
|
|
273
273
|
* type(/abc+/) === 'RegExp'
|
|
274
274
|
*/
|
|
275
|
-
type: function(
|
|
276
|
-
return Object.prototype.toString.call(
|
|
275
|
+
type: function(a) {
|
|
276
|
+
return Object.prototype.toString.call(a).slice(8, -1);
|
|
277
277
|
},
|
|
278
278
|
/**
|
|
279
279
|
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
@@ -281,8 +281,8 @@ function Me() {
|
|
|
281
281
|
* @param {Object} obj
|
|
282
282
|
* @returns {number}
|
|
283
283
|
*/
|
|
284
|
-
objId: function(
|
|
285
|
-
return
|
|
284
|
+
objId: function(a) {
|
|
285
|
+
return a.__id || Object.defineProperty(a, "__id", { value: ++E }), a.__id;
|
|
286
286
|
},
|
|
287
287
|
/**
|
|
288
288
|
* Creates a deep clone of the given object.
|
|
@@ -294,30 +294,30 @@ function Me() {
|
|
|
294
294
|
* @returns {T}
|
|
295
295
|
* @template T
|
|
296
296
|
*/
|
|
297
|
-
clone: function t
|
|
297
|
+
clone: function a(t, r) {
|
|
298
298
|
r = r || {};
|
|
299
299
|
var s, i;
|
|
300
|
-
switch (
|
|
300
|
+
switch (o.util.type(t)) {
|
|
301
301
|
case "Object":
|
|
302
|
-
if (i =
|
|
302
|
+
if (i = o.util.objId(t), r[i])
|
|
303
303
|
return r[i];
|
|
304
304
|
s = /** @type {Record<string, any>} */
|
|
305
305
|
{}, r[i] = s;
|
|
306
|
-
for (var g in
|
|
307
|
-
|
|
306
|
+
for (var g in t)
|
|
307
|
+
t.hasOwnProperty(g) && (s[g] = a(t[g], r));
|
|
308
308
|
return (
|
|
309
309
|
/** @type {any} */
|
|
310
310
|
s
|
|
311
311
|
);
|
|
312
312
|
case "Array":
|
|
313
|
-
return i =
|
|
313
|
+
return i = o.util.objId(t), r[i] ? r[i] : (s = [], r[i] = s, /** @type {Array} */
|
|
314
314
|
/** @type {any} */
|
|
315
|
-
|
|
316
|
-
s[d] =
|
|
315
|
+
t.forEach(function(p, d) {
|
|
316
|
+
s[d] = a(p, r);
|
|
317
317
|
}), /** @type {any} */
|
|
318
318
|
s);
|
|
319
319
|
default:
|
|
320
|
-
return
|
|
320
|
+
return t;
|
|
321
321
|
}
|
|
322
322
|
},
|
|
323
323
|
/**
|
|
@@ -328,12 +328,12 @@ function Me() {
|
|
|
328
328
|
* @param {Element} element
|
|
329
329
|
* @returns {string}
|
|
330
330
|
*/
|
|
331
|
-
getLanguage: function(
|
|
332
|
-
for (;
|
|
333
|
-
var
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
336
|
-
|
|
331
|
+
getLanguage: function(a) {
|
|
332
|
+
for (; a; ) {
|
|
333
|
+
var t = c.exec(a.className);
|
|
334
|
+
if (t)
|
|
335
|
+
return t[1].toLowerCase();
|
|
336
|
+
a = a.parentElement;
|
|
337
337
|
}
|
|
338
338
|
return "none";
|
|
339
339
|
},
|
|
@@ -344,8 +344,8 @@ function Me() {
|
|
|
344
344
|
* @param {string} language
|
|
345
345
|
* @returns {void}
|
|
346
346
|
*/
|
|
347
|
-
setLanguage: function(
|
|
348
|
-
|
|
347
|
+
setLanguage: function(a, t) {
|
|
348
|
+
a.className = a.className.replace(RegExp(c, "gi"), ""), a.classList.add("language-" + t);
|
|
349
349
|
},
|
|
350
350
|
/**
|
|
351
351
|
* Returns the script element that is currently executing.
|
|
@@ -365,12 +365,12 @@ function Me() {
|
|
|
365
365
|
try {
|
|
366
366
|
throw new Error();
|
|
367
367
|
} catch (s) {
|
|
368
|
-
var
|
|
369
|
-
if (
|
|
370
|
-
var
|
|
371
|
-
for (var r in
|
|
372
|
-
if (
|
|
373
|
-
return
|
|
368
|
+
var a = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(s.stack) || [])[1];
|
|
369
|
+
if (a) {
|
|
370
|
+
var t = document.getElementsByTagName("script");
|
|
371
|
+
for (var r in t)
|
|
372
|
+
if (t[r].src == a)
|
|
373
|
+
return t[r];
|
|
374
374
|
}
|
|
375
375
|
return null;
|
|
376
376
|
}
|
|
@@ -394,14 +394,14 @@ function Me() {
|
|
|
394
394
|
* @param {boolean} [defaultActivation=false]
|
|
395
395
|
* @returns {boolean}
|
|
396
396
|
*/
|
|
397
|
-
isActive: function(
|
|
398
|
-
for (var s = "no-" +
|
|
399
|
-
var i =
|
|
400
|
-
if (i.contains(
|
|
397
|
+
isActive: function(a, t, r) {
|
|
398
|
+
for (var s = "no-" + t; a; ) {
|
|
399
|
+
var i = a.classList;
|
|
400
|
+
if (i.contains(t))
|
|
401
401
|
return !0;
|
|
402
402
|
if (i.contains(s))
|
|
403
403
|
return !1;
|
|
404
|
-
|
|
404
|
+
a = a.parentElement;
|
|
405
405
|
}
|
|
406
406
|
return !!r;
|
|
407
407
|
}
|
|
@@ -417,10 +417,10 @@ function Me() {
|
|
|
417
417
|
/**
|
|
418
418
|
* The grammar for plain, unformatted text.
|
|
419
419
|
*/
|
|
420
|
-
plain:
|
|
421
|
-
plaintext:
|
|
422
|
-
text:
|
|
423
|
-
txt:
|
|
420
|
+
plain: S,
|
|
421
|
+
plaintext: S,
|
|
422
|
+
text: S,
|
|
423
|
+
txt: S,
|
|
424
424
|
/**
|
|
425
425
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
426
426
|
*
|
|
@@ -449,10 +449,10 @@ function Me() {
|
|
|
449
449
|
* 'color': /\b(?:red|green|blue)\b/
|
|
450
450
|
* });
|
|
451
451
|
*/
|
|
452
|
-
extend: function(
|
|
453
|
-
var r =
|
|
454
|
-
for (var s in
|
|
455
|
-
r[s] =
|
|
452
|
+
extend: function(a, t) {
|
|
453
|
+
var r = o.util.clone(o.languages[a]);
|
|
454
|
+
for (var s in t)
|
|
455
|
+
r[s] = t[s];
|
|
456
456
|
return r;
|
|
457
457
|
},
|
|
458
458
|
/**
|
|
@@ -530,31 +530,31 @@ function Me() {
|
|
|
530
530
|
* @returns {Grammar} The new grammar object.
|
|
531
531
|
* @public
|
|
532
532
|
*/
|
|
533
|
-
insertBefore: function(
|
|
533
|
+
insertBefore: function(a, t, r, s) {
|
|
534
534
|
s = s || /** @type {any} */
|
|
535
|
-
|
|
536
|
-
var i = s[
|
|
535
|
+
o.languages;
|
|
536
|
+
var i = s[a], g = {};
|
|
537
537
|
for (var p in i)
|
|
538
538
|
if (i.hasOwnProperty(p)) {
|
|
539
|
-
if (p ==
|
|
539
|
+
if (p == t)
|
|
540
540
|
for (var d in r)
|
|
541
541
|
r.hasOwnProperty(d) && (g[d] = r[d]);
|
|
542
542
|
r.hasOwnProperty(p) || (g[p] = i[p]);
|
|
543
543
|
}
|
|
544
|
-
var
|
|
545
|
-
return s[
|
|
546
|
-
|
|
544
|
+
var A = s[a];
|
|
545
|
+
return s[a] = g, o.languages.DFS(o.languages, function(b, F) {
|
|
546
|
+
F === A && b != a && (this[b] = g);
|
|
547
547
|
}), g;
|
|
548
548
|
},
|
|
549
549
|
// Traverse a language definition with Depth First Search
|
|
550
|
-
DFS: function t
|
|
550
|
+
DFS: function a(t, r, s, i) {
|
|
551
551
|
i = i || {};
|
|
552
|
-
var g =
|
|
553
|
-
for (var p in
|
|
554
|
-
if (
|
|
555
|
-
r.call(
|
|
556
|
-
var d =
|
|
557
|
-
|
|
552
|
+
var g = o.util.objId;
|
|
553
|
+
for (var p in t)
|
|
554
|
+
if (t.hasOwnProperty(p)) {
|
|
555
|
+
r.call(t, p, t[p], s || p);
|
|
556
|
+
var d = t[p], A = o.util.type(d);
|
|
557
|
+
A === "Object" && !i[g(d)] ? (i[g(d)] = !0, a(d, r, null, i)) : A === "Array" && !i[g(d)] && (i[g(d)] = !0, a(d, r, p, i));
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
},
|
|
@@ -571,8 +571,8 @@ function Me() {
|
|
|
571
571
|
* @memberof Prism
|
|
572
572
|
* @public
|
|
573
573
|
*/
|
|
574
|
-
highlightAll: function(
|
|
575
|
-
|
|
574
|
+
highlightAll: function(a, t) {
|
|
575
|
+
o.highlightAllUnder(document, a, t);
|
|
576
576
|
},
|
|
577
577
|
/**
|
|
578
578
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -589,15 +589,15 @@ function Me() {
|
|
|
589
589
|
* @memberof Prism
|
|
590
590
|
* @public
|
|
591
591
|
*/
|
|
592
|
-
highlightAllUnder: function(
|
|
592
|
+
highlightAllUnder: function(a, t, r) {
|
|
593
593
|
var s = {
|
|
594
594
|
callback: r,
|
|
595
|
-
container:
|
|
595
|
+
container: a,
|
|
596
596
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
597
597
|
};
|
|
598
|
-
|
|
598
|
+
o.hooks.run("before-highlightall", s), s.elements = Array.prototype.slice.apply(s.container.querySelectorAll(s.selector)), o.hooks.run("before-all-elements-highlight", s);
|
|
599
599
|
for (var i = 0, g; g = s.elements[i++]; )
|
|
600
|
-
|
|
600
|
+
o.highlightElement(g, t === !0, s.callback);
|
|
601
601
|
},
|
|
602
602
|
/**
|
|
603
603
|
* Highlights the code inside a single element.
|
|
@@ -627,39 +627,39 @@ function Me() {
|
|
|
627
627
|
* @memberof Prism
|
|
628
628
|
* @public
|
|
629
629
|
*/
|
|
630
|
-
highlightElement: function(
|
|
631
|
-
var s =
|
|
632
|
-
|
|
633
|
-
var g =
|
|
634
|
-
g && g.nodeName.toLowerCase() === "pre" &&
|
|
635
|
-
var p =
|
|
636
|
-
element:
|
|
630
|
+
highlightElement: function(a, t, r) {
|
|
631
|
+
var s = o.util.getLanguage(a), i = o.languages[s];
|
|
632
|
+
o.util.setLanguage(a, s);
|
|
633
|
+
var g = a.parentElement;
|
|
634
|
+
g && g.nodeName.toLowerCase() === "pre" && o.util.setLanguage(g, s);
|
|
635
|
+
var p = a.textContent, d = {
|
|
636
|
+
element: a,
|
|
637
637
|
language: s,
|
|
638
638
|
grammar: i,
|
|
639
639
|
code: p
|
|
640
640
|
};
|
|
641
|
-
function
|
|
642
|
-
d.highlightedCode =
|
|
641
|
+
function A(F) {
|
|
642
|
+
d.highlightedCode = F, o.hooks.run("before-insert", d), d.element.innerHTML = d.highlightedCode, o.hooks.run("after-highlight", d), o.hooks.run("complete", d), r && r.call(d.element);
|
|
643
643
|
}
|
|
644
|
-
if (
|
|
645
|
-
|
|
644
|
+
if (o.hooks.run("before-sanity-check", d), g = d.element.parentElement, g && g.nodeName.toLowerCase() === "pre" && !g.hasAttribute("tabindex") && g.setAttribute("tabindex", "0"), !d.code) {
|
|
645
|
+
o.hooks.run("complete", d), r && r.call(d.element);
|
|
646
646
|
return;
|
|
647
647
|
}
|
|
648
|
-
if (
|
|
649
|
-
|
|
648
|
+
if (o.hooks.run("before-highlight", d), !d.grammar) {
|
|
649
|
+
A(o.util.encode(d.code));
|
|
650
650
|
return;
|
|
651
651
|
}
|
|
652
|
-
if (
|
|
653
|
-
var b = new Worker(
|
|
654
|
-
b.onmessage = function(
|
|
655
|
-
|
|
652
|
+
if (t && l.Worker) {
|
|
653
|
+
var b = new Worker(o.filename);
|
|
654
|
+
b.onmessage = function(F) {
|
|
655
|
+
A(F.data);
|
|
656
656
|
}, b.postMessage(JSON.stringify({
|
|
657
657
|
language: d.language,
|
|
658
658
|
code: d.code,
|
|
659
659
|
immediateClose: !0
|
|
660
660
|
}));
|
|
661
661
|
} else
|
|
662
|
-
|
|
662
|
+
A(o.highlight(d.code, d.grammar, d.language));
|
|
663
663
|
},
|
|
664
664
|
/**
|
|
665
665
|
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
@@ -681,15 +681,15 @@ function Me() {
|
|
|
681
681
|
* @example
|
|
682
682
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
683
683
|
*/
|
|
684
|
-
highlight: function(
|
|
684
|
+
highlight: function(a, t, r) {
|
|
685
685
|
var s = {
|
|
686
|
-
code:
|
|
687
|
-
grammar:
|
|
686
|
+
code: a,
|
|
687
|
+
grammar: t,
|
|
688
688
|
language: r
|
|
689
689
|
};
|
|
690
|
-
if (
|
|
690
|
+
if (o.hooks.run("before-tokenize", s), !s.grammar)
|
|
691
691
|
throw new Error('The language "' + s.language + '" has no grammar.');
|
|
692
|
-
return s.tokens =
|
|
692
|
+
return s.tokens = o.tokenize(s.code, s.grammar), o.hooks.run("after-tokenize", s), h.stringify(o.util.encode(s.tokens), s.language);
|
|
693
693
|
},
|
|
694
694
|
/**
|
|
695
695
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -715,15 +715,15 @@ function Me() {
|
|
|
715
715
|
* }
|
|
716
716
|
* });
|
|
717
717
|
*/
|
|
718
|
-
tokenize: function(
|
|
719
|
-
var r =
|
|
718
|
+
tokenize: function(a, t) {
|
|
719
|
+
var r = t.rest;
|
|
720
720
|
if (r) {
|
|
721
721
|
for (var s in r)
|
|
722
|
-
|
|
723
|
-
delete
|
|
722
|
+
t[s] = r[s];
|
|
723
|
+
delete t.rest;
|
|
724
724
|
}
|
|
725
|
-
var i = new
|
|
726
|
-
return
|
|
725
|
+
var i = new v();
|
|
726
|
+
return w(i, i.head, a), R(a, i, t, i.head, 0), L(i);
|
|
727
727
|
},
|
|
728
728
|
/**
|
|
729
729
|
* @namespace
|
|
@@ -744,9 +744,9 @@ function Me() {
|
|
|
744
744
|
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
745
745
|
* @public
|
|
746
746
|
*/
|
|
747
|
-
add: function(
|
|
748
|
-
var r =
|
|
749
|
-
r[
|
|
747
|
+
add: function(a, t) {
|
|
748
|
+
var r = o.hooks.all;
|
|
749
|
+
r[a] = r[a] || [], r[a].push(t);
|
|
750
750
|
},
|
|
751
751
|
/**
|
|
752
752
|
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
@@ -757,134 +757,134 @@ function Me() {
|
|
|
757
757
|
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
758
758
|
* @public
|
|
759
759
|
*/
|
|
760
|
-
run: function(
|
|
761
|
-
var r =
|
|
760
|
+
run: function(a, t) {
|
|
761
|
+
var r = o.hooks.all[a];
|
|
762
762
|
if (!(!r || !r.length))
|
|
763
763
|
for (var s = 0, i; i = r[s++]; )
|
|
764
|
-
i(
|
|
764
|
+
i(t);
|
|
765
765
|
}
|
|
766
766
|
},
|
|
767
|
-
Token:
|
|
767
|
+
Token: h
|
|
768
768
|
};
|
|
769
|
-
l.Prism =
|
|
770
|
-
function
|
|
771
|
-
this.type =
|
|
769
|
+
l.Prism = o;
|
|
770
|
+
function h(a, t, r, s) {
|
|
771
|
+
this.type = a, this.content = t, this.alias = r, this.length = (s || "").length | 0;
|
|
772
772
|
}
|
|
773
|
-
|
|
774
|
-
if (typeof
|
|
775
|
-
return
|
|
776
|
-
if (Array.isArray(
|
|
773
|
+
h.stringify = function a(t, r) {
|
|
774
|
+
if (typeof t == "string")
|
|
775
|
+
return t;
|
|
776
|
+
if (Array.isArray(t)) {
|
|
777
777
|
var s = "";
|
|
778
|
-
return
|
|
779
|
-
s +=
|
|
778
|
+
return t.forEach(function(A) {
|
|
779
|
+
s += a(A, r);
|
|
780
780
|
}), s;
|
|
781
781
|
}
|
|
782
782
|
var i = {
|
|
783
|
-
type:
|
|
784
|
-
content: t
|
|
783
|
+
type: t.type,
|
|
784
|
+
content: a(t.content, r),
|
|
785
785
|
tag: "span",
|
|
786
|
-
classes: ["token",
|
|
786
|
+
classes: ["token", t.type],
|
|
787
787
|
attributes: {},
|
|
788
788
|
language: r
|
|
789
|
-
}, g =
|
|
790
|
-
g && (Array.isArray(g) ? Array.prototype.push.apply(i.classes, g) : i.classes.push(g)),
|
|
789
|
+
}, g = t.alias;
|
|
790
|
+
g && (Array.isArray(g) ? Array.prototype.push.apply(i.classes, g) : i.classes.push(g)), o.hooks.run("wrap", i);
|
|
791
791
|
var p = "";
|
|
792
792
|
for (var d in i.attributes)
|
|
793
793
|
p += " " + d + '="' + (i.attributes[d] || "").replace(/"/g, """) + '"';
|
|
794
794
|
return "<" + i.tag + ' class="' + i.classes.join(" ") + '"' + p + ">" + i.content + "</" + i.tag + ">";
|
|
795
795
|
};
|
|
796
|
-
function y(
|
|
797
|
-
|
|
798
|
-
var i =
|
|
796
|
+
function y(a, t, r, s) {
|
|
797
|
+
a.lastIndex = t;
|
|
798
|
+
var i = a.exec(r);
|
|
799
799
|
if (i && s && i[1]) {
|
|
800
800
|
var g = i[1].length;
|
|
801
801
|
i.index += g, i[0] = i[0].slice(g);
|
|
802
802
|
}
|
|
803
803
|
return i;
|
|
804
804
|
}
|
|
805
|
-
function
|
|
805
|
+
function R(a, t, r, s, i, g) {
|
|
806
806
|
for (var p in r)
|
|
807
807
|
if (!(!r.hasOwnProperty(p) || !r[p])) {
|
|
808
808
|
var d = r[p];
|
|
809
809
|
d = Array.isArray(d) ? d : [d];
|
|
810
|
-
for (var
|
|
811
|
-
if (g && g.cause == p + "," +
|
|
810
|
+
for (var A = 0; A < d.length; ++A) {
|
|
811
|
+
if (g && g.cause == p + "," + A)
|
|
812
812
|
return;
|
|
813
|
-
var b = d[
|
|
813
|
+
var b = d[A], F = b.inside, ee = !!b.lookbehind, te = !!b.greedy, me = b.alias;
|
|
814
814
|
if (te && !b.pattern.global) {
|
|
815
815
|
var Ae = b.pattern.toString().match(/[imsuy]*$/)[0];
|
|
816
816
|
b.pattern = RegExp(b.pattern.source, Ae + "g");
|
|
817
817
|
}
|
|
818
|
-
for (var ne = b.pattern || b, I = s.next,
|
|
818
|
+
for (var ne = b.pattern || b, I = s.next, N = i; I !== t.tail && !(g && N >= g.reach); N += I.value.length, I = I.next) {
|
|
819
819
|
var D = I.value;
|
|
820
|
-
if (
|
|
820
|
+
if (t.length > a.length)
|
|
821
821
|
return;
|
|
822
|
-
if (!(D instanceof
|
|
823
|
-
var M = 1,
|
|
822
|
+
if (!(D instanceof h)) {
|
|
823
|
+
var M = 1, O;
|
|
824
824
|
if (te) {
|
|
825
|
-
if (
|
|
825
|
+
if (O = y(ne, N, a, ee), !O || O.index >= a.length)
|
|
826
826
|
break;
|
|
827
|
-
var $ =
|
|
828
|
-
for (
|
|
829
|
-
I = I.next,
|
|
830
|
-
if (
|
|
827
|
+
var $ = O.index, Se = O.index + O[0].length, C = N;
|
|
828
|
+
for (C += I.value.length; $ >= C; )
|
|
829
|
+
I = I.next, C += I.value.length;
|
|
830
|
+
if (C -= I.value.length, N = C, I.value instanceof h)
|
|
831
831
|
continue;
|
|
832
|
-
for (var P = I; P !==
|
|
833
|
-
M++,
|
|
834
|
-
M--, D =
|
|
835
|
-
} else if (
|
|
832
|
+
for (var P = I; P !== t.tail && (C < Se || typeof P.value == "string"); P = P.next)
|
|
833
|
+
M++, C += P.value.length;
|
|
834
|
+
M--, D = a.slice(N, C), O.index -= N;
|
|
835
|
+
} else if (O = y(ne, 0, D, ee), !O)
|
|
836
836
|
continue;
|
|
837
|
-
var $ =
|
|
837
|
+
var $ = O.index, G = O[0], j = D.slice(0, $), ae = D.slice($ + G.length), K = N + D.length;
|
|
838
838
|
g && K > g.reach && (g.reach = K);
|
|
839
839
|
var B = I.prev;
|
|
840
|
-
j && (B =
|
|
841
|
-
var Te = new
|
|
842
|
-
if (I =
|
|
840
|
+
j && (B = w(t, B, j), N += j.length), k(t, B, M);
|
|
841
|
+
var Te = new h(p, F ? o.tokenize(G, F) : G, me, G);
|
|
842
|
+
if (I = w(t, B, Te), ae && w(t, I, ae), M > 1) {
|
|
843
843
|
var q = {
|
|
844
|
-
cause: p + "," +
|
|
844
|
+
cause: p + "," + A,
|
|
845
845
|
reach: K
|
|
846
846
|
};
|
|
847
|
-
|
|
847
|
+
R(a, t, r, I.prev, N, q), g && q.reach > g.reach && (g.reach = q.reach);
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
function
|
|
855
|
-
var
|
|
856
|
-
|
|
854
|
+
function v() {
|
|
855
|
+
var a = { value: null, prev: null, next: null }, t = { value: null, prev: a, next: null };
|
|
856
|
+
a.next = t, this.head = a, this.tail = t, this.length = 0;
|
|
857
857
|
}
|
|
858
|
-
function
|
|
859
|
-
var s =
|
|
860
|
-
return
|
|
858
|
+
function w(a, t, r) {
|
|
859
|
+
var s = t.next, i = { value: r, prev: t, next: s };
|
|
860
|
+
return t.next = i, s.prev = i, a.length++, i;
|
|
861
861
|
}
|
|
862
|
-
function k(
|
|
863
|
-
for (var s =
|
|
862
|
+
function k(a, t, r) {
|
|
863
|
+
for (var s = t.next, i = 0; i < r && s !== a.tail; i++)
|
|
864
864
|
s = s.next;
|
|
865
|
-
|
|
865
|
+
t.next = s, s.prev = t, a.length -= i;
|
|
866
866
|
}
|
|
867
|
-
function
|
|
868
|
-
for (var
|
|
869
|
-
|
|
870
|
-
return
|
|
867
|
+
function L(a) {
|
|
868
|
+
for (var t = [], r = a.head.next; r !== a.tail; )
|
|
869
|
+
t.push(r.value), r = r.next;
|
|
870
|
+
return t;
|
|
871
871
|
}
|
|
872
872
|
if (!l.document)
|
|
873
|
-
return l.addEventListener && (
|
|
874
|
-
var
|
|
875
|
-
l.postMessage(
|
|
876
|
-
}, !1)),
|
|
877
|
-
var
|
|
878
|
-
|
|
873
|
+
return l.addEventListener && (o.disableWorkerMessageHandler || l.addEventListener("message", function(a) {
|
|
874
|
+
var t = JSON.parse(a.data), r = t.language, s = t.code, i = t.immediateClose;
|
|
875
|
+
l.postMessage(o.highlight(s, o.languages[r], r)), i && l.close();
|
|
876
|
+
}, !1)), o;
|
|
877
|
+
var m = o.util.currentScript();
|
|
878
|
+
m && (o.filename = m.src, m.hasAttribute("data-manual") && (o.manual = !0));
|
|
879
879
|
function f() {
|
|
880
|
-
|
|
880
|
+
o.manual || o.highlightAll();
|
|
881
881
|
}
|
|
882
|
-
if (!
|
|
883
|
-
var
|
|
884
|
-
|
|
882
|
+
if (!o.manual) {
|
|
883
|
+
var T = document.readyState;
|
|
884
|
+
T === "loading" || T === "interactive" && m && m.defer ? document.addEventListener("DOMContentLoaded", f) : window.requestAnimationFrame ? window.requestAnimationFrame(f) : window.setTimeout(f, 16);
|
|
885
885
|
}
|
|
886
|
-
return
|
|
887
|
-
})(
|
|
886
|
+
return o;
|
|
887
|
+
})(u);
|
|
888
888
|
n.exports && (n.exports = e), typeof ie < "u" && (ie.Prism = e), e.languages.markup = {
|
|
889
889
|
comment: {
|
|
890
890
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
@@ -977,31 +977,31 @@ function Me() {
|
|
|
977
977
|
* addInlined('style', 'css');
|
|
978
978
|
*/
|
|
979
979
|
value: function(c, E) {
|
|
980
|
-
var
|
|
981
|
-
|
|
980
|
+
var S = {};
|
|
981
|
+
S["language-" + E] = {
|
|
982
982
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
983
983
|
lookbehind: !0,
|
|
984
984
|
inside: e.languages[E]
|
|
985
|
-
},
|
|
986
|
-
var
|
|
985
|
+
}, S.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
986
|
+
var o = {
|
|
987
987
|
"included-cdata": {
|
|
988
988
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
989
|
-
inside:
|
|
989
|
+
inside: S
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
|
-
|
|
992
|
+
o["language-" + E] = {
|
|
993
993
|
pattern: /[\s\S]+/,
|
|
994
994
|
inside: e.languages[E]
|
|
995
995
|
};
|
|
996
|
-
var
|
|
997
|
-
|
|
996
|
+
var h = {};
|
|
997
|
+
h[c] = {
|
|
998
998
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
999
999
|
return c;
|
|
1000
1000
|
}), "i"),
|
|
1001
1001
|
lookbehind: !0,
|
|
1002
1002
|
greedy: !0,
|
|
1003
|
-
inside:
|
|
1004
|
-
}, e.languages.insertBefore("markup", "cdata",
|
|
1003
|
+
inside: o
|
|
1004
|
+
}, e.languages.insertBefore("markup", "cdata", h);
|
|
1005
1005
|
}
|
|
1006
1006
|
}), Object.defineProperty(e.languages.markup.tag, "addAttribute", {
|
|
1007
1007
|
/**
|
|
@@ -1263,9 +1263,9 @@ function Me() {
|
|
|
1263
1263
|
if (typeof e > "u" || typeof document > "u")
|
|
1264
1264
|
return;
|
|
1265
1265
|
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1266
|
-
var l = "Loading…", c = function(
|
|
1267
|
-
return "✖ Error " +
|
|
1268
|
-
}, E = "✖ Error: File does not exist or is empty",
|
|
1266
|
+
var l = "Loading…", c = function(m, f) {
|
|
1267
|
+
return "✖ Error " + m + " while fetching file: " + f;
|
|
1268
|
+
}, E = "✖ Error: File does not exist or is empty", S = {
|
|
1269
1269
|
js: "javascript",
|
|
1270
1270
|
py: "python",
|
|
1271
1271
|
rb: "ruby",
|
|
@@ -1275,52 +1275,52 @@ function Me() {
|
|
|
1275
1275
|
bat: "batch",
|
|
1276
1276
|
h: "c",
|
|
1277
1277
|
tex: "latex"
|
|
1278
|
-
},
|
|
1279
|
-
function
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
},
|
|
1278
|
+
}, o = "data-src-status", h = "loading", y = "loaded", R = "failed", v = "pre[data-src]:not([" + o + '="' + y + '"]):not([' + o + '="' + h + '"])';
|
|
1279
|
+
function w(m, f, T) {
|
|
1280
|
+
var a = new XMLHttpRequest();
|
|
1281
|
+
a.open("GET", m, !0), a.onreadystatechange = function() {
|
|
1282
|
+
a.readyState == 4 && (a.status < 400 && a.responseText ? f(a.responseText) : a.status >= 400 ? T(c(a.status, a.statusText)) : T(E));
|
|
1283
|
+
}, a.send(null);
|
|
1284
1284
|
}
|
|
1285
|
-
function k(
|
|
1286
|
-
var f = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(
|
|
1285
|
+
function k(m) {
|
|
1286
|
+
var f = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(m || "");
|
|
1287
1287
|
if (f) {
|
|
1288
|
-
var
|
|
1289
|
-
return
|
|
1288
|
+
var T = Number(f[1]), a = f[2], t = f[3];
|
|
1289
|
+
return a ? t ? [T, Number(t)] : [T, void 0] : [T, T];
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
e.hooks.add("before-highlightall", function(
|
|
1293
|
-
|
|
1294
|
-
}), e.hooks.add("before-sanity-check", function(
|
|
1292
|
+
e.hooks.add("before-highlightall", function(m) {
|
|
1293
|
+
m.selector += ", " + v;
|
|
1294
|
+
}), e.hooks.add("before-sanity-check", function(m) {
|
|
1295
1295
|
var f = (
|
|
1296
1296
|
/** @type {HTMLPreElement} */
|
|
1297
|
-
|
|
1297
|
+
m.element
|
|
1298
1298
|
);
|
|
1299
|
-
if (f.matches(
|
|
1300
|
-
|
|
1301
|
-
var
|
|
1302
|
-
|
|
1303
|
-
var
|
|
1304
|
-
if (
|
|
1305
|
-
var r = (/\.(\w+)$/.exec(
|
|
1306
|
-
|
|
1299
|
+
if (f.matches(v)) {
|
|
1300
|
+
m.code = "", f.setAttribute(o, h);
|
|
1301
|
+
var T = f.appendChild(document.createElement("CODE"));
|
|
1302
|
+
T.textContent = l;
|
|
1303
|
+
var a = f.getAttribute("data-src"), t = m.language;
|
|
1304
|
+
if (t === "none") {
|
|
1305
|
+
var r = (/\.(\w+)$/.exec(a) || [, "none"])[1];
|
|
1306
|
+
t = S[r] || r;
|
|
1307
1307
|
}
|
|
1308
|
-
e.util.setLanguage(
|
|
1308
|
+
e.util.setLanguage(T, t), e.util.setLanguage(f, t);
|
|
1309
1309
|
var s = e.plugins.autoloader;
|
|
1310
|
-
s && s.loadLanguages(
|
|
1311
|
-
|
|
1310
|
+
s && s.loadLanguages(t), w(
|
|
1311
|
+
a,
|
|
1312
1312
|
function(i) {
|
|
1313
|
-
f.setAttribute(
|
|
1313
|
+
f.setAttribute(o, y);
|
|
1314
1314
|
var g = k(f.getAttribute("data-range"));
|
|
1315
1315
|
if (g) {
|
|
1316
|
-
var p = i.split(/\r\n?|\n/g), d = g[0],
|
|
1317
|
-
d < 0 && (d += p.length), d = Math.max(0, Math.min(d - 1, p.length)),
|
|
1316
|
+
var p = i.split(/\r\n?|\n/g), d = g[0], A = g[1] == null ? p.length : g[1];
|
|
1317
|
+
d < 0 && (d += p.length), d = Math.max(0, Math.min(d - 1, p.length)), A < 0 && (A += p.length), A = Math.max(0, Math.min(A, p.length)), i = p.slice(d, A).join(`
|
|
1318
1318
|
`), f.hasAttribute("data-start") || f.setAttribute("data-start", String(d + 1));
|
|
1319
1319
|
}
|
|
1320
|
-
|
|
1320
|
+
T.textContent = i, e.highlightElement(T);
|
|
1321
1321
|
},
|
|
1322
1322
|
function(i) {
|
|
1323
|
-
f.setAttribute(
|
|
1323
|
+
f.setAttribute(o, R), T.textContent = i;
|
|
1324
1324
|
}
|
|
1325
1325
|
);
|
|
1326
1326
|
}
|
|
@@ -1333,13 +1333,13 @@ function Me() {
|
|
|
1333
1333
|
* @param {ParentNode} [container=document]
|
|
1334
1334
|
*/
|
|
1335
1335
|
highlight: function(f) {
|
|
1336
|
-
for (var
|
|
1337
|
-
e.highlightElement(
|
|
1336
|
+
for (var T = (f || document).querySelectorAll(v), a = 0, t; t = T[a++]; )
|
|
1337
|
+
e.highlightElement(t);
|
|
1338
1338
|
}
|
|
1339
1339
|
};
|
|
1340
|
-
var
|
|
1340
|
+
var L = !1;
|
|
1341
1341
|
e.fileHighlight = function() {
|
|
1342
|
-
|
|
1342
|
+
L || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), L = !0), e.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1343
1343
|
};
|
|
1344
1344
|
})();
|
|
1345
1345
|
})(V)), V.exports;
|
|
@@ -1430,8 +1430,8 @@ function Be() {
|
|
|
1430
1430
|
// This is for `import type *, {}`
|
|
1431
1431
|
/\btype\b(?=\s*(?:[\{*]|$))/
|
|
1432
1432
|
), delete n.languages.typescript.parameter, delete n.languages.typescript["literal-property"];
|
|
1433
|
-
var
|
|
1434
|
-
delete
|
|
1433
|
+
var u = n.languages.extend("typescript", {});
|
|
1434
|
+
delete u["class-name"], n.languages.typescript["class-name"].inside = u, n.languages.insertBefore("typescript", "function", {
|
|
1435
1435
|
decorator: {
|
|
1436
1436
|
pattern: /@[$\w\xA0-\uFFFF]+/,
|
|
1437
1437
|
inside: {
|
|
@@ -1452,7 +1452,7 @@ function Be() {
|
|
|
1452
1452
|
pattern: /<[\s\S]+/,
|
|
1453
1453
|
// everything after the first <
|
|
1454
1454
|
alias: "class-name",
|
|
1455
|
-
inside:
|
|
1455
|
+
inside: u
|
|
1456
1456
|
}
|
|
1457
1457
|
}
|
|
1458
1458
|
}
|
|
@@ -1461,7 +1461,7 @@ function Be() {
|
|
|
1461
1461
|
}
|
|
1462
1462
|
Be();
|
|
1463
1463
|
(function(n) {
|
|
1464
|
-
var
|
|
1464
|
+
var u = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b", e = {
|
|
1465
1465
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1466
1466
|
lookbehind: !0,
|
|
1467
1467
|
alias: "punctuation",
|
|
@@ -1471,7 +1471,7 @@ Be();
|
|
|
1471
1471
|
}, l = {
|
|
1472
1472
|
bash: e,
|
|
1473
1473
|
environment: {
|
|
1474
|
-
pattern: RegExp("\\$" +
|
|
1474
|
+
pattern: RegExp("\\$" + u),
|
|
1475
1475
|
alias: "constant"
|
|
1476
1476
|
},
|
|
1477
1477
|
variable: [
|
|
@@ -1511,7 +1511,7 @@ Be();
|
|
|
1511
1511
|
operator: /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
1512
1512
|
punctuation: /[\[\]]/,
|
|
1513
1513
|
environment: {
|
|
1514
|
-
pattern: RegExp("(\\{)" +
|
|
1514
|
+
pattern: RegExp("(\\{)" + u),
|
|
1515
1515
|
lookbehind: !0,
|
|
1516
1516
|
alias: "constant"
|
|
1517
1517
|
}
|
|
@@ -1560,7 +1560,7 @@ Be();
|
|
|
1560
1560
|
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
1561
1561
|
inside: {
|
|
1562
1562
|
environment: {
|
|
1563
|
-
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" +
|
|
1563
|
+
pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + u),
|
|
1564
1564
|
lookbehind: !0,
|
|
1565
1565
|
alias: "constant"
|
|
1566
1566
|
}
|
|
@@ -1616,7 +1616,7 @@ Be();
|
|
|
1616
1616
|
}
|
|
1617
1617
|
],
|
|
1618
1618
|
environment: {
|
|
1619
|
-
pattern: RegExp("\\$?" +
|
|
1619
|
+
pattern: RegExp("\\$?" + u),
|
|
1620
1620
|
alias: "constant"
|
|
1621
1621
|
},
|
|
1622
1622
|
variable: l.variable,
|
|
@@ -1675,8 +1675,8 @@ Be();
|
|
|
1675
1675
|
"operator",
|
|
1676
1676
|
"punctuation",
|
|
1677
1677
|
"number"
|
|
1678
|
-
], E = l.variable[1].inside,
|
|
1679
|
-
E[c[
|
|
1678
|
+
], E = l.variable[1].inside, S = 0; S < c.length; S++)
|
|
1679
|
+
E[c[S]] = n.languages.bash[c[S]];
|
|
1680
1680
|
n.languages.sh = n.languages.bash, n.languages.shell = n.languages.bash;
|
|
1681
1681
|
})(Prism);
|
|
1682
1682
|
Prism.languages.json = {
|
|
@@ -1705,11 +1705,11 @@ Prism.languages.json = {
|
|
|
1705
1705
|
};
|
|
1706
1706
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
1707
1707
|
(function(n) {
|
|
1708
|
-
var
|
|
1708
|
+
var u = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1709
1709
|
n.languages.css = {
|
|
1710
1710
|
comment: /\/\*[\s\S]*?\*\//,
|
|
1711
1711
|
atrule: {
|
|
1712
|
-
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" +
|
|
1712
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + u.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1713
1713
|
inside: {
|
|
1714
1714
|
rule: /^@[\w-]+/,
|
|
1715
1715
|
"selector-function-argument": {
|
|
@@ -1726,23 +1726,23 @@ Prism.languages.webmanifest = Prism.languages.json;
|
|
|
1726
1726
|
},
|
|
1727
1727
|
url: {
|
|
1728
1728
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1729
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1729
|
+
pattern: RegExp("\\burl\\((?:" + u.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1730
1730
|
greedy: !0,
|
|
1731
1731
|
inside: {
|
|
1732
1732
|
function: /^url/i,
|
|
1733
1733
|
punctuation: /^\(|\)$/,
|
|
1734
1734
|
string: {
|
|
1735
|
-
pattern: RegExp("^" +
|
|
1735
|
+
pattern: RegExp("^" + u.source + "$"),
|
|
1736
1736
|
alias: "url"
|
|
1737
1737
|
}
|
|
1738
1738
|
}
|
|
1739
1739
|
},
|
|
1740
1740
|
selector: {
|
|
1741
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1741
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + u.source + ")*(?=\\s*\\{)"),
|
|
1742
1742
|
lookbehind: !0
|
|
1743
1743
|
},
|
|
1744
1744
|
string: {
|
|
1745
|
-
pattern:
|
|
1745
|
+
pattern: u,
|
|
1746
1746
|
greedy: !0
|
|
1747
1747
|
},
|
|
1748
1748
|
property: {
|
|
@@ -1854,7 +1854,7 @@ Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
|
1854
1854
|
* @example
|
|
1855
1855
|
* addInlined('style', 'css');
|
|
1856
1856
|
*/
|
|
1857
|
-
value: function(
|
|
1857
|
+
value: function(u, e) {
|
|
1858
1858
|
var l = {};
|
|
1859
1859
|
l["language-" + e] = {
|
|
1860
1860
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
@@ -1872,9 +1872,9 @@ Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
|
1872
1872
|
inside: Prism.languages[e]
|
|
1873
1873
|
};
|
|
1874
1874
|
var E = {};
|
|
1875
|
-
E[
|
|
1875
|
+
E[u] = {
|
|
1876
1876
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1877
|
-
return
|
|
1877
|
+
return u;
|
|
1878
1878
|
}), "i"),
|
|
1879
1879
|
lookbehind: !0,
|
|
1880
1880
|
greedy: !0,
|
|
@@ -1894,7 +1894,7 @@ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
|
1894
1894
|
* @example
|
|
1895
1895
|
* addAttribute('style', 'css');
|
|
1896
1896
|
*/
|
|
1897
|
-
value: function(n,
|
|
1897
|
+
value: function(n, u) {
|
|
1898
1898
|
Prism.languages.markup.tag.inside["special-attr"].push({
|
|
1899
1899
|
pattern: RegExp(
|
|
1900
1900
|
/(^|["'\s])/.source + "(?:" + n + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
@@ -1909,8 +1909,8 @@ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
|
1909
1909
|
value: {
|
|
1910
1910
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1911
1911
|
lookbehind: !0,
|
|
1912
|
-
alias: [
|
|
1913
|
-
inside: Prism.languages[
|
|
1912
|
+
alias: [u, "language-" + u],
|
|
1913
|
+
inside: Prism.languages[u]
|
|
1914
1914
|
},
|
|
1915
1915
|
punctuation: [
|
|
1916
1916
|
{
|
|
@@ -1978,8 +1978,8 @@ Y.setOptions({
|
|
|
1978
1978
|
gfm: !0
|
|
1979
1979
|
});
|
|
1980
1980
|
const he = new Y.Renderer();
|
|
1981
|
-
he.code = ({ text: n, lang:
|
|
1982
|
-
const e =
|
|
1981
|
+
he.code = ({ text: n, lang: u }) => {
|
|
1982
|
+
const e = u ? He[u] || u : "plaintext", l = ue.languages[e];
|
|
1983
1983
|
if (l) {
|
|
1984
1984
|
const E = ue.highlight(n, l, e);
|
|
1985
1985
|
return `<pre><code class="language-${e}">${E}</code></pre>`;
|
|
@@ -1998,47 +1998,47 @@ function ft(n) {
|
|
|
1998
1998
|
}
|
|
1999
1999
|
async function ze({
|
|
2000
2000
|
publishableApiKey: n,
|
|
2001
|
-
threadId:
|
|
2001
|
+
threadId: u,
|
|
2002
2002
|
fileName: e,
|
|
2003
2003
|
fileType: l,
|
|
2004
2004
|
fileSize: c,
|
|
2005
2005
|
baseUrl: E
|
|
2006
2006
|
}) {
|
|
2007
|
-
const
|
|
2007
|
+
const S = await Q(), o = await fetch(Le(E), {
|
|
2008
2008
|
method: "POST",
|
|
2009
2009
|
headers: {
|
|
2010
2010
|
"Content-Type": "application/json",
|
|
2011
2011
|
"X-Api-Key": n,
|
|
2012
|
-
...
|
|
2012
|
+
...S ? { Authorization: `Bearer ${S}` } : {}
|
|
2013
2013
|
},
|
|
2014
|
-
body: JSON.stringify({ threadId:
|
|
2014
|
+
body: JSON.stringify({ threadId: u, fileName: e, fileType: l, fileSize: c })
|
|
2015
2015
|
});
|
|
2016
|
-
if (!
|
|
2017
|
-
const
|
|
2016
|
+
if (!o.ok) {
|
|
2017
|
+
const h = await o.json().catch(() => ({}));
|
|
2018
2018
|
throw new Error(
|
|
2019
|
-
|
|
2019
|
+
h.error || `Upload URL request failed: ${o.status}`
|
|
2020
2020
|
);
|
|
2021
2021
|
}
|
|
2022
|
-
return
|
|
2022
|
+
return o.json();
|
|
2023
2023
|
}
|
|
2024
|
-
async function Ye(n,
|
|
2024
|
+
async function Ye(n, u) {
|
|
2025
2025
|
const e = await fetch(n, {
|
|
2026
2026
|
method: "PUT",
|
|
2027
|
-
headers: { "Content-Type":
|
|
2028
|
-
body:
|
|
2027
|
+
headers: { "Content-Type": u.type },
|
|
2028
|
+
body: u
|
|
2029
2029
|
});
|
|
2030
2030
|
if (!e.ok)
|
|
2031
2031
|
throw new Error(`Storage upload failed: ${e.status}`);
|
|
2032
2032
|
}
|
|
2033
2033
|
async function Et({
|
|
2034
2034
|
publishableApiKey: n,
|
|
2035
|
-
threadId:
|
|
2035
|
+
threadId: u,
|
|
2036
2036
|
file: e,
|
|
2037
2037
|
baseUrl: l
|
|
2038
2038
|
}) {
|
|
2039
2039
|
const { uploadUrl: c, storagePath: E } = await ze({
|
|
2040
2040
|
publishableApiKey: n,
|
|
2041
|
-
threadId:
|
|
2041
|
+
threadId: u,
|
|
2042
2042
|
fileName: e.name,
|
|
2043
2043
|
fileType: e.type,
|
|
2044
2044
|
fileSize: e.size,
|
|
@@ -2048,7 +2048,7 @@ async function Et({
|
|
|
2048
2048
|
}
|
|
2049
2049
|
async function ht({
|
|
2050
2050
|
publishableApiKey: n,
|
|
2051
|
-
storagePath:
|
|
2051
|
+
storagePath: u,
|
|
2052
2052
|
baseUrl: e
|
|
2053
2053
|
}) {
|
|
2054
2054
|
const l = await Q();
|
|
@@ -2060,7 +2060,7 @@ async function ht({
|
|
|
2060
2060
|
"X-Api-Key": n,
|
|
2061
2061
|
...l ? { Authorization: `Bearer ${l}` } : {}
|
|
2062
2062
|
},
|
|
2063
|
-
body: JSON.stringify({ storagePath:
|
|
2063
|
+
body: JSON.stringify({ storagePath: u })
|
|
2064
2064
|
});
|
|
2065
2065
|
return c.ok && (await c.json()).url || null;
|
|
2066
2066
|
} catch {
|
|
@@ -2079,8 +2079,8 @@ const We = "https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us
|
|
|
2079
2079
|
];
|
|
2080
2080
|
function je(n) {
|
|
2081
2081
|
if (n.tags?.source === "knest-widget") return !0;
|
|
2082
|
-
const
|
|
2083
|
-
return !
|
|
2082
|
+
const u = n.exception?.values?.[0]?.stacktrace?.frames;
|
|
2083
|
+
return !u || u.length === 0 ? !1 : u.some((e) => {
|
|
2084
2084
|
const l = e.filename || "";
|
|
2085
2085
|
return Xe.some((c) => l.includes(c));
|
|
2086
2086
|
});
|
|
@@ -2112,20 +2112,20 @@ function mt() {
|
|
|
2112
2112
|
}
|
|
2113
2113
|
}), pe = !0);
|
|
2114
2114
|
}
|
|
2115
|
-
function At(n,
|
|
2115
|
+
function At(n, u) {
|
|
2116
2116
|
const e = typeof n == "string" ? new Error(n) : n;
|
|
2117
2117
|
Z.captureException(e, {
|
|
2118
2118
|
tags: { source: "knest-widget" },
|
|
2119
|
-
extra:
|
|
2119
|
+
extra: u
|
|
2120
2120
|
});
|
|
2121
2121
|
}
|
|
2122
|
-
function St(n,
|
|
2122
|
+
function St(n, u) {
|
|
2123
2123
|
const e = xe();
|
|
2124
2124
|
if (!e)
|
|
2125
2125
|
return () => {
|
|
2126
2126
|
};
|
|
2127
2127
|
const l = e.channel(`thread:${n}`).on("broadcast", { event: "new-message" }, (c) => {
|
|
2128
|
-
|
|
2128
|
+
u(c.payload);
|
|
2129
2129
|
}).subscribe();
|
|
2130
2130
|
return () => {
|
|
2131
2131
|
l.unsubscribe();
|
|
@@ -2137,31 +2137,31 @@ function z(n) {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
function Tt(n) {
|
|
2139
2139
|
try {
|
|
2140
|
-
const
|
|
2141
|
-
if (!
|
|
2142
|
-
const e = JSON.parse(
|
|
2140
|
+
const u = localStorage.getItem(z(n));
|
|
2141
|
+
if (!u) return null;
|
|
2142
|
+
const e = JSON.parse(u);
|
|
2143
2143
|
return Date.now() - e.savedAt > qe ? (localStorage.removeItem(z(n)), null) : e;
|
|
2144
2144
|
} catch {
|
|
2145
2145
|
return null;
|
|
2146
2146
|
}
|
|
2147
2147
|
}
|
|
2148
|
-
function Ze(n,
|
|
2148
|
+
function Ze(n, u) {
|
|
2149
2149
|
try {
|
|
2150
|
-
localStorage.setItem(z(n), JSON.stringify(
|
|
2150
|
+
localStorage.setItem(z(n), JSON.stringify(u));
|
|
2151
2151
|
} catch {
|
|
2152
2152
|
}
|
|
2153
2153
|
}
|
|
2154
|
-
function bt(n,
|
|
2154
|
+
function bt(n, u) {
|
|
2155
2155
|
const e = U.get(n);
|
|
2156
2156
|
e !== void 0 && clearTimeout(e);
|
|
2157
2157
|
const l = setTimeout(() => {
|
|
2158
|
-
Ze(n,
|
|
2158
|
+
Ze(n, u), U.delete(n);
|
|
2159
2159
|
}, Ve);
|
|
2160
2160
|
U.set(n, l);
|
|
2161
2161
|
}
|
|
2162
2162
|
function It(n) {
|
|
2163
|
-
const
|
|
2164
|
-
|
|
2163
|
+
const u = U.get(n);
|
|
2164
|
+
u !== void 0 && (clearTimeout(u), U.delete(n));
|
|
2165
2165
|
try {
|
|
2166
2166
|
localStorage.removeItem(z(n));
|
|
2167
2167
|
} catch {
|
|
@@ -2170,7 +2170,7 @@ function It(n) {
|
|
|
2170
2170
|
export {
|
|
2171
2171
|
it as ACCEPTED_FILE_TYPES_STRING,
|
|
2172
2172
|
Ee as ALLOWED_ATTACHMENT_TYPES,
|
|
2173
|
-
|
|
2173
|
+
ve as ALLOWED_DOCUMENT_TYPES,
|
|
2174
2174
|
fe as ALLOWED_IMAGE_TYPES,
|
|
2175
2175
|
X as API_PATH,
|
|
2176
2176
|
Oe as AUTH_ERROR_MESSAGE,
|
|
@@ -2185,7 +2185,7 @@ export {
|
|
|
2185
2185
|
we as MAX_ATTACHMENT_SIZE_BYTES,
|
|
2186
2186
|
tt as PUBLIC_SUPABASE_ANON_KEY,
|
|
2187
2187
|
et as PUBLIC_SUPABASE_URL,
|
|
2188
|
-
|
|
2188
|
+
Ne as USAGE_LIMIT_MESSAGE,
|
|
2189
2189
|
At as captureWidgetException,
|
|
2190
2190
|
It as clearChatState,
|
|
2191
2191
|
ht as fetchSignedUrl,
|