@stacksee/analytics 0.3.4 → 0.4.3

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.
@@ -1,4198 +0,0 @@
1
- var g = typeof window < "u" ? window : void 0, K = typeof globalThis < "u" ? globalThis : g, Er = Array.prototype, ys = Er.forEach, bs = Er.indexOf, ie = K == null ? void 0 : K.navigator, y = K == null ? void 0 : K.document, Z = K == null ? void 0 : K.location, Ii = K == null ? void 0 : K.fetch, Fi = K != null && K.XMLHttpRequest && "withCredentials" in new K.XMLHttpRequest() ? K.XMLHttpRequest : void 0, ws = K == null ? void 0 : K.AbortController, J = ie == null ? void 0 : ie.userAgent, x = g ?? {}, xe = { DEBUG: !1, LIB_VERSION: "1.248.0" }, hi = "$copy_autocapture", Ln = ["$snapshot", "$pageview", "$pageleave", "$set", "survey dismissed", "survey sent", "survey shown", "$identify", "$groupidentify", "$create_alias", "$$client_ingestion_warning", "$web_experiment_applied", "$feature_enrollment_update", "$feature_flag_called"], Se = function(s) {
2
- return s.GZipJS = "gzip-js", s.Base64 = "base64", s;
3
- }({}), Dn = ["fatal", "error", "warning", "log", "info", "debug"];
4
- function I(s, e) {
5
- return s.indexOf(e) !== -1;
6
- }
7
- var ii = function(s) {
8
- return s.trim();
9
- }, $i = function(s) {
10
- return s.replace(/^\$/, "");
11
- }, Nn = Array.isArray, kr = Object.prototype, xr = kr.hasOwnProperty, si = kr.toString, C = Nn || function(s) {
12
- return si.call(s) === "[object Array]";
13
- }, ae = (s) => typeof s == "function", O = (s) => s === Object(s) && !C(s), tt = (s) => {
14
- if (O(s)) {
15
- for (var e in s) if (xr.call(s, e)) return !1;
16
- return !0;
17
- }
18
- return !1;
19
- }, _ = (s) => s === void 0, A = (s) => si.call(s) == "[object String]", Pi = (s) => A(s) && s.trim().length === 0, Ne = (s) => s === null, P = (s) => _(s) || Ne(s), z = (s) => si.call(s) == "[object Number]", ve = (s) => si.call(s) === "[object Boolean]", qn = (s) => s instanceof FormData, Bn = (s) => I(Ln, s), Sr = (s) => {
20
- var e = { t: function(t) {
21
- if (g && (xe.DEBUG || x.POSTHOG_DEBUG) && !_(g.console) && g.console) {
22
- for (var i = ("__rrweb_original__" in g.console[t]) ? g.console[t].__rrweb_original__ : g.console[t], r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++) n[a - 1] = arguments[a];
23
- i(s, ...n);
24
- }
25
- }, info: function() {
26
- for (var t = arguments.length, i = new Array(t), r = 0; r < t; r++) i[r] = arguments[r];
27
- e.t("log", ...i);
28
- }, warn: function() {
29
- for (var t = arguments.length, i = new Array(t), r = 0; r < t; r++) i[r] = arguments[r];
30
- e.t("warn", ...i);
31
- }, error: function() {
32
- for (var t = arguments.length, i = new Array(t), r = 0; r < t; r++) i[r] = arguments[r];
33
- e.t("error", ...i);
34
- }, critical: function() {
35
- for (var t = arguments.length, i = new Array(t), r = 0; r < t; r++) i[r] = arguments[r];
36
- console.error(s, ...i);
37
- }, uninitializedWarning: (t) => {
38
- e.error("You must initialize PostHog before calling " + t);
39
- }, createLogger: (t) => Sr(s + " " + t) };
40
- return e;
41
- }, w = Sr("[PostHog.js]"), j = w.createLogger, Hn = j("[ExternalScriptsLoader]"), Es = (s, e, t) => {
42
- if (s.config.disable_external_dependency_loading) return Hn.warn(e + " was requested but loading of external scripts is disabled."), t("Loading of external scripts is disabled");
43
- var i = y == null ? void 0 : y.querySelectorAll("script");
44
- if (i) {
45
- for (var r = 0; r < i.length; r++) if (i[r].src === e) return t();
46
- }
47
- var n = () => {
48
- if (!y) return t("document not found");
49
- var a = y.createElement("script");
50
- if (a.type = "text/javascript", a.crossOrigin = "anonymous", a.src = e, a.onload = (u) => t(void 0, u), a.onerror = (u) => t(u), s.config.prepare_external_dependency_script && (a = s.config.prepare_external_dependency_script(a)), !a) return t("prepare_external_dependency_script returned null");
51
- var o, l = y.querySelectorAll("body > script");
52
- l.length > 0 ? (o = l[0].parentNode) == null || o.insertBefore(a, l[0]) : y.body.appendChild(a);
53
- };
54
- y != null && y.body ? n() : y == null || y.addEventListener("DOMContentLoaded", n);
55
- };
56
- function m() {
57
- return m = Object.assign ? Object.assign.bind() : function(s) {
58
- for (var e = 1; e < arguments.length; e++) {
59
- var t = arguments[e];
60
- for (var i in t) ({}).hasOwnProperty.call(t, i) && (s[i] = t[i]);
61
- }
62
- return s;
63
- }, m.apply(null, arguments);
64
- }
65
- function Ir(s, e) {
66
- if (s == null) return {};
67
- var t = {};
68
- for (var i in s) if ({}.hasOwnProperty.call(s, i)) {
69
- if (e.indexOf(i) !== -1) continue;
70
- t[i] = s[i];
71
- }
72
- return t;
73
- }
74
- x.__PosthogExtensions__ = x.__PosthogExtensions__ || {}, x.__PosthogExtensions__.loadExternalDependency = (s, e, t) => {
75
- var i = "/static/" + e + ".js?v=" + s.version;
76
- if (e === "remote-config" && (i = "/array/" + s.config.token + "/config.js"), e === "toolbar") {
77
- var r = 3e5;
78
- i = i + "&t=" + Math.floor(Date.now() / r) * r;
79
- }
80
- var n = s.requestRouter.endpointFor("assets", i);
81
- Es(s, n, t);
82
- }, x.__PosthogExtensions__.loadSiteApp = (s, e, t) => {
83
- var i = s.requestRouter.endpointFor("api", e);
84
- Es(s, i, t);
85
- };
86
- var jt = {};
87
- function Ae(s, e, t) {
88
- if (C(s)) {
89
- if (ys && s.forEach === ys) s.forEach(e, t);
90
- else if ("length" in s && s.length === +s.length) {
91
- for (var i = 0, r = s.length; i < r; i++) if (i in s && e.call(t, s[i], i) === jt) return;
92
- }
93
- }
94
- }
95
- function R(s, e, t) {
96
- if (!P(s)) {
97
- if (C(s)) return Ae(s, e, t);
98
- if (qn(s)) {
99
- for (var i of s.entries()) if (e.call(t, i[1], i[0]) === jt) return;
100
- } else for (var r in s) if (xr.call(s, r) && e.call(t, s[r], r) === jt) return;
101
- }
102
- }
103
- var D = function(s) {
104
- for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++) t[i - 1] = arguments[i];
105
- return Ae(t, function(r) {
106
- for (var n in r) r[n] !== void 0 && (s[n] = r[n]);
107
- }), s;
108
- }, ri = function(s) {
109
- for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++) t[i - 1] = arguments[i];
110
- return Ae(t, function(r) {
111
- Ae(r, function(n) {
112
- s.push(n);
113
- });
114
- }), s;
115
- };
116
- function qt(s) {
117
- for (var e = Object.keys(s), t = e.length, i = new Array(t); t--; ) i[t] = [e[t], s[e[t]]];
118
- return i;
119
- }
120
- var ks = function(s) {
121
- try {
122
- return s();
123
- } catch {
124
- return;
125
- }
126
- }, jn = function(s) {
127
- return function() {
128
- try {
129
- for (var e = arguments.length, t = new Array(e), i = 0; i < e; i++) t[i] = arguments[i];
130
- return s.apply(this, t);
131
- } catch (r) {
132
- w.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."), w.critical(r);
133
- }
134
- };
135
- }, ts = function(s) {
136
- var e = {};
137
- return R(s, function(t, i) {
138
- (A(t) && t.length > 0 || z(t)) && (e[i] = t);
139
- }), e;
140
- };
141
- function Un(s, e) {
142
- return t = s, i = (n) => A(n) && !Ne(e) ? n.slice(0, e) : n, r = /* @__PURE__ */ new Set(), function n(a, o) {
143
- return a !== Object(a) ? i ? i(a, o) : a : r.has(a) ? void 0 : (r.add(a), C(a) ? (l = [], Ae(a, (u) => {
144
- l.push(n(u));
145
- })) : (l = {}, R(a, (u, c) => {
146
- r.has(u) || (l[c] = n(u, c));
147
- })), l);
148
- var l;
149
- }(t);
150
- var t, i, r;
151
- }
152
- var Wn = ["herokuapp.com", "vercel.app", "netlify.app"];
153
- function zn(s) {
154
- var e = s == null ? void 0 : s.hostname;
155
- if (!A(e)) return !1;
156
- var t = e.split(".").slice(-2).join(".");
157
- for (var i of Wn) if (t === i) return !1;
158
- return !0;
159
- }
160
- function Fr(s, e) {
161
- for (var t = 0; t < s.length; t++) if (e(s[t])) return s[t];
162
- }
163
- function T(s, e, t, i) {
164
- var { capture: r = !1, passive: n = !0 } = i ?? {};
165
- s == null || s.addEventListener(e, t, { capture: r, passive: n });
166
- }
167
- var $r = "$people_distinct_id", ft = "__alias", vt = "__timers", xs = "$autocapture_disabled_server_side", Ri = "$heatmaps_enabled_server_side", Ss = "$exception_capture_enabled_server_side", Mi = "$error_tracking_suppression_rules", Is = "$web_vitals_enabled_server_side", Pr = "$dead_clicks_enabled_server_side", Fs = "$web_vitals_allowed_metrics", Ci = "$session_recording_enabled_server_side", $s = "$console_log_recording_enabled_server_side", Ps = "$session_recording_network_payload_capture", Rs = "$session_recording_masking", Ms = "$session_recording_canvas_recording", Cs = "$replay_sample_rate", Ts = "$replay_minimum_duration", Os = "$replay_script_config", Ut = "$sesid", _t = "$session_is_sampled", Ti = "$session_recording_url_trigger_activated_session", Oi = "$session_recording_event_trigger_activated_session", it = "$enabled_feature_flags", Bt = "$early_access_features", Ai = "$feature_flag_details", mt = "$stored_person_properties", We = "$stored_group_properties", Li = "$surveys", Rt = "$surveys_activated", Wt = "$flag_call_reported", Ee = "$user_state", Di = "$client_session_props", Ni = "$capture_rate_limit", qi = "$initial_campaign_params", Bi = "$initial_referrer_info", zt = "$initial_person_info", Gt = "$epp", Rr = "__POSTHOG_TOOLBAR__", As = "$posthog_cookieless", Gn = [$r, ft, "__cmpns", vt, Ci, Ri, Ut, it, Mi, Ee, Bt, Ai, We, mt, Li, Wt, Di, Ni, qi, Bi, Gt, zt];
168
- function Ls(s) {
169
- return s instanceof Element && (s.id === Rr || !(s.closest == null || !s.closest(".toolbar-global-fade-container")));
170
- }
171
- function ni(s) {
172
- return !!s && s.nodeType === 1;
173
- }
174
- function Le(s, e) {
175
- return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
176
- }
177
- function Mr(s) {
178
- return !!s && s.nodeType === 3;
179
- }
180
- function Cr(s) {
181
- return !!s && s.nodeType === 11;
182
- }
183
- function is(s) {
184
- return s ? ii(s).split(/\s+/) : [];
185
- }
186
- function Ds(s) {
187
- var e = g == null ? void 0 : g.location.href;
188
- return !!(e && s && s.some((t) => e.match(t)));
189
- }
190
- function Vt(s) {
191
- var e = "";
192
- switch (typeof s.className) {
193
- case "string":
194
- e = s.className;
195
- break;
196
- case "object":
197
- e = (s.className && "baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
198
- break;
199
- default:
200
- e = "";
201
- }
202
- return is(e);
203
- }
204
- function Tr(s) {
205
- return P(s) ? null : ii(s).split(/(\s+)/).filter((e) => at(e)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255);
206
- }
207
- function ai(s) {
208
- var e = "";
209
- return ji(s) && !Lr(s) && s.childNodes && s.childNodes.length && R(s.childNodes, function(t) {
210
- var i;
211
- Mr(t) && t.textContent && (e += (i = Tr(t.textContent)) !== null && i !== void 0 ? i : "");
212
- }), ii(e);
213
- }
214
- function Or(s) {
215
- return _(s.target) ? s.srcElement || null : (e = s.target) != null && e.shadowRoot ? s.composedPath()[0] || null : s.target || null;
216
- var e;
217
- }
218
- var Hi = ["a", "button", "form", "input", "select", "textarea", "label"];
219
- function Ar(s) {
220
- var e = s.parentNode;
221
- return !(!e || !ni(e)) && e;
222
- }
223
- function Vn(s, e, t, i, r) {
224
- var n, a, o;
225
- if (t === void 0 && (t = void 0), !g || !s || Le(s, "html") || !ni(s) || (n = t) != null && n.url_allowlist && !Ds(t.url_allowlist) || (a = t) != null && a.url_ignorelist && Ds(t.url_ignorelist)) return !1;
226
- if ((o = t) != null && o.dom_event_allowlist) {
227
- var l = t.dom_event_allowlist;
228
- if (l && !l.some((b) => e.type === b)) return !1;
229
- }
230
- for (var u = !1, c = [s], p = !0, h = s; h.parentNode && !Le(h, "body"); ) if (Cr(h.parentNode)) c.push(h.parentNode.host), h = h.parentNode.host;
231
- else {
232
- if (!(p = Ar(h))) break;
233
- if (i || Hi.indexOf(p.tagName.toLowerCase()) > -1) u = !0;
234
- else {
235
- var d = g.getComputedStyle(p);
236
- d && d.getPropertyValue("cursor") === "pointer" && (u = !0);
237
- }
238
- c.push(p), h = p;
239
- }
240
- if (!function(b, E) {
241
- var k = E == null ? void 0 : E.element_allowlist;
242
- if (_(k)) return !0;
243
- var S, $ = function(V) {
244
- if (k.some((B) => V.tagName.toLowerCase() === B)) return { v: !0 };
245
- };
246
- for (var L of b) if (S = $(L)) return S.v;
247
- return !1;
248
- }(c, t) || !function(b, E) {
249
- var k = E == null ? void 0 : E.css_selector_allowlist;
250
- if (_(k)) return !0;
251
- var S, $ = function(V) {
252
- if (k.some((B) => V.matches(B))) return { v: !0 };
253
- };
254
- for (var L of b) if (S = $(L)) return S.v;
255
- return !1;
256
- }(c, t)) return !1;
257
- var v = g.getComputedStyle(s);
258
- if (v && v.getPropertyValue("cursor") === "pointer" && e.type === "click") return !0;
259
- var f = s.tagName.toLowerCase();
260
- switch (f) {
261
- case "html":
262
- return !1;
263
- case "form":
264
- return (r || ["submit"]).indexOf(e.type) >= 0;
265
- case "input":
266
- case "select":
267
- case "textarea":
268
- return (r || ["change", "click"]).indexOf(e.type) >= 0;
269
- default:
270
- return u ? (r || ["click"]).indexOf(e.type) >= 0 : (r || ["click"]).indexOf(e.type) >= 0 && (Hi.indexOf(f) > -1 || s.getAttribute("contenteditable") === "true");
271
- }
272
- }
273
- function ji(s) {
274
- for (var e = s; e.parentNode && !Le(e, "body"); e = e.parentNode) {
275
- var t = Vt(e);
276
- if (I(t, "ph-sensitive") || I(t, "ph-no-capture")) return !1;
277
- }
278
- if (I(Vt(s), "ph-include")) return !0;
279
- var i = s.type || "";
280
- if (A(i)) switch (i.toLowerCase()) {
281
- case "hidden":
282
- case "password":
283
- return !1;
284
- }
285
- var r = s.name || s.id || "";
286
- return !(A(r) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g, "")));
287
- }
288
- function Lr(s) {
289
- return !!(Le(s, "input") && !["button", "checkbox", "submit", "reset"].includes(s.type) || Le(s, "select") || Le(s, "textarea") || s.getAttribute("contenteditable") === "true");
290
- }
291
- var Dr = "(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})", Xn = new RegExp("^(?:" + Dr + ")$"), Yn = new RegExp(Dr), Nr = "\\d{3}-?\\d{2}-?\\d{4}", Jn = new RegExp("^(" + Nr + ")$"), Zn = new RegExp("(" + Nr + ")");
292
- function at(s, e) {
293
- return e === void 0 && (e = !0), !(P(s) || A(s) && (s = ii(s), (e ? Xn : Yn).test((s || "").replace(/[- ]/g, "")) || (e ? Jn : Zn).test(s)));
294
- }
295
- function qr(s) {
296
- var e = ai(s);
297
- return at(e = (e + " " + Br(s)).trim()) ? e : "";
298
- }
299
- function Br(s) {
300
- var e = "";
301
- return s && s.childNodes && s.childNodes.length && R(s.childNodes, function(t) {
302
- var i;
303
- if (t && ((i = t.tagName) == null ? void 0 : i.toLowerCase()) === "span") try {
304
- var r = ai(t);
305
- e = (e + " " + r).trim(), t.childNodes && t.childNodes.length && (e = (e + " " + Br(t)).trim());
306
- } catch (n) {
307
- w.error("[AutoCapture]", n);
308
- }
309
- }), e;
310
- }
311
- function Kn(s) {
312
- return function(e) {
313
- var t = e.map((i) => {
314
- var r, n, a = "";
315
- if (i.tag_name && (a += i.tag_name), i.attr_class) for (var o of (i.attr_class.sort(), i.attr_class)) a += "." + o.replace(/"/g, "");
316
- var l = m({}, i.text ? { text: i.text } : {}, { "nth-child": (r = i.nth_child) !== null && r !== void 0 ? r : 0, "nth-of-type": (n = i.nth_of_type) !== null && n !== void 0 ? n : 0 }, i.href ? { href: i.href } : {}, i.attr_id ? { attr_id: i.attr_id } : {}, i.attributes), u = {};
317
- return qt(l).sort((c, p) => {
318
- var [h] = c, [d] = p;
319
- return h.localeCompare(d);
320
- }).forEach((c) => {
321
- var [p, h] = c;
322
- return u[Ns(p.toString())] = Ns(h.toString());
323
- }), a += ":", a += qt(u).map((c) => {
324
- var [p, h] = c;
325
- return p + '="' + h + '"';
326
- }).join("");
327
- });
328
- return t.join(";");
329
- }(function(e) {
330
- return e.map((t) => {
331
- var i, r, n = { text: (i = t.$el_text) == null ? void 0 : i.slice(0, 400), tag_name: t.tag_name, href: (r = t.attr__href) == null ? void 0 : r.slice(0, 2048), attr_class: Qn(t), attr_id: t.attr__id, nth_child: t.nth_child, nth_of_type: t.nth_of_type, attributes: {} };
332
- return qt(t).filter((a) => {
333
- var [o] = a;
334
- return o.indexOf("attr__") === 0;
335
- }).forEach((a) => {
336
- var [o, l] = a;
337
- return n.attributes[o] = l;
338
- }), n;
339
- });
340
- }(s));
341
- }
342
- function Ns(s) {
343
- return s.replace(/"|\\"/g, '\\"');
344
- }
345
- function Qn(s) {
346
- var e = s.attr__class;
347
- return e ? C(e) ? e : is(e) : void 0;
348
- }
349
- class Hr {
350
- constructor() {
351
- this.clicks = [];
352
- }
353
- isRageClick(e, t, i) {
354
- var r = this.clicks[this.clicks.length - 1];
355
- if (r && Math.abs(e - r.x) + Math.abs(t - r.y) < 30 && i - r.timestamp < 1e3) {
356
- if (this.clicks.push({ x: e, y: t, timestamp: i }), this.clicks.length === 3) return !0;
357
- } else this.clicks = [{ x: e, y: t, timestamp: i }];
358
- return !1;
359
- }
360
- }
361
- var ea = ["localhost", "127.0.0.1"], ot = (s) => {
362
- var e = y == null ? void 0 : y.createElement("a");
363
- return _(e) ? null : (e.href = s, e);
364
- }, ta = function(s, e) {
365
- var t, i;
366
- e === void 0 && (e = "&");
367
- var r = [];
368
- return R(s, function(n, a) {
369
- _(n) || _(a) || a === "undefined" || (t = encodeURIComponent(((o) => o instanceof File)(n) ? n.name : n.toString()), i = encodeURIComponent(a), r[r.length] = i + "=" + t);
370
- }), r.join(e);
371
- }, Xt = function(s, e) {
372
- for (var t, i = ((s.split("#")[0] || "").split(/\?(.*)/)[1] || "").replace(/^\?+/g, "").split("&"), r = 0; r < i.length; r++) {
373
- var n = i[r].split("=");
374
- if (n[0] === e) {
375
- t = n;
376
- break;
377
- }
378
- }
379
- if (!C(t) || t.length < 2) return "";
380
- var a = t[1];
381
- try {
382
- a = decodeURIComponent(a);
383
- } catch {
384
- w.error("Skipping decoding for malformed query param: " + a);
385
- }
386
- return a.replace(/\+/g, " ");
387
- }, ss = function(s, e, t) {
388
- if (!s || !e || !e.length) return s;
389
- for (var i = s.split("#"), r = i[0] || "", n = i[1], a = r.split("?"), o = a[1], l = a[0], u = (o || "").split("&"), c = [], p = 0; p < u.length; p++) {
390
- var h = u[p].split("=");
391
- C(h) && (e.includes(h[0]) ? c.push(h[0] + "=" + t) : c.push(u[p]));
392
- }
393
- var d = l;
394
- return o != null && (d += "?" + c.join("&")), n != null && (d += "#" + n), d;
395
- }, Yt = function(s, e) {
396
- var t = s.match(new RegExp(e + "=([^&]*)"));
397
- return t ? t[1] : null;
398
- }, qs = j("[AutoCapture]");
399
- function di(s, e) {
400
- return e.length > s ? e.slice(0, s) + "..." : e;
401
- }
402
- function ia(s) {
403
- if (s.previousElementSibling) return s.previousElementSibling;
404
- var e = s;
405
- do
406
- e = e.previousSibling;
407
- while (e && !ni(e));
408
- return e;
409
- }
410
- function sa(s, e, t, i) {
411
- var r = s.tagName.toLowerCase(), n = { tag_name: r };
412
- Hi.indexOf(r) > -1 && !t && (r.toLowerCase() === "a" || r.toLowerCase() === "button" ? n.$el_text = di(1024, qr(s)) : n.$el_text = di(1024, ai(s)));
413
- var a = Vt(s);
414
- a.length > 0 && (n.classes = a.filter(function(c) {
415
- return c !== "";
416
- })), R(s.attributes, function(c) {
417
- var p;
418
- if ((!Lr(s) || ["name", "id", "class", "aria-label"].indexOf(c.name) !== -1) && (i == null || !i.includes(c.name)) && !e && at(c.value) && (p = c.name, !A(p) || p.substring(0, 10) !== "_ngcontent" && p.substring(0, 7) !== "_nghost")) {
419
- var h = c.value;
420
- c.name === "class" && (h = is(h).join(" ")), n["attr__" + c.name] = di(1024, h);
421
- }
422
- });
423
- for (var o = 1, l = 1, u = s; u = ia(u); ) o++, u.tagName === s.tagName && l++;
424
- return n.nth_child = o, n.nth_of_type = l, n;
425
- }
426
- function ra(s, e) {
427
- for (var t, i, { e: r, maskAllElementAttributes: n, maskAllText: a, elementAttributeIgnoreList: o, elementsChainAsString: l } = e, u = [s], c = s; c.parentNode && !Le(c, "body"); ) Cr(c.parentNode) ? (u.push(c.parentNode.host), c = c.parentNode.host) : (u.push(c.parentNode), c = c.parentNode);
428
- var p, h = [], d = {}, v = !1, f = !1;
429
- if (R(u, ($) => {
430
- var L = ji($);
431
- $.tagName.toLowerCase() === "a" && (v = $.getAttribute("href"), v = L && v && at(v) && v), I(Vt($), "ph-no-capture") && (f = !0), h.push(sa($, n, a, o));
432
- var V = function(B) {
433
- if (!ji(B)) return {};
434
- var F = {};
435
- return R(B.attributes, function(he) {
436
- if (he.name && he.name.indexOf("data-ph-capture-attribute") === 0) {
437
- var ee = he.name.replace("data-ph-capture-attribute-", ""), ue = he.value;
438
- ee && ue && at(ue) && (F[ee] = ue);
439
- }
440
- }), F;
441
- }($);
442
- D(d, V);
443
- }), f) return { props: {}, explicitNoCapture: f };
444
- if (a || (s.tagName.toLowerCase() === "a" || s.tagName.toLowerCase() === "button" ? h[0].$el_text = qr(s) : h[0].$el_text = ai(s)), v) {
445
- var b, E;
446
- h[0].attr__href = v;
447
- var k = (b = ot(v)) == null ? void 0 : b.host, S = g == null || (E = g.location) == null ? void 0 : E.host;
448
- k && S && k !== S && (p = v);
449
- }
450
- return { props: D({ $event_type: r.type, $ce_version: 1 }, l ? {} : { $elements: h }, { $elements_chain: Kn(h) }, (t = h[0]) != null && t.$el_text ? { $el_text: (i = h[0]) == null ? void 0 : i.$el_text } : {}, p && r.type === "click" ? { $external_click_url: p } : {}, d) };
451
- }
452
- class na {
453
- constructor(e) {
454
- this.i = !1, this.o = null, this.rageclicks = new Hr(), this.h = !1, this.instance = e, this.m = null;
455
- }
456
- get S() {
457
- var e, t, i = O(this.instance.config.autocapture) ? this.instance.config.autocapture : {};
458
- return i.url_allowlist = (e = i.url_allowlist) == null ? void 0 : e.map((r) => new RegExp(r)), i.url_ignorelist = (t = i.url_ignorelist) == null ? void 0 : t.map((r) => new RegExp(r)), i;
459
- }
460
- $() {
461
- if (this.isBrowserSupported()) {
462
- if (g && y) {
463
- var e = (i) => {
464
- i = i || (g == null ? void 0 : g.event);
465
- try {
466
- this.k(i);
467
- } catch (r) {
468
- qs.error("Failed to capture event", r);
469
- }
470
- };
471
- if (T(y, "submit", e, { capture: !0 }), T(y, "change", e, { capture: !0 }), T(y, "click", e, { capture: !0 }), this.S.capture_copied_text) {
472
- var t = (i) => {
473
- i = i || (g == null ? void 0 : g.event), this.k(i, hi);
474
- };
475
- T(y, "copy", t, { capture: !0 }), T(y, "cut", t, { capture: !0 });
476
- }
477
- }
478
- } else qs.info("Disabling Automatic Event Collection because this browser is not supported");
479
- }
480
- startIfEnabled() {
481
- this.isEnabled && !this.i && (this.$(), this.i = !0);
482
- }
483
- onRemoteConfig(e) {
484
- e.elementsChainAsString && (this.h = e.elementsChainAsString), this.instance.persistence && this.instance.persistence.register({ [xs]: !!e.autocapture_opt_out }), this.o = !!e.autocapture_opt_out, this.startIfEnabled();
485
- }
486
- setElementSelectors(e) {
487
- this.m = e;
488
- }
489
- getElementSelectors(e) {
490
- var t, i = [];
491
- return (t = this.m) == null || t.forEach((r) => {
492
- var n = y == null ? void 0 : y.querySelectorAll(r);
493
- n == null || n.forEach((a) => {
494
- e === a && i.push(r);
495
- });
496
- }), i;
497
- }
498
- get isEnabled() {
499
- var e, t, i = (e = this.instance.persistence) == null ? void 0 : e.props[xs], r = this.o;
500
- if (Ne(r) && !ve(i) && !this.instance.config.advanced_disable_decide) return !1;
501
- var n = (t = this.o) !== null && t !== void 0 ? t : !!i;
502
- return !!this.instance.config.autocapture && !n;
503
- }
504
- k(e, t) {
505
- if (t === void 0 && (t = "$autocapture"), this.isEnabled) {
506
- var i, r = Or(e);
507
- Mr(r) && (r = r.parentNode || null), t === "$autocapture" && e.type === "click" && e instanceof MouseEvent && this.instance.config.rageclick && (i = this.rageclicks) != null && i.isRageClick(e.clientX, e.clientY, (/* @__PURE__ */ new Date()).getTime()) && this.k(e, "$rageclick");
508
- var n = t === hi;
509
- if (r && Vn(r, e, this.S, n, n ? ["copy", "cut"] : void 0)) {
510
- var { props: a, explicitNoCapture: o } = ra(r, { e, maskAllElementAttributes: this.instance.config.mask_all_element_attributes, maskAllText: this.instance.config.mask_all_text, elementAttributeIgnoreList: this.S.element_attribute_ignorelist, elementsChainAsString: this.h });
511
- if (o) return !1;
512
- var l = this.getElementSelectors(r);
513
- if (l && l.length > 0 && (a.$element_selectors = l), t === hi) {
514
- var u, c = Tr(g == null || (u = g.getSelection()) == null ? void 0 : u.toString()), p = e.type || "clipboard";
515
- if (!c) return !1;
516
- a.$selected_content = c, a.$copy_type = p;
517
- }
518
- return this.instance.capture(t, a), !0;
519
- }
520
- }
521
- }
522
- isBrowserSupported() {
523
- return ae(y == null ? void 0 : y.querySelectorAll);
524
- }
525
- }
526
- Math.trunc || (Math.trunc = function(s) {
527
- return s < 0 ? Math.ceil(s) : Math.floor(s);
528
- }), Number.isInteger || (Number.isInteger = function(s) {
529
- return z(s) && isFinite(s) && Math.floor(s) === s;
530
- });
531
- var Bs = "0123456789abcdef";
532
- class Jt {
533
- constructor(e) {
534
- if (this.bytes = e, e.length !== 16) throw new TypeError("not 128-bit length");
535
- }
536
- static fromFieldsV7(e, t, i, r) {
537
- if (!Number.isInteger(e) || !Number.isInteger(t) || !Number.isInteger(i) || !Number.isInteger(r) || e < 0 || t < 0 || i < 0 || r < 0 || e > 281474976710655 || t > 4095 || i > 1073741823 || r > 4294967295) throw new RangeError("invalid field value");
538
- var n = new Uint8Array(16);
539
- return n[0] = e / Math.pow(2, 40), n[1] = e / Math.pow(2, 32), n[2] = e / Math.pow(2, 24), n[3] = e / Math.pow(2, 16), n[4] = e / Math.pow(2, 8), n[5] = e, n[6] = 112 | t >>> 8, n[7] = t, n[8] = 128 | i >>> 24, n[9] = i >>> 16, n[10] = i >>> 8, n[11] = i, n[12] = r >>> 24, n[13] = r >>> 16, n[14] = r >>> 8, n[15] = r, new Jt(n);
540
- }
541
- toString() {
542
- for (var e = "", t = 0; t < this.bytes.length; t++) e = e + Bs.charAt(this.bytes[t] >>> 4) + Bs.charAt(15 & this.bytes[t]), t !== 3 && t !== 5 && t !== 7 && t !== 9 || (e += "-");
543
- if (e.length !== 36) throw new Error("Invalid UUIDv7 was generated");
544
- return e;
545
- }
546
- clone() {
547
- return new Jt(this.bytes.slice(0));
548
- }
549
- equals(e) {
550
- return this.compareTo(e) === 0;
551
- }
552
- compareTo(e) {
553
- for (var t = 0; t < 16; t++) {
554
- var i = this.bytes[t] - e.bytes[t];
555
- if (i !== 0) return Math.sign(i);
556
- }
557
- return 0;
558
- }
559
- }
560
- class aa {
561
- constructor() {
562
- this.I = 0, this.P = 0, this.R = new oa();
563
- }
564
- generate() {
565
- var e = this.generateOrAbort();
566
- if (_(e)) {
567
- this.I = 0;
568
- var t = this.generateOrAbort();
569
- if (_(t)) throw new Error("Could not generate UUID after timestamp reset");
570
- return t;
571
- }
572
- return e;
573
- }
574
- generateOrAbort() {
575
- var e = Date.now();
576
- if (e > this.I) this.I = e, this.T();
577
- else {
578
- if (!(e + 1e4 > this.I)) return;
579
- this.P++, this.P > 4398046511103 && (this.I++, this.T());
580
- }
581
- return Jt.fromFieldsV7(this.I, Math.trunc(this.P / Math.pow(2, 30)), this.P & Math.pow(2, 30) - 1, this.R.nextUint32());
582
- }
583
- T() {
584
- this.P = 1024 * this.R.nextUint32() + (1023 & this.R.nextUint32());
585
- }
586
- }
587
- var Hs, jr = (s) => {
588
- if (typeof UUIDV7_DENY_WEAK_RNG < "u" && UUIDV7_DENY_WEAK_RNG) throw new Error("no cryptographically strong RNG available");
589
- for (var e = 0; e < s.length; e++) s[e] = 65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random());
590
- return s;
591
- };
592
- g && !_(g.crypto) && crypto.getRandomValues && (jr = (s) => crypto.getRandomValues(s));
593
- class oa {
594
- constructor() {
595
- this.M = new Uint32Array(8), this.C = 1 / 0;
596
- }
597
- nextUint32() {
598
- return this.C >= this.M.length && (jr(this.M), this.C = 0), this.M[this.C++];
599
- }
600
- }
601
- var Oe = () => la().toString(), la = () => (Hs || (Hs = new aa())).generate(), ht = "", ua = /[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;
602
- function ca(s, e) {
603
- if (e) {
604
- var t = function(r, n) {
605
- if (n === void 0 && (n = y), ht) return ht;
606
- if (!n || ["localhost", "127.0.0.1"].includes(r)) return "";
607
- for (var a = r.split("."), o = Math.min(a.length, 8), l = "dmn_chk_" + Oe(); !ht && o--; ) {
608
- var u = a.slice(o).join("."), c = l + "=1;domain=." + u + ";path=/";
609
- n.cookie = c + ";max-age=3", n.cookie.includes(l) && (n.cookie = c + ";max-age=0", ht = u);
610
- }
611
- return ht;
612
- }(s);
613
- if (!t) {
614
- var i = ((r) => {
615
- var n = r.match(ua);
616
- return n ? n[0] : "";
617
- })(s);
618
- i !== t && w.info("Warning: cookie subdomain discovery mismatch", i, t), t = i;
619
- }
620
- return t ? "; domain=." + t : "";
621
- }
622
- return "";
623
- }
624
- var Ie = { O: () => !!y, F: function(s) {
625
- w.error("cookieStore error: " + s);
626
- }, A: function(s) {
627
- if (y) {
628
- try {
629
- for (var e = s + "=", t = y.cookie.split(";").filter((n) => n.length), i = 0; i < t.length; i++) {
630
- for (var r = t[i]; r.charAt(0) == " "; ) r = r.substring(1, r.length);
631
- if (r.indexOf(e) === 0) return decodeURIComponent(r.substring(e.length, r.length));
632
- }
633
- } catch {
634
- }
635
- return null;
636
- }
637
- }, D: function(s) {
638
- var e;
639
- try {
640
- e = JSON.parse(Ie.A(s)) || {};
641
- } catch {
642
- }
643
- return e;
644
- }, L: function(s, e, t, i, r) {
645
- if (y) try {
646
- var n = "", a = "", o = ca(y.location.hostname, i);
647
- if (t) {
648
- var l = /* @__PURE__ */ new Date();
649
- l.setTime(l.getTime() + 24 * t * 60 * 60 * 1e3), n = "; expires=" + l.toUTCString();
650
- }
651
- r && (a = "; secure");
652
- var u = s + "=" + encodeURIComponent(JSON.stringify(e)) + n + "; SameSite=Lax; path=/" + o + a;
653
- return u.length > 3686.4 && w.warn("cookieStore warning: large cookie, len=" + u.length), y.cookie = u, u;
654
- } catch {
655
- return;
656
- }
657
- }, N: function(s, e) {
658
- try {
659
- Ie.L(s, "", -1, e);
660
- } catch {
661
- return;
662
- }
663
- } }, pi = null, q = { O: function() {
664
- if (!Ne(pi)) return pi;
665
- var s = !0;
666
- if (_(g)) s = !1;
667
- else try {
668
- var e = "__mplssupport__";
669
- q.L(e, "xyz"), q.A(e) !== '"xyz"' && (s = !1), q.N(e);
670
- } catch {
671
- s = !1;
672
- }
673
- return s || w.error("localStorage unsupported; falling back to cookie store"), pi = s, s;
674
- }, F: function(s) {
675
- w.error("localStorage error: " + s);
676
- }, A: function(s) {
677
- try {
678
- return g == null ? void 0 : g.localStorage.getItem(s);
679
- } catch (e) {
680
- q.F(e);
681
- }
682
- return null;
683
- }, D: function(s) {
684
- try {
685
- return JSON.parse(q.A(s)) || {};
686
- } catch {
687
- }
688
- return null;
689
- }, L: function(s, e) {
690
- try {
691
- g == null || g.localStorage.setItem(s, JSON.stringify(e));
692
- } catch (t) {
693
- q.F(t);
694
- }
695
- }, N: function(s) {
696
- try {
697
- g == null || g.localStorage.removeItem(s);
698
- } catch (e) {
699
- q.F(e);
700
- }
701
- } }, ha = ["distinct_id", Ut, _t, Gt, zt], Mt = m({}, q, { D: function(s) {
702
- try {
703
- var e = {};
704
- try {
705
- e = Ie.D(s) || {};
706
- } catch {
707
- }
708
- var t = D(e, JSON.parse(q.A(s) || "{}"));
709
- return q.L(s, t), t;
710
- } catch {
711
- }
712
- return null;
713
- }, L: function(s, e, t, i, r, n) {
714
- try {
715
- q.L(s, e, void 0, void 0, n);
716
- var a = {};
717
- ha.forEach((o) => {
718
- e[o] && (a[o] = e[o]);
719
- }), Object.keys(a).length && Ie.L(s, a, t, i, r, n);
720
- } catch (o) {
721
- q.F(o);
722
- }
723
- }, N: function(s, e) {
724
- try {
725
- g == null || g.localStorage.removeItem(s), Ie.N(s, e);
726
- } catch (t) {
727
- q.F(t);
728
- }
729
- } }), Ct = {}, da = { O: function() {
730
- return !0;
731
- }, F: function(s) {
732
- w.error("memoryStorage error: " + s);
733
- }, A: function(s) {
734
- return Ct[s] || null;
735
- }, D: function(s) {
736
- return Ct[s] || null;
737
- }, L: function(s, e) {
738
- Ct[s] = e;
739
- }, N: function(s) {
740
- delete Ct[s];
741
- } }, Be = null, H = { O: function() {
742
- if (!Ne(Be)) return Be;
743
- if (Be = !0, _(g)) Be = !1;
744
- else try {
745
- var s = "__support__";
746
- H.L(s, "xyz"), H.A(s) !== '"xyz"' && (Be = !1), H.N(s);
747
- } catch {
748
- Be = !1;
749
- }
750
- return Be;
751
- }, F: function(s) {
752
- w.error("sessionStorage error: ", s);
753
- }, A: function(s) {
754
- try {
755
- return g == null ? void 0 : g.sessionStorage.getItem(s);
756
- } catch (e) {
757
- H.F(e);
758
- }
759
- return null;
760
- }, D: function(s) {
761
- try {
762
- return JSON.parse(H.A(s)) || null;
763
- } catch {
764
- }
765
- return null;
766
- }, L: function(s, e) {
767
- try {
768
- g == null || g.sessionStorage.setItem(s, JSON.stringify(e));
769
- } catch (t) {
770
- H.F(t);
771
- }
772
- }, N: function(s) {
773
- try {
774
- g == null || g.sessionStorage.removeItem(s);
775
- } catch (e) {
776
- H.F(e);
777
- }
778
- } }, Ke = function(s) {
779
- return s[s.PENDING = -1] = "PENDING", s[s.DENIED = 0] = "DENIED", s[s.GRANTED = 1] = "GRANTED", s;
780
- }({});
781
- class pa {
782
- constructor(e) {
783
- this._instance = e;
784
- }
785
- get S() {
786
- return this._instance.config;
787
- }
788
- get consent() {
789
- return this.j() ? Ke.DENIED : this.U;
790
- }
791
- isOptedOut() {
792
- return this.consent === Ke.DENIED || this.consent === Ke.PENDING && this.S.opt_out_capturing_by_default;
793
- }
794
- isOptedIn() {
795
- return !this.isOptedOut();
796
- }
797
- optInOut(e) {
798
- this.q.L(this.B, e ? 1 : 0, this.S.cookie_expiration, this.S.cross_subdomain_cookie, this.S.secure_cookie);
799
- }
800
- reset() {
801
- this.q.N(this.B, this.S.cross_subdomain_cookie);
802
- }
803
- get B() {
804
- var { token: e, opt_out_capturing_cookie_prefix: t } = this._instance.config;
805
- return (t || "__ph_opt_in_out_") + e;
806
- }
807
- get U() {
808
- var e = this.q.A(this.B);
809
- return e === "1" ? Ke.GRANTED : e === "0" ? Ke.DENIED : Ke.PENDING;
810
- }
811
- get q() {
812
- if (!this.H) {
813
- var e = this.S.opt_out_capturing_persistence_type;
814
- this.H = e === "localStorage" ? q : Ie;
815
- var t = e === "localStorage" ? Ie : q;
816
- t.A(this.B) && (this.H.A(this.B) || this.optInOut(t.A(this.B) === "1"), t.N(this.B, this.S.cross_subdomain_cookie));
817
- }
818
- return this.H;
819
- }
820
- j() {
821
- return !!this.S.respect_dnt && !!Fr([ie == null ? void 0 : ie.doNotTrack, ie == null ? void 0 : ie.msDoNotTrack, x.doNotTrack], (e) => I([!0, 1, "1", "yes"], e));
822
- }
823
- }
824
- var Tt = j("[Dead Clicks]"), ga = () => !0, fa = (s) => {
825
- var e, t = !((e = s.instance.persistence) == null || !e.get_property(Pr)), i = s.instance.config.capture_dead_clicks;
826
- return ve(i) ? i : t;
827
- };
828
- class Ur {
829
- get lazyLoadedDeadClicksAutocapture() {
830
- return this.W;
831
- }
832
- constructor(e, t, i) {
833
- this.instance = e, this.isEnabled = t, this.onCapture = i, this.startIfEnabled();
834
- }
835
- onRemoteConfig(e) {
836
- this.instance.persistence && this.instance.persistence.register({ [Pr]: e == null ? void 0 : e.captureDeadClicks }), this.startIfEnabled();
837
- }
838
- startIfEnabled() {
839
- this.isEnabled(this) && this.G(() => {
840
- this.J();
841
- });
842
- }
843
- G(e) {
844
- var t, i;
845
- (t = x.__PosthogExtensions__) != null && t.initDeadClicksAutocapture && e(), (i = x.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this.instance, "dead-clicks-autocapture", (r) => {
846
- r ? Tt.error("failed to load script", r) : e();
847
- });
848
- }
849
- J() {
850
- var e;
851
- if (y) {
852
- if (!this.W && (e = x.__PosthogExtensions__) != null && e.initDeadClicksAutocapture) {
853
- var t = O(this.instance.config.capture_dead_clicks) ? this.instance.config.capture_dead_clicks : {};
854
- t.__onCapture = this.onCapture, this.W = x.__PosthogExtensions__.initDeadClicksAutocapture(this.instance, t), this.W.start(y), Tt.info("starting...");
855
- }
856
- } else Tt.error("`document` not found. Cannot start.");
857
- }
858
- stop() {
859
- this.W && (this.W.stop(), this.W = void 0, Tt.info("stopping..."));
860
- }
861
- }
862
- var gi = j("[ExceptionAutocapture]");
863
- class va {
864
- constructor(e) {
865
- var t;
866
- this.V = () => {
867
- var i;
868
- if (g && this.isEnabled && (i = x.__PosthogExtensions__) != null && i.errorWrappingFunctions) {
869
- var r = x.__PosthogExtensions__.errorWrappingFunctions.wrapOnError, n = x.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection, a = x.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;
870
- try {
871
- !this.K && this.S.capture_unhandled_errors && (this.K = r(this.captureException.bind(this))), !this.Y && this.S.capture_unhandled_rejections && (this.Y = n(this.captureException.bind(this))), !this.X && this.S.capture_console_errors && (this.X = a(this.captureException.bind(this)));
872
- } catch (o) {
873
- gi.error("failed to start", o), this.Z();
874
- }
875
- }
876
- }, this._instance = e, this.tt = !((t = this._instance.persistence) == null || !t.props[Ss]), this.S = this.it(), this.startIfEnabled();
877
- }
878
- it() {
879
- var e = this._instance.config.capture_exceptions, t = { capture_unhandled_errors: !1, capture_unhandled_rejections: !1, capture_console_errors: !1 };
880
- return O(e) ? t = m({}, t, e) : (_(e) ? this.tt : e) && (t = m({}, t, { capture_unhandled_errors: !0, capture_unhandled_rejections: !0 })), t;
881
- }
882
- get isEnabled() {
883
- return this.S.capture_console_errors || this.S.capture_unhandled_errors || this.S.capture_unhandled_rejections;
884
- }
885
- startIfEnabled() {
886
- this.isEnabled && (gi.info("enabled"), this.G(this.V));
887
- }
888
- G(e) {
889
- var t, i;
890
- (t = x.__PosthogExtensions__) != null && t.errorWrappingFunctions && e(), (i = x.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "exception-autocapture", (r) => {
891
- if (r) return gi.error("failed to load script", r);
892
- e();
893
- });
894
- }
895
- Z() {
896
- var e, t, i;
897
- (e = this.K) == null || e.call(this), this.K = void 0, (t = this.Y) == null || t.call(this), this.Y = void 0, (i = this.X) == null || i.call(this), this.X = void 0;
898
- }
899
- onRemoteConfig(e) {
900
- var t = e.autocaptureExceptions;
901
- this.tt = !!t || !1, this.S = this.it(), this._instance.persistence && this._instance.persistence.register({ [Ss]: this.tt }), this.startIfEnabled();
902
- }
903
- captureException(e) {
904
- var t = this._instance.requestRouter.endpointFor("ui");
905
- e.$exception_personURL = t + "/project/" + this._instance.config.token + "/person/" + this._instance.get_distinct_id(), this._instance.exceptions.sendExceptionEvent(e);
906
- }
907
- }
908
- function Wr(s) {
909
- return !_(Event) && zr(s, Event);
910
- }
911
- function zr(s, e) {
912
- try {
913
- return s instanceof e;
914
- } catch {
915
- return !1;
916
- }
917
- }
918
- function Gr(s) {
919
- switch (Object.prototype.toString.call(s)) {
920
- case "[object Error]":
921
- case "[object Exception]":
922
- case "[object DOMException]":
923
- case "[object DOMError]":
924
- return !0;
925
- default:
926
- return zr(s, Error);
927
- }
928
- }
929
- function Ht(s, e) {
930
- return Object.prototype.toString.call(s) === "[object " + e + "]";
931
- }
932
- function fi(s) {
933
- return Ht(s, "DOMError");
934
- }
935
- var js = /\(error: (.*)\)/, Us = 50, st = "?";
936
- function vi(s, e, t, i) {
937
- var r = { platform: "web:javascript", filename: s, function: e === "<anonymous>" ? st : e, in_app: !0 };
938
- return _(t) || (r.lineno = t), _(i) || (r.colno = i), r;
939
- }
940
- var _a = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i, ma = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, ya = /\((\S*)(?::(\d+))(?::(\d+))\)/, ba = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i, wa = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, Ea = function() {
941
- for (var s = arguments.length, e = new Array(s), t = 0; t < s; t++) e[t] = arguments[t];
942
- var i = e.sort((r, n) => r[0] - n[0]).map((r) => r[1]);
943
- return function(r, n) {
944
- n === void 0 && (n = 0);
945
- for (var a = [], o = r.split(`
946
- `), l = n; l < o.length; l++) {
947
- var u = o[l];
948
- if (!(u.length > 1024)) {
949
- var c = js.test(u) ? u.replace(js, "$1") : u;
950
- if (!c.match(/\S*Error: /)) {
951
- for (var p of i) {
952
- var h = p(c);
953
- if (h) {
954
- a.push(h);
955
- break;
956
- }
957
- }
958
- if (a.length >= Us) break;
959
- }
960
- }
961
- }
962
- return function(d) {
963
- if (!d.length) return [];
964
- var v = Array.from(d);
965
- return v.reverse(), v.slice(0, Us).map((f) => m({}, f, { filename: f.filename || ka(v).filename, function: f.function || st }));
966
- }(a);
967
- };
968
- }([30, (s) => {
969
- var e = _a.exec(s);
970
- if (e) {
971
- var [, t, i, r] = e;
972
- return vi(t, st, +i, +r);
973
- }
974
- var n = ma.exec(s);
975
- if (n) {
976
- if (n[2] && n[2].indexOf("eval") === 0) {
977
- var a = ya.exec(n[2]);
978
- a && (n[2] = a[1], n[3] = a[2], n[4] = a[3]);
979
- }
980
- var [o, l] = zs(n[1] || st, n[2]);
981
- return vi(l, o, n[3] ? +n[3] : void 0, n[4] ? +n[4] : void 0);
982
- }
983
- }], [50, (s) => {
984
- var e = ba.exec(s);
985
- if (e) {
986
- if (e[3] && e[3].indexOf(" > eval") > -1) {
987
- var t = wa.exec(e[3]);
988
- t && (e[1] = e[1] || "eval", e[3] = t[1], e[4] = t[2], e[5] = "");
989
- }
990
- var i = e[3], r = e[1] || st;
991
- return [r, i] = zs(r, i), vi(i, r, e[4] ? +e[4] : void 0, e[5] ? +e[5] : void 0);
992
- }
993
- }]);
994
- function ka(s) {
995
- return s[s.length - 1] || {};
996
- }
997
- var Ot, Ws, _i, zs = (s, e) => {
998
- var t = s.indexOf("safari-extension") !== -1, i = s.indexOf("safari-web-extension") !== -1;
999
- return t || i ? [s.indexOf("@") !== -1 ? s.split("@")[0] : st, t ? "safari-extension:" + e : "safari-web-extension:" + e] : [s, e];
1000
- }, xa = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
1001
- function rs(s, e) {
1002
- e === void 0 && (e = 0);
1003
- var t = s.stacktrace || s.stack || "", i = function(a) {
1004
- return a && Sa.test(a.message) ? 1 : 0;
1005
- }(s);
1006
- try {
1007
- var r = Ea, n = function(a, o) {
1008
- var l = function(u) {
1009
- var c = globalThis._posthogChunkIds;
1010
- if (!c) return {};
1011
- var p = Object.keys(c);
1012
- return _i && p.length === Ws || (Ws = p.length, _i = p.reduce((h, d) => {
1013
- Ot || (Ot = {});
1014
- var v = Ot[d];
1015
- if (v) h[v[0]] = v[1];
1016
- else for (var f = u(d), b = f.length - 1; b >= 0; b--) {
1017
- var E = f[b], k = E == null ? void 0 : E.filename, S = c[d];
1018
- if (k && S) {
1019
- h[k] = S, Ot[d] = [k, S];
1020
- break;
1021
- }
1022
- }
1023
- return h;
1024
- }, {})), _i;
1025
- }(o);
1026
- return a.forEach((u) => {
1027
- u.filename && (u.chunk_id = l[u.filename]);
1028
- }), a;
1029
- }(r(t, i), r);
1030
- return n.slice(0, n.length - e);
1031
- } catch {
1032
- }
1033
- return [];
1034
- }
1035
- var Sa = /Minified React error #\d+;/i;
1036
- function Ia(s, e) {
1037
- var t, i, r = rs(s), n = (t = e == null ? void 0 : e.handled) === null || t === void 0 || t, a = (i = e == null ? void 0 : e.synthetic) !== null && i !== void 0 && i;
1038
- return { type: e != null && e.overrideExceptionType ? e.overrideExceptionType : s.name, value: function(o) {
1039
- var l = o.message;
1040
- return l.error && typeof l.error.message == "string" ? String(l.error.message) : String(l);
1041
- }(s), stacktrace: { frames: r, type: "raw" }, mechanism: { handled: n, synthetic: a } };
1042
- }
1043
- function Vr(s, e) {
1044
- var t = Ia(s, e);
1045
- return s.cause && Gr(s.cause) && s.cause !== s ? [t, ...Vr(s.cause, { handled: e == null ? void 0 : e.handled, synthetic: e == null ? void 0 : e.synthetic })] : [t];
1046
- }
1047
- function mi(s, e) {
1048
- return { $exception_list: Vr(s, e), $exception_level: "error" };
1049
- }
1050
- function yi(s, e) {
1051
- var t, i, r, n = (t = e == null ? void 0 : e.handled) === null || t === void 0 || t, a = (i = e == null ? void 0 : e.synthetic) === null || i === void 0 || i, o = { type: e != null && e.overrideExceptionType ? e.overrideExceptionType : (r = e == null ? void 0 : e.defaultExceptionType) !== null && r !== void 0 ? r : "Error", value: s || (e == null ? void 0 : e.defaultExceptionMessage), mechanism: { handled: n, synthetic: a } };
1052
- if (e != null && e.syntheticException) {
1053
- var l = rs(e.syntheticException, 1);
1054
- l.length && (o.stacktrace = { frames: l, type: "raw" });
1055
- }
1056
- return { $exception_list: [o], $exception_level: "error" };
1057
- }
1058
- function Fa(s) {
1059
- return A(s) && !Pi(s) && Dn.indexOf(s) >= 0;
1060
- }
1061
- function $a(s, e) {
1062
- var t, i, r = (t = e == null ? void 0 : e.handled) === null || t === void 0 || t, n = (i = e == null ? void 0 : e.synthetic) === null || i === void 0 || i, a = e != null && e.overrideExceptionType ? e.overrideExceptionType : Wr(s) ? s.constructor.name : "Error", o = "Non-Error 'exception' captured with keys: " + function(c, p) {
1063
- p === void 0 && (p = 40);
1064
- var h = Object.keys(c);
1065
- if (h.sort(), !h.length) return "[object has no keys]";
1066
- for (var d = h.length; d > 0; d--) {
1067
- var v = h.slice(0, d).join(", ");
1068
- if (!(v.length > p)) return d === h.length || v.length <= p ? v : v.slice(0, p) + "...";
1069
- }
1070
- return "";
1071
- }(s), l = { type: a, value: o, mechanism: { handled: r, synthetic: n } };
1072
- if (e != null && e.syntheticException) {
1073
- var u = rs(e == null ? void 0 : e.syntheticException, 1);
1074
- u.length && (l.stacktrace = { frames: u, type: "raw" });
1075
- }
1076
- return { $exception_list: [l], $exception_level: Fa(s.level) ? s.level : "error" };
1077
- }
1078
- function Pa(s, e) {
1079
- var { error: t, event: i } = s, r = { $exception_list: [] }, n = t || i;
1080
- if (fi(n) || function(h) {
1081
- return Ht(h, "DOMException");
1082
- }(n)) {
1083
- var a = n;
1084
- if (function(h) {
1085
- return "stack" in h;
1086
- }(n)) r = mi(n, e);
1087
- else {
1088
- var o = a.name || (fi(a) ? "DOMError" : "DOMException"), l = a.message ? o + ": " + a.message : o;
1089
- r = yi(l, m({}, e, { overrideExceptionType: fi(a) ? "DOMError" : "DOMException", defaultExceptionMessage: l }));
1090
- }
1091
- return "code" in a && (r.$exception_DOMException_code = "" + a.code), r;
1092
- }
1093
- if (function(h) {
1094
- return Ht(h, "ErrorEvent");
1095
- }(n) && n.error) return mi(n.error, e);
1096
- if (Gr(n)) return mi(n, e);
1097
- if (function(h) {
1098
- return Ht(h, "Object");
1099
- }(n) || Wr(n)) return $a(n, e);
1100
- if (_(t) && A(i)) {
1101
- var u = "Error", c = i, p = i.match(xa);
1102
- return p && (u = p[1], c = p[2]), yi(c, m({}, e, { overrideExceptionType: u, defaultExceptionMessage: c }));
1103
- }
1104
- return yi(n, e);
1105
- }
1106
- function Gs(s, e, t) {
1107
- try {
1108
- if (!(e in s)) return () => {
1109
- };
1110
- var i = s[e], r = t(i);
1111
- return ae(r) && (r.prototype = r.prototype || {}, Object.defineProperties(r, { __posthog_wrapped__: { enumerable: !1, value: !0 } })), s[e] = r, () => {
1112
- s[e] = i;
1113
- };
1114
- } catch {
1115
- return () => {
1116
- };
1117
- }
1118
- }
1119
- class Ra {
1120
- constructor(e) {
1121
- var t;
1122
- this._instance = e, this.et = (g == null || (t = g.location) == null ? void 0 : t.pathname) || "";
1123
- }
1124
- get isEnabled() {
1125
- return this._instance.config.capture_pageview === "history_change";
1126
- }
1127
- startIfEnabled() {
1128
- this.isEnabled && (w.info("History API monitoring enabled, starting..."), this.monitorHistoryChanges());
1129
- }
1130
- stop() {
1131
- this.rt && this.rt(), this.rt = void 0, w.info("History API monitoring stopped");
1132
- }
1133
- monitorHistoryChanges() {
1134
- var e, t;
1135
- if (g && g.history) {
1136
- var i = this;
1137
- (e = g.history.pushState) != null && e.__posthog_wrapped__ || Gs(g.history, "pushState", (r) => function(n, a, o) {
1138
- r.call(this, n, a, o), i.st("pushState");
1139
- }), (t = g.history.replaceState) != null && t.__posthog_wrapped__ || Gs(g.history, "replaceState", (r) => function(n, a, o) {
1140
- r.call(this, n, a, o), i.st("replaceState");
1141
- }), this.nt();
1142
- }
1143
- }
1144
- st(e) {
1145
- try {
1146
- var t, i = g == null || (t = g.location) == null ? void 0 : t.pathname;
1147
- if (!i) return;
1148
- i !== this.et && this.isEnabled && this._instance.capture("$pageview", { navigation_type: e }), this.et = i;
1149
- } catch (r) {
1150
- w.error("Error capturing " + e + " pageview", r);
1151
- }
1152
- }
1153
- nt() {
1154
- if (!this.rt) {
1155
- var e = () => {
1156
- this.st("popstate");
1157
- };
1158
- T(g, "popstate", e), this.rt = () => {
1159
- g && g.removeEventListener("popstate", e);
1160
- };
1161
- }
1162
- }
1163
- }
1164
- function Zt(s) {
1165
- var e, t;
1166
- return ((e = JSON.stringify(s, (t = [], function(i, r) {
1167
- if (O(r)) {
1168
- for (; t.length > 0 && t[t.length - 1] !== this; ) t.pop();
1169
- return t.includes(r) ? "[Circular]" : (t.push(r), r);
1170
- }
1171
- return r;
1172
- }))) == null ? void 0 : e.length) || 0;
1173
- }
1174
- function Ui(s, e) {
1175
- if (e === void 0 && (e = 66060288e-1), s.size >= e && s.data.length > 1) {
1176
- var t = Math.floor(s.data.length / 2), i = s.data.slice(0, t), r = s.data.slice(t);
1177
- return [Ui({ size: Zt(i), data: i, sessionId: s.sessionId, windowId: s.windowId }), Ui({ size: Zt(r), data: r, sessionId: s.sessionId, windowId: s.windowId })].flatMap((n) => n);
1178
- }
1179
- return [s];
1180
- }
1181
- var ke = ((s) => (s[s.DomContentLoaded = 0] = "DomContentLoaded", s[s.Load = 1] = "Load", s[s.FullSnapshot = 2] = "FullSnapshot", s[s.IncrementalSnapshot = 3] = "IncrementalSnapshot", s[s.Meta = 4] = "Meta", s[s.Custom = 5] = "Custom", s[s.Plugin = 6] = "Plugin", s))(ke || {}), ce = ((s) => (s[s.Mutation = 0] = "Mutation", s[s.MouseMove = 1] = "MouseMove", s[s.MouseInteraction = 2] = "MouseInteraction", s[s.Scroll = 3] = "Scroll", s[s.ViewportResize = 4] = "ViewportResize", s[s.Input = 5] = "Input", s[s.TouchMove = 6] = "TouchMove", s[s.MediaInteraction = 7] = "MediaInteraction", s[s.StyleSheetRule = 8] = "StyleSheetRule", s[s.CanvasMutation = 9] = "CanvasMutation", s[s.Font = 10] = "Font", s[s.Log = 11] = "Log", s[s.Drag = 12] = "Drag", s[s.StyleDeclaration = 13] = "StyleDeclaration", s[s.Selection = 14] = "Selection", s[s.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", s[s.CustomElement = 16] = "CustomElement", s))(ce || {}), Wi = "[SessionRecording]", zi = "redacted", At = { initiatorTypes: ["audio", "beacon", "body", "css", "early-hint", "embed", "fetch", "frame", "iframe", "icon", "image", "img", "input", "link", "navigation", "object", "ping", "script", "track", "video", "xmlhttprequest"], maskRequestFn: (s) => s, recordHeaders: !1, recordBody: !1, recordInitialRequests: !1, recordPerformance: !1, performanceEntryTypeToObserve: ["first-input", "navigation", "paint", "resource"], payloadSizeLimitBytes: 1e6, payloadHostDenyList: [".lr-ingest.io", ".ingest.sentry.io", ".clarity.ms", "analytics.google.com", "bam.nr-data.net"] }, Ma = ["authorization", "x-forwarded-for", "authorization", "cookie", "set-cookie", "x-api-key", "x-real-ip", "remote-addr", "forwarded", "proxy-authorization", "x-csrf-token", "x-csrftoken", "x-xsrf-token"], Ca = ["password", "secret", "passwd", "api_key", "apikey", "auth", "credentials", "mysql_pwd", "privatekey", "private_key", "token"], Ta = ["/s/", "/e/", "/i/"];
1182
- function Vs(s, e, t, i) {
1183
- if (P(s)) return s;
1184
- var r = (e == null ? void 0 : e["content-length"]) || function(n) {
1185
- return new Blob([n]).size;
1186
- }(s);
1187
- return A(r) && (r = parseInt(r)), r > t ? Wi + " " + i + " body too large to record (" + r + " bytes)" : s;
1188
- }
1189
- function Xs(s, e) {
1190
- if (P(s)) return s;
1191
- var t = s;
1192
- return at(t, !1) || (t = Wi + " " + e + " body " + zi), R(Ca, (i) => {
1193
- var r, n;
1194
- (r = t) != null && r.length && ((n = t) == null ? void 0 : n.indexOf(i)) !== -1 && (t = Wi + " " + e + " body " + zi + " as might contain: " + i);
1195
- }), t;
1196
- }
1197
- var Oa = (s, e) => {
1198
- var t, i, r, n = { payloadSizeLimitBytes: At.payloadSizeLimitBytes, performanceEntryTypeToObserve: [...At.performanceEntryTypeToObserve], payloadHostDenyList: [...e.payloadHostDenyList || [], ...At.payloadHostDenyList] }, a = s.session_recording.recordHeaders !== !1 && e.recordHeaders, o = s.session_recording.recordBody !== !1 && e.recordBody, l = s.capture_performance !== !1 && e.recordPerformance, u = (t = n, r = Math.min(1e6, (i = t.payloadSizeLimitBytes) !== null && i !== void 0 ? i : 1e6), (h) => (h != null && h.requestBody && (h.requestBody = Vs(h.requestBody, h.requestHeaders, r, "Request")), h != null && h.responseBody && (h.responseBody = Vs(h.responseBody, h.responseHeaders, r, "Response")), h)), c = (h) => {
1199
- return u(((f, b) => {
1200
- var E, k = ot(f.name), S = b.indexOf("http") === 0 ? (E = ot(b)) == null ? void 0 : E.pathname : b;
1201
- S === "/" && (S = "");
1202
- var $ = k == null ? void 0 : k.pathname.replace(S || "", "");
1203
- if (!(k && $ && Ta.some((L) => $.indexOf(L) === 0))) return f;
1204
- })((v = (d = h).requestHeaders, P(v) || R(Object.keys(v ?? {}), (f) => {
1205
- Ma.includes(f.toLowerCase()) && (v[f] = zi);
1206
- }), d), s.api_host));
1207
- var d, v;
1208
- }, p = ae(s.session_recording.maskNetworkRequestFn);
1209
- return p && ae(s.session_recording.maskCapturedNetworkRequestFn) && w.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."), p && (s.session_recording.maskCapturedNetworkRequestFn = (h) => {
1210
- var d = s.session_recording.maskNetworkRequestFn({ url: h.name });
1211
- return m({}, h, { name: d == null ? void 0 : d.url });
1212
- }), n.maskRequestFn = ae(s.session_recording.maskCapturedNetworkRequestFn) ? (h) => {
1213
- var d, v = c(h);
1214
- return v && (d = s.session_recording.maskCapturedNetworkRequestFn == null ? void 0 : s.session_recording.maskCapturedNetworkRequestFn(v)) !== null && d !== void 0 ? d : void 0;
1215
- } : (h) => function(d) {
1216
- if (!_(d)) return d.requestBody = Xs(d.requestBody, "Request"), d.responseBody = Xs(d.responseBody, "Response"), d;
1217
- }(c(h)), m({}, At, n, { recordHeaders: a, recordBody: o, recordPerformance: l, recordInitialRequests: l });
1218
- };
1219
- function ne(s, e, t, i, r) {
1220
- return e > t && (w.warn("min cannot be greater than max."), e = t), z(s) ? s > t ? (i && w.warn(i + " cannot be greater than max: " + t + ". Using max value instead."), t) : s < e ? (i && w.warn(i + " cannot be less than min: " + e + ". Using min value instead."), e) : s : (i && w.warn(i + " must be a number. using max or fallback. max: " + t + ", fallback: " + r), ne(r || t, e, t, i));
1221
- }
1222
- class Aa {
1223
- constructor(e, t) {
1224
- var i, r;
1225
- t === void 0 && (t = {}), this.ot = 100, this.lt = 10, this.ut = {}, this.ht = {}, this.dt = () => {
1226
- Object.keys(this.ut).forEach((n) => {
1227
- this.ut[n] = this.ut[n] + this.lt, this.ut[n] >= this.ot && delete this.ut[n];
1228
- });
1229
- }, this.vt = (n) => {
1230
- var a = this._rrweb.mirror.getNode(n);
1231
- if ((a == null ? void 0 : a.nodeName) !== "svg" && a instanceof Element) {
1232
- var o = a.closest("svg");
1233
- if (o) return [this._rrweb.mirror.getId(o), o];
1234
- }
1235
- return [n, a];
1236
- }, this.ct = (n) => {
1237
- var a, o, l, u, c, p, h, d;
1238
- return ((a = (o = n.removes) == null ? void 0 : o.length) !== null && a !== void 0 ? a : 0) + ((l = (u = n.attributes) == null ? void 0 : u.length) !== null && l !== void 0 ? l : 0) + ((c = (p = n.texts) == null ? void 0 : p.length) !== null && c !== void 0 ? c : 0) + ((h = (d = n.adds) == null ? void 0 : d.length) !== null && h !== void 0 ? h : 0);
1239
- }, this.throttleMutations = (n) => {
1240
- if (n.type !== 3 || n.data.source !== 0) return n;
1241
- var a = n.data, o = this.ct(a);
1242
- a.attributes && (a.attributes = a.attributes.filter((u) => {
1243
- var c, p, h, [d, v] = this.vt(u.id);
1244
- return this.ut[d] === 0 ? !1 : (this.ut[d] = (c = this.ut[d]) !== null && c !== void 0 ? c : this.ot, this.ut[d] = Math.max(this.ut[d] - 1, 0), this.ut[d] === 0 && (this.ht[d] || (this.ht[d] = !0, (p = (h = this.ft).onBlockedNode) == null || p.call(h, d, v))), u);
1245
- }));
1246
- var l = this.ct(a);
1247
- return l !== 0 || o === l ? n : void 0;
1248
- }, this._rrweb = e, this.ft = t, this.lt = ne((i = this.ft.refillRate) !== null && i !== void 0 ? i : this.lt, 0, 100, "mutation throttling refill rate"), this.ot = ne((r = this.ft.bucketSize) !== null && r !== void 0 ? r : this.ot, 0, 100, "mutation throttling bucket size"), setInterval(() => {
1249
- this.dt();
1250
- }, 1e3);
1251
- }
1252
- }
1253
- var oe = Uint8Array, Q = Uint16Array, lt = Uint32Array, ns = new oe([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]), as = new oe([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]), Ys = new oe([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), Xr = function(s, e) {
1254
- for (var t = new Q(31), i = 0; i < 31; ++i) t[i] = e += 1 << s[i - 1];
1255
- var r = new lt(t[30]);
1256
- for (i = 1; i < 30; ++i) for (var n = t[i]; n < t[i + 1]; ++n) r[n] = n - t[i] << 5 | i;
1257
- return [t, r];
1258
- }, Yr = Xr(ns, 2), La = Yr[0], Gi = Yr[1];
1259
- La[28] = 258, Gi[258] = 28;
1260
- for (var Js = Xr(as, 0)[1], Jr = new Q(32768), M = 0; M < 32768; ++M) {
1261
- var He = (43690 & M) >>> 1 | (21845 & M) << 1;
1262
- He = (61680 & (He = (52428 & He) >>> 2 | (13107 & He) << 2)) >>> 4 | (3855 & He) << 4, Jr[M] = ((65280 & He) >>> 8 | (255 & He) << 8) >>> 1;
1263
- }
1264
- var kt = function(s, e, t) {
1265
- for (var i = s.length, r = 0, n = new Q(e); r < i; ++r) ++n[s[r] - 1];
1266
- var a, o = new Q(e);
1267
- for (r = 0; r < e; ++r) o[r] = o[r - 1] + n[r - 1] << 1;
1268
- for (a = new Q(i), r = 0; r < i; ++r) a[r] = Jr[o[s[r] - 1]++] >>> 15 - s[r];
1269
- return a;
1270
- }, Ge = new oe(288);
1271
- for (M = 0; M < 144; ++M) Ge[M] = 8;
1272
- for (M = 144; M < 256; ++M) Ge[M] = 9;
1273
- for (M = 256; M < 280; ++M) Ge[M] = 7;
1274
- for (M = 280; M < 288; ++M) Ge[M] = 8;
1275
- var Kt = new oe(32);
1276
- for (M = 0; M < 32; ++M) Kt[M] = 5;
1277
- var Da = kt(Ge, 9), Na = kt(Kt, 5), Zr = function(s) {
1278
- return (s / 8 >> 0) + (7 & s && 1);
1279
- }, Kr = function(s, e, t) {
1280
- (t == null || t > s.length) && (t = s.length);
1281
- var i = new (s instanceof Q ? Q : s instanceof lt ? lt : oe)(t - e);
1282
- return i.set(s.subarray(e, t)), i;
1283
- }, we = function(s, e, t) {
1284
- t <<= 7 & e;
1285
- var i = e / 8 >> 0;
1286
- s[i] |= t, s[i + 1] |= t >>> 8;
1287
- }, dt = function(s, e, t) {
1288
- t <<= 7 & e;
1289
- var i = e / 8 >> 0;
1290
- s[i] |= t, s[i + 1] |= t >>> 8, s[i + 2] |= t >>> 16;
1291
- }, bi = function(s, e) {
1292
- for (var t = [], i = 0; i < s.length; ++i) s[i] && t.push({ s: i, f: s[i] });
1293
- var r = t.length, n = t.slice();
1294
- if (!r) return [new oe(0), 0];
1295
- if (r == 1) {
1296
- var a = new oe(t[0].s + 1);
1297
- return a[t[0].s] = 1, [a, 1];
1298
- }
1299
- t.sort(function(L, V) {
1300
- return L.f - V.f;
1301
- }), t.push({ s: -1, f: 25001 });
1302
- var o = t[0], l = t[1], u = 0, c = 1, p = 2;
1303
- for (t[0] = { s: -1, f: o.f + l.f, l: o, r: l }; c != r - 1; ) o = t[t[u].f < t[p].f ? u++ : p++], l = t[u != c && t[u].f < t[p].f ? u++ : p++], t[c++] = { s: -1, f: o.f + l.f, l: o, r: l };
1304
- var h = n[0].s;
1305
- for (i = 1; i < r; ++i) n[i].s > h && (h = n[i].s);
1306
- var d = new Q(h + 1), v = Vi(t[c - 1], d, 0);
1307
- if (v > e) {
1308
- i = 0;
1309
- var f = 0, b = v - e, E = 1 << b;
1310
- for (n.sort(function(L, V) {
1311
- return d[V.s] - d[L.s] || L.f - V.f;
1312
- }); i < r; ++i) {
1313
- var k = n[i].s;
1314
- if (!(d[k] > e)) break;
1315
- f += E - (1 << v - d[k]), d[k] = e;
1316
- }
1317
- for (f >>>= b; f > 0; ) {
1318
- var S = n[i].s;
1319
- d[S] < e ? f -= 1 << e - d[S]++ - 1 : ++i;
1320
- }
1321
- for (; i >= 0 && f; --i) {
1322
- var $ = n[i].s;
1323
- d[$] == e && (--d[$], ++f);
1324
- }
1325
- v = e;
1326
- }
1327
- return [new oe(d), v];
1328
- }, Vi = function(s, e, t) {
1329
- return s.s == -1 ? Math.max(Vi(s.l, e, t + 1), Vi(s.r, e, t + 1)) : e[s.s] = t;
1330
- }, Zs = function(s) {
1331
- for (var e = s.length; e && !s[--e]; ) ;
1332
- for (var t = new Q(++e), i = 0, r = s[0], n = 1, a = function(l) {
1333
- t[i++] = l;
1334
- }, o = 1; o <= e; ++o) if (s[o] == r && o != e) ++n;
1335
- else {
1336
- if (!r && n > 2) {
1337
- for (; n > 138; n -= 138) a(32754);
1338
- n > 2 && (a(n > 10 ? n - 11 << 5 | 28690 : n - 3 << 5 | 12305), n = 0);
1339
- } else if (n > 3) {
1340
- for (a(r), --n; n > 6; n -= 6) a(8304);
1341
- n > 2 && (a(n - 3 << 5 | 8208), n = 0);
1342
- }
1343
- for (; n--; ) a(r);
1344
- n = 1, r = s[o];
1345
- }
1346
- return [t.subarray(0, i), e];
1347
- }, pt = function(s, e) {
1348
- for (var t = 0, i = 0; i < e.length; ++i) t += s[i] * e[i];
1349
- return t;
1350
- }, Xi = function(s, e, t) {
1351
- var i = t.length, r = Zr(e + 2);
1352
- s[r] = 255 & i, s[r + 1] = i >>> 8, s[r + 2] = 255 ^ s[r], s[r + 3] = 255 ^ s[r + 1];
1353
- for (var n = 0; n < i; ++n) s[r + n + 4] = t[n];
1354
- return 8 * (r + 4 + i);
1355
- }, Ks = function(s, e, t, i, r, n, a, o, l, u, c) {
1356
- we(e, c++, t), ++r[256];
1357
- for (var p = bi(r, 15), h = p[0], d = p[1], v = bi(n, 15), f = v[0], b = v[1], E = Zs(h), k = E[0], S = E[1], $ = Zs(f), L = $[0], V = $[1], B = new Q(19), F = 0; F < k.length; ++F) B[31 & k[F]]++;
1358
- for (F = 0; F < L.length; ++F) B[31 & L[F]]++;
1359
- for (var he = bi(B, 7), ee = he[0], ue = he[1], se = 19; se > 4 && !ee[Ys[se - 1]]; --se) ;
1360
- var be, de, pe, Ye, Fe = u + 5 << 3, qe = pt(r, Ge) + pt(n, Kt) + a, ge = pt(r, h) + pt(n, f) + a + 14 + 3 * se + pt(B, ee) + (2 * B[16] + 3 * B[17] + 7 * B[18]);
1361
- if (Fe <= qe && Fe <= ge) return Xi(e, c, s.subarray(l, l + u));
1362
- if (we(e, c, 1 + (ge < qe)), c += 2, ge < qe) {
1363
- be = kt(h, d), de = h, pe = kt(f, b), Ye = f;
1364
- var $e = kt(ee, ue);
1365
- for (we(e, c, S - 257), we(e, c + 5, V - 1), we(e, c + 10, se - 4), c += 14, F = 0; F < se; ++F) we(e, c + 3 * F, ee[Ys[F]]);
1366
- c += 3 * se;
1367
- for (var Je = [k, L], X = 0; X < 2; ++X) {
1368
- var re = Je[X];
1369
- for (F = 0; F < re.length; ++F) {
1370
- var te = 31 & re[F];
1371
- we(e, c, $e[te]), c += ee[te], te > 15 && (we(e, c, re[F] >>> 5 & 127), c += re[F] >>> 12);
1372
- }
1373
- }
1374
- } else be = Da, de = Ge, pe = Na, Ye = Kt;
1375
- for (F = 0; F < o; ++F) if (i[F] > 255) {
1376
- te = i[F] >>> 18 & 31, dt(e, c, be[te + 257]), c += de[te + 257], te > 7 && (we(e, c, i[F] >>> 23 & 31), c += ns[te]);
1377
- var Ze = 31 & i[F];
1378
- dt(e, c, pe[Ze]), c += Ye[Ze], Ze > 3 && (dt(e, c, i[F] >>> 5 & 8191), c += as[Ze]);
1379
- } else dt(e, c, be[i[F]]), c += de[i[F]];
1380
- return dt(e, c, be[256]), c + de[256];
1381
- }, qa = new lt([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]), Ba = function() {
1382
- for (var s = new lt(256), e = 0; e < 256; ++e) {
1383
- for (var t = e, i = 9; --i; ) t = (1 & t && 3988292384) ^ t >>> 1;
1384
- s[e] = t;
1385
- }
1386
- return s;
1387
- }(), Ha = function() {
1388
- var s = 4294967295;
1389
- return { p: function(e) {
1390
- for (var t = s, i = 0; i < e.length; ++i) t = Ba[255 & t ^ e[i]] ^ t >>> 8;
1391
- s = t;
1392
- }, d: function() {
1393
- return 4294967295 ^ s;
1394
- } };
1395
- }, ja = function(s, e, t, i, r) {
1396
- return function(n, a, o, l, u, c) {
1397
- var p = n.length, h = new oe(l + p + 5 * (1 + Math.floor(p / 7e3)) + u), d = h.subarray(l, h.length - u), v = 0;
1398
- if (!a || p < 8) for (var f = 0; f <= p; f += 65535) {
1399
- var b = f + 65535;
1400
- b < p ? v = Xi(d, v, n.subarray(f, b)) : (d[f] = c, v = Xi(d, v, n.subarray(f, p)));
1401
- }
1402
- else {
1403
- for (var E = qa[a - 1], k = E >>> 13, S = 8191 & E, $ = (1 << o) - 1, L = new Q(32768), V = new Q($ + 1), B = Math.ceil(o / 3), F = 2 * B, he = function(ci) {
1404
- return (n[ci] ^ n[ci + 1] << B ^ n[ci + 2] << F) & $;
1405
- }, ee = new lt(25e3), ue = new Q(288), se = new Q(32), be = 0, de = 0, pe = (f = 0, 0), Ye = 0, Fe = 0; f < p; ++f) {
1406
- var qe = he(f), ge = 32767 & f, $e = V[qe];
1407
- if (L[ge] = $e, V[qe] = ge, Ye <= f) {
1408
- var Je = p - f;
1409
- if ((be > 7e3 || pe > 24576) && Je > 423) {
1410
- v = Ks(n, d, 0, ee, ue, se, de, pe, Fe, f - Fe, v), pe = be = de = 0, Fe = f;
1411
- for (var X = 0; X < 286; ++X) ue[X] = 0;
1412
- for (X = 0; X < 30; ++X) se[X] = 0;
1413
- }
1414
- var re = 2, te = 0, Ze = S, Pe = ge - $e & 32767;
1415
- if (Je > 2 && qe == he(f - Pe)) for (var Cn = Math.min(k, Je) - 1, Tn = Math.min(32767, f), On = Math.min(258, Je); Pe <= Tn && --Ze && ge != $e; ) {
1416
- if (n[f + re] == n[f + re - Pe]) {
1417
- for (var Re = 0; Re < On && n[f + Re] == n[f + Re - Pe]; ++Re) ;
1418
- if (Re > re) {
1419
- if (re = Re, te = Pe, Re > Cn) break;
1420
- var An = Math.min(Pe, Re - 2), fs = 0;
1421
- for (X = 0; X < An; ++X) {
1422
- var ui = f - Pe + X + 32768 & 32767, vs = ui - L[ui] + 32768 & 32767;
1423
- vs > fs && (fs = vs, $e = ui);
1424
- }
1425
- }
1426
- }
1427
- Pe += (ge = $e) - ($e = L[ge]) + 32768 & 32767;
1428
- }
1429
- if (te) {
1430
- ee[pe++] = 268435456 | Gi[re] << 18 | Js[te];
1431
- var _s = 31 & Gi[re], ms = 31 & Js[te];
1432
- de += ns[_s] + as[ms], ++ue[257 + _s], ++se[ms], Ye = f + re, ++be;
1433
- } else ee[pe++] = n[f], ++ue[n[f]];
1434
- }
1435
- }
1436
- v = Ks(n, d, c, ee, ue, se, de, pe, Fe, f - Fe, v);
1437
- }
1438
- return Kr(h, 0, l + Zr(v) + u);
1439
- }(s, e.level == null ? 6 : e.level, e.mem == null ? Math.ceil(1.5 * Math.max(8, Math.min(13, Math.log(s.length)))) : 12 + e.mem, t, i, !0);
1440
- }, Yi = function(s, e, t) {
1441
- for (; t; ++e) s[e] = t, t >>>= 8;
1442
- }, Ua = function(s, e) {
1443
- var t = e.filename;
1444
- if (s[0] = 31, s[1] = 139, s[2] = 8, s[8] = e.level < 2 ? 4 : e.level == 9 ? 2 : 0, s[9] = 3, e.mtime != 0 && Yi(s, 4, Math.floor(new Date(e.mtime || Date.now()) / 1e3)), t) {
1445
- s[3] = 8;
1446
- for (var i = 0; i <= t.length; ++i) s[i + 10] = t.charCodeAt(i);
1447
- }
1448
- }, Wa = function(s) {
1449
- return 10 + (s.filename && s.filename.length + 1 || 0);
1450
- };
1451
- function Qr(s, e) {
1452
- e === void 0 && (e = {});
1453
- var t = Ha(), i = s.length;
1454
- t.p(s);
1455
- var r = ja(s, e, Wa(e), 8), n = r.length;
1456
- return Ua(r, e), Yi(r, n - 8, t.d()), Yi(r, n - 4, i), r;
1457
- }
1458
- function en(s, e) {
1459
- var t = s.length;
1460
- if (typeof TextEncoder < "u") return new TextEncoder().encode(s);
1461
- for (var i = new oe(s.length + (s.length >>> 1)), r = 0, n = function(u) {
1462
- i[r++] = u;
1463
- }, a = 0; a < t; ++a) {
1464
- if (r + 5 > i.length) {
1465
- var o = new oe(r + 8 + (t - a << 1));
1466
- o.set(i), i = o;
1467
- }
1468
- var l = s.charCodeAt(a);
1469
- l < 128 || e ? n(l) : l < 2048 ? (n(192 | l >>> 6), n(128 | 63 & l)) : l > 55295 && l < 57344 ? (n(240 | (l = 65536 + (1047552 & l) | 1023 & s.charCodeAt(++a)) >>> 18), n(128 | l >>> 12 & 63), n(128 | l >>> 6 & 63), n(128 | 63 & l)) : (n(224 | l >>> 12), n(128 | l >>> 6 & 63), n(128 | 63 & l));
1470
- }
1471
- return Kr(i, 0, r);
1472
- }
1473
- function za(s, e) {
1474
- return function(t) {
1475
- for (var i = 0, r = 0; r < t.length; r++) i = (i << 5) - i + t.charCodeAt(r), i |= 0;
1476
- return Math.abs(i);
1477
- }(s) % 100 < ne(100 * e, 0, 100);
1478
- }
1479
- var De = "disabled", os = "sampled", Qt = "active", Ve = "buffering", ls = "paused", us = "trigger", me = us + "_activated", G = us + "_pending", ye = us + "_" + De;
1480
- function Qs(s, e) {
1481
- return e.some((t) => t.matching === "regex" && new RegExp(t.url).test(s));
1482
- }
1483
- class tn {
1484
- constructor(e) {
1485
- this.gt = e;
1486
- }
1487
- triggerStatus(e) {
1488
- var t = this.gt.map((i) => i.triggerStatus(e));
1489
- return t.includes(me) ? me : t.includes(G) ? G : ye;
1490
- }
1491
- stop() {
1492
- this.gt.forEach((e) => e.stop());
1493
- }
1494
- }
1495
- class sn {
1496
- constructor(e) {
1497
- this.gt = e;
1498
- }
1499
- triggerStatus(e) {
1500
- var t = /* @__PURE__ */ new Set();
1501
- for (var i of this.gt) t.add(i.triggerStatus(e));
1502
- switch (t.delete(ye), t.size) {
1503
- case 0:
1504
- return ye;
1505
- case 1:
1506
- return Array.from(t)[0];
1507
- default:
1508
- return G;
1509
- }
1510
- }
1511
- stop() {
1512
- this.gt.forEach((e) => e.stop());
1513
- }
1514
- }
1515
- class Ga {
1516
- triggerStatus() {
1517
- return G;
1518
- }
1519
- stop() {
1520
- }
1521
- }
1522
- class Va {
1523
- constructor(e) {
1524
- this._t = [], this.bt = [], this.urlBlocked = !1, this._instance = e;
1525
- }
1526
- onRemoteConfig(e) {
1527
- var t, i;
1528
- this._t = ((t = e.sessionRecording) == null ? void 0 : t.urlTriggers) || [], this.bt = ((i = e.sessionRecording) == null ? void 0 : i.urlBlocklist) || [];
1529
- }
1530
- wt(e) {
1531
- var t;
1532
- return this._t.length === 0 ? ye : ((t = this._instance) == null ? void 0 : t.get_property(Ti)) === e ? me : G;
1533
- }
1534
- triggerStatus(e) {
1535
- var t = this.wt(e), i = t === me ? me : t === G ? G : ye;
1536
- return this._instance.register_for_session({ $sdk_debug_replay_url_trigger_status: i }), i;
1537
- }
1538
- checkUrlTriggerConditions(e, t, i) {
1539
- if (g !== void 0 && g.location.href) {
1540
- var r = g.location.href, n = this.urlBlocked, a = Qs(r, this.bt);
1541
- n && a || (a && !n ? e() : !a && n && t(), Qs(r, this._t) && i("url"));
1542
- }
1543
- }
1544
- stop() {
1545
- }
1546
- }
1547
- class Xa {
1548
- constructor(e) {
1549
- this.linkedFlag = null, this.linkedFlagSeen = !1, this.yt = () => {
1550
- }, this._instance = e;
1551
- }
1552
- triggerStatus() {
1553
- var e = G;
1554
- return P(this.linkedFlag) && (e = ye), this.linkedFlagSeen && (e = me), this._instance.register_for_session({ $sdk_debug_replay_linked_flag_trigger_status: e }), e;
1555
- }
1556
- onRemoteConfig(e, t) {
1557
- var i;
1558
- if (this.linkedFlag = ((i = e.sessionRecording) == null ? void 0 : i.linkedFlag) || null, !P(this.linkedFlag) && !this.linkedFlagSeen) {
1559
- var r = A(this.linkedFlag) ? this.linkedFlag : this.linkedFlag.flag, n = A(this.linkedFlag) ? null : this.linkedFlag.variant;
1560
- this.yt = this._instance.onFeatureFlags((a, o) => {
1561
- var l = !1;
1562
- if (O(o) && r in o) {
1563
- var u = o[r];
1564
- l = ve(u) ? u === !0 : n ? u === n : !!u;
1565
- }
1566
- this.linkedFlagSeen = l, l && t(r, n);
1567
- });
1568
- }
1569
- }
1570
- stop() {
1571
- this.yt();
1572
- }
1573
- }
1574
- class Ya {
1575
- constructor(e) {
1576
- this.St = [], this._instance = e;
1577
- }
1578
- onRemoteConfig(e) {
1579
- var t;
1580
- this.St = ((t = e.sessionRecording) == null ? void 0 : t.eventTriggers) || [];
1581
- }
1582
- $t(e) {
1583
- var t;
1584
- return this.St.length === 0 ? ye : ((t = this._instance) == null ? void 0 : t.get_property(Oi)) === e ? me : G;
1585
- }
1586
- triggerStatus(e) {
1587
- var t = this.$t(e), i = t === me ? me : t === G ? G : ye;
1588
- return this._instance.register_for_session({ $sdk_debug_replay_event_trigger_status: i }), i;
1589
- }
1590
- stop() {
1591
- }
1592
- }
1593
- function Ja(s) {
1594
- return s.isRecordingEnabled ? Ve : De;
1595
- }
1596
- function Za(s) {
1597
- if (!s.receivedDecide) return Ve;
1598
- if (!s.isRecordingEnabled) return De;
1599
- if (s.urlTriggerMatching.urlBlocked) return ls;
1600
- var e = s.isSampled === !0, t = new tn([s.eventTriggerMatching, s.urlTriggerMatching, s.linkedFlagMatching]).triggerStatus(s.sessionId);
1601
- return e ? os : t === me ? Qt : t === G ? Ve : s.isSampled === !1 ? De : Qt;
1602
- }
1603
- function Ka(s) {
1604
- if (!s.receivedDecide) return Ve;
1605
- if (!s.isRecordingEnabled) return De;
1606
- if (s.urlTriggerMatching.urlBlocked) return ls;
1607
- var e = new sn([s.eventTriggerMatching, s.urlTriggerMatching, s.linkedFlagMatching]).triggerStatus(s.sessionId), t = e !== ye, i = ve(s.isSampled);
1608
- return t && e === G ? Ve : t && e === ye || i && !s.isSampled ? De : s.isSampled === !0 ? os : Qt;
1609
- }
1610
- var yt = "[SessionRecording]", U = j(yt);
1611
- function Lt() {
1612
- var s;
1613
- return x == null || (s = x.__PosthogExtensions__) == null || (s = s.rrweb) == null ? void 0 : s.record;
1614
- }
1615
- var Qa = 3e5, eo = [ce.MouseMove, ce.MouseInteraction, ce.Scroll, ce.ViewportResize, ce.Input, ce.TouchMove, ce.MediaInteraction, ce.Drag], er = (s) => ({ rrwebMethod: s, enqueuedAt: Date.now(), attempt: 1 });
1616
- function je(s) {
1617
- return function(e, t) {
1618
- for (var i = "", r = 0; r < e.length; ) {
1619
- var n = e[r++];
1620
- i += String.fromCharCode(n);
1621
- }
1622
- return i;
1623
- }(Qr(en(JSON.stringify(s))));
1624
- }
1625
- function tr(s) {
1626
- return s.type === ke.Custom && s.data.tag === "sessionIdle";
1627
- }
1628
- class to {
1629
- get sessionId() {
1630
- return this.kt;
1631
- }
1632
- get xt() {
1633
- return this._instance.config.session_recording.session_idle_threshold_ms || 3e5;
1634
- }
1635
- get started() {
1636
- return this.Et;
1637
- }
1638
- get It() {
1639
- if (!this._instance.sessionManager) throw new Error(yt + " must be started with a valid sessionManager.");
1640
- return this._instance.sessionManager;
1641
- }
1642
- get Pt() {
1643
- var e, t;
1644
- return this.Rt.triggerStatus(this.sessionId) === G ? 6e4 : (e = (t = this._instance.config.session_recording) == null ? void 0 : t.full_snapshot_interval_millis) !== null && e !== void 0 ? e : Qa;
1645
- }
1646
- get Tt() {
1647
- var e = this._instance.get_property(_t);
1648
- return ve(e) ? e : null;
1649
- }
1650
- get Mt() {
1651
- var e, t, i = (e = this.M) == null ? void 0 : e.data[((t = this.M) == null ? void 0 : t.data.length) - 1], { sessionStartTimestamp: r } = this.It.checkAndGetSessionAndWindowId(!0);
1652
- return i ? i.timestamp - r : null;
1653
- }
1654
- get Ct() {
1655
- var e = !!this._instance.get_property(Ci), t = !this._instance.config.disable_session_recording;
1656
- return g && e && t;
1657
- }
1658
- get Ot() {
1659
- var e = !!this._instance.get_property($s), t = this._instance.config.enable_recording_console_log;
1660
- return t ?? e;
1661
- }
1662
- get Ft() {
1663
- var e, t, i, r, n, a, o = this._instance.config.session_recording.captureCanvas, l = this._instance.get_property(Ms), u = (e = (t = o == null ? void 0 : o.recordCanvas) !== null && t !== void 0 ? t : l == null ? void 0 : l.enabled) !== null && e !== void 0 && e, c = (i = (r = o == null ? void 0 : o.canvasFps) !== null && r !== void 0 ? r : l == null ? void 0 : l.fps) !== null && i !== void 0 ? i : 4, p = (n = (a = o == null ? void 0 : o.canvasQuality) !== null && a !== void 0 ? a : l == null ? void 0 : l.quality) !== null && n !== void 0 ? n : 0.4;
1664
- if (typeof p == "string") {
1665
- var h = parseFloat(p);
1666
- p = isNaN(h) ? 0.4 : h;
1667
- }
1668
- return { enabled: u, fps: ne(c, 0, 12, "canvas recording fps", 4), quality: ne(p, 0, 1, "canvas recording quality", 0.4) };
1669
- }
1670
- get At() {
1671
- var e, t, i = this._instance.get_property(Ps), r = { recordHeaders: (e = this._instance.config.session_recording) == null ? void 0 : e.recordHeaders, recordBody: (t = this._instance.config.session_recording) == null ? void 0 : t.recordBody }, n = (r == null ? void 0 : r.recordHeaders) || (i == null ? void 0 : i.recordHeaders), a = (r == null ? void 0 : r.recordBody) || (i == null ? void 0 : i.recordBody), o = O(this._instance.config.capture_performance) ? this._instance.config.capture_performance.network_timing : this._instance.config.capture_performance, l = !!(ve(o) ? o : i != null && i.capturePerformance);
1672
- return n || a || l ? { recordHeaders: n, recordBody: a, recordPerformance: l } : void 0;
1673
- }
1674
- get Dt() {
1675
- var e, t, i, r, n, a, o = this._instance.get_property(Rs), l = { maskAllInputs: (e = this._instance.config.session_recording) == null ? void 0 : e.maskAllInputs, maskTextSelector: (t = this._instance.config.session_recording) == null ? void 0 : t.maskTextSelector, blockSelector: (i = this._instance.config.session_recording) == null ? void 0 : i.blockSelector }, u = (r = l == null ? void 0 : l.maskAllInputs) !== null && r !== void 0 ? r : o == null ? void 0 : o.maskAllInputs, c = (n = l == null ? void 0 : l.maskTextSelector) !== null && n !== void 0 ? n : o == null ? void 0 : o.maskTextSelector, p = (a = l == null ? void 0 : l.blockSelector) !== null && a !== void 0 ? a : o == null ? void 0 : o.blockSelector;
1676
- return _(u) && _(c) && _(p) ? void 0 : { maskAllInputs: u == null || u, maskTextSelector: c, blockSelector: p };
1677
- }
1678
- get Lt() {
1679
- var e = this._instance.get_property(Cs);
1680
- return z(e) ? e : null;
1681
- }
1682
- get Nt() {
1683
- var e = this._instance.get_property(Ts);
1684
- return z(e) ? e : null;
1685
- }
1686
- get status() {
1687
- return this.jt ? this.zt({ receivedDecide: this.jt, isRecordingEnabled: this.Ct, isSampled: this.Tt, urlTriggerMatching: this.Ut, eventTriggerMatching: this.qt, linkedFlagMatching: this.Bt, sessionId: this.sessionId }) : Ve;
1688
- }
1689
- constructor(e) {
1690
- if (this.zt = Ja, this.jt = !1, this.Ht = [], this.Wt = "unknown", this.Gt = Date.now(), this.Rt = new Ga(), this.Jt = void 0, this.Vt = void 0, this.Kt = void 0, this.Yt = void 0, this.Xt = void 0, this._forceAllowLocalhostNetworkCapture = !1, this.Qt = () => {
1691
- this.Zt();
1692
- }, this.ti = () => {
1693
- this.ii("browser offline", {});
1694
- }, this.ei = () => {
1695
- this.ii("browser online", {});
1696
- }, this.ri = () => {
1697
- if (y != null && y.visibilityState) {
1698
- var r = "window " + y.visibilityState;
1699
- this.ii(r, {});
1700
- }
1701
- }, this._instance = e, this.Et = !1, this.si = "/s/", this.ni = void 0, this.jt = !1, !this._instance.sessionManager) throw U.error("started without valid sessionManager"), new Error(yt + " started without valid sessionManager. This is a bug.");
1702
- if (this._instance.config.__preview_experimental_cookieless_mode) throw new Error(yt + " cannot be used with __preview_experimental_cookieless_mode.");
1703
- this.Bt = new Xa(this._instance), this.Ut = new Va(this._instance), this.qt = new Ya(this._instance);
1704
- var { sessionId: t, windowId: i } = this.It.checkAndGetSessionAndWindowId();
1705
- this.kt = t, this.oi = i, this.M = this.ai(), this.xt >= this.It.sessionTimeoutMs && U.warn("session_idle_threshold_ms (" + this.xt + ") is greater than the session timeout (" + this.It.sessionTimeoutMs + "). Session will never be detected as idle");
1706
- }
1707
- startIfEnabledOrStop(e) {
1708
- this.Ct ? (this.li(e), T(g, "beforeunload", this.Qt), T(g, "offline", this.ti), T(g, "online", this.ei), T(g, "visibilitychange", this.ri), this.ui(), this.hi(), P(this.Jt) && (this.Jt = this._instance.on("eventCaptured", (t) => {
1709
- try {
1710
- if (t.event === "$pageview") {
1711
- var i = t != null && t.properties.$current_url ? this.di(t == null ? void 0 : t.properties.$current_url) : "";
1712
- if (!i) return;
1713
- this.ii("$pageview", { href: i });
1714
- }
1715
- } catch (r) {
1716
- U.error("Could not add $pageview to rrweb session", r);
1717
- }
1718
- })), this.Vt || (this.Vt = this.It.onSessionId((t, i, r) => {
1719
- var n, a;
1720
- r && (this.ii("$session_id_change", { sessionId: t, windowId: i, changeReason: r }), (n = this._instance) == null || (n = n.persistence) == null || n.unregister(Oi), (a = this._instance) == null || (a = a.persistence) == null || a.unregister(Ti));
1721
- }))) : this.stopRecording();
1722
- }
1723
- stopRecording() {
1724
- var e, t, i, r;
1725
- this.Et && this.ni && (this.ni(), this.ni = void 0, this.Et = !1, g == null || g.removeEventListener("beforeunload", this.Qt), g == null || g.removeEventListener("offline", this.ti), g == null || g.removeEventListener("online", this.ei), g == null || g.removeEventListener("visibilitychange", this.ri), this.ai(), clearInterval(this.vi), (e = this.Jt) == null || e.call(this), this.Jt = void 0, (t = this.Xt) == null || t.call(this), this.Xt = void 0, (i = this.Vt) == null || i.call(this), this.Vt = void 0, (r = this.Yt) == null || r.call(this), this.Yt = void 0, this.qt.stop(), this.Ut.stop(), this.Bt.stop(), U.info("stopped"));
1726
- }
1727
- ci() {
1728
- var e;
1729
- (e = this._instance.persistence) == null || e.unregister(_t);
1730
- }
1731
- fi(e) {
1732
- var t, i = this.kt !== e, r = this.Lt;
1733
- if (z(r)) {
1734
- var n = this.Tt, a = i || !ve(n), o = a ? za(e, r) : n;
1735
- a && (o ? this.pi(os) : U.warn("Sample rate (" + r + ") has determined that this sessionId (" + e + ") will not be sent to the server."), this.ii("samplingDecisionMade", { sampleRate: r, isSampled: o })), (t = this._instance.persistence) == null || t.register({ [_t]: o });
1736
- } else this.ci();
1737
- }
1738
- onRemoteConfig(e) {
1739
- var t, i, r, n;
1740
- this.ii("$remote_config_received", e), this.gi(e), (t = e.sessionRecording) != null && t.endpoint && (this.si = (n = e.sessionRecording) == null ? void 0 : n.endpoint), this.ui(), ((i = e.sessionRecording) == null ? void 0 : i.triggerMatchType) === "any" ? (this.zt = Za, this.Rt = new tn([this.qt, this.Ut])) : (this.zt = Ka, this.Rt = new sn([this.qt, this.Ut])), this._instance.register_for_session({ $sdk_debug_replay_remote_trigger_matching_config: (r = e.sessionRecording) == null ? void 0 : r.triggerMatchType }), this.Ut.onRemoteConfig(e), this.qt.onRemoteConfig(e), this.Bt.onRemoteConfig(e, (a, o) => {
1741
- this.pi("linked_flag_matched", { flag: a, variant: o });
1742
- }), this.jt = !0, this.startIfEnabledOrStop();
1743
- }
1744
- ui() {
1745
- z(this.Lt) && P(this.Yt) && (this.Yt = this.It.onSessionId((e) => {
1746
- this.fi(e);
1747
- }));
1748
- }
1749
- gi(e) {
1750
- if (this._instance.persistence) {
1751
- var t, i = this._instance.persistence, r = () => {
1752
- var n, a, o, l, u, c, p, h, d, v = (n = e.sessionRecording) == null ? void 0 : n.sampleRate, f = P(v) ? null : parseFloat(v);
1753
- P(f) && this.ci();
1754
- var b = (a = e.sessionRecording) == null ? void 0 : a.minimumDurationMilliseconds;
1755
- i.register({ [Ci]: !!e.sessionRecording, [$s]: (o = e.sessionRecording) == null ? void 0 : o.consoleLogRecordingEnabled, [Ps]: m({ capturePerformance: e.capturePerformance }, (l = e.sessionRecording) == null ? void 0 : l.networkPayloadCapture), [Rs]: (u = e.sessionRecording) == null ? void 0 : u.masking, [Ms]: { enabled: (c = e.sessionRecording) == null ? void 0 : c.recordCanvas, fps: (p = e.sessionRecording) == null ? void 0 : p.canvasFps, quality: (h = e.sessionRecording) == null ? void 0 : h.canvasQuality }, [Cs]: f, [Ts]: _(b) ? null : b, [Os]: (d = e.sessionRecording) == null ? void 0 : d.scriptConfig });
1756
- };
1757
- r(), (t = this.Kt) == null || t.call(this), this.Kt = this.It.onSessionId(r);
1758
- }
1759
- }
1760
- log(e, t) {
1761
- var i;
1762
- t === void 0 && (t = "log"), (i = this._instance.sessionRecording) == null || i.onRRwebEmit({ type: 6, data: { plugin: "rrweb/console@1", payload: { level: t, trace: [], payload: [JSON.stringify(e)] } }, timestamp: Date.now() });
1763
- }
1764
- li(e) {
1765
- if (!_(Object.assign) && !_(Array.from) && !(this.Et || this._instance.config.disable_session_recording || this._instance.consent.isOptedOut())) {
1766
- var t;
1767
- this.Et = !0, this.It.checkAndGetSessionAndWindowId(), Lt() ? this.mi() : (t = x.__PosthogExtensions__) == null || t.loadExternalDependency == null || t.loadExternalDependency(this._instance, this.bi, (i) => {
1768
- if (i) return U.error("could not load recorder", i);
1769
- this.mi();
1770
- }), U.info("starting"), this.status === Qt && this.pi(e || "recording_initialized");
1771
- }
1772
- }
1773
- get bi() {
1774
- var e;
1775
- return ((e = this._instance) == null || (e = e.persistence) == null || (e = e.get_property(Os)) == null ? void 0 : e.script) || "recorder";
1776
- }
1777
- wi(e) {
1778
- var t;
1779
- return e.type === 3 && eo.indexOf((t = e.data) == null ? void 0 : t.source) !== -1;
1780
- }
1781
- yi(e) {
1782
- var t = this.wi(e);
1783
- t || this.Wt || e.timestamp - this.Gt > this.xt && (this.Wt = !0, clearInterval(this.vi), this.ii("sessionIdle", { eventTimestamp: e.timestamp, lastActivityTimestamp: this.Gt, threshold: this.xt, bufferLength: this.M.data.length, bufferSize: this.M.size }), this.Zt());
1784
- var i = !1;
1785
- if (t && (this.Gt = e.timestamp, this.Wt)) {
1786
- var r = this.Wt === "unknown";
1787
- this.Wt = !1, r || (this.ii("sessionNoLongerIdle", { reason: "user activity", type: e.type }), i = !0);
1788
- }
1789
- if (!this.Wt) {
1790
- var { windowId: n, sessionId: a } = this.It.checkAndGetSessionAndWindowId(!t, e.timestamp), o = this.kt !== a, l = this.oi !== n;
1791
- this.oi = n, this.kt = a, o || l ? (this.stopRecording(), this.startIfEnabledOrStop("session_id_changed")) : i && this.Si();
1792
- }
1793
- }
1794
- $i(e) {
1795
- try {
1796
- return e.rrwebMethod(), !0;
1797
- } catch (t) {
1798
- return this.Ht.length < 10 ? this.Ht.push({ enqueuedAt: e.enqueuedAt || Date.now(), attempt: e.attempt++, rrwebMethod: e.rrwebMethod }) : U.warn("could not emit queued rrweb event.", t, e), !1;
1799
- }
1800
- }
1801
- ii(e, t) {
1802
- return this.$i(er(() => Lt().addCustomEvent(e, t)));
1803
- }
1804
- ki() {
1805
- return this.$i(er(() => Lt().takeFullSnapshot()));
1806
- }
1807
- mi() {
1808
- var e, t, i, r, n = { blockClass: "ph-no-capture", blockSelector: void 0, ignoreClass: "ph-ignore-input", maskTextClass: "ph-mask", maskTextSelector: void 0, maskTextFn: void 0, maskAllInputs: !0, maskInputOptions: { password: !0 }, maskInputFn: void 0, slimDOMOptions: {}, collectFonts: !1, inlineStylesheet: !0, recordCrossOriginIframes: !1 }, a = this._instance.config.session_recording;
1809
- for (var [o, l] of Object.entries(a || {})) o in n && (o === "maskInputOptions" ? n.maskInputOptions = m({ password: !0 }, l) : n[o] = l);
1810
- this.Ft && this.Ft.enabled && (n.recordCanvas = !0, n.sampling = { canvas: this.Ft.fps }, n.dataURLOptions = { type: "image/webp", quality: this.Ft.quality }), this.Dt && (n.maskAllInputs = (t = this.Dt.maskAllInputs) === null || t === void 0 || t, n.maskTextSelector = (i = this.Dt.maskTextSelector) !== null && i !== void 0 ? i : void 0, n.blockSelector = (r = this.Dt.blockSelector) !== null && r !== void 0 ? r : void 0);
1811
- var u = Lt();
1812
- if (u) {
1813
- this.xi = (e = this.xi) !== null && e !== void 0 ? e : new Aa(u, { refillRate: this._instance.config.session_recording.__mutationRateLimiterRefillRate, bucketSize: this._instance.config.session_recording.__mutationRateLimiterBucketSize, onBlockedNode: (p, h) => {
1814
- var d = "Too many mutations on node '" + p + "'. Rate limiting. This could be due to SVG animations or something similar";
1815
- U.info(d, { node: h }), this.log(yt + " " + d, "warn");
1816
- } });
1817
- var c = this.Ei();
1818
- this.ni = u(m({ emit: (p) => {
1819
- this.onRRwebEmit(p);
1820
- }, plugins: c }, n)), this.Gt = Date.now(), this.Wt = ve(this.Wt) ? this.Wt : "unknown", this.ii("$session_options", { sessionRecordingOptions: n, activePlugins: c.map((p) => p == null ? void 0 : p.name) }), this.ii("$posthog_config", { config: this._instance.config });
1821
- } else U.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.");
1822
- }
1823
- Si() {
1824
- if (this.vi && clearInterval(this.vi), this.Wt !== !0) {
1825
- var e = this.Pt;
1826
- e && (this.vi = setInterval(() => {
1827
- this.ki();
1828
- }, e));
1829
- }
1830
- }
1831
- Ei() {
1832
- var e, t, i = [], r = (e = x.__PosthogExtensions__) == null || (e = e.rrwebPlugins) == null ? void 0 : e.getRecordConsolePlugin;
1833
- r && this.Ot && i.push(r());
1834
- var n = (t = x.__PosthogExtensions__) == null || (t = t.rrwebPlugins) == null ? void 0 : t.getRecordNetworkPlugin;
1835
- return this.At && ae(n) && (!ea.includes(location.hostname) || this._forceAllowLocalhostNetworkCapture ? i.push(n(Oa(this._instance.config, this.At))) : U.info("NetworkCapture not started because we are on localhost.")), i;
1836
- }
1837
- onRRwebEmit(e) {
1838
- var t;
1839
- if (this.Ii(), e && O(e)) {
1840
- if (e.type === ke.Meta) {
1841
- var i = this.di(e.data.href);
1842
- if (this.Pi = i, !i) return;
1843
- e.data.href = i;
1844
- } else this.Ri();
1845
- if (this.Ut.checkUrlTriggerConditions(() => this.Ti(), () => this.Mi(), (h) => this.Ci(h)), !this.Ut.urlBlocked || (r = e).type === ke.Custom && r.data.tag === "recording paused") {
1846
- var r;
1847
- e.type === ke.FullSnapshot && this.Si(), e.type === ke.FullSnapshot && this.jt && this.Rt.triggerStatus(this.sessionId) === G && this.ai();
1848
- var n = this.xi ? this.xi.throttleMutations(e) : e;
1849
- if (n) {
1850
- var a = function(h) {
1851
- var d = h;
1852
- if (d && O(d) && d.type === 6 && O(d.data) && d.data.plugin === "rrweb/console@1") {
1853
- d.data.payload.payload.length > 10 && (d.data.payload.payload = d.data.payload.payload.slice(0, 10), d.data.payload.payload.push("...[truncated]"));
1854
- for (var v = [], f = 0; f < d.data.payload.payload.length; f++) d.data.payload.payload[f] && d.data.payload.payload[f].length > 2e3 ? v.push(d.data.payload.payload[f].slice(0, 2e3) + "...[truncated]") : v.push(d.data.payload.payload[f]);
1855
- return d.data.payload.payload = v, h;
1856
- }
1857
- return h;
1858
- }(n);
1859
- if (this.yi(a), this.Wt !== !0 || tr(a)) {
1860
- if (tr(a)) {
1861
- var o = a.data.payload;
1862
- if (o) {
1863
- var l = o.lastActivityTimestamp, u = o.threshold;
1864
- a.timestamp = l + u;
1865
- }
1866
- }
1867
- var c = (t = this._instance.config.session_recording.compress_events) === null || t === void 0 || t ? function(h) {
1868
- if (Zt(h) < 1024) return h;
1869
- try {
1870
- if (h.type === ke.FullSnapshot) return m({}, h, { data: je(h.data), cv: "2024-10" });
1871
- if (h.type === ke.IncrementalSnapshot && h.data.source === ce.Mutation) return m({}, h, { cv: "2024-10", data: m({}, h.data, { texts: je(h.data.texts), attributes: je(h.data.attributes), removes: je(h.data.removes), adds: je(h.data.adds) }) });
1872
- if (h.type === ke.IncrementalSnapshot && h.data.source === ce.StyleSheetRule) return m({}, h, { cv: "2024-10", data: m({}, h.data, { adds: h.data.adds ? je(h.data.adds) : void 0, removes: h.data.removes ? je(h.data.removes) : void 0 }) });
1873
- } catch (d) {
1874
- U.error("could not compress event - will use uncompressed event", d);
1875
- }
1876
- return h;
1877
- }(a) : a, p = { $snapshot_bytes: Zt(c), $snapshot_data: c, $session_id: this.kt, $window_id: this.oi };
1878
- this.status !== De ? this.Oi(p) : this.ai();
1879
- }
1880
- }
1881
- }
1882
- }
1883
- }
1884
- Ri() {
1885
- if (!this._instance.config.capture_pageview && g) {
1886
- var e = this.di(g.location.href);
1887
- this.Pi !== e && (this.ii("$url_changed", { href: e }), this.Pi = e);
1888
- }
1889
- }
1890
- Ii() {
1891
- if (this.Ht.length) {
1892
- var e = [...this.Ht];
1893
- this.Ht = [], e.forEach((t) => {
1894
- Date.now() - t.enqueuedAt <= 2e3 && this.$i(t);
1895
- });
1896
- }
1897
- }
1898
- di(e) {
1899
- var t = this._instance.config.session_recording;
1900
- if (t.maskNetworkRequestFn) {
1901
- var i, r = { url: e };
1902
- return (i = r = t.maskNetworkRequestFn(r)) == null ? void 0 : i.url;
1903
- }
1904
- return e;
1905
- }
1906
- ai() {
1907
- return this.M = { size: 0, data: [], sessionId: this.kt, windowId: this.oi }, this.M;
1908
- }
1909
- Zt() {
1910
- this.Fi && (clearTimeout(this.Fi), this.Fi = void 0);
1911
- var e = this.Nt, t = this.Mt, i = z(t) && t >= 0, r = z(e) && i && t < e;
1912
- return this.status === Ve || this.status === ls || this.status === De || r ? (this.Fi = setTimeout(() => {
1913
- this.Zt();
1914
- }, 2e3), this.M) : (this.M.data.length > 0 && Ui(this.M).forEach((n) => {
1915
- this.Ai({ $snapshot_bytes: n.size, $snapshot_data: n.data, $session_id: n.sessionId, $window_id: n.windowId, $lib: "web", $lib_version: xe.LIB_VERSION });
1916
- }), this.ai());
1917
- }
1918
- Oi(e) {
1919
- var t, i = 2 + (((t = this.M) == null ? void 0 : t.data.length) || 0);
1920
- !this.Wt && (this.M.size + e.$snapshot_bytes + i > 943718.4 || this.M.sessionId !== this.kt) && (this.M = this.Zt()), this.M.size += e.$snapshot_bytes, this.M.data.push(e.$snapshot_data), this.Fi || this.Wt || (this.Fi = setTimeout(() => {
1921
- this.Zt();
1922
- }, 2e3));
1923
- }
1924
- Ai(e) {
1925
- this._instance.capture("$snapshot", e, { _url: this._instance.requestRouter.endpointFor("api", this.si), _noTruncate: !0, _batchKey: "recordings", skip_client_rate_limiting: !0 });
1926
- }
1927
- Ci(e) {
1928
- var t;
1929
- this.Rt.triggerStatus(this.sessionId) === G && ((t = this._instance) == null || (t = t.persistence) == null || t.register({ [e === "url" ? Ti : Oi]: this.kt }), this.Zt(), this.pi(e + "_trigger_matched"));
1930
- }
1931
- Ti() {
1932
- this.Ut.urlBlocked || (this.Ut.urlBlocked = !0, clearInterval(this.vi), U.info("recording paused due to URL blocker"), this.ii("recording paused", { reason: "url blocker" }));
1933
- }
1934
- Mi() {
1935
- this.Ut.urlBlocked && (this.Ut.urlBlocked = !1, this.ki(), this.Si(), this.ii("recording resumed", { reason: "left blocked url" }), U.info("recording resumed"));
1936
- }
1937
- hi() {
1938
- this.qt.St.length !== 0 && P(this.Xt) && (this.Xt = this._instance.on("eventCaptured", (e) => {
1939
- try {
1940
- this.qt.St.includes(e.event) && this.Ci("event");
1941
- } catch (t) {
1942
- U.error("Could not activate event trigger", t);
1943
- }
1944
- }));
1945
- }
1946
- overrideLinkedFlag() {
1947
- this.Bt.linkedFlagSeen = !0, this.ki(), this.pi("linked_flag_overridden");
1948
- }
1949
- overrideSampling() {
1950
- var e;
1951
- (e = this._instance.persistence) == null || e.register({ [_t]: !0 }), this.ki(), this.pi("sampling_overridden");
1952
- }
1953
- overrideTrigger(e) {
1954
- this.Ci(e);
1955
- }
1956
- pi(e, t) {
1957
- this._instance.register_for_session({ $session_recording_start_reason: e }), U.info(e.replace("_", " "), t), I(["recording_initialized", "session_id_changed"], e) || this.ii(e, t);
1958
- }
1959
- get sdkDebugProperties() {
1960
- var { sessionStartTimestamp: e } = this.It.checkAndGetSessionAndWindowId(!0);
1961
- return { $recording_status: this.status, $sdk_debug_replay_internal_buffer_length: this.M.data.length, $sdk_debug_replay_internal_buffer_size: this.M.size, $sdk_debug_current_session_duration: this.Mt, $sdk_debug_session_start: e };
1962
- }
1963
- }
1964
- var wi = j("[SegmentIntegration]");
1965
- function io(s, e) {
1966
- var t = s.config.segment;
1967
- if (!t) return e();
1968
- (function(i, r) {
1969
- var n = i.config.segment;
1970
- if (!n) return r();
1971
- var a = (l) => {
1972
- var u = () => l.anonymousId() || Oe();
1973
- i.config.get_device_id = u, l.id() && (i.register({ distinct_id: l.id(), $device_id: u() }), i.persistence.set_property(Ee, "identified")), r();
1974
- }, o = n.user();
1975
- "then" in o && ae(o.then) ? o.then((l) => a(l)) : a(o);
1976
- })(s, () => {
1977
- t.register(((i) => {
1978
- Promise && Promise.resolve || wi.warn("This browser does not have Promise support, and can not use the segment integration");
1979
- var r = (n, a) => {
1980
- if (!a) return n;
1981
- n.event.userId || n.event.anonymousId === i.get_distinct_id() || (wi.info("No userId set, resetting PostHog"), i.reset()), n.event.userId && n.event.userId !== i.get_distinct_id() && (wi.info("UserId set, identifying with PostHog"), i.identify(n.event.userId));
1982
- var o = i.calculateEventProperties(a, n.event.properties);
1983
- return n.event.properties = Object.assign({}, o, n.event.properties), n;
1984
- };
1985
- return { name: "PostHog JS", type: "enrichment", version: "1.0.0", isLoaded: () => !0, load: () => Promise.resolve(), track: (n) => r(n, n.event.event), page: (n) => r(n, "$pageview"), identify: (n) => r(n, "$identify"), screen: (n) => r(n, "$screen") };
1986
- })(s)).then(() => {
1987
- e();
1988
- });
1989
- });
1990
- }
1991
- var rn = "posthog-js";
1992
- function nn(s, e) {
1993
- var { organization: t, projectId: i, prefix: r, severityAllowList: n = ["error"] } = e === void 0 ? {} : e;
1994
- return (a) => {
1995
- var o, l, u, c, p;
1996
- if (!(n === "*" || n.includes(a.level)) || !s.__loaded) return a;
1997
- a.tags || (a.tags = {});
1998
- var h = s.requestRouter.endpointFor("ui", "/project/" + s.config.token + "/person/" + s.get_distinct_id());
1999
- a.tags["PostHog Person URL"] = h, s.sessionRecordingStarted() && (a.tags["PostHog Recording URL"] = s.get_session_replay_url({ withTimestamp: !0 }));
2000
- var d = ((o = a.exception) == null ? void 0 : o.values) || [], v = d.map((b) => m({}, b, { stacktrace: b.stacktrace ? m({}, b.stacktrace, { type: "raw", frames: (b.stacktrace.frames || []).map((E) => m({}, E, { platform: "web:javascript" })) }) : void 0 })), f = { $exception_message: ((l = d[0]) == null ? void 0 : l.value) || a.message, $exception_type: (u = d[0]) == null ? void 0 : u.type, $exception_personURL: h, $exception_level: a.level, $exception_list: v, $sentry_event_id: a.event_id, $sentry_exception: a.exception, $sentry_exception_message: ((c = d[0]) == null ? void 0 : c.value) || a.message, $sentry_exception_type: (p = d[0]) == null ? void 0 : p.type, $sentry_tags: a.tags };
2001
- return t && i && (f.$sentry_url = (r || "https://sentry.io/organizations/") + t + "/issues/?project=" + i + "&query=" + a.event_id), s.exceptions.sendExceptionEvent(f), a;
2002
- };
2003
- }
2004
- class so {
2005
- constructor(e, t, i, r, n) {
2006
- this.name = rn, this.setupOnce = function(a) {
2007
- a(nn(e, { organization: t, projectId: i, prefix: r, severityAllowList: n }));
2008
- };
2009
- }
2010
- }
2011
- var ro = g != null && g.location ? Yt(g.location.hash, "__posthog") || Yt(location.hash, "state") : null, ir = "_postHogToolbarParams", sr = j("[Toolbar]"), Te = function(s) {
2012
- return s[s.UNINITIALIZED = 0] = "UNINITIALIZED", s[s.LOADING = 1] = "LOADING", s[s.LOADED = 2] = "LOADED", s;
2013
- }(Te || {});
2014
- class no {
2015
- constructor(e) {
2016
- this.instance = e;
2017
- }
2018
- Di(e) {
2019
- x.ph_toolbar_state = e;
2020
- }
2021
- Li() {
2022
- var e;
2023
- return (e = x.ph_toolbar_state) !== null && e !== void 0 ? e : Te.UNINITIALIZED;
2024
- }
2025
- maybeLoadToolbar(e, t, i) {
2026
- if (e === void 0 && (e = void 0), t === void 0 && (t = void 0), i === void 0 && (i = void 0), !g || !y) return !1;
2027
- e = e ?? g.location, i = i ?? g.history;
2028
- try {
2029
- if (!t) {
2030
- try {
2031
- g.localStorage.setItem("test", "test"), g.localStorage.removeItem("test");
2032
- } catch {
2033
- return !1;
2034
- }
2035
- t = g == null ? void 0 : g.localStorage;
2036
- }
2037
- var r, n = ro || Yt(e.hash, "__posthog") || Yt(e.hash, "state"), a = n ? ks(() => JSON.parse(atob(decodeURIComponent(n)))) || ks(() => JSON.parse(decodeURIComponent(n))) : null;
2038
- return a && a.action === "ph_authorize" ? ((r = a).source = "url", r && Object.keys(r).length > 0 && (a.desiredHash ? e.hash = a.desiredHash : i ? i.replaceState(i.state, "", e.pathname + e.search) : e.hash = "")) : ((r = JSON.parse(t.getItem(ir) || "{}")).source = "localstorage", delete r.userIntent), !(!r.token || this.instance.config.token !== r.token) && (this.loadToolbar(r), !0);
2039
- } catch {
2040
- return !1;
2041
- }
2042
- }
2043
- Ni(e) {
2044
- var t = x.ph_load_toolbar || x.ph_load_editor;
2045
- !P(t) && ae(t) ? t(e, this.instance) : sr.warn("No toolbar load function found");
2046
- }
2047
- loadToolbar(e) {
2048
- var t = !(y == null || !y.getElementById(Rr));
2049
- if (!g || t) return !1;
2050
- var i = this.instance.requestRouter.region === "custom" && this.instance.config.advanced_disable_toolbar_metrics, r = m({ token: this.instance.config.token }, e, { apiURL: this.instance.requestRouter.endpointFor("ui") }, i ? { instrument: !1 } : {});
2051
- if (g.localStorage.setItem(ir, JSON.stringify(m({}, r, { source: void 0 }))), this.Li() === Te.LOADED) this.Ni(r);
2052
- else if (this.Li() === Te.UNINITIALIZED) {
2053
- var n;
2054
- this.Di(Te.LOADING), (n = x.__PosthogExtensions__) == null || n.loadExternalDependency == null || n.loadExternalDependency(this.instance, "toolbar", (a) => {
2055
- if (a) return sr.error("[Toolbar] Failed to load", a), void this.Di(Te.UNINITIALIZED);
2056
- this.Di(Te.LOADED), this.Ni(r);
2057
- }), T(g, "turbolinks:load", () => {
2058
- this.Di(Te.UNINITIALIZED), this.loadToolbar(r);
2059
- });
2060
- }
2061
- return !0;
2062
- }
2063
- ji(e) {
2064
- return this.loadToolbar(e);
2065
- }
2066
- maybeLoadEditor(e, t, i) {
2067
- return e === void 0 && (e = void 0), t === void 0 && (t = void 0), i === void 0 && (i = void 0), this.maybeLoadToolbar(e, t, i);
2068
- }
2069
- }
2070
- var ao = j("[TracingHeaders]");
2071
- class oo {
2072
- constructor(e) {
2073
- this.zi = void 0, this.Ui = void 0, this.V = () => {
2074
- var t, i;
2075
- _(this.zi) && ((t = x.__PosthogExtensions__) == null || (t = t.tracingHeadersPatchFns) == null || t._patchXHR(this._instance.sessionManager)), _(this.Ui) && ((i = x.__PosthogExtensions__) == null || (i = i.tracingHeadersPatchFns) == null || i._patchFetch(this._instance.sessionManager));
2076
- }, this._instance = e;
2077
- }
2078
- G(e) {
2079
- var t, i;
2080
- (t = x.__PosthogExtensions__) != null && t.tracingHeadersPatchFns && e(), (i = x.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "tracing-headers", (r) => {
2081
- if (r) return ao.error("failed to load script", r);
2082
- e();
2083
- });
2084
- }
2085
- startIfEnabledOrStop() {
2086
- var e, t;
2087
- this._instance.config.__add_tracing_headers ? this.G(this.V) : ((e = this.zi) == null || e.call(this), (t = this.Ui) == null || t.call(this), this.zi = void 0, this.Ui = void 0);
2088
- }
2089
- }
2090
- var Me = j("[Web Vitals]"), rr = 9e5;
2091
- class lo {
2092
- constructor(e) {
2093
- var t;
2094
- this.qi = !1, this.i = !1, this.M = { url: void 0, metrics: [], firstMetricTimestamp: void 0 }, this.Bi = () => {
2095
- clearTimeout(this.Hi), this.M.metrics.length !== 0 && (this._instance.capture("$web_vitals", this.M.metrics.reduce((i, r) => m({}, i, { ["$web_vitals_" + r.name + "_event"]: m({}, r), ["$web_vitals_" + r.name + "_value"]: r.value }), {})), this.M = { url: void 0, metrics: [], firstMetricTimestamp: void 0 });
2096
- }, this.Wi = (i) => {
2097
- var r, n = (r = this._instance.sessionManager) == null ? void 0 : r.checkAndGetSessionAndWindowId(!0);
2098
- if (_(n)) Me.error("Could not read session ID. Dropping metrics!");
2099
- else {
2100
- this.M = this.M || { url: void 0, metrics: [], firstMetricTimestamp: void 0 };
2101
- var a = this.Gi();
2102
- _(a) || (P(i == null ? void 0 : i.name) || P(i == null ? void 0 : i.value) ? Me.error("Invalid metric received", i) : this.Ji && i.value >= this.Ji ? Me.error("Ignoring metric with value >= " + this.Ji, i) : (this.M.url !== a && (this.Bi(), this.Hi = setTimeout(this.Bi, this.flushToCaptureTimeoutMs)), _(this.M.url) && (this.M.url = a), this.M.firstMetricTimestamp = _(this.M.firstMetricTimestamp) ? Date.now() : this.M.firstMetricTimestamp, i.attribution && i.attribution.interactionTargetElement && (i.attribution.interactionTargetElement = void 0), this.M.metrics.push(m({}, i, { $current_url: a, $session_id: n.sessionId, $window_id: n.windowId, timestamp: Date.now() })), this.M.metrics.length === this.allowedMetrics.length && this.Bi()));
2103
- }
2104
- }, this.V = () => {
2105
- var i, r, n, a, o = x.__PosthogExtensions__;
2106
- _(o) || _(o.postHogWebVitalsCallbacks) || ({ onLCP: i, onCLS: r, onFCP: n, onINP: a } = o.postHogWebVitalsCallbacks), i && r && n && a ? (this.allowedMetrics.indexOf("LCP") > -1 && i(this.Wi.bind(this)), this.allowedMetrics.indexOf("CLS") > -1 && r(this.Wi.bind(this)), this.allowedMetrics.indexOf("FCP") > -1 && n(this.Wi.bind(this)), this.allowedMetrics.indexOf("INP") > -1 && a(this.Wi.bind(this)), this.i = !0) : Me.error("web vitals callbacks not loaded - not starting");
2107
- }, this._instance = e, this.qi = !((t = this._instance.persistence) == null || !t.props[Is]), this.startIfEnabled();
2108
- }
2109
- get allowedMetrics() {
2110
- var e, t, i = O(this._instance.config.capture_performance) ? (e = this._instance.config.capture_performance) == null ? void 0 : e.web_vitals_allowed_metrics : void 0;
2111
- return _(i) ? ((t = this._instance.persistence) == null ? void 0 : t.props[Fs]) || ["CLS", "FCP", "INP", "LCP"] : i;
2112
- }
2113
- get flushToCaptureTimeoutMs() {
2114
- return (O(this._instance.config.capture_performance) ? this._instance.config.capture_performance.web_vitals_delayed_flush_ms : void 0) || 5e3;
2115
- }
2116
- get Ji() {
2117
- var e = O(this._instance.config.capture_performance) && z(this._instance.config.capture_performance.__web_vitals_max_value) ? this._instance.config.capture_performance.__web_vitals_max_value : rr;
2118
- return 0 < e && e <= 6e4 ? rr : e;
2119
- }
2120
- get isEnabled() {
2121
- var e = Z == null ? void 0 : Z.protocol;
2122
- if (e !== "http:" && e !== "https:") return Me.info("Web Vitals are disabled on non-http/https protocols"), !1;
2123
- var t = O(this._instance.config.capture_performance) ? this._instance.config.capture_performance.web_vitals : ve(this._instance.config.capture_performance) ? this._instance.config.capture_performance : void 0;
2124
- return ve(t) ? t : this.qi;
2125
- }
2126
- startIfEnabled() {
2127
- this.isEnabled && !this.i && (Me.info("enabled, starting..."), this.G(this.V));
2128
- }
2129
- onRemoteConfig(e) {
2130
- var t = O(e.capturePerformance) && !!e.capturePerformance.web_vitals, i = O(e.capturePerformance) ? e.capturePerformance.web_vitals_allowed_metrics : void 0;
2131
- this._instance.persistence && (this._instance.persistence.register({ [Is]: t }), this._instance.persistence.register({ [Fs]: i })), this.qi = t, this.startIfEnabled();
2132
- }
2133
- G(e) {
2134
- var t, i;
2135
- (t = x.__PosthogExtensions__) != null && t.postHogWebVitalsCallbacks && e(), (i = x.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "web-vitals", (r) => {
2136
- r ? Me.error("failed to load script", r) : e();
2137
- });
2138
- }
2139
- Gi() {
2140
- var e = g ? g.location.href : void 0;
2141
- return e || Me.error("Could not determine current URL"), e;
2142
- }
2143
- }
2144
- var uo = j("[Heatmaps]");
2145
- function nr(s) {
2146
- return O(s) && "clientX" in s && "clientY" in s && z(s.clientX) && z(s.clientY);
2147
- }
2148
- class co {
2149
- constructor(e) {
2150
- var t;
2151
- this.rageclicks = new Hr(), this.qi = !1, this.i = !1, this.Vi = null, this.instance = e, this.qi = !((t = this.instance.persistence) == null || !t.props[Ri]);
2152
- }
2153
- get flushIntervalMilliseconds() {
2154
- var e = 5e3;
2155
- return O(this.instance.config.capture_heatmaps) && this.instance.config.capture_heatmaps.flush_interval_milliseconds && (e = this.instance.config.capture_heatmaps.flush_interval_milliseconds), e;
2156
- }
2157
- get isEnabled() {
2158
- return _(this.instance.config.capture_heatmaps) ? _(this.instance.config.enable_heatmaps) ? this.qi : this.instance.config.enable_heatmaps : this.instance.config.capture_heatmaps !== !1;
2159
- }
2160
- startIfEnabled() {
2161
- if (this.isEnabled) {
2162
- if (this.i) return;
2163
- uo.info("starting..."), this.Ki(), this.Vi = setInterval(this.Yi.bind(this), this.flushIntervalMilliseconds);
2164
- } else {
2165
- var e, t;
2166
- clearInterval((e = this.Vi) !== null && e !== void 0 ? e : void 0), (t = this.Xi) == null || t.stop(), this.getAndClearBuffer();
2167
- }
2168
- }
2169
- onRemoteConfig(e) {
2170
- var t = !!e.heatmaps;
2171
- this.instance.persistence && this.instance.persistence.register({ [Ri]: t }), this.qi = t, this.startIfEnabled();
2172
- }
2173
- getAndClearBuffer() {
2174
- var e = this.M;
2175
- return this.M = void 0, e;
2176
- }
2177
- Qi(e) {
2178
- this.Zi(e.originalEvent, "deadclick");
2179
- }
2180
- Ki() {
2181
- g && y && (T(g, "beforeunload", this.Yi.bind(this)), T(y, "click", (e) => this.Zi(e || (g == null ? void 0 : g.event)), { capture: !0 }), T(y, "mousemove", (e) => this.te(e || (g == null ? void 0 : g.event)), { capture: !0 }), this.Xi = new Ur(this.instance, ga, this.Qi.bind(this)), this.Xi.startIfEnabled(), this.i = !0);
2182
- }
2183
- ie(e, t) {
2184
- var i = this.instance.scrollManager.scrollY(), r = this.instance.scrollManager.scrollX(), n = this.instance.scrollManager.scrollElement(), a = function(o, l, u) {
2185
- for (var c = o; c && ni(c) && !Le(c, "body"); ) {
2186
- if (c === u) return !1;
2187
- if (I(l, g == null ? void 0 : g.getComputedStyle(c).position)) return !0;
2188
- c = Ar(c);
2189
- }
2190
- return !1;
2191
- }(Or(e), ["fixed", "sticky"], n);
2192
- return { x: e.clientX + (a ? 0 : r), y: e.clientY + (a ? 0 : i), target_fixed: a, type: t };
2193
- }
2194
- Zi(e, t) {
2195
- var i;
2196
- if (t === void 0 && (t = "click"), !Ls(e.target) && nr(e)) {
2197
- var r = this.ie(e, t);
2198
- (i = this.rageclicks) != null && i.isRageClick(e.clientX, e.clientY, (/* @__PURE__ */ new Date()).getTime()) && this.ee(m({}, r, { type: "rageclick" })), this.ee(r);
2199
- }
2200
- }
2201
- te(e) {
2202
- !Ls(e.target) && nr(e) && (clearTimeout(this.re), this.re = setTimeout(() => {
2203
- this.ee(this.ie(e, "mousemove"));
2204
- }, 500));
2205
- }
2206
- ee(e) {
2207
- if (g) {
2208
- var t = g.location.href;
2209
- this.M = this.M || {}, this.M[t] || (this.M[t] = []), this.M[t].push(e);
2210
- }
2211
- }
2212
- Yi() {
2213
- this.M && !tt(this.M) && this.instance.capture("$$heatmap", { $heatmap_data: this.getAndClearBuffer() });
2214
- }
2215
- }
2216
- class ho {
2217
- constructor(e) {
2218
- this._instance = e;
2219
- }
2220
- doPageView(e, t) {
2221
- var i, r = this.se(e, t);
2222
- return this.ne = { pathname: (i = g == null ? void 0 : g.location.pathname) !== null && i !== void 0 ? i : "", pageViewId: t, timestamp: e }, this._instance.scrollManager.resetContext(), r;
2223
- }
2224
- doPageLeave(e) {
2225
- var t;
2226
- return this.se(e, (t = this.ne) == null ? void 0 : t.pageViewId);
2227
- }
2228
- doEvent() {
2229
- var e;
2230
- return { $pageview_id: (e = this.ne) == null ? void 0 : e.pageViewId };
2231
- }
2232
- se(e, t) {
2233
- var i = this.ne;
2234
- if (!i) return { $pageview_id: t };
2235
- var r = { $pageview_id: t, $prev_pageview_id: i.pageViewId }, n = this._instance.scrollManager.getContext();
2236
- if (n && !this._instance.config.disable_scroll_properties) {
2237
- var { maxScrollHeight: a, lastScrollY: o, maxScrollY: l, maxContentHeight: u, lastContentY: c, maxContentY: p } = n;
2238
- if (!(_(a) || _(o) || _(l) || _(u) || _(c) || _(p))) {
2239
- a = Math.ceil(a), o = Math.ceil(o), l = Math.ceil(l), u = Math.ceil(u), c = Math.ceil(c), p = Math.ceil(p);
2240
- var h = a <= 1 ? 1 : ne(o / a, 0, 1), d = a <= 1 ? 1 : ne(l / a, 0, 1), v = u <= 1 ? 1 : ne(c / u, 0, 1), f = u <= 1 ? 1 : ne(p / u, 0, 1);
2241
- r = D(r, { $prev_pageview_last_scroll: o, $prev_pageview_last_scroll_percentage: h, $prev_pageview_max_scroll: l, $prev_pageview_max_scroll_percentage: d, $prev_pageview_last_content: c, $prev_pageview_last_content_percentage: v, $prev_pageview_max_content: p, $prev_pageview_max_content_percentage: f });
2242
- }
2243
- }
2244
- return i.pathname && (r.$prev_pageview_pathname = i.pathname), i.timestamp && (r.$prev_pageview_duration = (e.getTime() - i.timestamp.getTime()) / 1e3), r;
2245
- }
2246
- }
2247
- var po = function(s) {
2248
- var e, t, i, r, n = "";
2249
- for (e = t = 0, i = (s = (s + "").replace(/\r\n/g, `
2250
- `).replace(/\r/g, `
2251
- `)).length, r = 0; r < i; r++) {
2252
- var a = s.charCodeAt(r), o = null;
2253
- a < 128 ? t++ : o = a > 127 && a < 2048 ? String.fromCharCode(a >> 6 | 192, 63 & a | 128) : String.fromCharCode(a >> 12 | 224, a >> 6 & 63 | 128, 63 & a | 128), Ne(o) || (t > e && (n += s.substring(e, t)), n += o, e = t = r + 1);
2254
- }
2255
- return t > e && (n += s.substring(e, s.length)), n;
2256
- }, go = !!Fi || !!Ii, ar = "text/plain", ei = (s, e) => {
2257
- var [t, i] = s.split("?"), r = m({}, e);
2258
- i == null || i.split("&").forEach((a) => {
2259
- var [o] = a.split("=");
2260
- delete r[o];
2261
- });
2262
- var n = ta(r);
2263
- return t + "?" + (n = n ? (i ? i + "&" : "") + n : i);
2264
- }, bt = (s, e) => JSON.stringify(s, (t, i) => typeof i == "bigint" ? i.toString() : i, e), Ei = (s) => {
2265
- var { data: e, compression: t } = s;
2266
- if (e) {
2267
- if (t === Se.GZipJS) {
2268
- var i = Qr(en(bt(e)), { mtime: 0 }), r = new Blob([i], { type: ar });
2269
- return { contentType: ar, body: r, estimatedSize: r.size };
2270
- }
2271
- if (t === Se.Base64) {
2272
- var n = function(l) {
2273
- var u, c, p, h, d, v = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", f = 0, b = 0, E = "", k = [];
2274
- if (!l) return l;
2275
- l = po(l);
2276
- do
2277
- u = (d = l.charCodeAt(f++) << 16 | l.charCodeAt(f++) << 8 | l.charCodeAt(f++)) >> 18 & 63, c = d >> 12 & 63, p = d >> 6 & 63, h = 63 & d, k[b++] = v.charAt(u) + v.charAt(c) + v.charAt(p) + v.charAt(h);
2278
- while (f < l.length);
2279
- switch (E = k.join(""), l.length % 3) {
2280
- case 1:
2281
- E = E.slice(0, -2) + "==";
2282
- break;
2283
- case 2:
2284
- E = E.slice(0, -1) + "=";
2285
- }
2286
- return E;
2287
- }(bt(e)), a = ((l) => "data=" + encodeURIComponent(typeof l == "string" ? l : bt(l)))(n);
2288
- return { contentType: "application/x-www-form-urlencoded", body: a, estimatedSize: new Blob([a]).size };
2289
- }
2290
- var o = bt(e);
2291
- return { contentType: "application/json", body: o, estimatedSize: new Blob([o]).size };
2292
- }
2293
- }, xt = [];
2294
- Ii && xt.push({ transport: "fetch", method: (s) => {
2295
- var e, t, { contentType: i, body: r, estimatedSize: n } = (e = Ei(s)) !== null && e !== void 0 ? e : {}, a = new Headers();
2296
- R(s.headers, function(c, p) {
2297
- a.append(p, c);
2298
- }), i && a.append("Content-Type", i);
2299
- var o = s.url, l = null;
2300
- if (ws) {
2301
- var u = new ws();
2302
- l = { signal: u.signal, timeout: setTimeout(() => u.abort(), s.timeout) };
2303
- }
2304
- Ii(o, m({ method: (s == null ? void 0 : s.method) || "GET", headers: a, keepalive: s.method === "POST" && (n || 0) < 52428.8, body: r, signal: (t = l) == null ? void 0 : t.signal }, s.fetchOptions)).then((c) => c.text().then((p) => {
2305
- var h = { statusCode: c.status, text: p };
2306
- if (c.status === 200) try {
2307
- h.json = JSON.parse(p);
2308
- } catch (d) {
2309
- w.error(d);
2310
- }
2311
- s.callback == null || s.callback(h);
2312
- })).catch((c) => {
2313
- w.error(c), s.callback == null || s.callback({ statusCode: 0, text: c });
2314
- }).finally(() => l ? clearTimeout(l.timeout) : null);
2315
- } }), Fi && xt.push({ transport: "XHR", method: (s) => {
2316
- var e, t = new Fi();
2317
- t.open(s.method || "GET", s.url, !0);
2318
- var { contentType: i, body: r } = (e = Ei(s)) !== null && e !== void 0 ? e : {};
2319
- R(s.headers, function(n, a) {
2320
- t.setRequestHeader(a, n);
2321
- }), i && t.setRequestHeader("Content-Type", i), s.timeout && (t.timeout = s.timeout), t.withCredentials = !0, t.onreadystatechange = () => {
2322
- if (t.readyState === 4) {
2323
- var n = { statusCode: t.status, text: t.responseText };
2324
- if (t.status === 200) try {
2325
- n.json = JSON.parse(t.responseText);
2326
- } catch {
2327
- }
2328
- s.callback == null || s.callback(n);
2329
- }
2330
- }, t.send(r);
2331
- } }), ie != null && ie.sendBeacon && xt.push({ transport: "sendBeacon", method: (s) => {
2332
- var e = ei(s.url, { beacon: "1" });
2333
- try {
2334
- var t, { contentType: i, body: r } = (t = Ei(s)) !== null && t !== void 0 ? t : {}, n = typeof r == "string" ? new Blob([r], { type: i }) : r;
2335
- ie.sendBeacon(e, n);
2336
- } catch {
2337
- }
2338
- } });
2339
- var ut = function(s, e) {
2340
- if (!function(t) {
2341
- try {
2342
- new RegExp(t);
2343
- } catch {
2344
- return !1;
2345
- }
2346
- return !0;
2347
- }(e)) return !1;
2348
- try {
2349
- return new RegExp(e).test(s);
2350
- } catch {
2351
- return !1;
2352
- }
2353
- };
2354
- function or(s, e, t) {
2355
- return bt({ distinct_id: s, userPropertiesToSet: e, userPropertiesToSetOnce: t });
2356
- }
2357
- var fo = { exact: (s, e) => e.some((t) => s.some((i) => t === i)), is_not: (s, e) => e.every((t) => s.every((i) => t !== i)), regex: (s, e) => e.some((t) => s.some((i) => ut(t, i))), not_regex: (s, e) => e.every((t) => s.every((i) => !ut(t, i))), icontains: (s, e) => e.map(Dt).some((t) => s.map(Dt).some((i) => t.includes(i))), not_icontains: (s, e) => e.map(Dt).every((t) => s.map(Dt).every((i) => !t.includes(i))) }, Dt = (s) => s.toLowerCase(), vo = j("[Error tracking]");
2358
- class _o {
2359
- constructor(e) {
2360
- var t, i;
2361
- this.oe = [], this._instance = e, this.oe = (t = (i = this._instance.persistence) == null ? void 0 : i.get_property(Mi)) !== null && t !== void 0 ? t : [];
2362
- }
2363
- onRemoteConfig(e) {
2364
- var t, i, r = (t = (i = e.errorTracking) == null ? void 0 : i.suppressionRules) !== null && t !== void 0 ? t : [];
2365
- this.oe = r, this._instance.persistence && this._instance.persistence.register({ [Mi]: this.oe });
2366
- }
2367
- sendExceptionEvent(e) {
2368
- this.ae(e) ? vo.info("Skipping exception capture because a suppression rule matched") : this._instance.capture("$exception", e, { _noTruncate: !0, _batchKey: "exceptionEvent" });
2369
- }
2370
- ae(e) {
2371
- var t = e.$exception_list;
2372
- if (!t || !C(t) || t.length === 0) return !1;
2373
- var i = t.reduce((r, n) => {
2374
- var { type: a, value: o } = n;
2375
- return A(a) && a.length > 0 && r.$exception_types.push(a), A(o) && o.length > 0 && r.$exception_messages.push(o), r;
2376
- }, { $exception_types: [], $exception_messages: [] });
2377
- return this.oe.some((r) => {
2378
- var n = r.values.map((a) => {
2379
- var o = fo[a.operator], l = C(a.value) ? a.value : [a.value], u = i[a.key];
2380
- return l.length > 0 && o(l, u);
2381
- });
2382
- return r.type === "OR" ? n.some(Boolean) : n.every(Boolean);
2383
- });
2384
- }
2385
- }
2386
- var le = "Mobile", ti = "iOS", _e = "Android", It = "Tablet", an = _e + " " + It, on = "iPad", ln = "Apple", un = ln + " Watch", Ft = "Safari", ct = "BlackBerry", cn = "Samsung", hn = cn + "Browser", dn = cn + " Internet", Xe = "Chrome", mo = Xe + " OS", pn = Xe + " " + ti, cs = "Internet Explorer", gn = cs + " " + le, hs = "Opera", yo = hs + " Mini", ds = "Edge", fn = "Microsoft " + ds, rt = "Firefox", vn = rt + " " + ti, $t = "Nintendo", Pt = "PlayStation", nt = "Xbox", _n = _e + " " + le, mn = le + " " + Ft, wt = "Windows", Ji = wt + " Phone", lr = "Nokia", Zi = "Ouya", yn = "Generic", bo = yn + " " + le.toLowerCase(), bn = yn + " " + It.toLowerCase(), Ki = "Konqueror", Y = "(\\d+(\\.\\d+)?)", ki = new RegExp("Version/" + Y), wo = new RegExp(nt, "i"), Eo = new RegExp(Pt + " \\w+", "i"), ko = new RegExp($t + " \\w+", "i"), ps = new RegExp(ct + "|PlayBook|BB10", "i"), xo = { "NT3.51": "NT 3.11", "NT4.0": "NT 4.0", "5.0": "2000", 5.1: "XP", 5.2: "XP", "6.0": "Vista", 6.1: "7", 6.2: "8", 6.3: "8.1", 6.4: "10", "10.0": "10" }, So = (s, e) => e && I(e, ln) || function(t) {
2387
- return I(t, Ft) && !I(t, Xe) && !I(t, _e);
2388
- }(s), wn = function(s, e) {
2389
- return e = e || "", I(s, " OPR/") && I(s, "Mini") ? yo : I(s, " OPR/") ? hs : ps.test(s) ? ct : I(s, "IE" + le) || I(s, "WPDesktop") ? gn : I(s, hn) ? dn : I(s, ds) || I(s, "Edg/") ? fn : I(s, "FBIOS") ? "Facebook " + le : I(s, "UCWEB") || I(s, "UCBrowser") ? "UC Browser" : I(s, "CriOS") ? pn : I(s, "CrMo") || I(s, Xe) ? Xe : I(s, _e) && I(s, Ft) ? _n : I(s, "FxiOS") ? vn : I(s.toLowerCase(), Ki.toLowerCase()) ? Ki : So(s, e) ? I(s, le) ? mn : Ft : I(s, rt) ? rt : I(s, "MSIE") || I(s, "Trident/") ? cs : I(s, "Gecko") ? rt : "";
2390
- }, Io = { [gn]: [new RegExp("rv:" + Y)], [fn]: [new RegExp(ds + "?\\/" + Y)], [Xe]: [new RegExp("(" + Xe + "|CrMo)\\/" + Y)], [pn]: [new RegExp("CriOS\\/" + Y)], "UC Browser": [new RegExp("(UCBrowser|UCWEB)\\/" + Y)], [Ft]: [ki], [mn]: [ki], [hs]: [new RegExp("(Opera|OPR)\\/" + Y)], [rt]: [new RegExp(rt + "\\/" + Y)], [vn]: [new RegExp("FxiOS\\/" + Y)], [Ki]: [new RegExp("Konqueror[:/]?" + Y, "i")], [ct]: [new RegExp(ct + " " + Y), ki], [_n]: [new RegExp("android\\s" + Y, "i")], [dn]: [new RegExp(hn + "\\/" + Y)], [cs]: [new RegExp("(rv:|MSIE )" + Y)], Mozilla: [new RegExp("rv:" + Y)] }, Fo = function(s, e) {
2391
- var t = wn(s, e), i = Io[t];
2392
- if (_(i)) return null;
2393
- for (var r = 0; r < i.length; r++) {
2394
- var n = i[r], a = s.match(n);
2395
- if (a) return parseFloat(a[a.length - 2]);
2396
- }
2397
- return null;
2398
- }, ur = [[new RegExp(nt + "; " + nt + " (.*?)[);]", "i"), (s) => [nt, s && s[1] || ""]], [new RegExp($t, "i"), [$t, ""]], [new RegExp(Pt, "i"), [Pt, ""]], [ps, [ct, ""]], [new RegExp(wt, "i"), (s, e) => {
2399
- if (/Phone/.test(e) || /WPDesktop/.test(e)) return [Ji, ""];
2400
- if (new RegExp(le).test(e) && !/IEMobile\b/.test(e)) return [wt + " " + le, ""];
2401
- var t = /Windows NT ([0-9.]+)/i.exec(e);
2402
- if (t && t[1]) {
2403
- var i = t[1], r = xo[i] || "";
2404
- return /arm/i.test(e) && (r = "RT"), [wt, r];
2405
- }
2406
- return [wt, ""];
2407
- }], [/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/, (s) => {
2408
- if (s && s[3]) {
2409
- var e = [s[3], s[4], s[5] || "0"];
2410
- return [ti, e.join(".")];
2411
- }
2412
- return [ti, ""];
2413
- }], [/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i, (s) => {
2414
- var e = "";
2415
- return s && s.length >= 3 && (e = _(s[2]) ? s[3] : s[2]), ["watchOS", e];
2416
- }], [new RegExp("(" + _e + " (\\d+)\\.(\\d+)\\.?(\\d+)?|" + _e + ")", "i"), (s) => {
2417
- if (s && s[2]) {
2418
- var e = [s[2], s[3], s[4] || "0"];
2419
- return [_e, e.join(".")];
2420
- }
2421
- return [_e, ""];
2422
- }], [/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i, (s) => {
2423
- var e = ["Mac OS X", ""];
2424
- if (s && s[1]) {
2425
- var t = [s[1], s[2], s[3] || "0"];
2426
- e[1] = t.join(".");
2427
- }
2428
- return e;
2429
- }], [/Mac/i, ["Mac OS X", ""]], [/CrOS/, [mo, ""]], [/Linux|debian/i, ["Linux", ""]]], cr = function(s) {
2430
- return ko.test(s) ? $t : Eo.test(s) ? Pt : wo.test(s) ? nt : new RegExp(Zi, "i").test(s) ? Zi : new RegExp("(" + Ji + "|WPDesktop)", "i").test(s) ? Ji : /iPad/.test(s) ? on : /iPod/.test(s) ? "iPod Touch" : /iPhone/.test(s) ? "iPhone" : /(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s) ? un : ps.test(s) ? ct : /(kobo)\s(ereader|touch)/i.test(s) ? "Kobo" : new RegExp(lr, "i").test(s) ? lr : /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s) || /(kf[a-z]+)( bui|\)).+silk\//i.test(s) ? "Kindle Fire" : /(Android|ZTE)/i.test(s) ? !new RegExp(le).test(s) || /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s) ? /pixel[\daxl ]{1,6}/i.test(s) && !/pixel c/i.test(s) || /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s) || /lmy47v/i.test(s) && !/QTAQZ3/i.test(s) ? _e : an : _e : new RegExp("(pda|" + le + ")", "i").test(s) ? bo : new RegExp(It, "i").test(s) && !new RegExp(It + " pc", "i").test(s) ? bn : "";
2431
- }, Nt = "https?://(.*)", oi = ["gclid", "gclsrc", "dclid", "gbraid", "wbraid", "fbclid", "msclkid", "twclid", "li_fat_id", "igshid", "ttclid", "rdt_cid", "epik", "qclid", "sccid", "irclid", "_kx"], $o = ri(["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", "gad_source", "mc_cid"], oi), gs = "<masked>";
2432
- function En(s, e, t) {
2433
- if (!y) return {};
2434
- var i = e ? ri([], oi, t || []) : [];
2435
- return kn(ss(y.URL, i, gs), s);
2436
- }
2437
- function kn(s, e) {
2438
- var t = $o.concat(e || []), i = {};
2439
- return R(t, function(r) {
2440
- var n = Xt(s, r);
2441
- i[r] = n || null;
2442
- }), i;
2443
- }
2444
- function xn(s) {
2445
- var e = function(n) {
2446
- return n ? n.search(Nt + "google.([^/?]*)") === 0 ? "google" : n.search(Nt + "bing.com") === 0 ? "bing" : n.search(Nt + "yahoo.com") === 0 ? "yahoo" : n.search(Nt + "duckduckgo.com") === 0 ? "duckduckgo" : null : null;
2447
- }(s), t = e != "yahoo" ? "q" : "p", i = {};
2448
- if (!Ne(e)) {
2449
- i.$search_engine = e;
2450
- var r = y ? Xt(y.referrer, t) : "";
2451
- r.length && (i.ph_keyword = r);
2452
- }
2453
- return i;
2454
- }
2455
- function hr() {
2456
- return navigator.language || navigator.userLanguage;
2457
- }
2458
- function Sn() {
2459
- return (y == null ? void 0 : y.referrer) || "$direct";
2460
- }
2461
- function In(s, e) {
2462
- var t = s ? ri([], oi, e || []) : [], i = Z == null ? void 0 : Z.href.substring(0, 1e3);
2463
- return { r: Sn().substring(0, 1e3), u: i ? ss(i, t, gs) : void 0 };
2464
- }
2465
- function Fn(s) {
2466
- var e, { r: t, u: i } = s, r = { $referrer: t, $referring_domain: t == null ? void 0 : t == "$direct" ? "$direct" : (e = ot(t)) == null ? void 0 : e.host };
2467
- if (i) {
2468
- r.$current_url = i;
2469
- var n = ot(i);
2470
- r.$host = n == null ? void 0 : n.host, r.$pathname = n == null ? void 0 : n.pathname;
2471
- var a = kn(i);
2472
- D(r, a);
2473
- }
2474
- if (t) {
2475
- var o = xn(t);
2476
- D(r, o);
2477
- }
2478
- return r;
2479
- }
2480
- function $n() {
2481
- try {
2482
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
2483
- } catch {
2484
- return;
2485
- }
2486
- }
2487
- function Po() {
2488
- try {
2489
- return (/* @__PURE__ */ new Date()).getTimezoneOffset();
2490
- } catch {
2491
- return;
2492
- }
2493
- }
2494
- function Ro(s, e) {
2495
- if (!J) return {};
2496
- var t, i, r, n = s ? ri([], oi, e || []) : [], [a, o] = function(l) {
2497
- for (var u = 0; u < ur.length; u++) {
2498
- var [c, p] = ur[u], h = c.exec(l), d = h && (ae(p) ? p(h, l) : p);
2499
- if (d) return d;
2500
- }
2501
- return ["", ""];
2502
- }(J);
2503
- return D(ts({ $os: a, $os_version: o, $browser: wn(J, navigator.vendor), $device: cr(J), $device_type: (i = J, r = cr(i), r === on || r === an || r === "Kobo" || r === "Kindle Fire" || r === bn ? It : r === $t || r === nt || r === Pt || r === Zi ? "Console" : r === un ? "Wearable" : r ? le : "Desktop"), $timezone: $n(), $timezone_offset: Po() }), { $current_url: ss(Z == null ? void 0 : Z.href, n, gs), $host: Z == null ? void 0 : Z.host, $pathname: Z == null ? void 0 : Z.pathname, $raw_user_agent: J.length > 1e3 ? J.substring(0, 997) + "..." : J, $browser_version: Fo(J, navigator.vendor), $browser_language: hr(), $browser_language_prefix: (t = hr(), typeof t == "string" ? t.split("-")[0] : void 0), $screen_height: g == null ? void 0 : g.screen.height, $screen_width: g == null ? void 0 : g.screen.width, $viewport_height: g == null ? void 0 : g.innerHeight, $viewport_width: g == null ? void 0 : g.innerWidth, $lib: "web", $lib_version: xe.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), $time: Date.now() / 1e3 });
2504
- }
2505
- var fe = j("[FeatureFlags]"), xi = "$active_feature_flags", Qe = "$override_feature_flags", dr = "$feature_flag_payloads", gt = "$override_feature_flag_payloads", pr = "$feature_flag_request_id", gr = (s) => {
2506
- var e = {};
2507
- for (var [t, i] of qt(s || {})) i && (e[t] = i);
2508
- return e;
2509
- }, Mo = (s) => {
2510
- var e = s.flags;
2511
- return e ? (s.featureFlags = Object.fromEntries(Object.keys(e).map((t) => {
2512
- var i;
2513
- return [t, (i = e[t].variant) !== null && i !== void 0 ? i : e[t].enabled];
2514
- })), s.featureFlagPayloads = Object.fromEntries(Object.keys(e).filter((t) => e[t].enabled).filter((t) => {
2515
- var i;
2516
- return (i = e[t].metadata) == null ? void 0 : i.payload;
2517
- }).map((t) => {
2518
- var i;
2519
- return [t, (i = e[t].metadata) == null ? void 0 : i.payload];
2520
- }))) : fe.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"), s;
2521
- }, Co = function(s) {
2522
- return s.FeatureFlags = "feature_flags", s.Recordings = "recordings", s;
2523
- }({});
2524
- class To {
2525
- constructor(e) {
2526
- this.le = !1, this.ue = !1, this.he = !1, this.de = !1, this.ve = !1, this.ce = !1, this.fe = !1, this._instance = e, this.featureFlagEventHandlers = [];
2527
- }
2528
- decide() {
2529
- if (this._instance.config.__preview_remote_config) this.ce = !0;
2530
- else {
2531
- var e = !this.pe && (this._instance.config.advanced_disable_feature_flags || this._instance.config.advanced_disable_feature_flags_on_first_load);
2532
- this.ge({ disableFlags: e });
2533
- }
2534
- }
2535
- get hasLoadedFlags() {
2536
- return this.ue;
2537
- }
2538
- getFlags() {
2539
- return Object.keys(this.getFlagVariants());
2540
- }
2541
- getFlagsWithDetails() {
2542
- var e = this._instance.get_property(Ai), t = this._instance.get_property(Qe), i = this._instance.get_property(gt);
2543
- if (!i && !t) return e || {};
2544
- var r = D({}, e || {}), n = [.../* @__PURE__ */ new Set([...Object.keys(i || {}), ...Object.keys(t || {})])];
2545
- for (var a of n) {
2546
- var o, l, u = r[a], c = t == null ? void 0 : t[a], p = _(c) ? (o = u == null ? void 0 : u.enabled) !== null && o !== void 0 && o : !!c, h = _(c) ? u.variant : typeof c == "string" ? c : void 0, d = i == null ? void 0 : i[a], v = m({}, u, { enabled: p, variant: p ? h ?? (u == null ? void 0 : u.variant) : void 0 });
2547
- p !== (u == null ? void 0 : u.enabled) && (v.original_enabled = u == null ? void 0 : u.enabled), h !== (u == null ? void 0 : u.variant) && (v.original_variant = u == null ? void 0 : u.variant), d && (v.metadata = m({}, u == null ? void 0 : u.metadata, { payload: d, original_payload: u == null || (l = u.metadata) == null ? void 0 : l.payload })), r[a] = v;
2548
- }
2549
- return this.le || (fe.warn(" Overriding feature flag details!", { flagDetails: e, overriddenPayloads: i, finalDetails: r }), this.le = !0), r;
2550
- }
2551
- getFlagVariants() {
2552
- var e = this._instance.get_property(it), t = this._instance.get_property(Qe);
2553
- if (!t) return e || {};
2554
- for (var i = D({}, e), r = Object.keys(t), n = 0; n < r.length; n++) i[r[n]] = t[r[n]];
2555
- return this.le || (fe.warn(" Overriding feature flags!", { enabledFlags: e, overriddenFlags: t, finalFlags: i }), this.le = !0), i;
2556
- }
2557
- getFlagPayloads() {
2558
- var e = this._instance.get_property(dr), t = this._instance.get_property(gt);
2559
- if (!t) return e || {};
2560
- for (var i = D({}, e || {}), r = Object.keys(t), n = 0; n < r.length; n++) i[r[n]] = t[r[n]];
2561
- return this.le || (fe.warn(" Overriding feature flag payloads!", { flagPayloads: e, overriddenPayloads: t, finalPayloads: i }), this.le = !0), i;
2562
- }
2563
- reloadFeatureFlags() {
2564
- this.de || this._instance.config.advanced_disable_feature_flags || this.pe || (this.pe = setTimeout(() => {
2565
- this.ge();
2566
- }, 5));
2567
- }
2568
- _e() {
2569
- clearTimeout(this.pe), this.pe = void 0;
2570
- }
2571
- ensureFlagsLoaded() {
2572
- this.ue || this.he || this.pe || this.reloadFeatureFlags();
2573
- }
2574
- setAnonymousDistinctId(e) {
2575
- this.$anon_distinct_id = e;
2576
- }
2577
- setReloadingPaused(e) {
2578
- this.de = e;
2579
- }
2580
- ge(e) {
2581
- var t;
2582
- if (this._e(), !this._instance.config.advanced_disable_decide) if (this.he) this.ve = !0;
2583
- else {
2584
- var i = { token: this._instance.config.token, distinct_id: this._instance.get_distinct_id(), groups: this._instance.getGroups(), $anon_distinct_id: this.$anon_distinct_id, person_properties: m({}, ((t = this._instance.persistence) == null ? void 0 : t.get_initial_props()) || {}, this._instance.get_property(mt) || {}), group_properties: this._instance.get_property(We) };
2585
- (e != null && e.disableFlags || this._instance.config.advanced_disable_feature_flags) && (i.disable_flags = !0);
2586
- var r = this._instance.config.__preview_flags_v2 && this._instance.config.__preview_remote_config;
2587
- r && (i.timezone = $n()), this.he = !0, this._instance.me({ method: "POST", url: this._instance.requestRouter.endpointFor("api", r ? "/flags/?v=2" : "/decide/?v=4"), data: i, compression: this._instance.config.disable_compression ? void 0 : Se.Base64, timeout: this._instance.config.feature_flag_request_timeout_ms, callback: (n) => {
2588
- var a, o, l = !0;
2589
- if (n.statusCode === 200 && (this.ve || (this.$anon_distinct_id = void 0), l = !1), this.he = !1, this.ce || (this.ce = !0, this._instance.be((o = n.json) !== null && o !== void 0 ? o : {})), !i.disable_flags || this.ve) if (this.fe = !l, n.json && (a = n.json.quotaLimited) != null && a.includes(Co.FeatureFlags)) fe.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");
2590
- else {
2591
- var u;
2592
- i.disable_flags || this.receivedFeatureFlags((u = n.json) !== null && u !== void 0 ? u : {}, l), this.ve && (this.ve = !1, this.ge());
2593
- }
2594
- } });
2595
- }
2596
- }
2597
- getFeatureFlag(e, t) {
2598
- if (t === void 0 && (t = {}), this.ue || this.getFlags() && this.getFlags().length > 0) {
2599
- var i = this.getFlagVariants()[e], r = "" + i, n = this._instance.get_property(pr) || void 0, a = this._instance.get_property(Wt) || {};
2600
- if ((t.send_event || !("send_event" in t)) && (!(e in a) || !a[e].includes(r))) {
2601
- var o, l, u, c, p, h, d, v, f;
2602
- C(a[e]) ? a[e].push(r) : a[e] = [r], (o = this._instance.persistence) == null || o.register({ [Wt]: a });
2603
- var b = this.getFeatureFlagDetails(e), E = { $feature_flag: e, $feature_flag_response: i, $feature_flag_payload: this.getFeatureFlagPayload(e) || null, $feature_flag_request_id: n, $feature_flag_bootstrapped_response: ((l = this._instance.config.bootstrap) == null || (l = l.featureFlags) == null ? void 0 : l[e]) || null, $feature_flag_bootstrapped_payload: ((u = this._instance.config.bootstrap) == null || (u = u.featureFlagPayloads) == null ? void 0 : u[e]) || null, $used_bootstrap_value: !this.fe };
2604
- _(b == null || (c = b.metadata) == null ? void 0 : c.version) || (E.$feature_flag_version = b.metadata.version);
2605
- var k, S = (p = b == null || (h = b.reason) == null ? void 0 : h.description) !== null && p !== void 0 ? p : b == null || (d = b.reason) == null ? void 0 : d.code;
2606
- S && (E.$feature_flag_reason = S), b != null && (v = b.metadata) != null && v.id && (E.$feature_flag_id = b.metadata.id), _(b == null ? void 0 : b.original_variant) && _(b == null ? void 0 : b.original_enabled) || (E.$feature_flag_original_response = _(b.original_variant) ? b.original_enabled : b.original_variant), b != null && (f = b.metadata) != null && f.original_payload && (E.$feature_flag_original_payload = b == null || (k = b.metadata) == null ? void 0 : k.original_payload), this._instance.capture("$feature_flag_called", E);
2607
- }
2608
- return i;
2609
- }
2610
- fe.warn('getFeatureFlag for key "' + e + `" failed. Feature flags didn't load in time.`);
2611
- }
2612
- getFeatureFlagDetails(e) {
2613
- return this.getFlagsWithDetails()[e];
2614
- }
2615
- getFeatureFlagPayload(e) {
2616
- return this.getFlagPayloads()[e];
2617
- }
2618
- getRemoteConfigPayload(e, t) {
2619
- var i = this._instance.config.token;
2620
- this._instance.me({ method: "POST", url: this._instance.requestRouter.endpointFor("api", "/decide/?v=4"), data: { distinct_id: this._instance.get_distinct_id(), token: i }, compression: this._instance.config.disable_compression ? void 0 : Se.Base64, timeout: this._instance.config.feature_flag_request_timeout_ms, callback: (r) => {
2621
- var n, a = (n = r.json) == null ? void 0 : n.featureFlagPayloads;
2622
- t((a == null ? void 0 : a[e]) || void 0);
2623
- } });
2624
- }
2625
- isFeatureEnabled(e, t) {
2626
- if (t === void 0 && (t = {}), this.ue || this.getFlags() && this.getFlags().length > 0) return !!this.getFeatureFlag(e, t);
2627
- fe.warn('isFeatureEnabled for key "' + e + `" failed. Feature flags didn't load in time.`);
2628
- }
2629
- addFeatureFlagsHandler(e) {
2630
- this.featureFlagEventHandlers.push(e);
2631
- }
2632
- removeFeatureFlagsHandler(e) {
2633
- this.featureFlagEventHandlers = this.featureFlagEventHandlers.filter((t) => t !== e);
2634
- }
2635
- receivedFeatureFlags(e, t) {
2636
- if (this._instance.persistence) {
2637
- this.ue = !0;
2638
- var i = this.getFlagVariants(), r = this.getFlagPayloads(), n = this.getFlagsWithDetails();
2639
- (function(a, o, l, u, c) {
2640
- l === void 0 && (l = {}), u === void 0 && (u = {}), c === void 0 && (c = {});
2641
- var p = Mo(a), h = p.flags, d = p.featureFlags, v = p.featureFlagPayloads;
2642
- if (d) {
2643
- var f = a.requestId;
2644
- if (C(d)) {
2645
- fe.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");
2646
- var b = {};
2647
- if (d) for (var E = 0; E < d.length; E++) b[d[E]] = !0;
2648
- o && o.register({ [xi]: d, [it]: b });
2649
- } else {
2650
- var k = d, S = v, $ = h;
2651
- a.errorsWhileComputingFlags && (k = m({}, l, k), S = m({}, u, S), $ = m({}, c, $)), o && o.register(m({ [xi]: Object.keys(gr(k)), [it]: k || {}, [dr]: S || {}, [Ai]: $ || {} }, f ? { [pr]: f } : {}));
2652
- }
2653
- }
2654
- })(e, this._instance.persistence, i, r, n), this.we(t);
2655
- }
2656
- }
2657
- override(e, t) {
2658
- t === void 0 && (t = !1), fe.warn("override is deprecated. Please use overrideFeatureFlags instead."), this.overrideFeatureFlags({ flags: e, suppressWarning: t });
2659
- }
2660
- overrideFeatureFlags(e) {
2661
- if (!this._instance.__loaded || !this._instance.persistence) return fe.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");
2662
- if (e === !1) return this._instance.persistence.unregister(Qe), this._instance.persistence.unregister(gt), void this.we();
2663
- if (e && typeof e == "object" && ("flags" in e || "payloads" in e)) {
2664
- var t, i = e;
2665
- if (this.le = !!((t = i.suppressWarning) !== null && t !== void 0 && t), "flags" in i) {
2666
- if (i.flags === !1) this._instance.persistence.unregister(Qe);
2667
- else if (i.flags) if (C(i.flags)) {
2668
- for (var r = {}, n = 0; n < i.flags.length; n++) r[i.flags[n]] = !0;
2669
- this._instance.persistence.register({ [Qe]: r });
2670
- } else this._instance.persistence.register({ [Qe]: i.flags });
2671
- }
2672
- return "payloads" in i && (i.payloads === !1 ? this._instance.persistence.unregister(gt) : i.payloads && this._instance.persistence.register({ [gt]: i.payloads })), void this.we();
2673
- }
2674
- this.we();
2675
- }
2676
- onFeatureFlags(e) {
2677
- if (this.addFeatureFlagsHandler(e), this.ue) {
2678
- var { flags: t, flagVariants: i } = this.ye();
2679
- e(t, i);
2680
- }
2681
- return () => this.removeFeatureFlagsHandler(e);
2682
- }
2683
- updateEarlyAccessFeatureEnrollment(e, t) {
2684
- var i, r = (this._instance.get_property(Bt) || []).find((l) => l.flagKey === e), n = { ["$feature_enrollment/" + e]: t }, a = { $feature_flag: e, $feature_enrollment: t, $set: n };
2685
- r && (a.$early_access_feature_name = r.name), this._instance.capture("$feature_enrollment_update", a), this.setPersonPropertiesForFlags(n, !1);
2686
- var o = m({}, this.getFlagVariants(), { [e]: t });
2687
- (i = this._instance.persistence) == null || i.register({ [xi]: Object.keys(gr(o)), [it]: o }), this.we();
2688
- }
2689
- getEarlyAccessFeatures(e, t, i) {
2690
- t === void 0 && (t = !1);
2691
- var r = this._instance.get_property(Bt), n = i ? "&" + i.map((a) => "stage=" + a).join("&") : "";
2692
- if (r && !t) return e(r);
2693
- this._instance.me({ url: this._instance.requestRouter.endpointFor("api", "/api/early_access_features/?token=" + this._instance.config.token + n), method: "GET", callback: (a) => {
2694
- var o;
2695
- if (a.json) {
2696
- var l = a.json.earlyAccessFeatures;
2697
- return (o = this._instance.persistence) == null || o.register({ [Bt]: l }), e(l);
2698
- }
2699
- } });
2700
- }
2701
- ye() {
2702
- var e = this.getFlags(), t = this.getFlagVariants();
2703
- return { flags: e.filter((i) => t[i]), flagVariants: Object.keys(t).filter((i) => t[i]).reduce((i, r) => (i[r] = t[r], i), {}) };
2704
- }
2705
- we(e) {
2706
- var { flags: t, flagVariants: i } = this.ye();
2707
- this.featureFlagEventHandlers.forEach((r) => r(t, i, { errorsLoading: e }));
2708
- }
2709
- setPersonPropertiesForFlags(e, t) {
2710
- t === void 0 && (t = !0);
2711
- var i = this._instance.get_property(mt) || {};
2712
- this._instance.register({ [mt]: m({}, i, e) }), t && this._instance.reloadFeatureFlags();
2713
- }
2714
- resetPersonPropertiesForFlags() {
2715
- this._instance.unregister(mt);
2716
- }
2717
- setGroupPropertiesForFlags(e, t) {
2718
- t === void 0 && (t = !0);
2719
- var i = this._instance.get_property(We) || {};
2720
- Object.keys(i).length !== 0 && Object.keys(i).forEach((r) => {
2721
- i[r] = m({}, i[r], e[r]), delete e[r];
2722
- }), this._instance.register({ [We]: m({}, i, e) }), t && this._instance.reloadFeatureFlags();
2723
- }
2724
- resetGroupPropertiesForFlags(e) {
2725
- if (e) {
2726
- var t = this._instance.get_property(We) || {};
2727
- this._instance.register({ [We]: m({}, t, { [e]: {} }) });
2728
- } else this._instance.unregister(We);
2729
- }
2730
- }
2731
- var Oo = ["cookie", "localstorage", "localstorage+cookie", "sessionstorage", "memory"];
2732
- class Si {
2733
- constructor(e) {
2734
- this.S = e, this.props = {}, this.Se = !1, this.$e = ((t) => {
2735
- var i = "";
2736
- return t.token && (i = t.token.replace(/\+/g, "PL").replace(/\//g, "SL").replace(/=/g, "EQ")), t.persistence_name ? "ph_" + t.persistence_name : "ph_" + i + "_posthog";
2737
- })(e), this.q = this.ke(e), this.load(), e.debug && w.info("Persistence loaded", e.persistence, m({}, this.props)), this.update_config(e, e), this.save();
2738
- }
2739
- ke(e) {
2740
- Oo.indexOf(e.persistence.toLowerCase()) === -1 && (w.critical("Unknown persistence type " + e.persistence + "; falling back to localStorage+cookie"), e.persistence = "localStorage+cookie");
2741
- var t = e.persistence.toLowerCase();
2742
- return t === "localstorage" && q.O() ? q : t === "localstorage+cookie" && Mt.O() ? Mt : t === "sessionstorage" && H.O() ? H : t === "memory" ? da : t === "cookie" ? Ie : Mt.O() ? Mt : Ie;
2743
- }
2744
- properties() {
2745
- var e = {};
2746
- return R(this.props, function(t, i) {
2747
- if (i === it && O(t)) for (var r = Object.keys(t), n = 0; n < r.length; n++) e["$feature/" + r[n]] = t[r[n]];
2748
- else o = i, l = !1, (Ne(a = Gn) ? l : bs && a.indexOf === bs ? a.indexOf(o) != -1 : (R(a, function(u) {
2749
- if (l || (l = u === o)) return jt;
2750
- }), l)) || (e[i] = t);
2751
- var a, o, l;
2752
- }), e;
2753
- }
2754
- load() {
2755
- if (!this.xe) {
2756
- var e = this.q.D(this.$e);
2757
- e && (this.props = D({}, e));
2758
- }
2759
- }
2760
- save() {
2761
- this.xe || this.q.L(this.$e, this.props, this.Ee, this.Ie, this.Pe, this.S.debug);
2762
- }
2763
- remove() {
2764
- this.q.N(this.$e, !1), this.q.N(this.$e, !0);
2765
- }
2766
- clear() {
2767
- this.remove(), this.props = {};
2768
- }
2769
- register_once(e, t, i) {
2770
- if (O(e)) {
2771
- _(t) && (t = "None"), this.Ee = _(i) ? this.Re : i;
2772
- var r = !1;
2773
- if (R(e, (n, a) => {
2774
- this.props.hasOwnProperty(a) && this.props[a] !== t || (this.props[a] = n, r = !0);
2775
- }), r) return this.save(), !0;
2776
- }
2777
- return !1;
2778
- }
2779
- register(e, t) {
2780
- if (O(e)) {
2781
- this.Ee = _(t) ? this.Re : t;
2782
- var i = !1;
2783
- if (R(e, (r, n) => {
2784
- e.hasOwnProperty(n) && this.props[n] !== r && (this.props[n] = r, i = !0);
2785
- }), i) return this.save(), !0;
2786
- }
2787
- return !1;
2788
- }
2789
- unregister(e) {
2790
- e in this.props && (delete this.props[e], this.save());
2791
- }
2792
- update_campaign_params() {
2793
- if (!this.Se) {
2794
- var e = En(this.S.custom_campaign_params, this.S.mask_personal_data_properties, this.S.custom_personal_data_properties);
2795
- tt(ts(e)) || this.register(e), this.Se = !0;
2796
- }
2797
- }
2798
- update_search_keyword() {
2799
- var e;
2800
- this.register((e = y == null ? void 0 : y.referrer) ? xn(e) : {});
2801
- }
2802
- update_referrer_info() {
2803
- var e;
2804
- this.register_once({ $referrer: Sn(), $referring_domain: y != null && y.referrer && ((e = ot(y.referrer)) == null ? void 0 : e.host) || "$direct" }, void 0);
2805
- }
2806
- set_initial_person_info() {
2807
- this.props[qi] || this.props[Bi] || this.register_once({ [zt]: In(this.S.mask_personal_data_properties, this.S.custom_personal_data_properties) }, void 0);
2808
- }
2809
- get_initial_props() {
2810
- var e = {};
2811
- R([Bi, qi], (a) => {
2812
- var o = this.props[a];
2813
- o && R(o, function(l, u) {
2814
- e["$initial_" + $i(u)] = l;
2815
- });
2816
- });
2817
- var t, i, r = this.props[zt];
2818
- if (r) {
2819
- var n = (t = Fn(r), i = {}, R(t, function(a, o) {
2820
- i["$initial_" + $i(o)] = a;
2821
- }), i);
2822
- D(e, n);
2823
- }
2824
- return e;
2825
- }
2826
- safe_merge(e) {
2827
- return R(this.props, function(t, i) {
2828
- i in e || (e[i] = t);
2829
- }), e;
2830
- }
2831
- update_config(e, t) {
2832
- if (this.Re = this.Ee = e.cookie_expiration, this.set_disabled(e.disable_persistence), this.set_cross_subdomain(e.cross_subdomain_cookie), this.set_secure(e.secure_cookie), e.persistence !== t.persistence) {
2833
- var i = this.ke(e), r = this.props;
2834
- this.clear(), this.q = i, this.props = r, this.save();
2835
- }
2836
- }
2837
- set_disabled(e) {
2838
- this.xe = e, this.xe ? this.remove() : this.save();
2839
- }
2840
- set_cross_subdomain(e) {
2841
- e !== this.Ie && (this.Ie = e, this.remove(), this.save());
2842
- }
2843
- set_secure(e) {
2844
- e !== this.Pe && (this.Pe = e, this.remove(), this.save());
2845
- }
2846
- set_event_timer(e, t) {
2847
- var i = this.props[vt] || {};
2848
- i[e] = t, this.props[vt] = i, this.save();
2849
- }
2850
- remove_event_timer(e) {
2851
- var t = (this.props[vt] || {})[e];
2852
- return _(t) || (delete this.props[vt][e], this.save()), t;
2853
- }
2854
- get_property(e) {
2855
- return this.props[e];
2856
- }
2857
- set_property(e, t) {
2858
- this.props[e] = t, this.save();
2859
- }
2860
- }
2861
- class Pn {
2862
- constructor() {
2863
- this.Te = {}, this.Te = {};
2864
- }
2865
- on(e, t) {
2866
- return this.Te[e] || (this.Te[e] = []), this.Te[e].push(t), () => {
2867
- this.Te[e] = this.Te[e].filter((i) => i !== t);
2868
- };
2869
- }
2870
- emit(e, t) {
2871
- for (var i of this.Te[e] || []) i(t);
2872
- for (var r of this.Te["*"] || []) r(e, t);
2873
- }
2874
- }
2875
- class ze {
2876
- constructor(e) {
2877
- this.Me = new Pn(), this.Ce = (t, i) => this.Oe(t, i) && this.Fe(t, i) && this.Ae(t, i), this.Oe = (t, i) => i == null || !i.event || (t == null ? void 0 : t.event) === (i == null ? void 0 : i.event), this._instance = e, this.De = /* @__PURE__ */ new Set(), this.Le = /* @__PURE__ */ new Set();
2878
- }
2879
- init() {
2880
- var e;
2881
- if (!_((e = this._instance) == null ? void 0 : e.Ne)) {
2882
- var t;
2883
- (t = this._instance) == null || t.Ne((i, r) => {
2884
- this.on(i, r);
2885
- });
2886
- }
2887
- }
2888
- register(e) {
2889
- var t, i;
2890
- if (!_((t = this._instance) == null ? void 0 : t.Ne) && (e.forEach((a) => {
2891
- var o, l;
2892
- (o = this.Le) == null || o.add(a), (l = a.steps) == null || l.forEach((u) => {
2893
- var c;
2894
- (c = this.De) == null || c.add((u == null ? void 0 : u.event) || "");
2895
- });
2896
- }), (i = this._instance) != null && i.autocapture)) {
2897
- var r, n = /* @__PURE__ */ new Set();
2898
- e.forEach((a) => {
2899
- var o;
2900
- (o = a.steps) == null || o.forEach((l) => {
2901
- l != null && l.selector && n.add(l == null ? void 0 : l.selector);
2902
- });
2903
- }), (r = this._instance) == null || r.autocapture.setElementSelectors(n);
2904
- }
2905
- }
2906
- on(e, t) {
2907
- var i;
2908
- t != null && e.length != 0 && (this.De.has(e) || this.De.has(t == null ? void 0 : t.event)) && this.Le && ((i = this.Le) == null ? void 0 : i.size) > 0 && this.Le.forEach((r) => {
2909
- this.je(t, r) && this.Me.emit("actionCaptured", r.name);
2910
- });
2911
- }
2912
- ze(e) {
2913
- this.onAction("actionCaptured", (t) => e(t));
2914
- }
2915
- je(e, t) {
2916
- if ((t == null ? void 0 : t.steps) == null) return !1;
2917
- for (var i of t.steps) if (this.Ce(e, i)) return !0;
2918
- return !1;
2919
- }
2920
- onAction(e, t) {
2921
- return this.Me.on(e, t);
2922
- }
2923
- Fe(e, t) {
2924
- if (t != null && t.url) {
2925
- var i, r = e == null || (i = e.properties) == null ? void 0 : i.$current_url;
2926
- if (!r || typeof r != "string" || !ze.Ue(r, t == null ? void 0 : t.url, (t == null ? void 0 : t.url_matching) || "contains")) return !1;
2927
- }
2928
- return !0;
2929
- }
2930
- static Ue(e, t, i) {
2931
- switch (i) {
2932
- case "regex":
2933
- return !!g && ut(e, t);
2934
- case "exact":
2935
- return t === e;
2936
- case "contains":
2937
- var r = ze.qe(t).replace(/_/g, ".").replace(/%/g, ".*");
2938
- return ut(e, r);
2939
- default:
2940
- return !1;
2941
- }
2942
- }
2943
- static qe(e) {
2944
- return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
2945
- }
2946
- Ae(e, t) {
2947
- if ((t != null && t.href || t != null && t.tag_name || t != null && t.text) && !this.Be(e).some((n) => !(t != null && t.href && !ze.Ue(n.href || "", t == null ? void 0 : t.href, (t == null ? void 0 : t.href_matching) || "exact")) && (t == null || !t.tag_name || n.tag_name === (t == null ? void 0 : t.tag_name)) && !(t != null && t.text && !ze.Ue(n.text || "", t == null ? void 0 : t.text, (t == null ? void 0 : t.text_matching) || "exact") && !ze.Ue(n.$el_text || "", t == null ? void 0 : t.text, (t == null ? void 0 : t.text_matching) || "exact")))) return !1;
2948
- if (t != null && t.selector) {
2949
- var i, r = e == null || (i = e.properties) == null ? void 0 : i.$element_selectors;
2950
- if (!r || !r.includes(t == null ? void 0 : t.selector)) return !1;
2951
- }
2952
- return !0;
2953
- }
2954
- Be(e) {
2955
- return (e == null ? void 0 : e.properties.$elements) == null ? [] : e == null ? void 0 : e.properties.$elements;
2956
- }
2957
- }
2958
- var N = j("[Surveys]");
2959
- class Ao {
2960
- constructor(e) {
2961
- this._instance = e, this.He = /* @__PURE__ */ new Map(), this.We = /* @__PURE__ */ new Map();
2962
- }
2963
- register(e) {
2964
- var t;
2965
- _((t = this._instance) == null ? void 0 : t.Ne) || (this.Ge(e), this.Je(e));
2966
- }
2967
- Je(e) {
2968
- var t = e.filter((i) => {
2969
- var r, n;
2970
- return ((r = i.conditions) == null ? void 0 : r.actions) && ((n = i.conditions) == null || (n = n.actions) == null || (n = n.values) == null ? void 0 : n.length) > 0;
2971
- });
2972
- t.length !== 0 && (this.Ve == null && (this.Ve = new ze(this._instance), this.Ve.init(), this.Ve.ze((i) => {
2973
- this.onAction(i);
2974
- })), t.forEach((i) => {
2975
- var r, n, a, o, l;
2976
- i.conditions && (r = i.conditions) != null && r.actions && (n = i.conditions) != null && (n = n.actions) != null && n.values && ((a = i.conditions) == null || (a = a.actions) == null || (a = a.values) == null ? void 0 : a.length) > 0 && ((o = this.Ve) == null || o.register(i.conditions.actions.values), (l = i.conditions) == null || (l = l.actions) == null || (l = l.values) == null || l.forEach((u) => {
2977
- if (u && u.name) {
2978
- var c = this.We.get(u.name);
2979
- c && c.push(i.id), this.We.set(u.name, c || [i.id]);
2980
- }
2981
- }));
2982
- }));
2983
- }
2984
- Ge(e) {
2985
- var t;
2986
- e.filter((i) => {
2987
- var r, n;
2988
- return ((r = i.conditions) == null ? void 0 : r.events) && ((n = i.conditions) == null || (n = n.events) == null || (n = n.values) == null ? void 0 : n.length) > 0;
2989
- }).length !== 0 && ((t = this._instance) == null || t.Ne((i, r) => {
2990
- this.onEvent(i, r);
2991
- }), e.forEach((i) => {
2992
- var r;
2993
- (r = i.conditions) == null || (r = r.events) == null || (r = r.values) == null || r.forEach((n) => {
2994
- if (n && n.name) {
2995
- var a = this.He.get(n.name);
2996
- a && a.push(i.id), this.He.set(n.name, a || [i.id]);
2997
- }
2998
- });
2999
- }));
3000
- }
3001
- onEvent(e, t) {
3002
- var i, r = ((i = this._instance) == null || (i = i.persistence) == null ? void 0 : i.props[Rt]) || [];
3003
- if (e === "survey shown" && t && r.length > 0) {
3004
- var n;
3005
- N.info("survey event matched, removing survey from activated surveys", { event: e, eventPayload: t, existingActivatedSurveys: r });
3006
- var a = t == null || (n = t.properties) == null ? void 0 : n.$survey_id;
3007
- if (a) {
3008
- var o = r.indexOf(a);
3009
- o >= 0 && (r.splice(o, 1), this.Ke(r));
3010
- }
3011
- } else this.He.has(e) && (N.info("survey event matched, updating activated surveys", { event: e, surveys: this.He.get(e) }), this.Ke(r.concat(this.He.get(e) || [])));
3012
- }
3013
- onAction(e) {
3014
- var t, i = ((t = this._instance) == null || (t = t.persistence) == null ? void 0 : t.props[Rt]) || [];
3015
- this.We.has(e) && this.Ke(i.concat(this.We.get(e) || []));
3016
- }
3017
- Ke(e) {
3018
- var t;
3019
- (t = this._instance) == null || (t = t.persistence) == null || t.register({ [Rt]: [...new Set(e)] });
3020
- }
3021
- getSurveys() {
3022
- var e, t = (e = this._instance) == null || (e = e.persistence) == null ? void 0 : e.props[Rt];
3023
- return t || [];
3024
- }
3025
- getEventToSurveys() {
3026
- return this.He;
3027
- }
3028
- Ye() {
3029
- return this.Ve;
3030
- }
3031
- }
3032
- class Lo {
3033
- constructor(e) {
3034
- this.Xe = null, this.Qe = !1, this.Ze = !1, this.tr = [], this._instance = e, this._surveyEventReceiver = null;
3035
- }
3036
- onRemoteConfig(e) {
3037
- var t = e.surveys;
3038
- if (P(t)) return N.warn("Decide not loaded yet. Not loading surveys.");
3039
- var i = C(t);
3040
- this.ir = i ? t.length > 0 : t, N.info("decide response received, hasSurveys: " + this.ir), this.ir && this.loadIfEnabled();
3041
- }
3042
- reset() {
3043
- localStorage.removeItem("lastSeenSurveyDate");
3044
- for (var e = [], t = 0; t < localStorage.length; t++) {
3045
- var i = localStorage.key(t);
3046
- (i != null && i.startsWith("seenSurvey_") || i != null && i.startsWith("inProgressSurvey_")) && e.push(i);
3047
- }
3048
- e.forEach((r) => localStorage.removeItem(r));
3049
- }
3050
- loadIfEnabled() {
3051
- if (!this.Xe) if (this.Ze) N.info("Already initializing surveys, skipping...");
3052
- else if (this._instance.config.disable_surveys) N.info("Disabled. Not loading surveys.");
3053
- else if (this.ir) {
3054
- var e = x == null ? void 0 : x.__PosthogExtensions__;
3055
- if (e) {
3056
- this.Ze = !0;
3057
- try {
3058
- var t = e.generateSurveys;
3059
- if (t) return void this.er(t);
3060
- var i = e.loadExternalDependency;
3061
- if (!i) return void this.rr("PostHog loadExternalDependency extension not found.");
3062
- i(this._instance, "surveys", (r) => {
3063
- r || !e.generateSurveys ? this.rr("Could not load surveys script", r) : this.er(e.generateSurveys);
3064
- });
3065
- } catch (r) {
3066
- throw this.rr("Error initializing surveys", r), r;
3067
- } finally {
3068
- this.Ze = !1;
3069
- }
3070
- } else N.error("PostHog Extensions not found.");
3071
- } else N.info("No surveys to load.");
3072
- }
3073
- er(e) {
3074
- this.Xe = e(this._instance), this._surveyEventReceiver = new Ao(this._instance), N.info("Surveys loaded successfully"), this.sr({ isLoaded: !0 });
3075
- }
3076
- rr(e, t) {
3077
- N.error(e, t), this.sr({ isLoaded: !1, error: e });
3078
- }
3079
- onSurveysLoaded(e) {
3080
- return this.tr.push(e), this.Xe && this.sr({ isLoaded: !0 }), () => {
3081
- this.tr = this.tr.filter((t) => t !== e);
3082
- };
3083
- }
3084
- getSurveys(e, t) {
3085
- if (t === void 0 && (t = !1), this._instance.config.disable_surveys) return N.info("Disabled. Not loading surveys."), e([]);
3086
- var i = this._instance.get_property(Li);
3087
- if (i && !t) return e(i, { isLoaded: !0 });
3088
- if (this.Qe) return e([], { isLoaded: !1, error: "Surveys are already being loaded" });
3089
- try {
3090
- this.Qe = !0, this._instance.me({ url: this._instance.requestRouter.endpointFor("api", "/api/surveys/?token=" + this._instance.config.token), method: "GET", timeout: this._instance.config.surveys_request_timeout_ms, callback: (r) => {
3091
- var n;
3092
- this.Qe = !1;
3093
- var a = r.statusCode;
3094
- if (a !== 200 || !r.json) {
3095
- var o = "Surveys API could not be loaded, status: " + a;
3096
- return N.error(o), e([], { isLoaded: !1, error: o });
3097
- }
3098
- var l, u = r.json.surveys || [], c = u.filter((p) => function(h) {
3099
- return !(!h.start_date || h.end_date);
3100
- }(p) && (function(h) {
3101
- var d;
3102
- return !((d = h.conditions) == null || (d = d.events) == null || (d = d.values) == null || !d.length);
3103
- }(p) || function(h) {
3104
- var d;
3105
- return !((d = h.conditions) == null || (d = d.actions) == null || (d = d.values) == null || !d.length);
3106
- }(p)));
3107
- return c.length > 0 && ((l = this._surveyEventReceiver) == null || l.register(c)), (n = this._instance.persistence) == null || n.register({ [Li]: u }), e(u, { isLoaded: !0 });
3108
- } });
3109
- } catch (r) {
3110
- throw this.Qe = !1, r;
3111
- }
3112
- }
3113
- sr(e) {
3114
- for (var t of this.tr) try {
3115
- e.isLoaded ? this.getSurveys(t) : t([], e);
3116
- } catch (i) {
3117
- N.error("Error in survey callback", i);
3118
- }
3119
- }
3120
- getActiveMatchingSurveys(e, t) {
3121
- if (t === void 0 && (t = !1), !P(this.Xe)) return this.Xe.getActiveMatchingSurveys(e, t);
3122
- N.warn("init was not called");
3123
- }
3124
- nr(e) {
3125
- var t = null;
3126
- return this.getSurveys((i) => {
3127
- var r;
3128
- t = (r = i.find((n) => n.id === e)) !== null && r !== void 0 ? r : null;
3129
- }), t;
3130
- }
3131
- ar(e) {
3132
- if (P(this.Xe)) return { eligible: !1, reason: "SDK is not enabled or survey functionality is not yet loaded" };
3133
- var t = typeof e == "string" ? this.nr(e) : e;
3134
- return t ? this.Xe.checkSurveyEligibility(t) : { eligible: !1, reason: "Survey not found" };
3135
- }
3136
- canRenderSurvey(e) {
3137
- if (P(this.Xe)) return N.warn("init was not called"), { visible: !1, disabledReason: "SDK is not enabled or survey functionality is not yet loaded" };
3138
- var t = this.ar(e);
3139
- return { visible: t.eligible, disabledReason: t.reason };
3140
- }
3141
- canRenderSurveyAsync(e, t) {
3142
- return P(this.Xe) ? (N.warn("init was not called"), Promise.resolve({ visible: !1, disabledReason: "SDK is not enabled or survey functionality is not yet loaded" })) : new Promise((i) => {
3143
- this.getSurveys((r) => {
3144
- var n, a = (n = r.find((l) => l.id === e)) !== null && n !== void 0 ? n : null;
3145
- if (a) {
3146
- var o = this.ar(a);
3147
- i({ visible: o.eligible, disabledReason: o.reason });
3148
- } else i({ visible: !1, disabledReason: "Survey not found" });
3149
- }, t);
3150
- });
3151
- }
3152
- renderSurvey(e, t) {
3153
- if (P(this.Xe)) N.warn("init was not called");
3154
- else {
3155
- var i = this.nr(e), r = y == null ? void 0 : y.querySelector(t);
3156
- i ? r ? this.Xe.renderSurvey(i, r) : N.warn("Survey element not found") : N.warn("Survey not found");
3157
- }
3158
- }
3159
- }
3160
- var fr = j("[RateLimiter]");
3161
- class Do {
3162
- constructor(e) {
3163
- var t, i;
3164
- this.serverLimits = {}, this.lastEventRateLimited = !1, this.checkForLimiting = (r) => {
3165
- var n = r.text;
3166
- if (n && n.length) try {
3167
- (JSON.parse(n).quota_limited || []).forEach((a) => {
3168
- fr.info((a || "events") + " is quota limited."), this.serverLimits[a] = (/* @__PURE__ */ new Date()).getTime() + 6e4;
3169
- });
3170
- } catch (a) {
3171
- return void fr.warn('could not rate limit - continuing. Error: "' + (a == null ? void 0 : a.message) + '"', { text: n });
3172
- }
3173
- }, this.instance = e, this.captureEventsPerSecond = ((t = e.config.rate_limiting) == null ? void 0 : t.events_per_second) || 10, this.captureEventsBurstLimit = Math.max(((i = e.config.rate_limiting) == null ? void 0 : i.events_burst_limit) || 10 * this.captureEventsPerSecond, this.captureEventsPerSecond), this.lastEventRateLimited = this.clientRateLimitContext(!0).isRateLimited;
3174
- }
3175
- clientRateLimitContext(e) {
3176
- var t, i, r;
3177
- e === void 0 && (e = !1);
3178
- var n = (/* @__PURE__ */ new Date()).getTime(), a = (t = (i = this.instance.persistence) == null ? void 0 : i.get_property(Ni)) !== null && t !== void 0 ? t : { tokens: this.captureEventsBurstLimit, last: n };
3179
- a.tokens += (n - a.last) / 1e3 * this.captureEventsPerSecond, a.last = n, a.tokens > this.captureEventsBurstLimit && (a.tokens = this.captureEventsBurstLimit);
3180
- var o = a.tokens < 1;
3181
- return o || e || (a.tokens = Math.max(0, a.tokens - 1)), !o || this.lastEventRateLimited || e || this.instance.capture("$$client_ingestion_warning", { $$client_ingestion_warning_message: "posthog-js client rate limited. Config is set to " + this.captureEventsPerSecond + " events per second and " + this.captureEventsBurstLimit + " events burst limit." }, { skip_client_rate_limiting: !0 }), this.lastEventRateLimited = o, (r = this.instance.persistence) == null || r.set_property(Ni, a), { isRateLimited: o, remainingTokens: a.tokens };
3182
- }
3183
- isServerRateLimited(e) {
3184
- var t = this.serverLimits[e || "events"] || !1;
3185
- return t !== !1 && (/* @__PURE__ */ new Date()).getTime() < t;
3186
- }
3187
- }
3188
- var Ue = j("[RemoteConfig]");
3189
- class No {
3190
- constructor(e) {
3191
- this._instance = e;
3192
- }
3193
- get remoteConfig() {
3194
- var e;
3195
- return (e = x._POSTHOG_REMOTE_CONFIG) == null || (e = e[this._instance.config.token]) == null ? void 0 : e.config;
3196
- }
3197
- lr(e) {
3198
- var t, i;
3199
- (t = x.__PosthogExtensions__) != null && t.loadExternalDependency ? (i = x.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "remote-config", () => e(this.remoteConfig)) : (Ue.error("PostHog Extensions not found. Cannot load remote config."), e());
3200
- }
3201
- ur(e) {
3202
- this._instance.me({ method: "GET", url: this._instance.requestRouter.endpointFor("assets", "/array/" + this._instance.config.token + "/config"), callback: (t) => {
3203
- e(t.json);
3204
- } });
3205
- }
3206
- load() {
3207
- try {
3208
- if (this.remoteConfig) return Ue.info("Using preloaded remote config", this.remoteConfig), void this.be(this.remoteConfig);
3209
- if (this._instance.config.advanced_disable_decide) return void Ue.warn("Remote config is disabled. Falling back to local config.");
3210
- this.lr((e) => {
3211
- if (!e) return Ue.info("No config found after loading remote JS config. Falling back to JSON."), void this.ur((t) => {
3212
- this.be(t);
3213
- });
3214
- this.be(e);
3215
- });
3216
- } catch (e) {
3217
- Ue.error("Error loading remote config", e);
3218
- }
3219
- }
3220
- be(e) {
3221
- e ? this._instance.config.__preview_remote_config ? (this._instance.be(e), e.hasFeatureFlags !== !1 && this._instance.featureFlags.ensureFlagsLoaded()) : Ue.info("__preview_remote_config is disabled. Logging config instead", e) : Ue.error("Failed to fetch remote config from PostHog.");
3222
- }
3223
- }
3224
- var Qi = 3e3;
3225
- class qo {
3226
- constructor(e, t) {
3227
- this.hr = !0, this.dr = [], this.vr = ne((t == null ? void 0 : t.flush_interval_ms) || Qi, 250, 5e3, "flush interval", Qi), this.cr = e;
3228
- }
3229
- enqueue(e) {
3230
- this.dr.push(e), this.pr || this.gr();
3231
- }
3232
- unload() {
3233
- this._r();
3234
- var e = this.dr.length > 0 ? this.mr() : {}, t = Object.values(e);
3235
- [...t.filter((i) => i.url.indexOf("/e") === 0), ...t.filter((i) => i.url.indexOf("/e") !== 0)].map((i) => {
3236
- this.cr(m({}, i, { transport: "sendBeacon" }));
3237
- });
3238
- }
3239
- enable() {
3240
- this.hr = !1, this.gr();
3241
- }
3242
- gr() {
3243
- var e = this;
3244
- this.hr || (this.pr = setTimeout(() => {
3245
- if (this._r(), this.dr.length > 0) {
3246
- var t = this.mr(), i = function() {
3247
- var n = t[r], a = (/* @__PURE__ */ new Date()).getTime();
3248
- n.data && C(n.data) && R(n.data, (o) => {
3249
- o.offset = Math.abs(o.timestamp - a), delete o.timestamp;
3250
- }), e.cr(n);
3251
- };
3252
- for (var r in t) i();
3253
- }
3254
- }, this.vr));
3255
- }
3256
- _r() {
3257
- clearTimeout(this.pr), this.pr = void 0;
3258
- }
3259
- mr() {
3260
- var e = {};
3261
- return R(this.dr, (t) => {
3262
- var i, r = t, n = (r ? r.batchKey : null) || r.url;
3263
- _(e[n]) && (e[n] = m({}, r, { data: [] })), (i = e[n].data) == null || i.push(r.data);
3264
- }), this.dr = [], e;
3265
- }
3266
- }
3267
- var Bo = ["retriesPerformedSoFar"];
3268
- class Ho {
3269
- constructor(e) {
3270
- this.br = !1, this.wr = 3e3, this.dr = [], this._instance = e, this.dr = [], this.yr = !0, !_(g) && "onLine" in g.navigator && (this.yr = g.navigator.onLine, T(g, "online", () => {
3271
- this.yr = !0, this.Yi();
3272
- }), T(g, "offline", () => {
3273
- this.yr = !1;
3274
- }));
3275
- }
3276
- get length() {
3277
- return this.dr.length;
3278
- }
3279
- retriableRequest(e) {
3280
- var { retriesPerformedSoFar: t } = e, i = Ir(e, Bo);
3281
- z(t) && t > 0 && (i.url = ei(i.url, { retry_count: t })), this._instance.me(m({}, i, { callback: (r) => {
3282
- r.statusCode !== 200 && (r.statusCode < 400 || r.statusCode >= 500) && (t ?? 0) < 10 ? this.Sr(m({ retriesPerformedSoFar: t }, i)) : i.callback == null || i.callback(r);
3283
- } }));
3284
- }
3285
- Sr(e) {
3286
- var t = e.retriesPerformedSoFar || 0;
3287
- e.retriesPerformedSoFar = t + 1;
3288
- var i = function(a) {
3289
- var o = 3e3 * Math.pow(2, a), l = o / 2, u = Math.min(18e5, o), c = (Math.random() - 0.5) * (u - l);
3290
- return Math.ceil(u + c);
3291
- }(t), r = Date.now() + i;
3292
- this.dr.push({ retryAt: r, requestOptions: e });
3293
- var n = "Enqueued failed request for retry in " + i;
3294
- navigator.onLine || (n += " (Browser is offline)"), w.warn(n), this.br || (this.br = !0, this.$r());
3295
- }
3296
- $r() {
3297
- this.kr && clearTimeout(this.kr), this.kr = setTimeout(() => {
3298
- this.yr && this.dr.length > 0 && this.Yi(), this.$r();
3299
- }, this.wr);
3300
- }
3301
- Yi() {
3302
- var e = Date.now(), t = [], i = this.dr.filter((n) => n.retryAt < e || (t.push(n), !1));
3303
- if (this.dr = t, i.length > 0) for (var { requestOptions: r } of i) this.retriableRequest(r);
3304
- }
3305
- unload() {
3306
- for (var { requestOptions: e } of (this.kr && (clearTimeout(this.kr), this.kr = void 0), this.dr)) try {
3307
- this._instance.me(m({}, e, { transport: "sendBeacon" }));
3308
- } catch (t) {
3309
- w.error(t);
3310
- }
3311
- this.dr = [];
3312
- }
3313
- }
3314
- class jo {
3315
- constructor(e) {
3316
- this.Er = () => {
3317
- var t, i, r, n;
3318
- this.Ir || (this.Ir = {});
3319
- var a = this.scrollElement(), o = this.scrollY(), l = a ? Math.max(0, a.scrollHeight - a.clientHeight) : 0, u = o + ((a == null ? void 0 : a.clientHeight) || 0), c = (a == null ? void 0 : a.scrollHeight) || 0;
3320
- this.Ir.lastScrollY = Math.ceil(o), this.Ir.maxScrollY = Math.max(o, (t = this.Ir.maxScrollY) !== null && t !== void 0 ? t : 0), this.Ir.maxScrollHeight = Math.max(l, (i = this.Ir.maxScrollHeight) !== null && i !== void 0 ? i : 0), this.Ir.lastContentY = u, this.Ir.maxContentY = Math.max(u, (r = this.Ir.maxContentY) !== null && r !== void 0 ? r : 0), this.Ir.maxContentHeight = Math.max(c, (n = this.Ir.maxContentHeight) !== null && n !== void 0 ? n : 0);
3321
- }, this._instance = e;
3322
- }
3323
- getContext() {
3324
- return this.Ir;
3325
- }
3326
- resetContext() {
3327
- var e = this.Ir;
3328
- return setTimeout(this.Er, 0), e;
3329
- }
3330
- startMeasuringScrollPosition() {
3331
- T(g, "scroll", this.Er, { capture: !0 }), T(g, "scrollend", this.Er, { capture: !0 }), T(g, "resize", this.Er);
3332
- }
3333
- scrollElement() {
3334
- if (!this._instance.config.scroll_root_selector) return g == null ? void 0 : g.document.documentElement;
3335
- var e = C(this._instance.config.scroll_root_selector) ? this._instance.config.scroll_root_selector : [this._instance.config.scroll_root_selector];
3336
- for (var t of e) {
3337
- var i = g == null ? void 0 : g.document.querySelector(t);
3338
- if (i) return i;
3339
- }
3340
- }
3341
- scrollY() {
3342
- if (this._instance.config.scroll_root_selector) {
3343
- var e = this.scrollElement();
3344
- return e && e.scrollTop || 0;
3345
- }
3346
- return g && (g.scrollY || g.pageYOffset || g.document.documentElement.scrollTop) || 0;
3347
- }
3348
- scrollX() {
3349
- if (this._instance.config.scroll_root_selector) {
3350
- var e = this.scrollElement();
3351
- return e && e.scrollLeft || 0;
3352
- }
3353
- return g && (g.scrollX || g.pageXOffset || g.document.documentElement.scrollLeft) || 0;
3354
- }
3355
- }
3356
- var Uo = (s) => In(s == null ? void 0 : s.config.mask_personal_data_properties, s == null ? void 0 : s.config.custom_personal_data_properties);
3357
- class Wo {
3358
- constructor(e, t, i, r) {
3359
- this.Pr = (n) => {
3360
- var a = this.Rr();
3361
- if (!a || a.sessionId !== n) {
3362
- var o = { sessionId: n, props: this.Tr(this._instance) };
3363
- this.Mr.register({ [Di]: o });
3364
- }
3365
- }, this._instance = e, this.Cr = t, this.Mr = i, this.Tr = r || Uo, this.Cr.onSessionId(this.Pr);
3366
- }
3367
- Rr() {
3368
- return this.Mr.props[Di];
3369
- }
3370
- getSetOnceProps() {
3371
- var e, t = (e = this.Rr()) == null ? void 0 : e.props;
3372
- return t ? "r" in t ? Fn(t) : { $referring_domain: t.referringDomain, $pathname: t.initialPathName, utm_source: t.utm_source, utm_campaign: t.utm_campaign, utm_medium: t.utm_medium, utm_content: t.utm_content, utm_term: t.utm_term } : {};
3373
- }
3374
- getSessionProps() {
3375
- var e = {};
3376
- return R(ts(this.getSetOnceProps()), (t, i) => {
3377
- i === "$current_url" && (i = "url"), e["$session_entry_" + $i(i)] = t;
3378
- }), e;
3379
- }
3380
- }
3381
- var vr = j("[SessionId]");
3382
- class zo {
3383
- constructor(e, t, i) {
3384
- var r;
3385
- if (this.Or = [], !e.persistence) throw new Error("SessionIdManager requires a PostHogPersistence instance");
3386
- if (e.config.__preview_experimental_cookieless_mode) throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");
3387
- this.S = e.config, this.Mr = e.persistence, this.oi = void 0, this.kt = void 0, this._sessionStartTimestamp = null, this._sessionActivityTimestamp = null, this.Fr = t || Oe, this.Ar = i || Oe;
3388
- var n = this.S.persistence_name || this.S.token, a = this.S.session_idle_timeout_seconds || 1800;
3389
- if (this._sessionTimeoutMs = 1e3 * ne(a, 60, 36e3, "session_idle_timeout_seconds", 1800), e.register({ $configured_session_timeout_ms: this._sessionTimeoutMs }), this.Dr(), this.Lr = "ph_" + n + "_window_id", this.Nr = "ph_" + n + "_primary_window_exists", this.jr()) {
3390
- var o = H.D(this.Lr), l = H.D(this.Nr);
3391
- o && !l ? this.oi = o : H.N(this.Lr), H.L(this.Nr, !0);
3392
- }
3393
- if ((r = this.S.bootstrap) != null && r.sessionID) try {
3394
- var u = ((c) => {
3395
- var p = c.replace(/-/g, "");
3396
- if (p.length !== 32) throw new Error("Not a valid UUID");
3397
- if (p[12] !== "7") throw new Error("Not a UUIDv7");
3398
- return parseInt(p.substring(0, 12), 16);
3399
- })(this.S.bootstrap.sessionID);
3400
- this.zr(this.S.bootstrap.sessionID, (/* @__PURE__ */ new Date()).getTime(), u);
3401
- } catch (c) {
3402
- vr.error("Invalid sessionID in bootstrap", c);
3403
- }
3404
- this.Ur();
3405
- }
3406
- get sessionTimeoutMs() {
3407
- return this._sessionTimeoutMs;
3408
- }
3409
- onSessionId(e) {
3410
- return _(this.Or) && (this.Or = []), this.Or.push(e), this.kt && e(this.kt, this.oi), () => {
3411
- this.Or = this.Or.filter((t) => t !== e);
3412
- };
3413
- }
3414
- jr() {
3415
- return this.S.persistence !== "memory" && !this.Mr.xe && H.O();
3416
- }
3417
- qr(e) {
3418
- e !== this.oi && (this.oi = e, this.jr() && H.L(this.Lr, e));
3419
- }
3420
- Br() {
3421
- return this.oi ? this.oi : this.jr() ? H.D(this.Lr) : null;
3422
- }
3423
- zr(e, t, i) {
3424
- e === this.kt && t === this._sessionActivityTimestamp && i === this._sessionStartTimestamp || (this._sessionStartTimestamp = i, this._sessionActivityTimestamp = t, this.kt = e, this.Mr.register({ [Ut]: [t, e, i] }));
3425
- }
3426
- Hr() {
3427
- if (this.kt && this._sessionActivityTimestamp && this._sessionStartTimestamp) return [this._sessionActivityTimestamp, this.kt, this._sessionStartTimestamp];
3428
- var e = this.Mr.props[Ut];
3429
- return C(e) && e.length === 2 && e.push(e[0]), e || [0, null, 0];
3430
- }
3431
- resetSessionId() {
3432
- this.zr(null, null, null);
3433
- }
3434
- Ur() {
3435
- T(g, "beforeunload", () => {
3436
- this.jr() && H.N(this.Nr);
3437
- }, { capture: !1 });
3438
- }
3439
- checkAndGetSessionAndWindowId(e, t) {
3440
- if (e === void 0 && (e = !1), t === void 0 && (t = null), this.S.__preview_experimental_cookieless_mode) throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");
3441
- var i = t || (/* @__PURE__ */ new Date()).getTime(), [r, n, a] = this.Hr(), o = this.Br(), l = z(a) && a > 0 && Math.abs(i - a) > 864e5, u = !1, c = !n, p = !e && Math.abs(i - r) > this.sessionTimeoutMs;
3442
- c || p || l ? (n = this.Fr(), o = this.Ar(), vr.info("new session ID generated", { sessionId: n, windowId: o, changeReason: { noSessionId: c, activityTimeout: p, sessionPastMaximumLength: l } }), a = i, u = !0) : o || (o = this.Ar(), u = !0);
3443
- var h = r === 0 || !e || l ? i : r, d = a === 0 ? (/* @__PURE__ */ new Date()).getTime() : a;
3444
- return this.qr(o), this.zr(n, h, d), e || this.Dr(), u && this.Or.forEach((v) => v(n, o, u ? { noSessionId: c, activityTimeout: p, sessionPastMaximumLength: l } : void 0)), { sessionId: n, windowId: o, sessionStartTimestamp: d, changeReason: u ? { noSessionId: c, activityTimeout: p, sessionPastMaximumLength: l } : void 0, lastActivityTimestamp: r };
3445
- }
3446
- Dr() {
3447
- clearTimeout(this.Wr), this.Wr = setTimeout(() => {
3448
- this.resetSessionId();
3449
- }, 1.1 * this.sessionTimeoutMs);
3450
- }
3451
- }
3452
- var Go = ["$set_once", "$set"], Ce = j("[SiteApps]");
3453
- class Vo {
3454
- constructor(e) {
3455
- this._instance = e, this.Gr = [], this.apps = {};
3456
- }
3457
- get isEnabled() {
3458
- return !!this._instance.config.opt_in_site_apps;
3459
- }
3460
- Jr(e, t) {
3461
- if (t) {
3462
- var i = this.globalsForEvent(t);
3463
- this.Gr.push(i), this.Gr.length > 1e3 && (this.Gr = this.Gr.slice(10));
3464
- }
3465
- }
3466
- get siteAppLoaders() {
3467
- var e;
3468
- return (e = x._POSTHOG_REMOTE_CONFIG) == null || (e = e[this._instance.config.token]) == null ? void 0 : e.siteApps;
3469
- }
3470
- init() {
3471
- if (this.isEnabled) {
3472
- var e = this._instance.Ne(this.Jr.bind(this));
3473
- this.Vr = () => {
3474
- e(), this.Gr = [], this.Vr = void 0;
3475
- };
3476
- }
3477
- }
3478
- globalsForEvent(e) {
3479
- var t, i, r, n, a, o, l;
3480
- if (!e) throw new Error("Event payload is required");
3481
- var u = {}, c = this._instance.get_property("$groups") || [], p = this._instance.get_property("$stored_group_properties") || {};
3482
- for (var [h, d] of Object.entries(p)) u[h] = { id: c[h], type: h, properties: d };
3483
- var { $set_once: v, $set: f } = e;
3484
- return { event: m({}, Ir(e, Go), { properties: m({}, e.properties, f ? { $set: m({}, (t = (i = e.properties) == null ? void 0 : i.$set) !== null && t !== void 0 ? t : {}, f) } : {}, v ? { $set_once: m({}, (r = (n = e.properties) == null ? void 0 : n.$set_once) !== null && r !== void 0 ? r : {}, v) } : {}), elements_chain: (a = (o = e.properties) == null ? void 0 : o.$elements_chain) !== null && a !== void 0 ? a : "", distinct_id: (l = e.properties) == null ? void 0 : l.distinct_id }), person: { properties: this._instance.get_property("$stored_person_properties") }, groups: u };
3485
- }
3486
- setupSiteApp(e) {
3487
- var t = this.apps[e.id], i = () => {
3488
- var o;
3489
- !t.errored && this.Gr.length && (Ce.info("Processing " + this.Gr.length + " events for site app with id " + e.id), this.Gr.forEach((l) => t.processEvent == null ? void 0 : t.processEvent(l)), t.processedBuffer = !0), Object.values(this.apps).every((l) => l.processedBuffer || l.errored) && ((o = this.Vr) == null || o.call(this));
3490
- }, r = !1, n = (o) => {
3491
- t.errored = !o, t.loaded = !0, Ce.info("Site app with id " + e.id + " " + (o ? "loaded" : "errored")), r && i();
3492
- };
3493
- try {
3494
- var { processEvent: a } = e.init({ posthog: this._instance, callback: (o) => {
3495
- n(o);
3496
- } });
3497
- a && (t.processEvent = a), r = !0;
3498
- } catch (o) {
3499
- Ce.error("Error while initializing PostHog app with config id " + e.id, o), n(!1);
3500
- }
3501
- if (r && t.loaded) try {
3502
- i();
3503
- } catch (o) {
3504
- Ce.error("Error while processing buffered events PostHog app with config id " + e.id, o), t.errored = !0;
3505
- }
3506
- }
3507
- Kr() {
3508
- var e = this.siteAppLoaders || [];
3509
- for (var t of e) this.apps[t.id] = { id: t.id, loaded: !1, errored: !1, processedBuffer: !1 };
3510
- for (var i of e) this.setupSiteApp(i);
3511
- }
3512
- Yr(e) {
3513
- if (Object.keys(this.apps).length !== 0) {
3514
- var t = this.globalsForEvent(e);
3515
- for (var i of Object.values(this.apps)) try {
3516
- i.processEvent == null || i.processEvent(t);
3517
- } catch (r) {
3518
- Ce.error("Error while processing event " + e.event + " for site app " + i.id, r);
3519
- }
3520
- }
3521
- }
3522
- onRemoteConfig(e) {
3523
- var t, i, r, n = this;
3524
- if ((t = this.siteAppLoaders) != null && t.length) return this.isEnabled ? (this.Kr(), void this._instance.on("eventCaptured", (u) => this.Yr(u))) : void Ce.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');
3525
- if ((i = this.Vr) == null || i.call(this), (r = e.siteApps) != null && r.length) if (this.isEnabled) {
3526
- var a = function(u) {
3527
- var c;
3528
- x["__$$ph_site_app_" + u] = n._instance, (c = x.__PosthogExtensions__) == null || c.loadSiteApp == null || c.loadSiteApp(n._instance, l, (p) => {
3529
- if (p) return Ce.error("Error while initializing PostHog app with config id " + u, p);
3530
- });
3531
- };
3532
- for (var { id: o, url: l } of e.siteApps) a(o);
3533
- } else Ce.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');
3534
- }
3535
- }
3536
- var Xo = ["amazonbot", "amazonproductbot", "app.hypefactors.com", "applebot", "archive.org_bot", "awariobot", "backlinksextendedbot", "baiduspider", "bingbot", "bingpreview", "chrome-lighthouse", "dataforseobot", "deepscan", "duckduckbot", "facebookexternal", "facebookcatalog", "http://yandex.com/bots", "hubspot", "ia_archiver", "linkedinbot", "meta-externalagent", "mj12bot", "msnbot", "nessus", "petalbot", "pinterest", "prerender", "rogerbot", "screaming frog", "sebot-wa", "sitebulb", "slackbot", "slurp", "trendictionbot", "turnitin", "twitterbot", "vercelbot", "yahoo! slurp", "yandexbot", "zoombot", "bot.htm", "bot.php", "(bot;", "bot/", "crawler", "ahrefsbot", "ahrefssiteaudit", "semrushbot", "siteauditbot", "splitsignalbot", "gptbot", "oai-searchbot", "chatgpt-user", "perplexitybot", "better uptime bot", "sentryuptimebot", "uptimerobot", "headlesschrome", "cypress", "google-hoteladsverifier", "adsbot-google", "apis-google", "duplexweb-google", "feedfetcher-google", "google favicon", "google web preview", "google-read-aloud", "googlebot", "googleother", "google-cloudvertexbot", "googleweblight", "mediapartners-google", "storebot-google", "google-inspectiontool", "bytespider"], _r = function(s, e) {
3537
- if (!s) return !1;
3538
- var t = s.toLowerCase();
3539
- return Xo.concat(e || []).some((i) => {
3540
- var r = i.toLowerCase();
3541
- return t.indexOf(r) !== -1;
3542
- });
3543
- }, Rn = function(s, e) {
3544
- if (!s) return !1;
3545
- var t = s.userAgent;
3546
- if (t && _r(t, e)) return !0;
3547
- try {
3548
- var i = s == null ? void 0 : s.userAgentData;
3549
- if (i != null && i.brands && i.brands.some((r) => _r(r == null ? void 0 : r.brand, e))) return !0;
3550
- } catch {
3551
- }
3552
- return !!s.webdriver;
3553
- }, Et = function(s) {
3554
- return s.US = "us", s.EU = "eu", s.CUSTOM = "custom", s;
3555
- }({}), mr = "i.posthog.com";
3556
- class Yo {
3557
- constructor(e) {
3558
- this.Xr = {}, this.instance = e;
3559
- }
3560
- get apiHost() {
3561
- var e = this.instance.config.api_host.trim().replace(/\/$/, "");
3562
- return e === "https://app.posthog.com" ? "https://us.i.posthog.com" : e;
3563
- }
3564
- get uiHost() {
3565
- var e, t = (e = this.instance.config.ui_host) == null ? void 0 : e.replace(/\/$/, "");
3566
- return t || (t = this.apiHost.replace("." + mr, ".posthog.com")), t === "https://app.posthog.com" ? "https://us.posthog.com" : t;
3567
- }
3568
- get region() {
3569
- return this.Xr[this.apiHost] || (/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? this.Xr[this.apiHost] = Et.US : /https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? this.Xr[this.apiHost] = Et.EU : this.Xr[this.apiHost] = Et.CUSTOM), this.Xr[this.apiHost];
3570
- }
3571
- endpointFor(e, t) {
3572
- if (t === void 0 && (t = ""), t && (t = t[0] === "/" ? t : "/" + t), e === "ui") return this.uiHost + t;
3573
- if (this.region === Et.CUSTOM) return this.apiHost + t;
3574
- var i = mr + t;
3575
- switch (e) {
3576
- case "assets":
3577
- return "https://" + this.region + "-assets." + i;
3578
- case "api":
3579
- return "https://" + this.region + "." + i;
3580
- }
3581
- }
3582
- }
3583
- var Jo = { icontains: (s, e) => !!g && e.href.toLowerCase().indexOf(s.toLowerCase()) > -1, not_icontains: (s, e) => !!g && e.href.toLowerCase().indexOf(s.toLowerCase()) === -1, regex: (s, e) => !!g && ut(e.href, s), not_regex: (s, e) => !!g && !ut(e.href, s), exact: (s, e) => e.href === s, is_not: (s, e) => e.href !== s };
3584
- class W {
3585
- constructor(e) {
3586
- var t = this;
3587
- this.getWebExperimentsAndEvaluateDisplayLogic = function(i) {
3588
- i === void 0 && (i = !1), t.getWebExperiments((r) => {
3589
- W.Qr("retrieved web experiments from the server"), t.Zr = /* @__PURE__ */ new Map(), r.forEach((n) => {
3590
- if (n.feature_flag_key) {
3591
- var a;
3592
- t.Zr && (W.Qr("setting flag key ", n.feature_flag_key, " to web experiment ", n), (a = t.Zr) == null || a.set(n.feature_flag_key, n));
3593
- var o = t._instance.getFeatureFlag(n.feature_flag_key);
3594
- A(o) && n.variants[o] && t.ts(n.name, o, n.variants[o].transforms);
3595
- } else if (n.variants) for (var l in n.variants) {
3596
- var u = n.variants[l];
3597
- W.es(u) && t.ts(n.name, l, u.transforms);
3598
- }
3599
- });
3600
- }, i);
3601
- }, this._instance = e, this._instance.onFeatureFlags((i) => {
3602
- this.onFeatureFlags(i);
3603
- });
3604
- }
3605
- onFeatureFlags(e) {
3606
- if (this._is_bot()) W.Qr("Refusing to render web experiment since the viewer is a likely bot");
3607
- else if (!this._instance.config.disable_web_experiments) {
3608
- if (P(this.Zr)) return this.Zr = /* @__PURE__ */ new Map(), this.loadIfEnabled(), void this.previewWebExperiment();
3609
- W.Qr("applying feature flags", e), e.forEach((t) => {
3610
- var i;
3611
- if (this.Zr && (i = this.Zr) != null && i.has(t)) {
3612
- var r, n = this._instance.getFeatureFlag(t), a = (r = this.Zr) == null ? void 0 : r.get(t);
3613
- n && a != null && a.variants[n] && this.ts(a.name, n, a.variants[n].transforms);
3614
- }
3615
- });
3616
- }
3617
- }
3618
- previewWebExperiment() {
3619
- var e = W.getWindowLocation();
3620
- if (e != null && e.search) {
3621
- var t = Xt(e == null ? void 0 : e.search, "__experiment_id"), i = Xt(e == null ? void 0 : e.search, "__experiment_variant");
3622
- t && i && (W.Qr("previewing web experiments " + t + " && " + i), this.getWebExperiments((r) => {
3623
- this.rs(parseInt(t), i, r);
3624
- }, !1, !0));
3625
- }
3626
- }
3627
- loadIfEnabled() {
3628
- this._instance.config.disable_web_experiments || this.getWebExperimentsAndEvaluateDisplayLogic();
3629
- }
3630
- getWebExperiments(e, t, i) {
3631
- if (this._instance.config.disable_web_experiments && !i) return e([]);
3632
- var r = this._instance.get_property("$web_experiments");
3633
- if (r && !t) return e(r);
3634
- this._instance.me({ url: this._instance.requestRouter.endpointFor("api", "/api/web_experiments/?token=" + this._instance.config.token), method: "GET", callback: (n) => {
3635
- if (n.statusCode !== 200 || !n.json) return e([]);
3636
- var a = n.json.experiments || [];
3637
- return e(a);
3638
- } });
3639
- }
3640
- rs(e, t, i) {
3641
- var r = i.filter((n) => n.id === e);
3642
- r && r.length > 0 && (W.Qr("Previewing web experiment [" + r[0].name + "] with variant [" + t + "]"), this.ts(r[0].name, t, r[0].variants[t].transforms));
3643
- }
3644
- static es(e) {
3645
- return !P(e.conditions) && W.ss(e) && W.ns(e);
3646
- }
3647
- static ss(e) {
3648
- var t;
3649
- if (P(e.conditions) || P((t = e.conditions) == null ? void 0 : t.url)) return !0;
3650
- var i, r, n, a = W.getWindowLocation();
3651
- return !!a && ((i = e.conditions) == null || !i.url || Jo[(r = (n = e.conditions) == null ? void 0 : n.urlMatchType) !== null && r !== void 0 ? r : "icontains"](e.conditions.url, a));
3652
- }
3653
- static getWindowLocation() {
3654
- return g == null ? void 0 : g.location;
3655
- }
3656
- static ns(e) {
3657
- var t;
3658
- if (P(e.conditions) || P((t = e.conditions) == null ? void 0 : t.utm)) return !0;
3659
- var i = En();
3660
- if (i.utm_source) {
3661
- var r, n, a, o, l, u, c, p, h = (r = e.conditions) == null || (r = r.utm) == null || !r.utm_campaign || ((n = e.conditions) == null || (n = n.utm) == null ? void 0 : n.utm_campaign) == i.utm_campaign, d = (a = e.conditions) == null || (a = a.utm) == null || !a.utm_source || ((o = e.conditions) == null || (o = o.utm) == null ? void 0 : o.utm_source) == i.utm_source, v = (l = e.conditions) == null || (l = l.utm) == null || !l.utm_medium || ((u = e.conditions) == null || (u = u.utm) == null ? void 0 : u.utm_medium) == i.utm_medium, f = (c = e.conditions) == null || (c = c.utm) == null || !c.utm_term || ((p = e.conditions) == null || (p = p.utm) == null ? void 0 : p.utm_term) == i.utm_term;
3662
- return h && v && f && d;
3663
- }
3664
- return !1;
3665
- }
3666
- static Qr(e) {
3667
- for (var t = arguments.length, i = new Array(t > 1 ? t - 1 : 0), r = 1; r < t; r++) i[r - 1] = arguments[r];
3668
- w.info("[WebExperiments] " + e, i);
3669
- }
3670
- ts(e, t, i) {
3671
- this._is_bot() ? W.Qr("Refusing to render web experiment since the viewer is a likely bot") : t !== "control" ? i.forEach((r) => {
3672
- if (r.selector) {
3673
- var n;
3674
- W.Qr("applying transform of variant " + t + " for experiment " + e + " ", r);
3675
- var a = (n = document) == null ? void 0 : n.querySelectorAll(r.selector);
3676
- a == null || a.forEach((o) => {
3677
- var l = o;
3678
- r.html && (l.innerHTML = r.html), r.css && l.setAttribute("style", r.css);
3679
- });
3680
- }
3681
- }) : W.Qr("Control variants leave the page unmodified.");
3682
- }
3683
- _is_bot() {
3684
- return ie && this._instance ? Rn(ie, this._instance.config.custom_blocked_useragents) : void 0;
3685
- }
3686
- }
3687
- var St = {}, es = () => {
3688
- }, et = "posthog", Mn = !go && (J == null ? void 0 : J.indexOf("MSIE")) === -1 && (J == null ? void 0 : J.indexOf("Mozilla")) === -1, yr = (s) => {
3689
- var e;
3690
- return { api_host: "https://us.i.posthog.com", ui_host: null, token: "", autocapture: !0, rageclick: !0, cross_subdomain_cookie: zn(y == null ? void 0 : y.location), persistence: "localStorage+cookie", persistence_name: "", loaded: es, save_campaign_params: !0, custom_campaign_params: [], custom_blocked_useragents: [], save_referrer: !0, capture_pageview: s !== "2025-05-24" || "history_change", capture_pageleave: "if_capture_pageview", defaults: s ?? "unset", debug: Z && A(Z == null ? void 0 : Z.search) && Z.search.indexOf("__posthog_debug=true") !== -1 || !1, cookie_expiration: 365, upgrade: !1, disable_session_recording: !1, disable_persistence: !1, disable_web_experiments: !0, disable_surveys: !1, disable_external_dependency_loading: !1, enable_recording_console_log: void 0, secure_cookie: (g == null || (e = g.location) == null ? void 0 : e.protocol) === "https:", ip: !0, opt_out_capturing_by_default: !1, opt_out_persistence_by_default: !1, opt_out_useragent_filter: !1, opt_out_capturing_persistence_type: "localStorage", opt_out_capturing_cookie_prefix: null, opt_in_site_apps: !1, property_denylist: [], respect_dnt: !1, sanitize_properties: null, request_headers: {}, request_batching: !0, properties_string_max_length: 65535, session_recording: {}, mask_all_element_attributes: !1, mask_all_text: !1, mask_personal_data_properties: !1, custom_personal_data_properties: [], advanced_disable_decide: !1, advanced_disable_feature_flags: !1, advanced_disable_feature_flags_on_first_load: !1, advanced_disable_toolbar_metrics: !1, feature_flag_request_timeout_ms: 3e3, surveys_request_timeout_ms: 1e4, on_request_error: (t) => {
3691
- var i = "Bad HTTP status: " + t.statusCode + " " + t.text;
3692
- w.error(i);
3693
- }, get_device_id: (t) => t, capture_performance: void 0, name: "posthog", bootstrap: {}, disable_compression: !1, session_idle_timeout_seconds: 1800, person_profiles: "identified_only", before_send: void 0, request_queue_config: { flush_interval_ms: Qi }, _onCapture: es };
3694
- }, br = (s) => {
3695
- var e = {};
3696
- _(s.process_person) || (e.person_profiles = s.process_person), _(s.xhr_headers) || (e.request_headers = s.xhr_headers), _(s.cookie_name) || (e.persistence_name = s.cookie_name), _(s.disable_cookie) || (e.disable_persistence = s.disable_cookie), _(s.store_google) || (e.save_campaign_params = s.store_google), _(s.verbose) || (e.debug = s.verbose);
3697
- var t = D({}, e, s);
3698
- return C(s.property_blacklist) && (_(s.property_denylist) ? t.property_denylist = s.property_blacklist : C(s.property_denylist) ? t.property_denylist = [...s.property_blacklist, ...s.property_denylist] : w.error("Invalid value for property_denylist config: " + s.property_denylist)), t;
3699
- };
3700
- class Zo {
3701
- constructor() {
3702
- this.__forceAllowLocalhost = !1;
3703
- }
3704
- get os() {
3705
- return this.__forceAllowLocalhost;
3706
- }
3707
- set os(e) {
3708
- w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"), this.__forceAllowLocalhost = e;
3709
- }
3710
- }
3711
- class li {
3712
- get decideEndpointWasHit() {
3713
- var e, t;
3714
- return (e = (t = this.featureFlags) == null ? void 0 : t.hasLoadedFlags) !== null && e !== void 0 && e;
3715
- }
3716
- constructor() {
3717
- this.webPerformance = new Zo(), this.ls = !1, this.version = xe.LIB_VERSION, this.us = new Pn(), this._calculate_event_properties = this.calculateEventProperties.bind(this), this.config = yr(), this.SentryIntegration = so, this.sentryIntegration = (e) => function(t, i) {
3718
- var r = nn(t, i);
3719
- return { name: rn, processEvent: (n) => r(n) };
3720
- }(this, e), this.__request_queue = [], this.__loaded = !1, this.analyticsDefaultEndpoint = "/e/", this.hs = !1, this.ds = null, this.vs = null, this.cs = null, this.featureFlags = new To(this), this.toolbar = new no(this), this.scrollManager = new jo(this), this.pageViewManager = new ho(this), this.surveys = new Lo(this), this.experiments = new W(this), this.exceptions = new _o(this), this.rateLimiter = new Do(this), this.requestRouter = new Yo(this), this.consent = new pa(this), this.people = { set: (e, t, i) => {
3721
- var r = A(e) ? { [e]: t } : e;
3722
- this.setPersonProperties(r), i == null || i({});
3723
- }, set_once: (e, t, i) => {
3724
- var r = A(e) ? { [e]: t } : e;
3725
- this.setPersonProperties(void 0, r), i == null || i({});
3726
- } }, this.on("eventCaptured", (e) => w.info('send "' + (e == null ? void 0 : e.event) + '"', e));
3727
- }
3728
- init(e, t, i) {
3729
- if (i && i !== et) {
3730
- var r, n = (r = St[i]) !== null && r !== void 0 ? r : new li();
3731
- return n._init(e, t, i), St[i] = n, St[et][i] = n, n;
3732
- }
3733
- return this._init(e, t, i);
3734
- }
3735
- _init(e, t, i) {
3736
- var r, n;
3737
- if (t === void 0 && (t = {}), _(e) || Pi(e)) return w.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"), this;
3738
- if (this.__loaded) return w.warn("You have already initialized PostHog! Re-initializing is a no-op"), this;
3739
- this.__loaded = !0, this.config = {}, this.fs = [], t.person_profiles && (this.vs = t.person_profiles), this.set_config(D({}, yr(t.defaults), br(t), { name: i, token: e })), this.config.on_xhr_error && w.error("on_xhr_error is deprecated. Use on_request_error instead"), this.compression = t.disable_compression ? void 0 : Se.GZipJS, this.persistence = new Si(this.config), this.sessionPersistence = this.config.persistence === "sessionStorage" || this.config.persistence === "memory" ? this.persistence : new Si(m({}, this.config, { persistence: "sessionStorage" }));
3740
- var a = m({}, this.persistence.props), o = m({}, this.sessionPersistence.props);
3741
- if (this.ps = new qo((E) => this.gs(E), this.config.request_queue_config), this._s = new Ho(this), this.__request_queue = [], this.config.__preview_experimental_cookieless_mode || (this.sessionManager = new zo(this), this.sessionPropsManager = new Wo(this, this.sessionManager, this.persistence)), new oo(this).startIfEnabledOrStop(), this.siteApps = new Vo(this), (r = this.siteApps) == null || r.init(), this.config.__preview_experimental_cookieless_mode || (this.sessionRecording = new to(this), this.sessionRecording.startIfEnabledOrStop()), this.config.disable_scroll_properties || this.scrollManager.startMeasuringScrollPosition(), this.autocapture = new na(this), this.autocapture.startIfEnabled(), this.surveys.loadIfEnabled(), this.heatmaps = new co(this), this.heatmaps.startIfEnabled(), this.webVitalsAutocapture = new lo(this), this.exceptionObserver = new va(this), this.exceptionObserver.startIfEnabled(), this.deadClicksAutocapture = new Ur(this, fa), this.deadClicksAutocapture.startIfEnabled(), this.historyAutocapture = new Ra(this), this.historyAutocapture.startIfEnabled(), xe.DEBUG = xe.DEBUG || this.config.debug, xe.DEBUG && w.info("Starting in debug mode", { this: this, config: t, thisC: m({}, this.config), p: a, s: o }), this.bs(), ((n = t.bootstrap) == null ? void 0 : n.distinctID) !== void 0) {
3742
- var l, u, c = this.config.get_device_id(Oe()), p = (l = t.bootstrap) != null && l.isIdentifiedID ? c : t.bootstrap.distinctID;
3743
- this.persistence.set_property(Ee, (u = t.bootstrap) != null && u.isIdentifiedID ? "identified" : "anonymous"), this.register({ distinct_id: t.bootstrap.distinctID, $device_id: p });
3744
- }
3745
- if (this.ws()) {
3746
- var h, d, v = Object.keys(((h = t.bootstrap) == null ? void 0 : h.featureFlags) || {}).filter((E) => {
3747
- var k;
3748
- return !((k = t.bootstrap) == null || (k = k.featureFlags) == null || !k[E]);
3749
- }).reduce((E, k) => {
3750
- var S;
3751
- return E[k] = ((S = t.bootstrap) == null || (S = S.featureFlags) == null ? void 0 : S[k]) || !1, E;
3752
- }, {}), f = Object.keys(((d = t.bootstrap) == null ? void 0 : d.featureFlagPayloads) || {}).filter((E) => v[E]).reduce((E, k) => {
3753
- var S, $;
3754
- return (S = t.bootstrap) != null && (S = S.featureFlagPayloads) != null && S[k] && (E[k] = ($ = t.bootstrap) == null || ($ = $.featureFlagPayloads) == null ? void 0 : $[k]), E;
3755
- }, {});
3756
- this.featureFlags.receivedFeatureFlags({ featureFlags: v, featureFlagPayloads: f });
3757
- }
3758
- if (this.config.__preview_experimental_cookieless_mode) this.register_once({ distinct_id: As, $device_id: null }, "");
3759
- else if (!this.get_distinct_id()) {
3760
- var b = this.config.get_device_id(Oe());
3761
- this.register_once({ distinct_id: b, $device_id: b }, ""), this.persistence.set_property(Ee, "anonymous");
3762
- }
3763
- return T(g, "onpagehide" in self ? "pagehide" : "unload", this._handle_unload.bind(this), { passive: !1 }), this.toolbar.maybeLoadToolbar(), t.segment ? io(this, () => this.ys()) : this.ys(), ae(this.config._onCapture) && this.config._onCapture !== es && (w.warn("onCapture is deprecated. Please use `before_send` instead"), this.on("eventCaptured", (E) => this.config._onCapture(E.event, E))), this;
3764
- }
3765
- be(e) {
3766
- var t, i, r, n, a, o, l, u;
3767
- if (!y || !y.body) return w.info("document not ready yet, trying again in 500 milliseconds..."), void setTimeout(() => {
3768
- this.be(e);
3769
- }, 500);
3770
- this.compression = void 0, e.supportedCompression && !this.config.disable_compression && (this.compression = I(e.supportedCompression, Se.GZipJS) ? Se.GZipJS : I(e.supportedCompression, Se.Base64) ? Se.Base64 : void 0), (t = e.analytics) != null && t.endpoint && (this.analyticsDefaultEndpoint = e.analytics.endpoint), this.set_config({ person_profiles: this.vs ? this.vs : "identified_only" }), (i = this.siteApps) == null || i.onRemoteConfig(e), (r = this.sessionRecording) == null || r.onRemoteConfig(e), (n = this.autocapture) == null || n.onRemoteConfig(e), (a = this.heatmaps) == null || a.onRemoteConfig(e), this.surveys.onRemoteConfig(e), (o = this.webVitalsAutocapture) == null || o.onRemoteConfig(e), (l = this.exceptionObserver) == null || l.onRemoteConfig(e), this.exceptions.onRemoteConfig(e), (u = this.deadClicksAutocapture) == null || u.onRemoteConfig(e);
3771
- }
3772
- ys() {
3773
- try {
3774
- this.config.loaded(this);
3775
- } catch (e) {
3776
- w.critical("`loaded` function failed", e);
3777
- }
3778
- this.Ss(), this.config.capture_pageview && setTimeout(() => {
3779
- this.consent.isOptedIn() && this.$s();
3780
- }, 1), new No(this).load(), this.featureFlags.decide();
3781
- }
3782
- Ss() {
3783
- var e;
3784
- this.has_opted_out_capturing() || this.config.request_batching && ((e = this.ps) == null || e.enable());
3785
- }
3786
- _dom_loaded() {
3787
- this.has_opted_out_capturing() || Ae(this.__request_queue, (e) => this.gs(e)), this.__request_queue = [], this.Ss();
3788
- }
3789
- _handle_unload() {
3790
- var e, t;
3791
- this.config.request_batching ? (this.ks() && this.capture("$pageleave"), (e = this.ps) == null || e.unload(), (t = this._s) == null || t.unload()) : this.ks() && this.capture("$pageleave", null, { transport: "sendBeacon" });
3792
- }
3793
- me(e) {
3794
- this.__loaded && (Mn ? this.__request_queue.push(e) : this.rateLimiter.isServerRateLimited(e.batchKey) || (e.transport = e.transport || this.config.api_transport, e.url = ei(e.url, { ip: this.config.ip ? 1 : 0 }), e.headers = m({}, this.config.request_headers), e.compression = e.compression === "best-available" ? this.compression : e.compression, e.fetchOptions = e.fetchOptions || this.config.fetch_options, ((t) => {
3795
- var i, r, n, a = m({}, t);
3796
- a.timeout = a.timeout || 6e4, a.url = ei(a.url, { _: (/* @__PURE__ */ new Date()).getTime().toString(), ver: xe.LIB_VERSION, compression: a.compression });
3797
- var o = (i = a.transport) !== null && i !== void 0 ? i : "fetch", l = (r = (n = Fr(xt, (u) => u.transport === o)) == null ? void 0 : n.method) !== null && r !== void 0 ? r : xt[0].method;
3798
- if (!l) throw new Error("No available transport method");
3799
- l(a);
3800
- })(m({}, e, { callback: (t) => {
3801
- var i, r;
3802
- this.rateLimiter.checkForLimiting(t), t.statusCode >= 400 && ((i = (r = this.config).on_request_error) == null || i.call(r, t)), e.callback == null || e.callback(t);
3803
- } }))));
3804
- }
3805
- gs(e) {
3806
- this._s ? this._s.retriableRequest(e) : this.me(e);
3807
- }
3808
- _execute_array(e) {
3809
- var t, i = [], r = [], n = [];
3810
- Ae(e, (o) => {
3811
- o && (t = o[0], C(t) ? n.push(o) : ae(o) ? o.call(this) : C(o) && t === "alias" ? i.push(o) : C(o) && t.indexOf("capture") !== -1 && ae(this[t]) ? n.push(o) : r.push(o));
3812
- });
3813
- var a = function(o, l) {
3814
- Ae(o, function(u) {
3815
- if (C(u[0])) {
3816
- var c = l;
3817
- R(u, function(p) {
3818
- c = c[p[0]].apply(c, p.slice(1));
3819
- });
3820
- } else this[u[0]].apply(this, u.slice(1));
3821
- }, l);
3822
- };
3823
- a(i, this), a(r, this), a(n, this);
3824
- }
3825
- ws() {
3826
- var e, t;
3827
- return ((e = this.config.bootstrap) == null ? void 0 : e.featureFlags) && Object.keys((t = this.config.bootstrap) == null ? void 0 : t.featureFlags).length > 0 || !1;
3828
- }
3829
- push(e) {
3830
- this._execute_array([e]);
3831
- }
3832
- capture(e, t, i) {
3833
- var r;
3834
- if (this.__loaded && this.persistence && this.sessionPersistence && this.ps) {
3835
- if (!this.consent.isOptedOut()) if (!_(e) && A(e)) {
3836
- if (this.config.opt_out_useragent_filter || !this._is_bot()) {
3837
- var n = i != null && i.skip_client_rate_limiting ? void 0 : this.rateLimiter.clientRateLimitContext();
3838
- if (n == null || !n.isRateLimited) {
3839
- t != null && t.$current_url && !A(t == null ? void 0 : t.$current_url) && (w.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."), t == null || delete t.$current_url), this.sessionPersistence.update_search_keyword(), this.config.save_campaign_params && this.sessionPersistence.update_campaign_params(), this.config.save_referrer && this.sessionPersistence.update_referrer_info(), (this.config.save_campaign_params || this.config.save_referrer) && this.persistence.set_initial_person_info();
3840
- var a = /* @__PURE__ */ new Date(), o = (i == null ? void 0 : i.timestamp) || a, l = Oe(), u = { uuid: l, event: e, properties: this.calculateEventProperties(e, t || {}, o, l) };
3841
- n && (u.properties.$lib_rate_limit_remaining_tokens = n.remainingTokens), i != null && i.$set && (u.$set = i == null ? void 0 : i.$set);
3842
- var c = this.xs(i == null ? void 0 : i.$set_once);
3843
- c && (u.$set_once = c), (u = Un(u, i != null && i._noTruncate ? null : this.config.properties_string_max_length)).timestamp = o, _(i == null ? void 0 : i.timestamp) || (u.properties.$event_time_override_provided = !0, u.properties.$event_time_override_system_time = a);
3844
- var p = m({}, u.properties.$set, u.$set);
3845
- if (tt(p) || this.setPersonPropertiesForFlags(p), !P(this.config.before_send)) {
3846
- var h = this.Es(u);
3847
- if (!h) return;
3848
- u = h;
3849
- }
3850
- this.us.emit("eventCaptured", u);
3851
- var d = { method: "POST", url: (r = i == null ? void 0 : i._url) !== null && r !== void 0 ? r : this.requestRouter.endpointFor("api", this.analyticsDefaultEndpoint), data: u, compression: "best-available", batchKey: i == null ? void 0 : i._batchKey };
3852
- return !this.config.request_batching || i && (i == null || !i._batchKey) || i != null && i.send_instantly ? this.gs(d) : this.ps.enqueue(d), u;
3853
- }
3854
- w.critical("This capture call is ignored due to client rate limiting.");
3855
- }
3856
- } else w.error("No event name provided to posthog.capture");
3857
- } else w.uninitializedWarning("posthog.capture");
3858
- }
3859
- Ne(e) {
3860
- return this.on("eventCaptured", (t) => e(t.event, t));
3861
- }
3862
- calculateEventProperties(e, t, i, r, n) {
3863
- if (i = i || /* @__PURE__ */ new Date(), !this.persistence || !this.sessionPersistence) return t;
3864
- var a = n ? void 0 : this.persistence.remove_event_timer(e), o = m({}, t);
3865
- if (o.token = this.config.token, o.$config_defaults = this.config.defaults, this.config.__preview_experimental_cookieless_mode && (o.$cookieless_mode = !0), e === "$snapshot") {
3866
- var l = m({}, this.persistence.properties(), this.sessionPersistence.properties());
3867
- return o.distinct_id = l.distinct_id, (!A(o.distinct_id) && !z(o.distinct_id) || Pi(o.distinct_id)) && w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"), o;
3868
- }
3869
- var u, c = Ro(this.config.mask_personal_data_properties, this.config.custom_personal_data_properties);
3870
- if (this.sessionManager) {
3871
- var { sessionId: p, windowId: h } = this.sessionManager.checkAndGetSessionAndWindowId(n, i.getTime());
3872
- o.$session_id = p, o.$window_id = h;
3873
- }
3874
- this.sessionPropsManager && D(o, this.sessionPropsManager.getSessionProps());
3875
- try {
3876
- var d;
3877
- this.sessionRecording && D(o, this.sessionRecording.sdkDebugProperties), o.$sdk_debug_retry_queue_size = (d = this._s) == null ? void 0 : d.length;
3878
- } catch (E) {
3879
- o.$sdk_debug_error_capturing_properties = String(E);
3880
- }
3881
- if (this.requestRouter.region === Et.CUSTOM && (o.$lib_custom_api_host = this.config.api_host), u = e !== "$pageview" || n ? e !== "$pageleave" || n ? this.pageViewManager.doEvent() : this.pageViewManager.doPageLeave(i) : this.pageViewManager.doPageView(i, r), o = D(o, u), e === "$pageview" && y && (o.title = y.title), !_(a)) {
3882
- var v = i.getTime() - a;
3883
- o.$duration = parseFloat((v / 1e3).toFixed(3));
3884
- }
3885
- J && this.config.opt_out_useragent_filter && (o.$browser_type = this._is_bot() ? "bot" : "browser"), (o = D({}, c, this.persistence.properties(), this.sessionPersistence.properties(), o)).$is_identified = this._isIdentified(), C(this.config.property_denylist) ? R(this.config.property_denylist, function(E) {
3886
- delete o[E];
3887
- }) : w.error("Invalid value for property_denylist config: " + this.config.property_denylist + " or property_blacklist config: " + this.config.property_blacklist);
3888
- var f = this.config.sanitize_properties;
3889
- f && (w.error("sanitize_properties is deprecated. Use before_send instead"), o = f(o, e));
3890
- var b = this.Is();
3891
- return o.$process_person_profile = b, b && !n && this.Ps("_calculate_event_properties"), o;
3892
- }
3893
- xs(e) {
3894
- var t;
3895
- if (!this.persistence || !this.Is() || this.ls) return e;
3896
- var i = this.persistence.get_initial_props(), r = (t = this.sessionPropsManager) == null ? void 0 : t.getSetOnceProps(), n = D({}, i, r || {}, e || {}), a = this.config.sanitize_properties;
3897
- return a && (w.error("sanitize_properties is deprecated. Use before_send instead"), n = a(n, "$set_once")), this.ls = !0, tt(n) ? void 0 : n;
3898
- }
3899
- register(e, t) {
3900
- var i;
3901
- (i = this.persistence) == null || i.register(e, t);
3902
- }
3903
- register_once(e, t, i) {
3904
- var r;
3905
- (r = this.persistence) == null || r.register_once(e, t, i);
3906
- }
3907
- register_for_session(e) {
3908
- var t;
3909
- (t = this.sessionPersistence) == null || t.register(e);
3910
- }
3911
- unregister(e) {
3912
- var t;
3913
- (t = this.persistence) == null || t.unregister(e);
3914
- }
3915
- unregister_for_session(e) {
3916
- var t;
3917
- (t = this.sessionPersistence) == null || t.unregister(e);
3918
- }
3919
- Rs(e, t) {
3920
- this.register({ [e]: t });
3921
- }
3922
- getFeatureFlag(e, t) {
3923
- return this.featureFlags.getFeatureFlag(e, t);
3924
- }
3925
- getFeatureFlagPayload(e) {
3926
- var t = this.featureFlags.getFeatureFlagPayload(e);
3927
- try {
3928
- return JSON.parse(t);
3929
- } catch {
3930
- return t;
3931
- }
3932
- }
3933
- isFeatureEnabled(e, t) {
3934
- return this.featureFlags.isFeatureEnabled(e, t);
3935
- }
3936
- reloadFeatureFlags() {
3937
- this.featureFlags.reloadFeatureFlags();
3938
- }
3939
- updateEarlyAccessFeatureEnrollment(e, t) {
3940
- this.featureFlags.updateEarlyAccessFeatureEnrollment(e, t);
3941
- }
3942
- getEarlyAccessFeatures(e, t, i) {
3943
- return t === void 0 && (t = !1), this.featureFlags.getEarlyAccessFeatures(e, t, i);
3944
- }
3945
- on(e, t) {
3946
- return this.us.on(e, t);
3947
- }
3948
- onFeatureFlags(e) {
3949
- return this.featureFlags.onFeatureFlags(e);
3950
- }
3951
- onSurveysLoaded(e) {
3952
- return this.surveys.onSurveysLoaded(e);
3953
- }
3954
- onSessionId(e) {
3955
- var t, i;
3956
- return (t = (i = this.sessionManager) == null ? void 0 : i.onSessionId(e)) !== null && t !== void 0 ? t : () => {
3957
- };
3958
- }
3959
- getSurveys(e, t) {
3960
- t === void 0 && (t = !1), this.surveys.getSurveys(e, t);
3961
- }
3962
- getActiveMatchingSurveys(e, t) {
3963
- t === void 0 && (t = !1), this.surveys.getActiveMatchingSurveys(e, t);
3964
- }
3965
- renderSurvey(e, t) {
3966
- this.surveys.renderSurvey(e, t);
3967
- }
3968
- canRenderSurvey(e) {
3969
- return this.surveys.canRenderSurvey(e);
3970
- }
3971
- canRenderSurveyAsync(e, t) {
3972
- return t === void 0 && (t = !1), this.surveys.canRenderSurveyAsync(e, t);
3973
- }
3974
- identify(e, t, i) {
3975
- if (!this.__loaded || !this.persistence) return w.uninitializedWarning("posthog.identify");
3976
- if (z(e) && (e = e.toString(), w.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")), e) {
3977
- if (["distinct_id", "distinctid"].includes(e.toLowerCase())) w.critical('The string "' + e + '" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');
3978
- else if (this.Ps("posthog.identify")) {
3979
- var r = this.get_distinct_id();
3980
- if (this.register({ $user_id: e }), !this.get_property("$device_id")) {
3981
- var n = r;
3982
- this.register_once({ $had_persisted_distinct_id: !0, $device_id: n }, "");
3983
- }
3984
- e !== r && e !== this.get_property(ft) && (this.unregister(ft), this.register({ distinct_id: e }));
3985
- var a = (this.persistence.get_property(Ee) || "anonymous") === "anonymous";
3986
- e !== r && a ? (this.persistence.set_property(Ee, "identified"), this.setPersonPropertiesForFlags(m({}, i || {}, t || {}), !1), this.capture("$identify", { distinct_id: e, $anon_distinct_id: r }, { $set: t || {}, $set_once: i || {} }), this.cs = or(e, t, i), this.featureFlags.setAnonymousDistinctId(r)) : (t || i) && this.setPersonProperties(t, i), e !== r && (this.reloadFeatureFlags(), this.unregister(Wt));
3987
- }
3988
- } else w.error("Unique user id has not been set in posthog.identify");
3989
- }
3990
- setPersonProperties(e, t) {
3991
- if ((e || t) && this.Ps("posthog.setPersonProperties")) {
3992
- var i = or(this.get_distinct_id(), e, t);
3993
- this.cs !== i ? (this.setPersonPropertiesForFlags(m({}, t || {}, e || {})), this.capture("$set", { $set: e || {}, $set_once: t || {} }), this.cs = i) : w.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.");
3994
- }
3995
- }
3996
- group(e, t, i) {
3997
- if (e && t) {
3998
- if (this.Ps("posthog.group")) {
3999
- var r = this.getGroups();
4000
- r[e] !== t && this.resetGroupPropertiesForFlags(e), this.register({ $groups: m({}, r, { [e]: t }) }), i && (this.capture("$groupidentify", { $group_type: e, $group_key: t, $group_set: i }), this.setGroupPropertiesForFlags({ [e]: i })), r[e] === t || i || this.reloadFeatureFlags();
4001
- }
4002
- } else w.error("posthog.group requires a group type and group key");
4003
- }
4004
- resetGroups() {
4005
- this.register({ $groups: {} }), this.resetGroupPropertiesForFlags(), this.reloadFeatureFlags();
4006
- }
4007
- setPersonPropertiesForFlags(e, t) {
4008
- t === void 0 && (t = !0), this.featureFlags.setPersonPropertiesForFlags(e, t);
4009
- }
4010
- resetPersonPropertiesForFlags() {
4011
- this.featureFlags.resetPersonPropertiesForFlags();
4012
- }
4013
- setGroupPropertiesForFlags(e, t) {
4014
- t === void 0 && (t = !0), this.Ps("posthog.setGroupPropertiesForFlags") && this.featureFlags.setGroupPropertiesForFlags(e, t);
4015
- }
4016
- resetGroupPropertiesForFlags(e) {
4017
- this.featureFlags.resetGroupPropertiesForFlags(e);
4018
- }
4019
- reset(e) {
4020
- var t, i, r, n;
4021
- if (w.info("reset"), !this.__loaded) return w.uninitializedWarning("posthog.reset");
4022
- var a = this.get_property("$device_id");
4023
- if (this.consent.reset(), (t = this.persistence) == null || t.clear(), (i = this.sessionPersistence) == null || i.clear(), this.surveys.reset(), (r = this.persistence) == null || r.set_property(Ee, "anonymous"), (n = this.sessionManager) == null || n.resetSessionId(), this.cs = null, this.config.__preview_experimental_cookieless_mode) this.register_once({ distinct_id: As, $device_id: null }, "");
4024
- else {
4025
- var o = this.config.get_device_id(Oe());
4026
- this.register_once({ distinct_id: o, $device_id: e ? o : a }, "");
4027
- }
4028
- this.register({ $last_posthog_reset: (/* @__PURE__ */ new Date()).toISOString() }, 1);
4029
- }
4030
- get_distinct_id() {
4031
- return this.get_property("distinct_id");
4032
- }
4033
- getGroups() {
4034
- return this.get_property("$groups") || {};
4035
- }
4036
- get_session_id() {
4037
- var e, t;
4038
- return (e = (t = this.sessionManager) == null ? void 0 : t.checkAndGetSessionAndWindowId(!0).sessionId) !== null && e !== void 0 ? e : "";
4039
- }
4040
- get_session_replay_url(e) {
4041
- if (!this.sessionManager) return "";
4042
- var { sessionId: t, sessionStartTimestamp: i } = this.sessionManager.checkAndGetSessionAndWindowId(!0), r = this.requestRouter.endpointFor("ui", "/project/" + this.config.token + "/replay/" + t);
4043
- if (e != null && e.withTimestamp && i) {
4044
- var n, a = (n = e.timestampLookBack) !== null && n !== void 0 ? n : 10;
4045
- if (!i) return r;
4046
- r += "?t=" + Math.max(Math.floor(((/* @__PURE__ */ new Date()).getTime() - i) / 1e3) - a, 0);
4047
- }
4048
- return r;
4049
- }
4050
- alias(e, t) {
4051
- return e === this.get_property($r) ? (w.critical("Attempting to create alias for existing People user - aborting."), -2) : this.Ps("posthog.alias") ? (_(t) && (t = this.get_distinct_id()), e !== t ? (this.Rs(ft, e), this.capture("$create_alias", { alias: e, distinct_id: t })) : (w.warn("alias matches current distinct_id - skipping api call."), this.identify(e), -1)) : void 0;
4052
- }
4053
- set_config(e) {
4054
- var t, i, r, n, a = m({}, this.config);
4055
- O(e) && (D(this.config, br(e)), (t = this.persistence) == null || t.update_config(this.config, a), this.sessionPersistence = this.config.persistence === "sessionStorage" || this.config.persistence === "memory" ? this.persistence : new Si(m({}, this.config, { persistence: "sessionStorage" })), q.O() && q.A("ph_debug") === "true" && (this.config.debug = !0), this.config.debug && (xe.DEBUG = !0, w.info("set_config", JSON.stringify({ config: e, oldConfig: a, newConfig: m({}, this.config) }, null, 2))), (i = this.sessionRecording) == null || i.startIfEnabledOrStop(), (r = this.autocapture) == null || r.startIfEnabled(), (n = this.heatmaps) == null || n.startIfEnabled(), this.surveys.loadIfEnabled(), this.bs());
4056
- }
4057
- startSessionRecording(e) {
4058
- var t = e === !0, i = { sampling: t || !(e == null || !e.sampling), linked_flag: t || !(e == null || !e.linked_flag), url_trigger: t || !(e == null || !e.url_trigger), event_trigger: t || !(e == null || !e.event_trigger) };
4059
- if (Object.values(i).some(Boolean)) {
4060
- var r, n, a, o, l;
4061
- (r = this.sessionManager) == null || r.checkAndGetSessionAndWindowId(), i.sampling && ((n = this.sessionRecording) == null || n.overrideSampling()), i.linked_flag && ((a = this.sessionRecording) == null || a.overrideLinkedFlag()), i.url_trigger && ((o = this.sessionRecording) == null || o.overrideTrigger("url")), i.event_trigger && ((l = this.sessionRecording) == null || l.overrideTrigger("event"));
4062
- }
4063
- this.set_config({ disable_session_recording: !1 });
4064
- }
4065
- stopSessionRecording() {
4066
- this.set_config({ disable_session_recording: !0 });
4067
- }
4068
- sessionRecordingStarted() {
4069
- var e;
4070
- return !((e = this.sessionRecording) == null || !e.started);
4071
- }
4072
- captureException(e, t) {
4073
- var i = new Error("PostHog syntheticException");
4074
- this.exceptions.sendExceptionEvent(m({}, Pa(((r) => r instanceof Error)(e) ? { error: e, event: e.message } : { event: e }, { syntheticException: i }), t));
4075
- }
4076
- loadToolbar(e) {
4077
- return this.toolbar.loadToolbar(e);
4078
- }
4079
- get_property(e) {
4080
- var t;
4081
- return (t = this.persistence) == null ? void 0 : t.props[e];
4082
- }
4083
- getSessionProperty(e) {
4084
- var t;
4085
- return (t = this.sessionPersistence) == null ? void 0 : t.props[e];
4086
- }
4087
- toString() {
4088
- var e, t = (e = this.config.name) !== null && e !== void 0 ? e : et;
4089
- return t !== et && (t = et + "." + t), t;
4090
- }
4091
- _isIdentified() {
4092
- var e, t;
4093
- return ((e = this.persistence) == null ? void 0 : e.get_property(Ee)) === "identified" || ((t = this.sessionPersistence) == null ? void 0 : t.get_property(Ee)) === "identified";
4094
- }
4095
- Is() {
4096
- var e, t;
4097
- return !(this.config.person_profiles === "never" || this.config.person_profiles === "identified_only" && !this._isIdentified() && tt(this.getGroups()) && ((e = this.persistence) == null || (e = e.props) == null || !e[ft]) && ((t = this.persistence) == null || (t = t.props) == null || !t[Gt]));
4098
- }
4099
- ks() {
4100
- return this.config.capture_pageleave === !0 || this.config.capture_pageleave === "if_capture_pageview" && (this.config.capture_pageview === !0 || this.config.capture_pageview === "history_change");
4101
- }
4102
- createPersonProfile() {
4103
- this.Is() || this.Ps("posthog.createPersonProfile") && this.setPersonProperties({}, {});
4104
- }
4105
- Ps(e) {
4106
- return this.config.person_profiles === "never" ? (w.error(e + ' was called, but process_person is set to "never". This call will be ignored.'), !1) : (this.Rs(Gt, !0), !0);
4107
- }
4108
- bs() {
4109
- var e, t, i, r, n = this.consent.isOptedOut(), a = this.config.opt_out_persistence_by_default, o = this.config.disable_persistence || n && !!a;
4110
- ((e = this.persistence) == null ? void 0 : e.xe) !== o && ((i = this.persistence) == null || i.set_disabled(o)), ((t = this.sessionPersistence) == null ? void 0 : t.xe) !== o && ((r = this.sessionPersistence) == null || r.set_disabled(o));
4111
- }
4112
- opt_in_capturing(e) {
4113
- var t;
4114
- this.consent.optInOut(!0), this.bs(), (_(e == null ? void 0 : e.captureEventName) || e != null && e.captureEventName) && this.capture((t = e == null ? void 0 : e.captureEventName) !== null && t !== void 0 ? t : "$opt_in", e == null ? void 0 : e.captureProperties, { send_instantly: !0 }), this.config.capture_pageview && this.$s();
4115
- }
4116
- opt_out_capturing() {
4117
- this.consent.optInOut(!1), this.bs();
4118
- }
4119
- has_opted_in_capturing() {
4120
- return this.consent.isOptedIn();
4121
- }
4122
- has_opted_out_capturing() {
4123
- return this.consent.isOptedOut();
4124
- }
4125
- clear_opt_in_out_capturing() {
4126
- this.consent.reset(), this.bs();
4127
- }
4128
- _is_bot() {
4129
- return ie ? Rn(ie, this.config.custom_blocked_useragents) : void 0;
4130
- }
4131
- $s() {
4132
- y && (y.visibilityState === "visible" ? this.hs || (this.hs = !0, this.capture("$pageview", { title: y.title }, { send_instantly: !0 }), this.ds && (y.removeEventListener("visibilitychange", this.ds), this.ds = null)) : this.ds || (this.ds = this.$s.bind(this), T(y, "visibilitychange", this.ds)));
4133
- }
4134
- debug(e) {
4135
- e === !1 ? (g == null || g.console.log("You've disabled debug mode."), localStorage && localStorage.removeItem("ph_debug"), this.set_config({ debug: !1 })) : (g == null || g.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."), localStorage && localStorage.setItem("ph_debug", "true"), this.set_config({ debug: !0 }));
4136
- }
4137
- Es(e) {
4138
- if (P(this.config.before_send)) return e;
4139
- var t = C(this.config.before_send) ? this.config.before_send : [this.config.before_send], i = e;
4140
- for (var r of t) {
4141
- if (i = r(i), P(i)) {
4142
- var n = "Event '" + e.event + "' was rejected in beforeSend function";
4143
- return Bn(e.event) ? w.warn(n + ". This can cause unexpected behavior.") : w.info(n), null;
4144
- }
4145
- i.properties && !tt(i.properties) || w.warn("Event '" + e.event + "' has no properties after beforeSend function, this is likely an error.");
4146
- }
4147
- return i;
4148
- }
4149
- getPageViewId() {
4150
- var e;
4151
- return (e = this.pageViewManager.ne) == null ? void 0 : e.pageViewId;
4152
- }
4153
- captureTraceFeedback(e, t) {
4154
- this.capture("$ai_feedback", { $ai_trace_id: String(e), $ai_feedback_text: t });
4155
- }
4156
- captureTraceMetric(e, t, i) {
4157
- this.capture("$ai_metric", { $ai_trace_id: String(e), $ai_metric_name: t, $ai_metric_value: String(i) });
4158
- }
4159
- }
4160
- (function(s, e) {
4161
- for (var t = 0; t < e.length; t++) s.prototype[e[t]] = jn(s.prototype[e[t]]);
4162
- })(li, ["identify"]);
4163
- var wr;
4164
- (function(s) {
4165
- return s.Button = "button", s.Tab = "tab", s.Selector = "selector", s;
4166
- })({});
4167
- (function(s) {
4168
- return s.TopLeft = "top_left", s.TopRight = "top_right", s.TopCenter = "top_center", s.MiddleLeft = "middle_left", s.MiddleRight = "middle_right", s.MiddleCenter = "middle_center", s.Left = "left", s.Center = "center", s.Right = "right", s.NextToTrigger = "next_to_trigger", s;
4169
- })({});
4170
- (function(s) {
4171
- return s.Popover = "popover", s.API = "api", s.Widget = "widget", s;
4172
- })({});
4173
- (function(s) {
4174
- return s.Open = "open", s.MultipleChoice = "multiple_choice", s.SingleChoice = "single_choice", s.Rating = "rating", s.Link = "link", s;
4175
- })({});
4176
- (function(s) {
4177
- return s.NextQuestion = "next_question", s.End = "end", s.ResponseBased = "response_based", s.SpecificQuestion = "specific_question", s;
4178
- })({});
4179
- (function(s) {
4180
- return s.Once = "once", s.Recurring = "recurring", s.Always = "always", s;
4181
- })({});
4182
- var Ko = (wr = St[et] = new li(), function() {
4183
- function s() {
4184
- s.done || (s.done = !0, Mn = !1, R(St, function(e) {
4185
- e._dom_loaded();
4186
- }));
4187
- }
4188
- y != null && y.addEventListener ? y.readyState === "complete" ? s() : T(y, "DOMContentLoaded", s, { capture: !1 }) : g && w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized");
4189
- }(), wr);
4190
- export {
4191
- hi as COPY_AUTOCAPTURE_EVENT,
4192
- Se as Compression,
4193
- li as PostHog,
4194
- Ko as default,
4195
- Ln as knownUnsafeEditableEvent,
4196
- Ko as posthog,
4197
- Dn as severityLevels
4198
- };