@useknest/widget-core 0.1.0-beta.11 → 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/attachments.d.ts +44 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +524 -418
- package/dist/streaming.d.ts +5 -1
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,53 +1,67 @@
|
|
|
1
|
-
import { createClient as
|
|
2
|
-
import { marked as
|
|
3
|
-
import * as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
return `${
|
|
1
|
+
import { createClient as be } from "@supabase/supabase-js";
|
|
2
|
+
import { marked as Y } from "marked";
|
|
3
|
+
import * as Z from "@sentry/browser";
|
|
4
|
+
const W = "https://useknest.com", X = "/api/v1", et = "https://lghrsugmhzpccpriqhrx.supabase.co", tt = "sb_publishable_-KUwilDA78QM849gk662FA_kEzMezNS";
|
|
5
|
+
function Ie(n = W) {
|
|
6
|
+
return `${n}${X}/chat-messages`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return `${
|
|
8
|
+
function ye(n = W) {
|
|
9
|
+
return `${n}${X}/widget-config`;
|
|
10
10
|
}
|
|
11
|
-
const
|
|
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
|
-
],
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
], fe = ["image/jpeg", "image/png", "image/gif", "image/webp"], ve = [
|
|
16
|
+
"application/pdf",
|
|
17
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
18
|
+
"text/plain"
|
|
19
|
+
], Ee = [...fe, ...ve], it = Ee.join(","), we = 10 * 1024 * 1024, ot = 5;
|
|
20
|
+
function Le(n = W) {
|
|
21
|
+
return `${n}${X}/chat-attachments/upload-url`;
|
|
18
22
|
}
|
|
19
|
-
function
|
|
23
|
+
function Fe(n = W) {
|
|
24
|
+
return `${n}${X}/chat-attachments/signed-url`;
|
|
25
|
+
}
|
|
26
|
+
function ut(n) {
|
|
27
|
+
return fe.includes(n);
|
|
28
|
+
}
|
|
29
|
+
const Ce = "knest-widget-config-", ke = 1440 * 60 * 1e3;
|
|
30
|
+
function J(n) {
|
|
31
|
+
return Ce + n;
|
|
32
|
+
}
|
|
33
|
+
function _e(n, u) {
|
|
20
34
|
try {
|
|
21
|
-
const e = localStorage.getItem(
|
|
35
|
+
const e = localStorage.getItem(J(n));
|
|
22
36
|
if (!e) return null;
|
|
23
|
-
const { config: l, cachedAt:
|
|
24
|
-
return Date.now() -
|
|
37
|
+
const { config: l, cachedAt: c } = JSON.parse(e);
|
|
38
|
+
return Date.now() - c > ke ? (localStorage.removeItem(J(n)), null) : (u && l.updatedAt, l);
|
|
25
39
|
} catch {
|
|
26
40
|
return null;
|
|
27
41
|
}
|
|
28
42
|
}
|
|
29
|
-
function
|
|
43
|
+
function De(n, u) {
|
|
30
44
|
try {
|
|
31
45
|
const e = { config: u, cachedAt: Date.now() };
|
|
32
|
-
localStorage.setItem(
|
|
46
|
+
localStorage.setItem(J(n), JSON.stringify(e));
|
|
33
47
|
} catch {
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
|
-
async function
|
|
50
|
+
async function se(n, u) {
|
|
37
51
|
try {
|
|
38
|
-
const e = await fetch(
|
|
52
|
+
const e = await fetch(ye(u), {
|
|
39
53
|
method: "GET",
|
|
40
54
|
headers: {
|
|
41
|
-
"X-Api-Key":
|
|
55
|
+
"X-Api-Key": n
|
|
42
56
|
}
|
|
43
57
|
});
|
|
44
58
|
if (e.ok) {
|
|
45
|
-
const
|
|
46
|
-
return
|
|
59
|
+
const c = await e.json();
|
|
60
|
+
return De(n, c), { config: c, error: null };
|
|
47
61
|
}
|
|
48
62
|
if (e.status === 401 || e.status === 403) {
|
|
49
|
-
const
|
|
50
|
-
return console.warn("Widget config auth error:", e.status,
|
|
63
|
+
const c = await e.json().catch(() => ({}));
|
|
64
|
+
return console.warn("Widget config auth error:", e.status, c), { config: null, error: "auth" };
|
|
51
65
|
}
|
|
52
66
|
const l = await e.text();
|
|
53
67
|
return console.warn("Failed to fetch widget config:", e.status, l), { config: null, error: "network" };
|
|
@@ -55,17 +69,17 @@ async function ne(a, u) {
|
|
|
55
69
|
return console.error("Error fetching widget config:", e), { config: null, error: "network" };
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
|
-
async function
|
|
59
|
-
const l =
|
|
60
|
-
return l ? (e &&
|
|
61
|
-
|
|
62
|
-
}), { config: l, error: null }) :
|
|
72
|
+
async function lt(n, u, e) {
|
|
73
|
+
const l = _e(n);
|
|
74
|
+
return l ? (e && se(n, u).then((c) => {
|
|
75
|
+
c.config && c.config.updatedAt !== l.updatedAt && e(c.config);
|
|
76
|
+
}), { config: l, error: null }) : se(n, u);
|
|
63
77
|
}
|
|
64
|
-
let
|
|
65
|
-
async function
|
|
66
|
-
return x || (H &&
|
|
78
|
+
let _ = null, H = !1, x = null;
|
|
79
|
+
async function ct(n, u) {
|
|
80
|
+
return x || (H && _ ? !0 : (x = (async () => {
|
|
67
81
|
try {
|
|
68
|
-
|
|
82
|
+
_ = be(n, u, {
|
|
69
83
|
auth: {
|
|
70
84
|
// Persist session in localStorage for cross-page persistence.
|
|
71
85
|
persistSession: !0,
|
|
@@ -75,10 +89,10 @@ async function Qe(a, u) {
|
|
|
75
89
|
});
|
|
76
90
|
const {
|
|
77
91
|
data: { session: e }
|
|
78
|
-
} = await
|
|
92
|
+
} = await _.auth.getSession();
|
|
79
93
|
if (e)
|
|
80
94
|
return H = !0, !0;
|
|
81
|
-
const { error: l } = await
|
|
95
|
+
const { error: l } = await _.auth.signInAnonymously();
|
|
82
96
|
return l ? (console.error("Widget auth error:", l.message), !1) : (H = !0, !0);
|
|
83
97
|
} catch (e) {
|
|
84
98
|
return console.error("Widget auth initialization failed:", e), !1;
|
|
@@ -87,93 +101,93 @@ async function Qe(a, u) {
|
|
|
87
101
|
}
|
|
88
102
|
})(), x));
|
|
89
103
|
}
|
|
90
|
-
async function
|
|
91
|
-
if (!
|
|
104
|
+
async function Q() {
|
|
105
|
+
if (!_)
|
|
92
106
|
return null;
|
|
93
107
|
const {
|
|
94
|
-
data: { session:
|
|
95
|
-
} = await
|
|
96
|
-
return
|
|
108
|
+
data: { session: n }
|
|
109
|
+
} = await _.auth.getSession();
|
|
110
|
+
return n?.access_token || null;
|
|
97
111
|
}
|
|
98
|
-
function
|
|
112
|
+
function Pe() {
|
|
99
113
|
return H;
|
|
100
114
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
115
|
+
function xe() {
|
|
116
|
+
return _;
|
|
103
117
|
}
|
|
104
|
-
async function
|
|
105
|
-
const { publishableApiKey: u, content: e, threadId: l, callbacks:
|
|
118
|
+
async function dt(n) {
|
|
119
|
+
const { publishableApiKey: u, content: e, threadId: l, callbacks: c, baseUrl: E, metadata: S, user: o } = n;
|
|
106
120
|
try {
|
|
107
|
-
if (!
|
|
121
|
+
if (!Pe())
|
|
108
122
|
throw new Error("Widget not authenticated. Call initWidgetAuth() first.");
|
|
109
|
-
const
|
|
110
|
-
if (!
|
|
123
|
+
const h = await Q();
|
|
124
|
+
if (!h)
|
|
111
125
|
throw new Error("No access token available. Please refresh and try again.");
|
|
112
|
-
const
|
|
113
|
-
l && (
|
|
114
|
-
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), {
|
|
115
129
|
method: "POST",
|
|
116
130
|
headers: {
|
|
117
131
|
"Content-Type": "application/json",
|
|
118
132
|
"X-Api-Key": u,
|
|
119
|
-
Authorization: `Bearer ${
|
|
133
|
+
Authorization: `Bearer ${h}`
|
|
120
134
|
},
|
|
121
135
|
credentials: "include",
|
|
122
|
-
body: JSON.stringify(
|
|
136
|
+
body: JSON.stringify(y)
|
|
123
137
|
});
|
|
124
|
-
if (!
|
|
125
|
-
if (
|
|
126
|
-
throw new Error(
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
129
|
-
throw
|
|
138
|
+
if (!R.ok) {
|
|
139
|
+
if (R.status === 401 || R.status === 403)
|
|
140
|
+
throw new Error(Oe);
|
|
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");
|
|
130
144
|
}
|
|
131
|
-
const
|
|
132
|
-
throw new Error(
|
|
145
|
+
const m = await R.json();
|
|
146
|
+
throw new Error(m.error || "Failed to send message");
|
|
133
147
|
}
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
148
|
+
const v = R.body?.getReader();
|
|
149
|
+
if (!v)
|
|
136
150
|
throw new Error("Response body is not readable");
|
|
137
|
-
const
|
|
138
|
-
let
|
|
151
|
+
const w = new TextDecoder();
|
|
152
|
+
let k = "", L = !1;
|
|
139
153
|
for (; ; ) {
|
|
140
|
-
const { done:
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
const T =
|
|
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(`
|
|
144
158
|
`);
|
|
145
|
-
|
|
146
|
-
for (const
|
|
147
|
-
if (
|
|
159
|
+
k = T.pop() || "";
|
|
160
|
+
for (const a of T)
|
|
161
|
+
if (a.startsWith("data: "))
|
|
148
162
|
try {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
else if (
|
|
153
|
-
|
|
154
|
-
else if (
|
|
155
|
-
|
|
156
|
-
else if (
|
|
157
|
-
|
|
158
|
-
else if (
|
|
159
|
-
throw new Error(
|
|
160
|
-
} catch (
|
|
161
|
-
console.error("Error parsing SSE data:",
|
|
163
|
+
const t = JSON.parse(a.slice(6));
|
|
164
|
+
if (t.type === "init")
|
|
165
|
+
t.threadId && c.onInit && c.onInit(t.threadId);
|
|
166
|
+
else if (t.type === "content")
|
|
167
|
+
t.content && (L = !0, c.onContent(t.content));
|
|
168
|
+
else if (t.type === "complete")
|
|
169
|
+
c.onComplete && c.onComplete(t.sources || []);
|
|
170
|
+
else if (t.type === "done")
|
|
171
|
+
t.humanTakeover && (L = !0), c.onDone && c.onDone({ humanTakeover: t.humanTakeover });
|
|
172
|
+
else if (t.type === "error")
|
|
173
|
+
throw new Error(t.error || re);
|
|
174
|
+
} catch (t) {
|
|
175
|
+
console.error("Error parsing SSE data:", t, a);
|
|
162
176
|
}
|
|
163
177
|
}
|
|
164
|
-
|
|
165
|
-
} catch (
|
|
166
|
-
const
|
|
167
|
-
|
|
178
|
+
L || c.onError(Re);
|
|
179
|
+
} catch (h) {
|
|
180
|
+
const y = h instanceof Error ? h.message : re;
|
|
181
|
+
c.onError(y);
|
|
168
182
|
}
|
|
169
183
|
}
|
|
170
|
-
var
|
|
171
|
-
function
|
|
172
|
-
return
|
|
184
|
+
var ie = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
185
|
+
function Ue(n) {
|
|
186
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
173
187
|
}
|
|
174
|
-
var
|
|
175
|
-
function
|
|
176
|
-
return
|
|
188
|
+
var V = { exports: {} }, oe;
|
|
189
|
+
function Me() {
|
|
190
|
+
return oe || (oe = 1, (function(n) {
|
|
177
191
|
var u = typeof window < "u" ? window : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? self : {};
|
|
178
192
|
/**
|
|
179
193
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
@@ -184,7 +198,7 @@ function ke() {
|
|
|
184
198
|
* @public
|
|
185
199
|
*/
|
|
186
200
|
var e = (function(l) {
|
|
187
|
-
var
|
|
201
|
+
var c = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i, E = 0, S = {}, o = {
|
|
188
202
|
/**
|
|
189
203
|
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
190
204
|
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
@@ -239,8 +253,8 @@ function ke() {
|
|
|
239
253
|
* @memberof Prism
|
|
240
254
|
*/
|
|
241
255
|
util: {
|
|
242
|
-
encode: function
|
|
243
|
-
return t instanceof
|
|
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, " ");
|
|
244
258
|
},
|
|
245
259
|
/**
|
|
246
260
|
* Returns the name of the type of the given value.
|
|
@@ -258,8 +272,8 @@ function ke() {
|
|
|
258
272
|
* type(String) === 'Function'
|
|
259
273
|
* type(/abc+/) === 'RegExp'
|
|
260
274
|
*/
|
|
261
|
-
type: function(
|
|
262
|
-
return Object.prototype.toString.call(
|
|
275
|
+
type: function(a) {
|
|
276
|
+
return Object.prototype.toString.call(a).slice(8, -1);
|
|
263
277
|
},
|
|
264
278
|
/**
|
|
265
279
|
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
@@ -267,8 +281,8 @@ function ke() {
|
|
|
267
281
|
* @param {Object} obj
|
|
268
282
|
* @returns {number}
|
|
269
283
|
*/
|
|
270
|
-
objId: function(
|
|
271
|
-
return
|
|
284
|
+
objId: function(a) {
|
|
285
|
+
return a.__id || Object.defineProperty(a, "__id", { value: ++E }), a.__id;
|
|
272
286
|
},
|
|
273
287
|
/**
|
|
274
288
|
* Creates a deep clone of the given object.
|
|
@@ -280,7 +294,7 @@ function ke() {
|
|
|
280
294
|
* @returns {T}
|
|
281
295
|
* @template T
|
|
282
296
|
*/
|
|
283
|
-
clone: function
|
|
297
|
+
clone: function a(t, r) {
|
|
284
298
|
r = r || {};
|
|
285
299
|
var s, i;
|
|
286
300
|
switch (o.util.type(t)) {
|
|
@@ -290,7 +304,7 @@ function ke() {
|
|
|
290
304
|
s = /** @type {Record<string, any>} */
|
|
291
305
|
{}, r[i] = s;
|
|
292
306
|
for (var g in t)
|
|
293
|
-
t.hasOwnProperty(g) && (s[g] =
|
|
307
|
+
t.hasOwnProperty(g) && (s[g] = a(t[g], r));
|
|
294
308
|
return (
|
|
295
309
|
/** @type {any} */
|
|
296
310
|
s
|
|
@@ -298,8 +312,8 @@ function ke() {
|
|
|
298
312
|
case "Array":
|
|
299
313
|
return i = o.util.objId(t), r[i] ? r[i] : (s = [], r[i] = s, /** @type {Array} */
|
|
300
314
|
/** @type {any} */
|
|
301
|
-
t.forEach(function(
|
|
302
|
-
s[
|
|
315
|
+
t.forEach(function(p, d) {
|
|
316
|
+
s[d] = a(p, r);
|
|
303
317
|
}), /** @type {any} */
|
|
304
318
|
s);
|
|
305
319
|
default:
|
|
@@ -314,12 +328,12 @@ function ke() {
|
|
|
314
328
|
* @param {Element} element
|
|
315
329
|
* @returns {string}
|
|
316
330
|
*/
|
|
317
|
-
getLanguage: function(
|
|
318
|
-
for (;
|
|
319
|
-
var t =
|
|
331
|
+
getLanguage: function(a) {
|
|
332
|
+
for (; a; ) {
|
|
333
|
+
var t = c.exec(a.className);
|
|
320
334
|
if (t)
|
|
321
335
|
return t[1].toLowerCase();
|
|
322
|
-
|
|
336
|
+
a = a.parentElement;
|
|
323
337
|
}
|
|
324
338
|
return "none";
|
|
325
339
|
},
|
|
@@ -330,8 +344,8 @@ function ke() {
|
|
|
330
344
|
* @param {string} language
|
|
331
345
|
* @returns {void}
|
|
332
346
|
*/
|
|
333
|
-
setLanguage: function(
|
|
334
|
-
|
|
347
|
+
setLanguage: function(a, t) {
|
|
348
|
+
a.className = a.className.replace(RegExp(c, "gi"), ""), a.classList.add("language-" + t);
|
|
335
349
|
},
|
|
336
350
|
/**
|
|
337
351
|
* Returns the script element that is currently executing.
|
|
@@ -351,11 +365,11 @@ function ke() {
|
|
|
351
365
|
try {
|
|
352
366
|
throw new Error();
|
|
353
367
|
} catch (s) {
|
|
354
|
-
var
|
|
355
|
-
if (
|
|
368
|
+
var a = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(s.stack) || [])[1];
|
|
369
|
+
if (a) {
|
|
356
370
|
var t = document.getElementsByTagName("script");
|
|
357
371
|
for (var r in t)
|
|
358
|
-
if (t[r].src ==
|
|
372
|
+
if (t[r].src == a)
|
|
359
373
|
return t[r];
|
|
360
374
|
}
|
|
361
375
|
return null;
|
|
@@ -380,14 +394,14 @@ function ke() {
|
|
|
380
394
|
* @param {boolean} [defaultActivation=false]
|
|
381
395
|
* @returns {boolean}
|
|
382
396
|
*/
|
|
383
|
-
isActive: function(
|
|
384
|
-
for (var s = "no-" + t;
|
|
385
|
-
var i =
|
|
397
|
+
isActive: function(a, t, r) {
|
|
398
|
+
for (var s = "no-" + t; a; ) {
|
|
399
|
+
var i = a.classList;
|
|
386
400
|
if (i.contains(t))
|
|
387
401
|
return !0;
|
|
388
402
|
if (i.contains(s))
|
|
389
403
|
return !1;
|
|
390
|
-
|
|
404
|
+
a = a.parentElement;
|
|
391
405
|
}
|
|
392
406
|
return !!r;
|
|
393
407
|
}
|
|
@@ -403,10 +417,10 @@ function ke() {
|
|
|
403
417
|
/**
|
|
404
418
|
* The grammar for plain, unformatted text.
|
|
405
419
|
*/
|
|
406
|
-
plain:
|
|
407
|
-
plaintext:
|
|
408
|
-
text:
|
|
409
|
-
txt:
|
|
420
|
+
plain: S,
|
|
421
|
+
plaintext: S,
|
|
422
|
+
text: S,
|
|
423
|
+
txt: S,
|
|
410
424
|
/**
|
|
411
425
|
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
412
426
|
*
|
|
@@ -435,8 +449,8 @@ function ke() {
|
|
|
435
449
|
* 'color': /\b(?:red|green|blue)\b/
|
|
436
450
|
* });
|
|
437
451
|
*/
|
|
438
|
-
extend: function(
|
|
439
|
-
var r = o.util.clone(o.languages[
|
|
452
|
+
extend: function(a, t) {
|
|
453
|
+
var r = o.util.clone(o.languages[a]);
|
|
440
454
|
for (var s in t)
|
|
441
455
|
r[s] = t[s];
|
|
442
456
|
return r;
|
|
@@ -516,31 +530,31 @@ function ke() {
|
|
|
516
530
|
* @returns {Grammar} The new grammar object.
|
|
517
531
|
* @public
|
|
518
532
|
*/
|
|
519
|
-
insertBefore: function(
|
|
533
|
+
insertBefore: function(a, t, r, s) {
|
|
520
534
|
s = s || /** @type {any} */
|
|
521
535
|
o.languages;
|
|
522
|
-
var i = s[
|
|
523
|
-
for (var
|
|
524
|
-
if (i.hasOwnProperty(
|
|
525
|
-
if (
|
|
526
|
-
for (var
|
|
527
|
-
r.hasOwnProperty(
|
|
528
|
-
r.hasOwnProperty(
|
|
536
|
+
var i = s[a], g = {};
|
|
537
|
+
for (var p in i)
|
|
538
|
+
if (i.hasOwnProperty(p)) {
|
|
539
|
+
if (p == t)
|
|
540
|
+
for (var d in r)
|
|
541
|
+
r.hasOwnProperty(d) && (g[d] = r[d]);
|
|
542
|
+
r.hasOwnProperty(p) || (g[p] = i[p]);
|
|
529
543
|
}
|
|
530
|
-
var
|
|
531
|
-
return s[
|
|
532
|
-
F ===
|
|
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);
|
|
533
547
|
}), g;
|
|
534
548
|
},
|
|
535
549
|
// Traverse a language definition with Depth First Search
|
|
536
|
-
DFS: function
|
|
550
|
+
DFS: function a(t, r, s, i) {
|
|
537
551
|
i = i || {};
|
|
538
552
|
var g = o.util.objId;
|
|
539
|
-
for (var
|
|
540
|
-
if (t.hasOwnProperty(
|
|
541
|
-
r.call(t,
|
|
542
|
-
var
|
|
543
|
-
|
|
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));
|
|
544
558
|
}
|
|
545
559
|
}
|
|
546
560
|
},
|
|
@@ -557,8 +571,8 @@ function ke() {
|
|
|
557
571
|
* @memberof Prism
|
|
558
572
|
* @public
|
|
559
573
|
*/
|
|
560
|
-
highlightAll: function(
|
|
561
|
-
o.highlightAllUnder(document,
|
|
574
|
+
highlightAll: function(a, t) {
|
|
575
|
+
o.highlightAllUnder(document, a, t);
|
|
562
576
|
},
|
|
563
577
|
/**
|
|
564
578
|
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
@@ -575,10 +589,10 @@ function ke() {
|
|
|
575
589
|
* @memberof Prism
|
|
576
590
|
* @public
|
|
577
591
|
*/
|
|
578
|
-
highlightAllUnder: function(
|
|
592
|
+
highlightAllUnder: function(a, t, r) {
|
|
579
593
|
var s = {
|
|
580
594
|
callback: r,
|
|
581
|
-
container:
|
|
595
|
+
container: a,
|
|
582
596
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
583
597
|
};
|
|
584
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);
|
|
@@ -613,39 +627,39 @@ function ke() {
|
|
|
613
627
|
* @memberof Prism
|
|
614
628
|
* @public
|
|
615
629
|
*/
|
|
616
|
-
highlightElement: function(
|
|
617
|
-
var s = o.util.getLanguage(
|
|
618
|
-
o.util.setLanguage(
|
|
619
|
-
var g =
|
|
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;
|
|
620
634
|
g && g.nodeName.toLowerCase() === "pre" && o.util.setLanguage(g, s);
|
|
621
|
-
var
|
|
622
|
-
element:
|
|
635
|
+
var p = a.textContent, d = {
|
|
636
|
+
element: a,
|
|
623
637
|
language: s,
|
|
624
638
|
grammar: i,
|
|
625
|
-
code:
|
|
639
|
+
code: p
|
|
626
640
|
};
|
|
627
|
-
function
|
|
628
|
-
|
|
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);
|
|
629
643
|
}
|
|
630
|
-
if (o.hooks.run("before-sanity-check",
|
|
631
|
-
o.hooks.run("complete",
|
|
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);
|
|
632
646
|
return;
|
|
633
647
|
}
|
|
634
|
-
if (o.hooks.run("before-highlight",
|
|
635
|
-
|
|
648
|
+
if (o.hooks.run("before-highlight", d), !d.grammar) {
|
|
649
|
+
A(o.util.encode(d.code));
|
|
636
650
|
return;
|
|
637
651
|
}
|
|
638
652
|
if (t && l.Worker) {
|
|
639
653
|
var b = new Worker(o.filename);
|
|
640
654
|
b.onmessage = function(F) {
|
|
641
|
-
|
|
655
|
+
A(F.data);
|
|
642
656
|
}, b.postMessage(JSON.stringify({
|
|
643
|
-
language:
|
|
644
|
-
code:
|
|
657
|
+
language: d.language,
|
|
658
|
+
code: d.code,
|
|
645
659
|
immediateClose: !0
|
|
646
660
|
}));
|
|
647
661
|
} else
|
|
648
|
-
|
|
662
|
+
A(o.highlight(d.code, d.grammar, d.language));
|
|
649
663
|
},
|
|
650
664
|
/**
|
|
651
665
|
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
@@ -667,15 +681,15 @@ function ke() {
|
|
|
667
681
|
* @example
|
|
668
682
|
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
669
683
|
*/
|
|
670
|
-
highlight: function(
|
|
684
|
+
highlight: function(a, t, r) {
|
|
671
685
|
var s = {
|
|
672
|
-
code:
|
|
686
|
+
code: a,
|
|
673
687
|
grammar: t,
|
|
674
688
|
language: r
|
|
675
689
|
};
|
|
676
690
|
if (o.hooks.run("before-tokenize", s), !s.grammar)
|
|
677
691
|
throw new Error('The language "' + s.language + '" has no grammar.');
|
|
678
|
-
return s.tokens = o.tokenize(s.code, s.grammar), o.hooks.run("after-tokenize", s),
|
|
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);
|
|
679
693
|
},
|
|
680
694
|
/**
|
|
681
695
|
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
@@ -701,7 +715,7 @@ function ke() {
|
|
|
701
715
|
* }
|
|
702
716
|
* });
|
|
703
717
|
*/
|
|
704
|
-
tokenize: function(
|
|
718
|
+
tokenize: function(a, t) {
|
|
705
719
|
var r = t.rest;
|
|
706
720
|
if (r) {
|
|
707
721
|
for (var s in r)
|
|
@@ -709,7 +723,7 @@ function ke() {
|
|
|
709
723
|
delete t.rest;
|
|
710
724
|
}
|
|
711
725
|
var i = new v();
|
|
712
|
-
return
|
|
726
|
+
return w(i, i.head, a), R(a, i, t, i.head, 0), L(i);
|
|
713
727
|
},
|
|
714
728
|
/**
|
|
715
729
|
* @namespace
|
|
@@ -730,9 +744,9 @@ function ke() {
|
|
|
730
744
|
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
731
745
|
* @public
|
|
732
746
|
*/
|
|
733
|
-
add: function(
|
|
747
|
+
add: function(a, t) {
|
|
734
748
|
var r = o.hooks.all;
|
|
735
|
-
r[
|
|
749
|
+
r[a] = r[a] || [], r[a].push(t);
|
|
736
750
|
},
|
|
737
751
|
/**
|
|
738
752
|
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
@@ -743,94 +757,94 @@ function ke() {
|
|
|
743
757
|
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
744
758
|
* @public
|
|
745
759
|
*/
|
|
746
|
-
run: function(
|
|
747
|
-
var r = o.hooks.all[
|
|
760
|
+
run: function(a, t) {
|
|
761
|
+
var r = o.hooks.all[a];
|
|
748
762
|
if (!(!r || !r.length))
|
|
749
763
|
for (var s = 0, i; i = r[s++]; )
|
|
750
764
|
i(t);
|
|
751
765
|
}
|
|
752
766
|
},
|
|
753
|
-
Token:
|
|
767
|
+
Token: h
|
|
754
768
|
};
|
|
755
769
|
l.Prism = o;
|
|
756
|
-
function
|
|
757
|
-
this.type =
|
|
770
|
+
function h(a, t, r, s) {
|
|
771
|
+
this.type = a, this.content = t, this.alias = r, this.length = (s || "").length | 0;
|
|
758
772
|
}
|
|
759
|
-
|
|
773
|
+
h.stringify = function a(t, r) {
|
|
760
774
|
if (typeof t == "string")
|
|
761
775
|
return t;
|
|
762
776
|
if (Array.isArray(t)) {
|
|
763
777
|
var s = "";
|
|
764
|
-
return t.forEach(function(
|
|
765
|
-
s +=
|
|
778
|
+
return t.forEach(function(A) {
|
|
779
|
+
s += a(A, r);
|
|
766
780
|
}), s;
|
|
767
781
|
}
|
|
768
782
|
var i = {
|
|
769
783
|
type: t.type,
|
|
770
|
-
content:
|
|
784
|
+
content: a(t.content, r),
|
|
771
785
|
tag: "span",
|
|
772
786
|
classes: ["token", t.type],
|
|
773
787
|
attributes: {},
|
|
774
788
|
language: r
|
|
775
789
|
}, g = t.alias;
|
|
776
790
|
g && (Array.isArray(g) ? Array.prototype.push.apply(i.classes, g) : i.classes.push(g)), o.hooks.run("wrap", i);
|
|
777
|
-
var
|
|
778
|
-
for (var
|
|
779
|
-
|
|
780
|
-
return "<" + i.tag + ' class="' + i.classes.join(" ") + '"' +
|
|
791
|
+
var p = "";
|
|
792
|
+
for (var d in i.attributes)
|
|
793
|
+
p += " " + d + '="' + (i.attributes[d] || "").replace(/"/g, """) + '"';
|
|
794
|
+
return "<" + i.tag + ' class="' + i.classes.join(" ") + '"' + p + ">" + i.content + "</" + i.tag + ">";
|
|
781
795
|
};
|
|
782
|
-
function
|
|
783
|
-
|
|
784
|
-
var i =
|
|
796
|
+
function y(a, t, r, s) {
|
|
797
|
+
a.lastIndex = t;
|
|
798
|
+
var i = a.exec(r);
|
|
785
799
|
if (i && s && i[1]) {
|
|
786
800
|
var g = i[1].length;
|
|
787
801
|
i.index += g, i[0] = i[0].slice(g);
|
|
788
802
|
}
|
|
789
803
|
return i;
|
|
790
804
|
}
|
|
791
|
-
function
|
|
792
|
-
for (var
|
|
793
|
-
if (!(!r.hasOwnProperty(
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
for (var
|
|
797
|
-
if (g && g.cause ==
|
|
805
|
+
function R(a, t, r, s, i, g) {
|
|
806
|
+
for (var p in r)
|
|
807
|
+
if (!(!r.hasOwnProperty(p) || !r[p])) {
|
|
808
|
+
var d = r[p];
|
|
809
|
+
d = Array.isArray(d) ? d : [d];
|
|
810
|
+
for (var A = 0; A < d.length; ++A) {
|
|
811
|
+
if (g && g.cause == p + "," + A)
|
|
798
812
|
return;
|
|
799
|
-
var b =
|
|
800
|
-
if (
|
|
801
|
-
var
|
|
802
|
-
b.pattern = RegExp(b.pattern.source,
|
|
813
|
+
var b = d[A], F = b.inside, ee = !!b.lookbehind, te = !!b.greedy, me = b.alias;
|
|
814
|
+
if (te && !b.pattern.global) {
|
|
815
|
+
var Ae = b.pattern.toString().match(/[imsuy]*$/)[0];
|
|
816
|
+
b.pattern = RegExp(b.pattern.source, Ae + "g");
|
|
803
817
|
}
|
|
804
|
-
for (var
|
|
805
|
-
var
|
|
806
|
-
if (t.length >
|
|
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
|
+
var D = I.value;
|
|
820
|
+
if (t.length > a.length)
|
|
807
821
|
return;
|
|
808
|
-
if (!(
|
|
809
|
-
var M = 1,
|
|
810
|
-
if (
|
|
811
|
-
if (
|
|
822
|
+
if (!(D instanceof h)) {
|
|
823
|
+
var M = 1, O;
|
|
824
|
+
if (te) {
|
|
825
|
+
if (O = y(ne, N, a, ee), !O || O.index >= a.length)
|
|
812
826
|
break;
|
|
813
|
-
var $ =
|
|
814
|
-
for (
|
|
815
|
-
I = I.next,
|
|
816
|
-
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)
|
|
817
831
|
continue;
|
|
818
|
-
for (var P = I; P !== t.tail && (
|
|
819
|
-
M++,
|
|
820
|
-
M--,
|
|
821
|
-
} 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)
|
|
822
836
|
continue;
|
|
823
|
-
var $ =
|
|
824
|
-
g &&
|
|
837
|
+
var $ = O.index, G = O[0], j = D.slice(0, $), ae = D.slice($ + G.length), K = N + D.length;
|
|
838
|
+
g && K > g.reach && (g.reach = K);
|
|
825
839
|
var B = I.prev;
|
|
826
|
-
|
|
827
|
-
var
|
|
828
|
-
if (I =
|
|
829
|
-
var
|
|
830
|
-
cause:
|
|
831
|
-
reach:
|
|
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
|
+
var q = {
|
|
844
|
+
cause: p + "," + A,
|
|
845
|
+
reach: K
|
|
832
846
|
};
|
|
833
|
-
|
|
847
|
+
R(a, t, r, I.prev, N, q), g && q.reach > g.reach && (g.reach = q.reach);
|
|
834
848
|
}
|
|
835
849
|
}
|
|
836
850
|
}
|
|
@@ -838,40 +852,40 @@ function ke() {
|
|
|
838
852
|
}
|
|
839
853
|
}
|
|
840
854
|
function v() {
|
|
841
|
-
var
|
|
842
|
-
|
|
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;
|
|
843
857
|
}
|
|
844
|
-
function
|
|
858
|
+
function w(a, t, r) {
|
|
845
859
|
var s = t.next, i = { value: r, prev: t, next: s };
|
|
846
|
-
return t.next = i, s.prev = i,
|
|
860
|
+
return t.next = i, s.prev = i, a.length++, i;
|
|
847
861
|
}
|
|
848
|
-
function
|
|
849
|
-
for (var s = t.next, i = 0; i < r && s !==
|
|
862
|
+
function k(a, t, r) {
|
|
863
|
+
for (var s = t.next, i = 0; i < r && s !== a.tail; i++)
|
|
850
864
|
s = s.next;
|
|
851
|
-
t.next = s, s.prev = t,
|
|
865
|
+
t.next = s, s.prev = t, a.length -= i;
|
|
852
866
|
}
|
|
853
|
-
function
|
|
854
|
-
for (var t = [], r =
|
|
867
|
+
function L(a) {
|
|
868
|
+
for (var t = [], r = a.head.next; r !== a.tail; )
|
|
855
869
|
t.push(r.value), r = r.next;
|
|
856
870
|
return t;
|
|
857
871
|
}
|
|
858
872
|
if (!l.document)
|
|
859
|
-
return l.addEventListener && (o.disableWorkerMessageHandler || l.addEventListener("message", function(
|
|
860
|
-
var t = JSON.parse(
|
|
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;
|
|
861
875
|
l.postMessage(o.highlight(s, o.languages[r], r)), i && l.close();
|
|
862
876
|
}, !1)), o;
|
|
863
|
-
var
|
|
864
|
-
|
|
865
|
-
function
|
|
877
|
+
var m = o.util.currentScript();
|
|
878
|
+
m && (o.filename = m.src, m.hasAttribute("data-manual") && (o.manual = !0));
|
|
879
|
+
function f() {
|
|
866
880
|
o.manual || o.highlightAll();
|
|
867
881
|
}
|
|
868
882
|
if (!o.manual) {
|
|
869
|
-
var
|
|
870
|
-
|
|
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);
|
|
871
885
|
}
|
|
872
886
|
return o;
|
|
873
887
|
})(u);
|
|
874
|
-
|
|
888
|
+
n.exports && (n.exports = e), typeof ie < "u" && (ie.Prism = e), e.languages.markup = {
|
|
875
889
|
comment: {
|
|
876
890
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
877
891
|
greedy: !0
|
|
@@ -962,32 +976,32 @@ function ke() {
|
|
|
962
976
|
* @example
|
|
963
977
|
* addInlined('style', 'css');
|
|
964
978
|
*/
|
|
965
|
-
value: function(
|
|
966
|
-
var
|
|
967
|
-
|
|
979
|
+
value: function(c, E) {
|
|
980
|
+
var S = {};
|
|
981
|
+
S["language-" + E] = {
|
|
968
982
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
969
983
|
lookbehind: !0,
|
|
970
|
-
inside: e.languages[
|
|
971
|
-
},
|
|
984
|
+
inside: e.languages[E]
|
|
985
|
+
}, S.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
972
986
|
var o = {
|
|
973
987
|
"included-cdata": {
|
|
974
988
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
975
|
-
inside:
|
|
989
|
+
inside: S
|
|
976
990
|
}
|
|
977
991
|
};
|
|
978
|
-
o["language-" +
|
|
992
|
+
o["language-" + E] = {
|
|
979
993
|
pattern: /[\s\S]+/,
|
|
980
|
-
inside: e.languages[
|
|
994
|
+
inside: e.languages[E]
|
|
981
995
|
};
|
|
982
|
-
var
|
|
983
|
-
|
|
996
|
+
var h = {};
|
|
997
|
+
h[c] = {
|
|
984
998
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
985
|
-
return
|
|
999
|
+
return c;
|
|
986
1000
|
}), "i"),
|
|
987
1001
|
lookbehind: !0,
|
|
988
1002
|
greedy: !0,
|
|
989
1003
|
inside: o
|
|
990
|
-
}, e.languages.insertBefore("markup", "cdata",
|
|
1004
|
+
}, e.languages.insertBefore("markup", "cdata", h);
|
|
991
1005
|
}
|
|
992
1006
|
}), Object.defineProperty(e.languages.markup.tag, "addAttribute", {
|
|
993
1007
|
/**
|
|
@@ -1001,7 +1015,7 @@ function ke() {
|
|
|
1001
1015
|
* @example
|
|
1002
1016
|
* addAttribute('style', 'css');
|
|
1003
1017
|
*/
|
|
1004
|
-
value: function(l,
|
|
1018
|
+
value: function(l, c) {
|
|
1005
1019
|
e.languages.markup.tag.inside["special-attr"].push({
|
|
1006
1020
|
pattern: RegExp(
|
|
1007
1021
|
/(^|["'\s])/.source + "(?:" + l + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
@@ -1016,8 +1030,8 @@ function ke() {
|
|
|
1016
1030
|
value: {
|
|
1017
1031
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
1018
1032
|
lookbehind: !0,
|
|
1019
|
-
alias: [
|
|
1020
|
-
inside: e.languages[
|
|
1033
|
+
alias: [c, "language-" + c],
|
|
1034
|
+
inside: e.languages[c]
|
|
1021
1035
|
},
|
|
1022
1036
|
punctuation: [
|
|
1023
1037
|
{
|
|
@@ -1032,11 +1046,11 @@ function ke() {
|
|
|
1032
1046
|
});
|
|
1033
1047
|
}
|
|
1034
1048
|
}), e.languages.html = e.languages.markup, e.languages.mathml = e.languages.markup, e.languages.svg = e.languages.markup, e.languages.xml = e.languages.extend("markup", {}), e.languages.ssml = e.languages.xml, e.languages.atom = e.languages.xml, e.languages.rss = e.languages.xml, (function(l) {
|
|
1035
|
-
var
|
|
1049
|
+
var c = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1036
1050
|
l.languages.css = {
|
|
1037
1051
|
comment: /\/\*[\s\S]*?\*\//,
|
|
1038
1052
|
atrule: {
|
|
1039
|
-
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" +
|
|
1053
|
+
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + c.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
1040
1054
|
inside: {
|
|
1041
1055
|
rule: /^@[\w-]+/,
|
|
1042
1056
|
"selector-function-argument": {
|
|
@@ -1053,23 +1067,23 @@ function ke() {
|
|
|
1053
1067
|
},
|
|
1054
1068
|
url: {
|
|
1055
1069
|
// https://drafts.csswg.org/css-values-3/#urls
|
|
1056
|
-
pattern: RegExp("\\burl\\((?:" +
|
|
1070
|
+
pattern: RegExp("\\burl\\((?:" + c.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
|
|
1057
1071
|
greedy: !0,
|
|
1058
1072
|
inside: {
|
|
1059
1073
|
function: /^url/i,
|
|
1060
1074
|
punctuation: /^\(|\)$/,
|
|
1061
1075
|
string: {
|
|
1062
|
-
pattern: RegExp("^" +
|
|
1076
|
+
pattern: RegExp("^" + c.source + "$"),
|
|
1063
1077
|
alias: "url"
|
|
1064
1078
|
}
|
|
1065
1079
|
}
|
|
1066
1080
|
},
|
|
1067
1081
|
selector: {
|
|
1068
|
-
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` +
|
|
1082
|
+
pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + c.source + ")*(?=\\s*\\{)"),
|
|
1069
1083
|
lookbehind: !0
|
|
1070
1084
|
},
|
|
1071
1085
|
string: {
|
|
1072
|
-
pattern:
|
|
1086
|
+
pattern: c,
|
|
1073
1087
|
greedy: !0
|
|
1074
1088
|
},
|
|
1075
1089
|
property: {
|
|
@@ -1083,8 +1097,8 @@ function ke() {
|
|
|
1083
1097
|
},
|
|
1084
1098
|
punctuation: /[(){};:,]/
|
|
1085
1099
|
}, l.languages.css.atrule.inside.rest = l.languages.css;
|
|
1086
|
-
var
|
|
1087
|
-
|
|
1100
|
+
var E = l.languages.markup;
|
|
1101
|
+
E && (E.tag.addInlined("style", "css"), E.tag.addAttribute("style", "css"));
|
|
1088
1102
|
})(e), e.languages.clike = {
|
|
1089
1103
|
comment: [
|
|
1090
1104
|
{
|
|
@@ -1249,9 +1263,9 @@ function ke() {
|
|
|
1249
1263
|
if (typeof e > "u" || typeof document > "u")
|
|
1250
1264
|
return;
|
|
1251
1265
|
Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector);
|
|
1252
|
-
var l = "Loading…",
|
|
1253
|
-
return "✖ Error " +
|
|
1254
|
-
},
|
|
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 = {
|
|
1255
1269
|
js: "javascript",
|
|
1256
1270
|
py: "python",
|
|
1257
1271
|
rb: "ruby",
|
|
@@ -1261,52 +1275,52 @@ function ke() {
|
|
|
1261
1275
|
bat: "batch",
|
|
1262
1276
|
h: "c",
|
|
1263
1277
|
tex: "latex"
|
|
1264
|
-
}, o = "data-src-status",
|
|
1265
|
-
function
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
},
|
|
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);
|
|
1270
1284
|
}
|
|
1271
|
-
function
|
|
1272
|
-
var
|
|
1273
|
-
if (
|
|
1274
|
-
var
|
|
1275
|
-
return
|
|
1285
|
+
function k(m) {
|
|
1286
|
+
var f = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(m || "");
|
|
1287
|
+
if (f) {
|
|
1288
|
+
var T = Number(f[1]), a = f[2], t = f[3];
|
|
1289
|
+
return a ? t ? [T, Number(t)] : [T, void 0] : [T, T];
|
|
1276
1290
|
}
|
|
1277
1291
|
}
|
|
1278
|
-
e.hooks.add("before-highlightall", function(
|
|
1279
|
-
|
|
1280
|
-
}), e.hooks.add("before-sanity-check", function(
|
|
1281
|
-
var
|
|
1292
|
+
e.hooks.add("before-highlightall", function(m) {
|
|
1293
|
+
m.selector += ", " + v;
|
|
1294
|
+
}), e.hooks.add("before-sanity-check", function(m) {
|
|
1295
|
+
var f = (
|
|
1282
1296
|
/** @type {HTMLPreElement} */
|
|
1283
|
-
|
|
1297
|
+
m.element
|
|
1284
1298
|
);
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
var
|
|
1288
|
-
|
|
1289
|
-
var
|
|
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;
|
|
1290
1304
|
if (t === "none") {
|
|
1291
|
-
var r = (/\.(\w+)$/.exec(
|
|
1292
|
-
t =
|
|
1305
|
+
var r = (/\.(\w+)$/.exec(a) || [, "none"])[1];
|
|
1306
|
+
t = S[r] || r;
|
|
1293
1307
|
}
|
|
1294
|
-
e.util.setLanguage(
|
|
1308
|
+
e.util.setLanguage(T, t), e.util.setLanguage(f, t);
|
|
1295
1309
|
var s = e.plugins.autoloader;
|
|
1296
|
-
s && s.loadLanguages(t),
|
|
1297
|
-
|
|
1310
|
+
s && s.loadLanguages(t), w(
|
|
1311
|
+
a,
|
|
1298
1312
|
function(i) {
|
|
1299
|
-
|
|
1300
|
-
var g =
|
|
1313
|
+
f.setAttribute(o, y);
|
|
1314
|
+
var g = k(f.getAttribute("data-range"));
|
|
1301
1315
|
if (g) {
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1304
|
-
`),
|
|
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
|
+
`), f.hasAttribute("data-start") || f.setAttribute("data-start", String(d + 1));
|
|
1305
1319
|
}
|
|
1306
|
-
|
|
1320
|
+
T.textContent = i, e.highlightElement(T);
|
|
1307
1321
|
},
|
|
1308
1322
|
function(i) {
|
|
1309
|
-
|
|
1323
|
+
f.setAttribute(o, R), T.textContent = i;
|
|
1310
1324
|
}
|
|
1311
1325
|
);
|
|
1312
1326
|
}
|
|
@@ -1318,23 +1332,23 @@ function ke() {
|
|
|
1318
1332
|
*
|
|
1319
1333
|
* @param {ParentNode} [container=document]
|
|
1320
1334
|
*/
|
|
1321
|
-
highlight: function(
|
|
1322
|
-
for (var
|
|
1335
|
+
highlight: function(f) {
|
|
1336
|
+
for (var T = (f || document).querySelectorAll(v), a = 0, t; t = T[a++]; )
|
|
1323
1337
|
e.highlightElement(t);
|
|
1324
1338
|
}
|
|
1325
1339
|
};
|
|
1326
|
-
var
|
|
1340
|
+
var L = !1;
|
|
1327
1341
|
e.fileHighlight = function() {
|
|
1328
|
-
|
|
1342
|
+
L || (console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."), L = !0), e.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
1329
1343
|
};
|
|
1330
1344
|
})();
|
|
1331
|
-
})(
|
|
1345
|
+
})(V)), V.exports;
|
|
1332
1346
|
}
|
|
1333
|
-
var
|
|
1334
|
-
const
|
|
1335
|
-
var
|
|
1336
|
-
function
|
|
1337
|
-
return
|
|
1347
|
+
var $e = Me();
|
|
1348
|
+
const ue = /* @__PURE__ */ Ue($e);
|
|
1349
|
+
var le = {}, ce;
|
|
1350
|
+
function Ge() {
|
|
1351
|
+
return ce || (ce = 1, Prism.languages.python = {
|
|
1338
1352
|
comment: {
|
|
1339
1353
|
pattern: /(^|[^\\])#.*/,
|
|
1340
1354
|
lookbehind: !0,
|
|
@@ -1394,13 +1408,13 @@ function _e() {
|
|
|
1394
1408
|
number: /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
1395
1409
|
operator: /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
1396
1410
|
punctuation: /[{}[\];(),.:]/
|
|
1397
|
-
}, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python),
|
|
1411
|
+
}, Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest = Prism.languages.python, Prism.languages.py = Prism.languages.python), le;
|
|
1398
1412
|
}
|
|
1399
|
-
|
|
1400
|
-
var
|
|
1401
|
-
function
|
|
1402
|
-
return
|
|
1403
|
-
|
|
1413
|
+
Ge();
|
|
1414
|
+
var de = {}, ge;
|
|
1415
|
+
function Be() {
|
|
1416
|
+
return ge || (ge = 1, (function(n) {
|
|
1417
|
+
n.languages.typescript = n.languages.extend("javascript", {
|
|
1404
1418
|
"class-name": {
|
|
1405
1419
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
|
|
1406
1420
|
lookbehind: !0,
|
|
@@ -1409,15 +1423,15 @@ function Pe() {
|
|
|
1409
1423
|
// see below
|
|
1410
1424
|
},
|
|
1411
1425
|
builtin: /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/
|
|
1412
|
-
}),
|
|
1426
|
+
}), n.languages.typescript.keyword.push(
|
|
1413
1427
|
/\b(?:abstract|declare|is|keyof|readonly|require)\b/,
|
|
1414
1428
|
// keywords that have to be followed by an identifier
|
|
1415
1429
|
/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,
|
|
1416
1430
|
// This is for `import type *, {}`
|
|
1417
1431
|
/\btype\b(?=\s*(?:[\{*]|$))/
|
|
1418
|
-
), delete
|
|
1419
|
-
var u =
|
|
1420
|
-
delete u["class-name"],
|
|
1432
|
+
), delete n.languages.typescript.parameter, delete n.languages.typescript["literal-property"];
|
|
1433
|
+
var u = n.languages.extend("typescript", {});
|
|
1434
|
+
delete u["class-name"], n.languages.typescript["class-name"].inside = u, n.languages.insertBefore("typescript", "function", {
|
|
1421
1435
|
decorator: {
|
|
1422
1436
|
pattern: /@[$\w\xA0-\uFFFF]+/,
|
|
1423
1437
|
inside: {
|
|
@@ -1442,11 +1456,11 @@ function Pe() {
|
|
|
1442
1456
|
}
|
|
1443
1457
|
}
|
|
1444
1458
|
}
|
|
1445
|
-
}),
|
|
1446
|
-
})(Prism)),
|
|
1459
|
+
}), n.languages.ts = n.languages.typescript;
|
|
1460
|
+
})(Prism)), de;
|
|
1447
1461
|
}
|
|
1448
|
-
|
|
1449
|
-
(function(
|
|
1462
|
+
Be();
|
|
1463
|
+
(function(n) {
|
|
1450
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 = {
|
|
1451
1465
|
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
1452
1466
|
lookbehind: !0,
|
|
@@ -1508,7 +1522,7 @@ Pe();
|
|
|
1508
1522
|
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
1509
1523
|
entity: /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
1510
1524
|
};
|
|
1511
|
-
|
|
1525
|
+
n.languages.bash = {
|
|
1512
1526
|
shebang: {
|
|
1513
1527
|
pattern: /^#!\s*\/.*/,
|
|
1514
1528
|
alias: "important"
|
|
@@ -1644,8 +1658,8 @@ Pe();
|
|
|
1644
1658
|
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
1645
1659
|
lookbehind: !0
|
|
1646
1660
|
}
|
|
1647
|
-
}, e.inside =
|
|
1648
|
-
for (var
|
|
1661
|
+
}, e.inside = n.languages.bash;
|
|
1662
|
+
for (var c = [
|
|
1649
1663
|
"comment",
|
|
1650
1664
|
"function-name",
|
|
1651
1665
|
"for-or-select",
|
|
@@ -1661,9 +1675,9 @@ Pe();
|
|
|
1661
1675
|
"operator",
|
|
1662
1676
|
"punctuation",
|
|
1663
1677
|
"number"
|
|
1664
|
-
],
|
|
1665
|
-
|
|
1666
|
-
|
|
1678
|
+
], E = l.variable[1].inside, S = 0; S < c.length; S++)
|
|
1679
|
+
E[c[S]] = n.languages.bash[c[S]];
|
|
1680
|
+
n.languages.sh = n.languages.bash, n.languages.shell = n.languages.bash;
|
|
1667
1681
|
})(Prism);
|
|
1668
1682
|
Prism.languages.json = {
|
|
1669
1683
|
property: {
|
|
@@ -1690,9 +1704,9 @@ Prism.languages.json = {
|
|
|
1690
1704
|
}
|
|
1691
1705
|
};
|
|
1692
1706
|
Prism.languages.webmanifest = Prism.languages.json;
|
|
1693
|
-
(function(
|
|
1707
|
+
(function(n) {
|
|
1694
1708
|
var u = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
1695
|
-
|
|
1709
|
+
n.languages.css = {
|
|
1696
1710
|
comment: /\/\*[\s\S]*?\*\//,
|
|
1697
1711
|
atrule: {
|
|
1698
1712
|
pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + u.source + ")*?" + /(?:;|(?=\s*\{))/.source),
|
|
@@ -1741,8 +1755,8 @@ Prism.languages.webmanifest = Prism.languages.json;
|
|
|
1741
1755
|
lookbehind: !0
|
|
1742
1756
|
},
|
|
1743
1757
|
punctuation: /[(){};:,]/
|
|
1744
|
-
},
|
|
1745
|
-
var e =
|
|
1758
|
+
}, n.languages.css.atrule.inside.rest = n.languages.css;
|
|
1759
|
+
var e = n.languages.markup;
|
|
1746
1760
|
e && (e.tag.addInlined("style", "css"), e.tag.addAttribute("style", "css"));
|
|
1747
1761
|
})(Prism);
|
|
1748
1762
|
Prism.languages.markup = {
|
|
@@ -1825,8 +1839,8 @@ Prism.languages.markup = {
|
|
|
1825
1839
|
};
|
|
1826
1840
|
Prism.languages.markup.tag.inside["attr-value"].inside.entity = Prism.languages.markup.entity;
|
|
1827
1841
|
Prism.languages.markup.doctype.inside["internal-subset"].inside = Prism.languages.markup;
|
|
1828
|
-
Prism.hooks.add("wrap", function(
|
|
1829
|
-
|
|
1842
|
+
Prism.hooks.add("wrap", function(n) {
|
|
1843
|
+
n.type === "entity" && (n.attributes.title = n.content.replace(/&/, "&"));
|
|
1830
1844
|
});
|
|
1831
1845
|
Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
1832
1846
|
/**
|
|
@@ -1847,25 +1861,25 @@ Object.defineProperty(Prism.languages.markup.tag, "addInlined", {
|
|
|
1847
1861
|
lookbehind: !0,
|
|
1848
1862
|
inside: Prism.languages[e]
|
|
1849
1863
|
}, l.cdata = /^<!\[CDATA\[|\]\]>$/i;
|
|
1850
|
-
var
|
|
1864
|
+
var c = {
|
|
1851
1865
|
"included-cdata": {
|
|
1852
1866
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1853
1867
|
inside: l
|
|
1854
1868
|
}
|
|
1855
1869
|
};
|
|
1856
|
-
|
|
1870
|
+
c["language-" + e] = {
|
|
1857
1871
|
pattern: /[\s\S]+/,
|
|
1858
1872
|
inside: Prism.languages[e]
|
|
1859
1873
|
};
|
|
1860
|
-
var
|
|
1861
|
-
|
|
1874
|
+
var E = {};
|
|
1875
|
+
E[u] = {
|
|
1862
1876
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
|
|
1863
1877
|
return u;
|
|
1864
1878
|
}), "i"),
|
|
1865
1879
|
lookbehind: !0,
|
|
1866
1880
|
greedy: !0,
|
|
1867
|
-
inside:
|
|
1868
|
-
}, Prism.languages.insertBefore("markup", "cdata",
|
|
1881
|
+
inside: c
|
|
1882
|
+
}, Prism.languages.insertBefore("markup", "cdata", E);
|
|
1869
1883
|
}
|
|
1870
1884
|
});
|
|
1871
1885
|
Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
@@ -1880,10 +1894,10 @@ Object.defineProperty(Prism.languages.markup.tag, "addAttribute", {
|
|
|
1880
1894
|
* @example
|
|
1881
1895
|
* addAttribute('style', 'css');
|
|
1882
1896
|
*/
|
|
1883
|
-
value: function(
|
|
1897
|
+
value: function(n, u) {
|
|
1884
1898
|
Prism.languages.markup.tag.inside["special-attr"].push({
|
|
1885
1899
|
pattern: RegExp(
|
|
1886
|
-
/(^|["'\s])/.source + "(?:" +
|
|
1900
|
+
/(^|["'\s])/.source + "(?:" + n + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
1887
1901
|
"i"
|
|
1888
1902
|
),
|
|
1889
1903
|
lookbehind: !0,
|
|
@@ -1951,7 +1965,7 @@ Prism.languages.sql = {
|
|
|
1951
1965
|
operator: /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
|
|
1952
1966
|
punctuation: /[;[\]()`,.]/
|
|
1953
1967
|
};
|
|
1954
|
-
const
|
|
1968
|
+
const He = {
|
|
1955
1969
|
js: "javascript",
|
|
1956
1970
|
ts: "typescript",
|
|
1957
1971
|
shell: "bash",
|
|
@@ -1959,24 +1973,101 @@ const xe = {
|
|
|
1959
1973
|
html: "markup",
|
|
1960
1974
|
xml: "markup"
|
|
1961
1975
|
};
|
|
1962
|
-
|
|
1976
|
+
Y.setOptions({
|
|
1963
1977
|
breaks: !0,
|
|
1964
1978
|
gfm: !0
|
|
1965
1979
|
});
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
const e = u ?
|
|
1980
|
+
const he = new Y.Renderer();
|
|
1981
|
+
he.code = ({ text: n, lang: u }) => {
|
|
1982
|
+
const e = u ? He[u] || u : "plaintext", l = ue.languages[e];
|
|
1969
1983
|
if (l) {
|
|
1970
|
-
const
|
|
1971
|
-
return `<pre><code class="language-${e}">${
|
|
1984
|
+
const E = ue.highlight(n, l, e);
|
|
1985
|
+
return `<pre><code class="language-${e}">${E}</code></pre>`;
|
|
1972
1986
|
}
|
|
1973
|
-
return `<pre><code>${
|
|
1987
|
+
return `<pre><code>${n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</code></pre>`;
|
|
1974
1988
|
};
|
|
1975
|
-
|
|
1976
|
-
function
|
|
1977
|
-
return
|
|
1989
|
+
Y.use({ renderer: he });
|
|
1990
|
+
function gt(n) {
|
|
1991
|
+
return Y.parse(n);
|
|
1992
|
+
}
|
|
1993
|
+
function pt(n) {
|
|
1994
|
+
return n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
1995
|
+
}
|
|
1996
|
+
function ft(n) {
|
|
1997
|
+
return Ee.includes(n.type) ? n.size > we ? "File exceeds the 10MB size limit." : null : `File type "${n.type}" is not supported.`;
|
|
1998
|
+
}
|
|
1999
|
+
async function ze({
|
|
2000
|
+
publishableApiKey: n,
|
|
2001
|
+
threadId: u,
|
|
2002
|
+
fileName: e,
|
|
2003
|
+
fileType: l,
|
|
2004
|
+
fileSize: c,
|
|
2005
|
+
baseUrl: E
|
|
2006
|
+
}) {
|
|
2007
|
+
const S = await Q(), o = await fetch(Le(E), {
|
|
2008
|
+
method: "POST",
|
|
2009
|
+
headers: {
|
|
2010
|
+
"Content-Type": "application/json",
|
|
2011
|
+
"X-Api-Key": n,
|
|
2012
|
+
...S ? { Authorization: `Bearer ${S}` } : {}
|
|
2013
|
+
},
|
|
2014
|
+
body: JSON.stringify({ threadId: u, fileName: e, fileType: l, fileSize: c })
|
|
2015
|
+
});
|
|
2016
|
+
if (!o.ok) {
|
|
2017
|
+
const h = await o.json().catch(() => ({}));
|
|
2018
|
+
throw new Error(
|
|
2019
|
+
h.error || `Upload URL request failed: ${o.status}`
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
return o.json();
|
|
2023
|
+
}
|
|
2024
|
+
async function Ye(n, u) {
|
|
2025
|
+
const e = await fetch(n, {
|
|
2026
|
+
method: "PUT",
|
|
2027
|
+
headers: { "Content-Type": u.type },
|
|
2028
|
+
body: u
|
|
2029
|
+
});
|
|
2030
|
+
if (!e.ok)
|
|
2031
|
+
throw new Error(`Storage upload failed: ${e.status}`);
|
|
2032
|
+
}
|
|
2033
|
+
async function Et({
|
|
2034
|
+
publishableApiKey: n,
|
|
2035
|
+
threadId: u,
|
|
2036
|
+
file: e,
|
|
2037
|
+
baseUrl: l
|
|
2038
|
+
}) {
|
|
2039
|
+
const { uploadUrl: c, storagePath: E } = await ze({
|
|
2040
|
+
publishableApiKey: n,
|
|
2041
|
+
threadId: u,
|
|
2042
|
+
fileName: e.name,
|
|
2043
|
+
fileType: e.type,
|
|
2044
|
+
fileSize: e.size,
|
|
2045
|
+
baseUrl: l
|
|
2046
|
+
});
|
|
2047
|
+
return await Ye(c, e), { fileName: e.name, fileType: e.type, fileSize: e.size, storagePath: E };
|
|
2048
|
+
}
|
|
2049
|
+
async function ht({
|
|
2050
|
+
publishableApiKey: n,
|
|
2051
|
+
storagePath: u,
|
|
2052
|
+
baseUrl: e
|
|
2053
|
+
}) {
|
|
2054
|
+
const l = await Q();
|
|
2055
|
+
try {
|
|
2056
|
+
const c = await fetch(Fe(e), {
|
|
2057
|
+
method: "POST",
|
|
2058
|
+
headers: {
|
|
2059
|
+
"Content-Type": "application/json",
|
|
2060
|
+
"X-Api-Key": n,
|
|
2061
|
+
...l ? { Authorization: `Bearer ${l}` } : {}
|
|
2062
|
+
},
|
|
2063
|
+
body: JSON.stringify({ storagePath: u })
|
|
2064
|
+
});
|
|
2065
|
+
return c.ok && (await c.json()).url || null;
|
|
2066
|
+
} catch {
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
1978
2069
|
}
|
|
1979
|
-
const
|
|
2070
|
+
const We = "https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us.sentry.io/4510472944156672", Xe = [
|
|
1980
2071
|
"@useknest",
|
|
1981
2072
|
"useknest",
|
|
1982
2073
|
"widget-core",
|
|
@@ -1986,22 +2077,22 @@ const Ue = "https://005d25250a41bd0071570b0c0a2b2c4d@o4510467570073600.ingest.us
|
|
|
1986
2077
|
"widget.js",
|
|
1987
2078
|
"knest"
|
|
1988
2079
|
];
|
|
1989
|
-
function
|
|
1990
|
-
if (
|
|
1991
|
-
const u =
|
|
2080
|
+
function je(n) {
|
|
2081
|
+
if (n.tags?.source === "knest-widget") return !0;
|
|
2082
|
+
const u = n.exception?.values?.[0]?.stacktrace?.frames;
|
|
1992
2083
|
return !u || u.length === 0 ? !1 : u.some((e) => {
|
|
1993
2084
|
const l = e.filename || "";
|
|
1994
|
-
return
|
|
2085
|
+
return Xe.some((c) => l.includes(c));
|
|
1995
2086
|
});
|
|
1996
2087
|
}
|
|
1997
|
-
let
|
|
1998
|
-
function
|
|
1999
|
-
|
|
2000
|
-
dsn:
|
|
2088
|
+
let pe = !1;
|
|
2089
|
+
function mt() {
|
|
2090
|
+
pe || (Z.init({
|
|
2091
|
+
dsn: We,
|
|
2001
2092
|
// Only capture errors, not performance data.
|
|
2002
2093
|
tracesSampleRate: 0,
|
|
2003
2094
|
integrations: [
|
|
2004
|
-
|
|
2095
|
+
Z.breadcrumbsIntegration({
|
|
2005
2096
|
console: !1,
|
|
2006
2097
|
dom: !0,
|
|
2007
2098
|
fetch: !0,
|
|
@@ -2016,93 +2107,108 @@ function nt() {
|
|
|
2016
2107
|
}
|
|
2017
2108
|
},
|
|
2018
2109
|
// Filter out errors that don't originate from our widget code.
|
|
2019
|
-
beforeSend(
|
|
2020
|
-
return
|
|
2110
|
+
beforeSend(n) {
|
|
2111
|
+
return je(n) ? n : null;
|
|
2021
2112
|
}
|
|
2022
|
-
}),
|
|
2113
|
+
}), pe = !0);
|
|
2023
2114
|
}
|
|
2024
|
-
function
|
|
2025
|
-
const e = typeof
|
|
2026
|
-
|
|
2115
|
+
function At(n, u) {
|
|
2116
|
+
const e = typeof n == "string" ? new Error(n) : n;
|
|
2117
|
+
Z.captureException(e, {
|
|
2027
2118
|
tags: { source: "knest-widget" },
|
|
2028
2119
|
extra: u
|
|
2029
2120
|
});
|
|
2030
2121
|
}
|
|
2031
|
-
function
|
|
2032
|
-
const e =
|
|
2122
|
+
function St(n, u) {
|
|
2123
|
+
const e = xe();
|
|
2033
2124
|
if (!e)
|
|
2034
2125
|
return () => {
|
|
2035
2126
|
};
|
|
2036
|
-
const l = e.channel(`thread:${
|
|
2037
|
-
u(
|
|
2127
|
+
const l = e.channel(`thread:${n}`).on("broadcast", { event: "new-message" }, (c) => {
|
|
2128
|
+
u(c.payload);
|
|
2038
2129
|
}).subscribe();
|
|
2039
2130
|
return () => {
|
|
2040
2131
|
l.unsubscribe();
|
|
2041
2132
|
};
|
|
2042
2133
|
}
|
|
2043
|
-
const
|
|
2044
|
-
function
|
|
2045
|
-
return
|
|
2134
|
+
const Ke = "knest-widget-chat-", qe = 14400 * 1e3, Ve = 300, U = /* @__PURE__ */ new Map();
|
|
2135
|
+
function z(n) {
|
|
2136
|
+
return Ke + n;
|
|
2046
2137
|
}
|
|
2047
|
-
function
|
|
2138
|
+
function Tt(n) {
|
|
2048
2139
|
try {
|
|
2049
|
-
const u = localStorage.getItem(
|
|
2140
|
+
const u = localStorage.getItem(z(n));
|
|
2050
2141
|
if (!u) return null;
|
|
2051
2142
|
const e = JSON.parse(u);
|
|
2052
|
-
return Date.now() - e.savedAt >
|
|
2143
|
+
return Date.now() - e.savedAt > qe ? (localStorage.removeItem(z(n)), null) : e;
|
|
2053
2144
|
} catch {
|
|
2054
2145
|
return null;
|
|
2055
2146
|
}
|
|
2056
2147
|
}
|
|
2057
|
-
function
|
|
2148
|
+
function Ze(n, u) {
|
|
2058
2149
|
try {
|
|
2059
|
-
localStorage.setItem(
|
|
2150
|
+
localStorage.setItem(z(n), JSON.stringify(u));
|
|
2060
2151
|
} catch {
|
|
2061
2152
|
}
|
|
2062
2153
|
}
|
|
2063
|
-
function
|
|
2064
|
-
const e = U.get(
|
|
2154
|
+
function bt(n, u) {
|
|
2155
|
+
const e = U.get(n);
|
|
2065
2156
|
e !== void 0 && clearTimeout(e);
|
|
2066
2157
|
const l = setTimeout(() => {
|
|
2067
|
-
|
|
2068
|
-
},
|
|
2069
|
-
U.set(
|
|
2158
|
+
Ze(n, u), U.delete(n);
|
|
2159
|
+
}, Ve);
|
|
2160
|
+
U.set(n, l);
|
|
2070
2161
|
}
|
|
2071
|
-
function
|
|
2072
|
-
const u = U.get(
|
|
2073
|
-
u !== void 0 && (clearTimeout(u), U.delete(
|
|
2162
|
+
function It(n) {
|
|
2163
|
+
const u = U.get(n);
|
|
2164
|
+
u !== void 0 && (clearTimeout(u), U.delete(n));
|
|
2074
2165
|
try {
|
|
2075
|
-
localStorage.removeItem(
|
|
2166
|
+
localStorage.removeItem(z(n));
|
|
2076
2167
|
} catch {
|
|
2077
2168
|
}
|
|
2078
2169
|
}
|
|
2079
2170
|
export {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
ot as
|
|
2094
|
-
|
|
2095
|
-
tt as
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2171
|
+
it as ACCEPTED_FILE_TYPES_STRING,
|
|
2172
|
+
Ee as ALLOWED_ATTACHMENT_TYPES,
|
|
2173
|
+
ve as ALLOWED_DOCUMENT_TYPES,
|
|
2174
|
+
fe as ALLOWED_IMAGE_TYPES,
|
|
2175
|
+
X as API_PATH,
|
|
2176
|
+
Oe as AUTH_ERROR_MESSAGE,
|
|
2177
|
+
nt as DEFAULT_AVATAR_URL,
|
|
2178
|
+
W as DEFAULT_BASE_URL,
|
|
2179
|
+
at as DEFAULT_BRAND_COLOR,
|
|
2180
|
+
re as DEFAULT_ERROR_MESSAGE,
|
|
2181
|
+
st as DEFAULT_EXAMPLE_QUESTIONS,
|
|
2182
|
+
rt as DEFAULT_WELCOME_MESSAGE,
|
|
2183
|
+
Re as FALLBACK_ERROR_MESSAGE,
|
|
2184
|
+
ot as MAX_ATTACHMENTS_PER_MESSAGE,
|
|
2185
|
+
we as MAX_ATTACHMENT_SIZE_BYTES,
|
|
2186
|
+
tt as PUBLIC_SUPABASE_ANON_KEY,
|
|
2187
|
+
et as PUBLIC_SUPABASE_URL,
|
|
2188
|
+
Ne as USAGE_LIMIT_MESSAGE,
|
|
2189
|
+
At as captureWidgetException,
|
|
2190
|
+
It as clearChatState,
|
|
2191
|
+
ht as fetchSignedUrl,
|
|
2192
|
+
lt as fetchWidgetConfig,
|
|
2193
|
+
gt as formatContent,
|
|
2194
|
+
pt as formatFileSize,
|
|
2195
|
+
Q as getAccessToken,
|
|
2196
|
+
Fe as getAttachmentSignedUrlEndpoint,
|
|
2197
|
+
Le as getAttachmentUploadUrl,
|
|
2198
|
+
Ie as getChatApiUrl,
|
|
2199
|
+
ye as getConfigApiUrl,
|
|
2200
|
+
xe as getSupabaseClient,
|
|
2201
|
+
ct as initWidgetAuth,
|
|
2202
|
+
mt as initWidgetSentry,
|
|
2203
|
+
Pe as isAuthenticated,
|
|
2204
|
+
ut as isImageType,
|
|
2205
|
+
Tt as loadChatState,
|
|
2206
|
+
ze as requestUploadUrl,
|
|
2207
|
+
Ze as saveChatState,
|
|
2208
|
+
bt as saveChatStateDebounced,
|
|
2209
|
+
dt as streamChatMessage,
|
|
2210
|
+
St as subscribeToThread,
|
|
2211
|
+
Et as uploadAttachment,
|
|
2212
|
+
Ye as uploadToStorage,
|
|
2213
|
+
ft as validateAttachment
|
|
2108
2214
|
};
|