@cimulate/copilot-widget 1.58.0 → 1.58.1

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.
@@ -0,0 +1,1979 @@
1
+ var Ce = Object.defineProperty;
2
+ var K = Object.getOwnPropertySymbols;
3
+ var Ie = Object.prototype.hasOwnProperty, Ae = Object.prototype.propertyIsEnumerable;
4
+ var Y = (l, e, t) => e in l ? Ce(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t, W = (l, e) => {
5
+ for (var t in e || (e = {}))
6
+ Ie.call(e, t) && Y(l, t, e[t]);
7
+ if (K)
8
+ for (var t of K(e))
9
+ Ae.call(e, t) && Y(l, t, e[t]);
10
+ return l;
11
+ };
12
+ var B = (l, e, t) => new Promise((r, i) => {
13
+ var s = (u) => {
14
+ try {
15
+ a(t.next(u));
16
+ } catch (h) {
17
+ i(h);
18
+ }
19
+ }, n = (u) => {
20
+ try {
21
+ a(t.throw(u));
22
+ } catch (h) {
23
+ i(h);
24
+ }
25
+ }, a = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(s, n);
26
+ a((t = t.apply(l, e)).next());
27
+ });
28
+ import { s as A, u as o, c as x, p as L, m as k, U as ne, P as oe, a as Se } from "./shared-v_qZLEbr.js";
29
+ const Ee = { namespace: "sf.instrumentation", name: "PayloadDiags", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { PayloadDiags: { fields: { extras: { rule: "repeated", id: 1, type: "string" } } } } } } } } } }, ke = { namespace: "sf.instrumentation", name: "IdleDetectorReport", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { IdleDetectorReport: { fields: { listenerCount: { id: 3, type: "uint32" }, busyTasks: { rule: "repeated", id: 5, type: "string" }, busyDurations: { rule: "repeated", id: 6, type: "double" }, pollableCount: { id: 4, type: "uint32" }, pollCounts: { rule: "repeated", id: 8, type: "double" }, logThreshold: { id: 2, type: "double" }, maxDuration: {
30
+ id: 1,
31
+ type: "double"
32
+ }, pollables: { rule: "repeated", id: 7, type: "string" } } } } } } } } } }, we = { namespace: "sf.instrumentation", name: "InstrumentedEvent", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { MouseEvent: { reserved: [[6, 6], [7, 7], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22]], fields: {
33
+ cancelable: { id: 5, type: "bool" },
34
+ ctrlKey: { id: 9, type: "bool" },
35
+ type: { id: 25, type: "string" },
36
+ button: { id: 3, type: "uint32" },
37
+ offsetX: { id: 30, type: "double" },
38
+ eventPhase: { id: 12, type: "uint32" },
39
+ shiftKey: { id: 23, type: "bool" },
40
+ offsetY: { id: 31, type: "double" },
41
+ composed: { id: 8, type: "bool" },
42
+ altKey: { id: 1, type: "bool" },
43
+ isTrusted: { id: 13, type: "bool" },
44
+ buttons: { id: 4, type: "uint32" },
45
+ movementY: { id: 29, type: "double" },
46
+ clientY: { id: 27, type: "double" },
47
+ clientX: { id: 26, type: "double" },
48
+ movementX: { id: 28, type: "double" },
49
+ defaultPrevented: { id: 10, type: "bool" },
50
+ metaKey: { id: 14, type: "bool" },
51
+ timeStamp: { id: 24, type: "double" },
52
+ bubbles: { id: 2, type: "bool" },
53
+ detail: { id: 11, type: "int64" },
54
+ pageY: { id: 33, type: "double" },
55
+ pageX: { id: 32, type: "double" },
56
+ screenX: { id: 34, type: "double" },
57
+ screenY: { id: 35, type: "double" }
58
+ } }, Event: { fields: { type: { id: 1, type: "string" } } }, InstrumentedEvent: { oneofs: { event: { oneof: ["mouseEvent", "baseEvent"] } }, reserved: [[4, 4], "xpath", [6, 6], [8, 8]], fields: {
59
+ mouseEvent: { id: 7, type: "MouseEvent" },
60
+ auto: { id: 3, type: "bool" },
61
+ parentComponent: { id: 2, type: "string" },
62
+ baseEvent: { id: 10, type: "Event" },
63
+ ownerComponent: { id: 1, type: "string" },
64
+ userPayload: { id: 5, type: "Payload" },
65
+ simplePath: { id: 9, type: "string" }
66
+ } }, Payload: { fields: { payload: { id: 2, type: "bytes" }, schemaName: { id: 1, type: "string" } } } } } } } } } }, Re = { namespace: "sf.instrumentation", name: "Network", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { Network: { fields: { mtd: { id: 1, type: "string" }, url: { id: 2, type: "string" } } } } } } } } } }, Pe = { namespace: "sf.instrumentation", name: "Activity", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { Activity: { reserved: [[5, 5], [7, 7]], fields: { stopReason: { id: 6, type: "string" }, externalParentId: { id: 17, type: "string" }, isRoot: { id: 8, type: "bool" }, isExternal: { id: 16, type: "bool" }, isSampled: { id: 11, type: "bool" }, preRootId: { id: 9, type: "string" }, parentId: { id: 13, type: "string" }, duration: { id: 3, type: "double" }, timerOverridden: {
67
+ id: 12,
68
+ type: "uint32"
69
+ }, isRerooted: { id: 15, type: "bool" }, name: { options: { "(meta.max_length)": 25 }, id: 2, type: "string" }, traceIdSource: { id: 14, type: "string" }, id: { id: 1, type: "string" }, userPayload: { id: 4, type: "Payload" }, errorCount: { id: 10, type: "uint32" } } }, Payload: { fields: { payload: { id: 2, type: "bytes" }, schemaName: { id: 1, type: "string" } } } } } } } } } }, Q = { namespace: "sf.instrumentation", name: "Simple", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { Simple: { fields: { text: { options: { "(meta.max_length)": 25 }, id: 1, type: "string" } } } } } } } } } }, xe = { namespace: "sf.instrumentation", name: "Error", pbjsSchema: { nested: { sf: { nested: { instrumentation: { nested: { Error: { reserved: [[5, 5], [7, 7]], fields: { activityId: { id: 6, type: "string" }, stack: { id: 3, type: "string" }, name: { id: 1, type: "string" }, message: { options: { "(meta.max_length)": 200 }, id: 2, type: "string" }, userPayload: { id: 4, type: "Payload" } } }, Payload: { fields: { payload: { id: 2, type: "bytes" }, schemaName: { id: 1, type: "string" } } } } } } } } } }, Te = /* @__PURE__ */ Symbol("o11y.stampTenantClass");
70
+ class Oe {
71
+ get isBusy() {
72
+ return this._isOk ? this._busyCount > 0 : void 0;
73
+ }
74
+ constructor(e, t, r, i) {
75
+ this.name = e, this._doneCallback = r, this._overDoneCallback = i, this._busyCount = 0, this._isOk = !0, this._busyCount = t;
76
+ }
77
+ add() {
78
+ this._isOk && (this._busyCount += 1);
79
+ }
80
+ done() {
81
+ this._isOk && (this._busyCount > 0 ? (this._busyCount -= 1, this._busyCount || this._doneCallback()) : (this._isOk = !1, this._overDoneCallback()));
82
+ }
83
+ }
84
+ const Ne = 300;
85
+ class Le {
86
+ constructor(e) {
87
+ this._taskers = /* @__PURE__ */ new Map(), this._listeners = /* @__PURE__ */ new Set(), this._busyCheckers = /* @__PURE__ */ new Map(), this._logThreshold = Ne, this._endedTasks = new Array(), this._pollableReport = new Array(), o.requireArgumentIfDefined(e == null ? void 0 : e.logThreshold, "options.logThreshold", "number") && (this._logThreshold = e.logThreshold), o.requireArgumentIfDefined(e == null ? void 0 : e.reportListener, "options.reportListener", "function") && (this._reportListener = e.reportListener), o.requireArgumentIfDefined(e == null ? void 0 : e.errorListener, "options.errorListener", "function") && (this._errorListener = e.errorListener);
88
+ }
89
+ requestIdleDetectedCallback(e) {
90
+ o.requireArgument(e, "callback", "function"), this._listeners.size === 0 && (this._firstCallbackTime = o.time().perfNow), this._listeners.add(e), this._checkIfLoaded();
91
+ }
92
+ _reportTaskEnded(e) {
93
+ if (this._listeners.size) {
94
+ const t = Object.assign({}, this._taskers.get(e));
95
+ this._endedTasks.push(t);
96
+ }
97
+ }
98
+ declareNotifierTaskSingle(e) {
99
+ o.requireArgument(e, "name", "string");
100
+ const t = this._addTasker(e, 1);
101
+ return {
102
+ get isBusy() {
103
+ return t.isBusy;
104
+ },
105
+ done: () => {
106
+ t.done(), this._taskers.delete(t);
107
+ }
108
+ };
109
+ }
110
+ declareNotifierTaskMulti(e, t = 0) {
111
+ if (o.requireArgument(e, "name", "string"), t !== void 0 && (o.requireArgument(t, "existingBusyCount", "number"), !Number.isInteger(t) || t < 0))
112
+ throw new Error("existingBusyCount accepts only non-negative integers");
113
+ const r = this._addTasker(e, t);
114
+ return {
115
+ get isBusy() {
116
+ return r.isBusy;
117
+ },
118
+ add: () => {
119
+ if (!r.isBusy) {
120
+ const s = this._taskers.get(r);
121
+ s.start = o.time().perfNow, s.end = void 0;
122
+ }
123
+ r.add();
124
+ },
125
+ done: r.done.bind(r)
126
+ };
127
+ }
128
+ declarePollableTaskMulti(e, t) {
129
+ o.requireArgument(e, "name", "string"), o.requireArgument(t, "isBusyChecker", "function"), this._busyCheckers.set(t, e);
130
+ }
131
+ _addTasker(e, t) {
132
+ const r = new Oe(e, t, () => {
133
+ this._taskers.get(r).end = o.time().perfNow, this._reportTaskEnded(r), this._checkIfLoaded();
134
+ }, () => {
135
+ var i;
136
+ (i = this._errorListener) === null || i === void 0 || i.call(this, `Overdone: ${r.name}`), o.noProdThrow(`Tasker '${r.name}' is done too many times.`);
137
+ });
138
+ return this._taskers.set(r, {
139
+ name: e,
140
+ start: t > 0 ? o.time().perfNow : void 0,
141
+ end: void 0
142
+ }), r;
143
+ }
144
+ _areAllNotifiersIdle() {
145
+ return !Array.from(this._taskers.keys()).some((e) => e.isBusy);
146
+ }
147
+ _getFirstBusyPollable() {
148
+ const e = Array.from(this._busyCheckers).find((t) => {
149
+ var r;
150
+ const i = t[0], s = t[1];
151
+ try {
152
+ return i();
153
+ } catch (n) {
154
+ return (r = this._errorListener) === null || r === void 0 || r.call(this, n, `BusyChecker ${s}`), o.noProdThrow(n), !1;
155
+ }
156
+ });
157
+ return e ? e[1] : void 0;
158
+ }
159
+ _checkIfLoaded() {
160
+ this._listeners.size && (this._timerCheckQueued && clearTimeout(this._timerCheckQueued), this._areAllNotifiersIdle() && (this._timerCheckQueued = setTimeout(() => {
161
+ this._timerCheckQueued = setTimeout(() => {
162
+ this._doubleCheck();
163
+ }, 40);
164
+ }, 0)));
165
+ }
166
+ _doubleCheck() {
167
+ if (this._timerCheckQueued = void 0, this._areAllNotifiersIdle()) {
168
+ const e = this._getFirstBusyPollable();
169
+ if (e !== void 0)
170
+ this._addToPollableReport(e), this._timerCheckQueued = setTimeout(() => {
171
+ this._doubleCheck();
172
+ }, 15);
173
+ else {
174
+ const t = o.time().perfNow - this._firstCallbackTime, r = Array.from(this._listeners.values());
175
+ this._listeners.clear(), this._firstCallbackTime = void 0;
176
+ const i = this._endedTasks.splice(0), s = this._pollableReport.splice(0);
177
+ this._notify(r, t, i, s);
178
+ }
179
+ }
180
+ }
181
+ _addToPollableReport(e) {
182
+ const t = this._pollableReport.length ? this._pollableReport[this._pollableReport.length - 1] : void 0;
183
+ (t == null ? void 0 : t.name) === e ? t.count += 1 : this._pollableReport.push({
184
+ name: e,
185
+ count: 1
186
+ });
187
+ }
188
+ _notify(e, t, r, i) {
189
+ var s;
190
+ if (t >= this._logThreshold && this._reportListener) {
191
+ const a = this._getReport(t, e.length, r, i);
192
+ this._reportListener(a);
193
+ }
194
+ e.reverse();
195
+ const n = o.time().tsNow;
196
+ for (const [a, u] of e.entries())
197
+ try {
198
+ u(n);
199
+ } catch (h) {
200
+ (s = this._errorListener) === null || s === void 0 || s.call(this, h, `Listener #${e.length - 1 - a}`), o.noProdThrow(h);
201
+ }
202
+ }
203
+ getReport() {
204
+ const e = o.time().perfNow, t = this._firstCallbackTime > 0 ? e - this._firstCallbackTime : void 0, r = Array.from(this._taskers.entries()).filter((i) => i[0].isBusy).map((i) => ({
205
+ name: i[1].name,
206
+ start: i[1].start,
207
+ end: e
208
+ }));
209
+ return this._getReport(t, this._listeners.size, this._endedTasks.concat(r), this._pollableReport);
210
+ }
211
+ _getReport(e, t, r, i) {
212
+ const s = r.map((n) => ({
213
+ name: n.name,
214
+ duration: n.end - n.start
215
+ })).sort((n, a) => a.duration - n.duration);
216
+ return {
217
+ logThreshold: this._logThreshold,
218
+ maxDuration: e,
219
+ listenerCount: t,
220
+ pollableCount: this._busyCheckers.size,
221
+ busyTasks: s.map((n) => n.name),
222
+ busyDurations: s.map((n) => n.duration),
223
+ pollables: i.map((n) => n.name),
224
+ pollCounts: i.map((n) => n.count)
225
+ };
226
+ }
227
+ }
228
+ const De = { namespace: "sfcore.performance", name: "ResourceTiming", pbjsSchema: { nested: { sfcore: { nested: { performance: { nested: { ResourceTiming: { oneofs: {
229
+ _xhrDelay: { oneof: ["xhrDelay"] },
230
+ _renderBlockingStatus: { oneof: ["renderBlockingStatus"] },
231
+ _firstInterimResponseStart: { oneof: ["firstInterimResponseStart"] },
232
+ _srvDuration: { oneof: ["srvDuration"] },
233
+ _isCdnCached: { oneof: ["isCdnCached"] },
234
+ _responseStatus: { oneof: ["responseStatus"] },
235
+ _dbDuration: { oneof: ["dbDuration"] },
236
+ _reqBatchCount: { oneof: ["reqBatchCount"] }
237
+ }, fields: { encodedBodySize: { id: 21, type: "uint32" }, reqActionNames: { rule: "repeated", id: 28, type: "string" }, responseEnd: { id: 19, type: "double" }, domainLookupEnd: { id: 12, type: "double" }, firstInterimResponseStart: { options: { proto3_optional: !0 }, id: 18, type: "double" }, duration: { id: 3, type: "double" }, decodedBodySize: { id: 22, type: "uint32" }, redirectStart: { id: 8, type: "double" }, connectEnd: { id: 15, type: "double" }, isCdnCached: {
238
+ options: { proto3_optional: !0 },
239
+ id: 24,
240
+ type: "bool"
241
+ }, requestStart: { id: 16, type: "double" }, startTime: { id: 2, type: "double" }, fetchStart: { id: 10, type: "double" }, srvReqId: { id: 29, type: "string" }, reqBatchCount: { options: { proto3_optional: !0 }, id: 27, type: "uint32" }, renderBlockingStatus: { options: { proto3_optional: !0 }, id: 6, type: "string" }, workerStart: { id: 7, type: "double" }, responseStart: { id: 17, type: "double" }, xhrDelay: { options: { proto3_optional: !0 }, id: 30, type: "double" }, domainLookupStart: {
242
+ id: 11,
243
+ type: "double"
244
+ }, responseStatus: { options: { proto3_optional: !0 }, id: 23, type: "uint32" }, redirectEnd: { id: 9, type: "double" }, transferSize: { id: 20, type: "uint32" }, srvDuration: { options: { proto3_optional: !0 }, id: 26, type: "double" }, dbDuration: { options: { proto3_optional: !0 }, id: 25, type: "double" }, connectStart: { id: 13, type: "double" }, secureConnectionStart: { id: 14, type: "double" }, name: { id: 1, type: "string" }, nextHopProtocol: { id: 5, type: "string" }, initiatorType: {
245
+ id: 4,
246
+ type: "string"
247
+ } } } } } } } } } }, qe = { namespace: "sfcore.performance", name: "NavigationTiming", pbjsSchema: { nested: { sfcore: { nested: { performance: { nested: { NavigationTiming: { oneofs: {
248
+ _xhrDelay: { oneof: ["xhrDelay"] },
249
+ _renderBlockingStatus: { oneof: ["renderBlockingStatus"] },
250
+ _firstInterimResponseStart: { oneof: ["firstInterimResponseStart"] },
251
+ _srvDuration: { oneof: ["srvDuration"] },
252
+ _isCdnCached: { oneof: ["isCdnCached"] },
253
+ _responseStatus: { oneof: ["responseStatus"] },
254
+ _dbDuration: { oneof: ["dbDuration"] },
255
+ _reqBatchCount: { oneof: ["reqBatchCount"] }
256
+ }, fields: {
257
+ redirectCount: { id: 37, type: "uint32" },
258
+ encodedBodySize: { id: 21, type: "uint32" },
259
+ reqActionNames: { rule: "repeated", id: 28, type: "string" },
260
+ unloadEventEnd: { id: 40, type: "double" },
261
+ responseEnd: { id: 19, type: "double" },
262
+ domainLookupEnd: { id: 12, type: "double" },
263
+ unloadEventStart: { id: 39, type: "double" },
264
+ domContentLoadedEventStart: { id: 32, type: "double" },
265
+ type: { id: 38, type: "string" },
266
+ firstInterimResponseStart: {
267
+ options: { proto3_optional: !0 },
268
+ id: 18,
269
+ type: "double"
270
+ },
271
+ duration: { id: 3, type: "double" },
272
+ decodedBodySize: { id: 22, type: "uint32" },
273
+ redirectStart: { id: 8, type: "double" },
274
+ connectEnd: { id: 15, type: "double" },
275
+ isCdnCached: { options: { proto3_optional: !0 }, id: 24, type: "bool" },
276
+ requestStart: { id: 16, type: "double" },
277
+ startTime: { id: 2, type: "double" },
278
+ fetchStart: { id: 10, type: "double" },
279
+ domContentLoadedEventEnd: { id: 33, type: "double" },
280
+ srvReqId: { id: 29, type: "string" },
281
+ reqBatchCount: {
282
+ options: { proto3_optional: !0 },
283
+ id: 27,
284
+ type: "uint32"
285
+ },
286
+ renderBlockingStatus: { options: { proto3_optional: !0 }, id: 6, type: "string" },
287
+ workerStart: { id: 7, type: "double" },
288
+ responseStart: { id: 17, type: "double" },
289
+ xhrDelay: { options: { proto3_optional: !0 }, id: 30, type: "double" },
290
+ domInteractive: { id: 34, type: "double" },
291
+ domComplete: { id: 31, type: "double" },
292
+ domainLookupStart: { id: 11, type: "double" },
293
+ responseStatus: { options: { proto3_optional: !0 }, id: 23, type: "uint32" },
294
+ redirectEnd: { id: 9, type: "double" },
295
+ logEvent: { id: 41, type: "string" },
296
+ transferSize: { id: 20, type: "uint32" },
297
+ srvDuration: { options: { proto3_optional: !0 }, id: 26, type: "double" },
298
+ dbDuration: { options: { proto3_optional: !0 }, id: 25, type: "double" },
299
+ connectStart: { id: 13, type: "double" },
300
+ loadEventStart: { id: 35, type: "double" },
301
+ secureConnectionStart: { id: 14, type: "double" },
302
+ name: { id: 1, type: "string" },
303
+ nextHopProtocol: { id: 5, type: "string" },
304
+ initiatorType: { id: 4, type: "string" },
305
+ loadEventEnd: {
306
+ id: 36,
307
+ type: "double"
308
+ }
309
+ } } } } } } } } };
310
+ class He {
311
+ constructor(e) {
312
+ this._fuzzyKeyRange = e, this._map = /* @__PURE__ */ new Map(), o.requireArgument(e, "_fuzzyKeyRange", "number");
313
+ }
314
+ add(e, t, r) {
315
+ const i = this._map.get(e);
316
+ i ? i.push({ fuzzyKey: t, value: r }) : this._map.set(e, [{ fuzzyKey: t, value: r }]);
317
+ }
318
+ pop(e, t) {
319
+ const r = this._map.get(e);
320
+ if ((r == null ? void 0 : r.length) >= 1) {
321
+ let i = Number.POSITIVE_INFINITY, s = -1;
322
+ for (let n = 0; n < r.length; n++) {
323
+ const { fuzzyKey: a } = r[n], u = Math.abs(a - t);
324
+ u <= this._fuzzyKeyRange && u < i && (i = u, s = n);
325
+ }
326
+ if (s >= 0) {
327
+ const { value: n } = r.splice(s, 1)[0];
328
+ return r.length === 0 && this._map.delete(e), n;
329
+ }
330
+ }
331
+ }
332
+ clear() {
333
+ this._map.clear();
334
+ }
335
+ }
336
+ const Me = ["fetch", "xmlhttprequest"];
337
+ class Be {
338
+ constructor(e, t, r, i, s) {
339
+ if (this._instr = e, this._skipUrls = r, this._logPerformanceActivityName = i, this._boundObserverCallback = this._logPerformanceEntries.bind(this), this._boundNavigationTimingEventCallback = (n) => {
340
+ this._logNavigationEntries(n);
341
+ }, this._setTimeoutNavigationCallback = (n) => {
342
+ setTimeout(() => {
343
+ this._boundNavigationTimingEventCallback(n);
344
+ }, 0);
345
+ }, this._visibilityChangeNavigationCallback = (n) => {
346
+ document.visibilityState === "hidden" && this._boundNavigationTimingEventCallback(n);
347
+ }, this._isStarted = !1, this._processedNavigationTiming = !1, o.requireArgument(e, "_instr", "object"), o.requireArgument(t, "fuzzyMapRange", "number"), o.requireArgumentIfDefined(r, "_skipUrls", Array), o.requireArgumentIfDefined(i, "_logPerformanceActivityName", "string"), o.requireArgumentIfDefined(s, "logLevel", "string"), this._hasPerf = typeof performance != "undefined" && typeof PerformanceObserver == "function", this._hasWindow = typeof window != "undefined", !s || s.toLowerCase() === "full")
348
+ this._logLevel = 1;
349
+ else if ((s == null ? void 0 : s.toLowerCase()) === "basic")
350
+ this._logLevel = 0;
351
+ else
352
+ throw new Error(`Invalid log level: ${s}`);
353
+ this._fuzzyMapper = new He(t);
354
+ }
355
+ get isStarted() {
356
+ return this._isStarted;
357
+ }
358
+ get logLevel() {
359
+ return this._logLevel;
360
+ }
361
+ start() {
362
+ this._hasPerf && (this._isStarted || (this._isStarted = !0, this._resourceObserver = new PerformanceObserver(this._boundObserverCallback), this._resourceObserver.observe({ type: "resource", buffered: !0 }), this._addNavigationListeners()));
363
+ }
364
+ stop() {
365
+ this._resourceObserver && (this._resourceObserver.disconnect(), this._resourceObserver = void 0), this._removeNavigationListeners(), this._fuzzyMapper.clear(), this._isStarted = !1;
366
+ }
367
+ _addNavigationListeners() {
368
+ this._hasWindow && (window.addEventListener("load", this._setTimeoutNavigationCallback), window.addEventListener("pagehide", this._boundNavigationTimingEventCallback), document.addEventListener("visibilitychange", this._visibilityChangeNavigationCallback));
369
+ }
370
+ _removeNavigationListeners() {
371
+ this._hasWindow && (window.removeEventListener("load", this._setTimeoutNavigationCallback), window.removeEventListener("pagehide", this._boundNavigationTimingEventCallback), document.removeEventListener("visibilitychange", this._visibilityChangeNavigationCallback));
372
+ }
373
+ addEntry(e, t, r) {
374
+ this._fuzzyMapper.add(e, t, r);
375
+ }
376
+ _resourceEntryToResourceTiming(e) {
377
+ var t, r;
378
+ const i = {
379
+ name: e.name,
380
+ startTime: e.startTime,
381
+ duration: e.duration,
382
+ initiatorType: e.initiatorType,
383
+ nextHopProtocol: e.nextHopProtocol,
384
+ renderBlockingStatus: e.renderBlockingStatus,
385
+ workerStart: e.workerStart,
386
+ redirectStart: e.redirectStart,
387
+ redirectEnd: e.redirectEnd,
388
+ fetchStart: e.fetchStart,
389
+ domainLookupStart: e.domainLookupStart,
390
+ domainLookupEnd: e.domainLookupEnd,
391
+ connectStart: e.connectStart,
392
+ secureConnectionStart: e.secureConnectionStart,
393
+ connectEnd: e.connectEnd,
394
+ requestStart: e.requestStart,
395
+ responseStart: e.responseStart,
396
+ firstInterimResponseStart: e.firstInterimResponseStart,
397
+ responseEnd: e.responseEnd,
398
+ transferSize: e.transferSize,
399
+ encodedBodySize: e.encodedBodySize,
400
+ decodedBodySize: e.decodedBodySize,
401
+ responseStatus: e.responseStatus
402
+ }, s = e.serverTiming;
403
+ return Array.isArray(s) && (i.dbDuration = (t = s.find((n) => n.name === "db")) === null || t === void 0 ? void 0 : t.duration, i.srvDuration = (r = s.find((n) => n.name === "Total")) === null || r === void 0 ? void 0 : r.duration), i;
404
+ }
405
+ _shouldInclude(e) {
406
+ var t;
407
+ return ((t = this._skipUrls) === null || t === void 0 ? void 0 : t.some((i) => i instanceof RegExp ? i.test(e.name) : e.name === i)) ? !1 : this._logLevel === 1 ? !0 : Me.indexOf(e.initiatorType) >= 0 || e.entryType === "navigation";
408
+ }
409
+ _calculateXhrDelay(e, t) {
410
+ if (t) {
411
+ if (e.initiatorType === "fetch") {
412
+ if (e.responseStart === 0)
413
+ return -1;
414
+ if (t.activityDuration !== void 0) {
415
+ const r = e.responseStart - e.startTime;
416
+ return t.activityDuration - r;
417
+ }
418
+ return;
419
+ }
420
+ if (t.activityDuration !== void 0)
421
+ return t.activityDuration - e.duration;
422
+ }
423
+ }
424
+ _logActivity(e, t, r, i) {
425
+ const s = {
426
+ id: r
427
+ }, n = {
428
+ perfStartOverride: t.startTime,
429
+ perfStopOverride: t.startTime + t.duration,
430
+ errorCount: i
431
+ };
432
+ this._instr.startActivity(this._logPerformanceActivityName, s).stop(e, t, n);
433
+ }
434
+ _logNavigationEntries(e) {
435
+ if (!this._processedNavigationTiming)
436
+ for (const t of performance.getEntriesByType("navigation")) {
437
+ const r = t;
438
+ if (this._shouldInclude(r)) {
439
+ this._processedNavigationTiming = !0;
440
+ const i = this._resourceEntryToResourceTiming(r), s = {
441
+ domComplete: r.domComplete,
442
+ domContentLoadedEventStart: r.domContentLoadedEventStart,
443
+ domContentLoadedEventEnd: r.domContentLoadedEventEnd,
444
+ domInteractive: r.domInteractive,
445
+ loadEventStart: r.loadEventStart,
446
+ loadEventEnd: r.loadEventEnd,
447
+ redirectCount: r.redirectCount,
448
+ type: r.type,
449
+ unloadEventStart: r.unloadEventStart,
450
+ unloadEventEnd: r.unloadEventEnd,
451
+ logEvent: e.type
452
+ };
453
+ this._logActivity(qe, Object.assign(i, s));
454
+ }
455
+ break;
456
+ }
457
+ }
458
+ _logPerformanceEntries(e) {
459
+ for (const t of e.getEntriesByType("resource")) {
460
+ const r = t, i = this._fuzzyMapper.pop(r.name, r.startTime);
461
+ if (this._shouldInclude(r)) {
462
+ const s = this._resourceEntryToResourceTiming(r);
463
+ Object.assign(s, {
464
+ srvReqId: i == null ? void 0 : i.requestId,
465
+ xhrDelay: this._calculateXhrDelay(r, i)
466
+ }), s.responseStatus === void 0 && (s.responseStatus = i == null ? void 0 : i.responseStatus), this._logActivity(De, s, i == null ? void 0 : i.activityId, i == null ? void 0 : i.errorCount);
467
+ }
468
+ }
469
+ }
470
+ }
471
+ const Fe = 32, Ue = 16, J = 16, je = "traceparent", Xe = "b3", ae = "X-B3-TraceId", de = "X-B3-SpanId", le = "X-B3-Sampled", ue = "X-B3-ParentSpanId", Z = "X-SFDC-Request-Id", ze = "baggage", Ve = "fetch", $e = "xhr_send", Ge = "perf-timing", Ke = 50, Ye = [
472
+ ze,
473
+ ae,
474
+ de,
475
+ ue,
476
+ le
477
+ ], I = /* @__PURE__ */ new WeakMap();
478
+ class d {
479
+ constructor(e, t) {
480
+ this._instr = e, this._idleDetector = t, o.requireArgument(e, "_instr", "object"), o.requireArgument(t, "_idleDetector", "object");
481
+ }
482
+ static _getB3CompactFormat(e, t, r, i) {
483
+ let s = `${e}-${t}`;
484
+ return (r !== void 0 || i !== void 0) && (s += r ? "-1" : "-0", i !== void 0 && (s += `-${i}`)), s;
485
+ }
486
+ static _getW3CompactFormat(e, t, r) {
487
+ return `00-${e}-${t}-${r ? "01" : "00"}`;
488
+ }
489
+ static _conformTextAsId(e, t) {
490
+ e = e.toLowerCase();
491
+ const r = e.length;
492
+ for (let i = 0; i < r; i += 1) {
493
+ const s = e[i];
494
+ if (!(s >= "a" && s <= "f") && !(s >= "0" && s <= "9"))
495
+ throw new Error(`The text '${e}' has an invalid character at index #${i}`);
496
+ }
497
+ return r > t ? e.substr(r - t) : r < t ? e.padStart(t, "0") : e;
498
+ }
499
+ static setHeaders(e) {
500
+ if (e === void 0) {
501
+ d._userHeaders = {};
502
+ return;
503
+ }
504
+ Object.entries(e).forEach(([t]) => {
505
+ Ye.includes(t) || delete e[t];
506
+ }), d._userHeaders = e;
507
+ }
508
+ static getHeaders(e, t, r, i) {
509
+ o.requireArgument(t, "spanId", "string");
510
+ const s = i == null ? void 0 : i.useB3Headers, n = {};
511
+ if (e === void 0)
512
+ return n;
513
+ e = this._conformTextAsId(e, (i == null ? void 0 : i.traceIdEffectiveLength) !== void 0 ? i.traceIdEffectiveLength : s ? Ue : Fe), t = this._conformTextAsId(t, J);
514
+ const a = i && i.parentSpanId !== void 0 && this._conformTextAsId(i.parentSpanId, J) || void 0;
515
+ return s ? (i == null ? void 0 : i.useCompactHeader) ? n[Xe] = this._getB3CompactFormat(e, t, r, a) : (n[ae] = e, n[de] = t, a !== void 0 && (n[ue] = a), r !== void 0 && (n[le] = r ? "1" : "0")) : n[je] = this._getW3CompactFormat(e, t, r), n;
516
+ }
517
+ _disableNetworkInstrumentation() {
518
+ d._isNetworkInstrumentationEnabled && (d._originalFetch && (d._global.fetch = d._originalFetch, d._originalFetch = void 0), d._originalXhr && (d._global.XMLHttpRequest = d._originalXhr, d._originalXhr = void 0), d._originalXhrOpen && (d._global.XMLHttpRequest.prototype.open = d._originalXhrOpen, d._originalXhrOpen = void 0), d._originalXhrSetRequestHeader && (d._global.XMLHttpRequest.prototype.setRequestHeader = d._originalXhrSetRequestHeader, d._originalXhrSetRequestHeader = void 0), d._originalXhrSend && (d._global.XMLHttpRequest.prototype.send = d._originalXhrSend, d._originalXhrSend = void 0), d._performanceObservability && (d._performanceObservability.stop(), d._performanceObservability = void 0), d._isNetworkInstrumentationEnabled = !1);
519
+ }
520
+ _enableNetworkInstrumentation(e, t, r, i, s, n, a, u, h, f) {
521
+ typeof d._global.fetch == "function" && (this._overrideFetch(e, t, r, i, s, n, h), d._isNetworkInstrumentationEnabled = !0), typeof d._global.XMLHttpRequest == "function" && (this._overrideXhr(e, t, r, i, s, n, h), d._isNetworkInstrumentationEnabled = !0), a && (d._performanceObservability = new Be(e, f, h, u, a === !0 ? "full" : a), d._performanceObservability.start(), d._isNetworkInstrumentationEnabled = !0);
522
+ }
523
+ static _getTraceHeaders(e, t, r, i, s) {
524
+ let n;
525
+ if (e)
526
+ n = e.getTraceHeaders(r) || {};
527
+ else {
528
+ const a = t.internalInstrumentationContext;
529
+ a != null && a.rootId ? n = d.getHeaders(a.rootId, o.generateUniqueId(), a.isRootActivitySampled, r) : n = {};
530
+ }
531
+ if (typeof (r == null ? void 0 : r.headerProcessor) == "function")
532
+ n = r.headerProcessor({
533
+ method: i,
534
+ url: s,
535
+ defaultHeaders: n
536
+ });
537
+ else if (typeof window == "object") {
538
+ let a;
539
+ try {
540
+ a = new URL(s);
541
+ } catch (u) {
542
+ }
543
+ a && a.host !== window.location.host && (n = void 0);
544
+ }
545
+ return d._userHeaders && Object.keys(d._userHeaders).length > 0 && (n = W({}, n), Object.entries(d._userHeaders).forEach(([a, u]) => {
546
+ n[a] = u;
547
+ }), d._userHeaders = void 0), n || {};
548
+ }
549
+ static _extractHeader(e, t, r) {
550
+ if ((r == null ? void 0 : r.headers) instanceof Headers)
551
+ return r.headers.get(e);
552
+ if (Array.isArray(r == null ? void 0 : r.headers)) {
553
+ const i = r.headers.find((s) => s[0] === e);
554
+ return i == null ? void 0 : i[1];
555
+ }
556
+ if (typeof (r == null ? void 0 : r.headers) == "object")
557
+ return r.headers[e];
558
+ if (t instanceof Request)
559
+ return t.headers.get(e);
560
+ }
561
+ _overrideFetch(e, t, r, i, s, n, a) {
562
+ d._originalFetch = d._global.fetch;
563
+ const u = (h, f, ..._) => B(this, null, function* () {
564
+ var m;
565
+ let c, p, g, C, $, H = !1, R;
566
+ try {
567
+ n == null || n.add(), C = f == null ? void 0 : f.method;
568
+ const y = f == null ? void 0 : f.o11y, M = y == null ? void 0 : y.skipInstr;
569
+ if (H = M || d._shouldSkipUrl(a, h), !H)
570
+ c = e.startActivity(r || Ve);
571
+ else if (M) {
572
+ d._reqIndex += 1;
573
+ try {
574
+ if (h instanceof URL)
575
+ h.searchParams.append("o11y", d._reqIndex.toString());
576
+ else if (typeof h == "string") {
577
+ const b = new URL(h), G = `o11y=${d._reqIndex}`;
578
+ b.search += b.search.startsWith("?") ? `&${G}` : G, h = b.toString();
579
+ }
580
+ } catch (b) {
581
+ }
582
+ }
583
+ if (f == null || delete f.o11y, p = h == null ? void 0 : h.toString(), g = o.tryGetAbsoluteUrl(p), i) {
584
+ h instanceof Request && (C || (C = h.method), p = h.url, g = o.tryGetAbsoluteUrl(p));
585
+ const b = d._getTraceHeaders(c, e, s, C, g);
586
+ !this._applyTraceHeaders(h, f, b) && f === void 0 && (f = {
587
+ headers: b
588
+ });
589
+ }
590
+ return $ = o.perfNow(), R = yield d._originalFetch.call(d._global, h, f, ..._), R;
591
+ } catch (y) {
592
+ throw t && !H && (c ? c.error(y) : e.error(y)), y;
593
+ } finally {
594
+ try {
595
+ const y = d._endActivity(c, p, C);
596
+ if (!((m = d._performanceObservability) === null || m === void 0) && m.isStarted) {
597
+ const b = {
598
+ requestId: d._extractHeader(Z, h, f),
599
+ activityDuration: y,
600
+ activityId: c == null ? void 0 : c.getId(),
601
+ errorCount: c == null ? void 0 : c.getErrorCount(),
602
+ responseStatus: R == null ? void 0 : R.status
603
+ };
604
+ d._performanceObservability.addEntry(g, $, b);
605
+ }
606
+ } finally {
607
+ n == null || n.done();
608
+ }
609
+ }
610
+ });
611
+ d._global.fetch = u;
612
+ }
613
+ static _endActivity(e, t, r) {
614
+ var i;
615
+ if (e)
616
+ return !((i = d._performanceObservability) === null || i === void 0) && i.isStarted ? e.discard() : e.stop(Re, {
617
+ mtd: r,
618
+ url: t
619
+ }), e.getStopPerfTime() - e.getStartPerfTime();
620
+ }
621
+ _overrideXhr(e, t, r, i, s, n, a) {
622
+ d._originalXhr = d._global.XMLHttpRequest, d._originalXhrOpen = d._originalXhr.prototype.open, d._originalXhrSetRequestHeader = d._originalXhr.prototype.setRequestHeader, d._originalXhrSend = d._originalXhr.prototype.send;
623
+ function u(f, _) {
624
+ var m;
625
+ const c = I.get(f);
626
+ if (c) {
627
+ const p = c.activity, g = d._endActivity(p, c.url, c.method);
628
+ !_ && (!((m = d._performanceObservability) === null || m === void 0) && m.isStarted) && d._performanceObservability.addEntry(c.absoluteUrl, c.sendTime, {
629
+ requestId: c.requestId,
630
+ activityDuration: g,
631
+ activityId: p == null ? void 0 : p.getId(),
632
+ errorCount: p == null ? void 0 : p.getErrorCount(),
633
+ responseStatus: f.status
634
+ });
635
+ }
636
+ }
637
+ d._originalXhr.prototype.open = function(f, _, m, c, p) {
638
+ const g = {
639
+ method: f,
640
+ url: _ == null ? void 0 : _.toString()
641
+ };
642
+ I.set(this, g), g.absoluteUrl = o.tryGetAbsoluteUrl(g.url), g.suspendInstrumentation = d._shouldSkipUrl(a, g.absoluteUrl), d._originalXhrOpen.apply(this, arguments);
643
+ }, d._originalXhr.prototype.setRequestHeader = function(f, _) {
644
+ var m;
645
+ if (((m = f == null ? void 0 : f.toLowerCase) === null || m === void 0 ? void 0 : m.call(f)) === Z.toLowerCase()) {
646
+ const c = I.get(this);
647
+ c && (c.requestId = _);
648
+ }
649
+ d._originalXhrSetRequestHeader.apply(this, arguments);
650
+ }, d._originalXhr.prototype.send = function(...f) {
651
+ let _;
652
+ const m = this;
653
+ let c = I.get(m);
654
+ c || (c = {}, I.set(m, c));
655
+ try {
656
+ if (n == null || n.add(), c.suspendInstrumentation || (c.activity = _ = e.startActivity(r || $e)), i) {
657
+ const p = d._getTraceHeaders(_, e, s, c.method, c.absoluteUrl);
658
+ Object.entries(p).forEach((g) => {
659
+ m.setRequestHeader(g[0], g[1]);
660
+ });
661
+ }
662
+ c.sendTime = o.perfNow(), d._originalXhrSend.call(this, ...f);
663
+ } catch (p) {
664
+ throw t && !(c != null && c.suspendInstrumentation) && (_ ? _.error(p) : e.error(p)), u(m, !0), n == null || n.done(), p;
665
+ }
666
+ };
667
+ const h = new Proxy(d._originalXhr, {
668
+ construct(f) {
669
+ const _ = new f();
670
+ return _.addEventListener("load", () => {
671
+ u(_), n == null || n.done();
672
+ }), _.addEventListener("error", (m) => {
673
+ const c = I.get(_) || {};
674
+ try {
675
+ if (t && !(c != null && c.suspendInstrumentation)) {
676
+ const p = new Error("XHR Network-Level Error"), g = c == null ? void 0 : c.activity;
677
+ g ? g.error(p) : e.error(p);
678
+ }
679
+ u(_);
680
+ } finally {
681
+ n == null || n.done();
682
+ }
683
+ }), _.addEventListener("abort", () => {
684
+ var m;
685
+ const c = I.get(_) || {};
686
+ (m = c == null ? void 0 : c.activity) === null || m === void 0 || m.discard(), n == null || n.done();
687
+ }), _;
688
+ }
689
+ });
690
+ d._global.XMLHttpRequest = h;
691
+ }
692
+ networkInstrumentation(e) {
693
+ var t;
694
+ if (o.requireArgument(e, "options", ["boolean", "object"]), this._disableNetworkInstrumentation(), e) {
695
+ const r = typeof e == "object" ? e : {};
696
+ let i;
697
+ o.definedValueOrDefault(r.useTasker, !0) && (i = (t = this._idleDetector) === null || t === void 0 ? void 0 : t.declareNotifierTaskMulti("o11y network")), this._enableNetworkInstrumentation(o.definedValueOrDefault(r.instrumentation, this._instr), o.definedValueOrDefault(r.logErrors, !0), r.activityName, o.definedValueOrDefault(r.useTracing, !0), r.tracingHeadersOptions, i, o.definedValueOrDefault(r.logPerformance, !0), o.definedValueOrDefault(r.logPerformanceActivityName, Ge), o.definedValueOrDefault(r.skipUrls, []), o.definedValueOrDefault(r.fuzzyMapRange, Ke));
698
+ }
699
+ }
700
+ resetRequestCounter() {
701
+ d._reqIndex = 0;
702
+ }
703
+ _applyTraceHeaders(e, t, r) {
704
+ if ((t == null ? void 0 : t.headers) !== void 0) {
705
+ if (t.headers instanceof Headers && typeof t.headers.set == "function")
706
+ return Object.entries(r).forEach(([i, s]) => {
707
+ t.headers.set(i, s);
708
+ }), !0;
709
+ if (Array.isArray(t.headers))
710
+ return Object.entries(r).forEach((i) => {
711
+ t.headers.push(i);
712
+ }), !0;
713
+ if (typeof t.headers == "object")
714
+ return t.headers = Object.assign(t.headers, r), !0;
715
+ } else {
716
+ if (e instanceof Request && e.headers instanceof Headers)
717
+ return Object.entries(r).forEach(([i, s]) => {
718
+ e.headers.set(i, s);
719
+ }), !0;
720
+ if (t)
721
+ return t.headers = Object.assign({}, r), !0;
722
+ }
723
+ return !1;
724
+ }
725
+ static _shouldSkipUrl(e, t) {
726
+ var r;
727
+ let i = t;
728
+ return t instanceof URL ? i = (r = t.toString) === null || r === void 0 ? void 0 : r.call(t) : t instanceof Request && (i = t.url), e == null ? void 0 : e.some((s) => s instanceof RegExp ? s.test(i) : i === s);
729
+ }
730
+ }
731
+ d._global = o.getGlobal();
732
+ d._isNetworkInstrumentationEnabled = !1;
733
+ d._reqIndex = 0;
734
+ var v;
735
+ (function(l) {
736
+ l[l.none = 0] = "none", l[l.start = 1] = "start", l[l.stop = 2] = "stop", l[l.both = 3] = "both";
737
+ })(v || (v = {}));
738
+ const We = "timedout", Qe = "terminated", V = "discarded", T = {
739
+ timedout: We,
740
+ terminated: Qe,
741
+ discarded: V
742
+ };
743
+ class w {
744
+ constructor(e, t, r, i, s, n, a, u, h, f, _) {
745
+ var m, c;
746
+ this._name = e, this._rootId = t, this._onStopped = r, this._onError = i, this._isSampled = a, this._noRerooting = h, this._isExternal = f, this._parentActivity = _, this._isRoot = !1, this._errorCount = 0, this._timerOverridden = v.none;
747
+ const { tsNow: p, perfNow: g } = o.time();
748
+ if (w._count += 1, this._id = n || o.generateUniqueId(), this._usePerf = typeof performance != "undefined" && typeof performance.mark == "function" && typeof performance.measure == "function", this._usePerf) {
749
+ this._perfName = `${this._name}__${w._count}`, this._perfId = `${this._name}__${this.id}`;
750
+ try {
751
+ performance.mark(this._perfId);
752
+ } catch (C) {
753
+ this._usePerf = !1;
754
+ }
755
+ }
756
+ this._startTimestamp = p, this._startPerfTime = g, this._overrideTimer(u), s > 0 && (this._timer = setTimeout(() => {
757
+ this._stopReason = this._stopReason || T.timedout, this.stop();
758
+ }, s)), this._safety = new oe(), this._externalParentActivity = !((m = this._parentActivity) === null || m === void 0) && m.isExternal() ? this._parentActivity : (c = this._parentActivity) === null || c === void 0 ? void 0 : c.getExternalParentActivity();
759
+ }
760
+ get id() {
761
+ return this._id;
762
+ }
763
+ getId() {
764
+ return this.id;
765
+ }
766
+ getRootId() {
767
+ return this._rootId;
768
+ }
769
+ get stopReason() {
770
+ return this._stopReason;
771
+ }
772
+ getParentActivity() {
773
+ return this._parentActivity;
774
+ }
775
+ isExternal() {
776
+ var e;
777
+ return (e = this._isExternal) !== null && e !== void 0 ? e : !1;
778
+ }
779
+ getExternalParentActivity() {
780
+ return this._externalParentActivity;
781
+ }
782
+ error(e, t, r) {
783
+ this._safety.tryCatch(() => {
784
+ this._errorCount += 1, typeof e == "string" && (e = new Error(e)), this._onError(e, this._getDetail(t, r));
785
+ }, { op: "activity.error" });
786
+ }
787
+ stop(e, t, r) {
788
+ this._safety.tryCatch(() => {
789
+ if (o.requireArgumentIfDefined(e, "userSchemaOrText", [
790
+ "object",
791
+ "string"
792
+ ]), o.requireArgumentIfDefined(t, "userData", "object"), r) {
793
+ const i = r.perfStartOverride, s = o.requireArgumentIfDefined(i, "options.perfStartOverride", "number"), n = r.perfStopOverride, a = o.requireArgumentIfDefined(n, "options.perfStopOverride", "number"), u = r.errorCount;
794
+ if (o.requireArgumentIfDefined(u, "options.errorCount", "number") && (this._errorCount = u), s && i < 0)
795
+ throw new Error("perfStartOverride, if defined, must be >= 0");
796
+ if (a && (n < 0 || n < (s ? i : this._startPerfTime) || n > o.time().perfNow + 100))
797
+ throw new Error("perfStopOverride, if defined, must be >= 0 and >= startTime and <= now");
798
+ }
799
+ this._stopInternal(e, t, r);
800
+ }, { op: "activity.stop" });
801
+ }
802
+ _overrideTimer(e, t) {
803
+ e !== void 0 && (this._startTimestamp = Math.round(this._startTimestamp - (this._startPerfTime - e)), this._startPerfTime = e, this._setTimerOverride(v.start)), t !== void 0 && (this._stopPerfTime = t, this._setTimerOverride(v.stop));
804
+ }
805
+ _setTimerOverride(e) {
806
+ this._timerOverridden === v.both || this._timerOverridden === e || e === v.none || (this._timerOverridden = this._timerOverridden === v.none ? e : v.both);
807
+ }
808
+ _stopInternal(e, t, r) {
809
+ const i = o.perfNow();
810
+ if (this._usePerf)
811
+ try {
812
+ this._stopReason !== T.discarded && performance.measure(this._perfName, this._perfId), performance.clearMarks(this._perfId), performance.clearMeasures(this._perfName);
813
+ } catch (n) {
814
+ }
815
+ if (this._timer && (clearTimeout(this._timer), this._timer = void 0), this.isStopped)
816
+ return;
817
+ r && this._overrideTimer(r.perfStartOverride, r.perfStopOverride), this._stopPerfTime = this._timerOverridden === v.none || this._timerOverridden === v.start ? i : this._stopPerfTime;
818
+ const s = this._getDetail(e, t);
819
+ this._onStopped(s);
820
+ }
821
+ get isStopped() {
822
+ return this._stopPerfTime !== void 0;
823
+ }
824
+ discard() {
825
+ this._safety.tryCatch(() => {
826
+ this._stopReason = this._stopReason || T.discarded, this.stop();
827
+ }, { op: "activity.discard" });
828
+ }
829
+ terminate(e, t, r) {
830
+ this._safety.tryCatch(() => {
831
+ this._stopReason = this._stopReason || T.terminated, this.stop(e, t, r);
832
+ }, { op: "activity.terminate" });
833
+ }
834
+ getIsSampled() {
835
+ return this._isSampled || !1;
836
+ }
837
+ _getDetail(e, t) {
838
+ return {
839
+ id: this._id,
840
+ rootId: this._rootId,
841
+ name: this._name,
842
+ userSchemaOrText: e,
843
+ userData: t,
844
+ stopReason: this._stopReason,
845
+ startTimestamp: this._startTimestamp,
846
+ startPerfTime: this._startPerfTime,
847
+ stopPerfTime: this._stopPerfTime,
848
+ errorCount: this._errorCount,
849
+ isSampled: this.getIsSampled(),
850
+ timerOverridden: this._timerOverridden,
851
+ noRerooting: this._noRerooting,
852
+ isExternal: this._isExternal,
853
+ parentActivity: this._parentActivity,
854
+ externalParentActivity: this._externalParentActivity
855
+ };
856
+ }
857
+ getTraceHeaders(e) {
858
+ const t = this.id, r = this._isRoot ? this.id : this._rootId;
859
+ return d.getHeaders(r, t, this.getIsSampled(), e);
860
+ }
861
+ getStartTimestamp() {
862
+ return this._startTimestamp;
863
+ }
864
+ getStartPerfTime() {
865
+ return this._startPerfTime;
866
+ }
867
+ getStopPerfTime() {
868
+ return this._stopPerfTime;
869
+ }
870
+ getErrorCount() {
871
+ return this._errorCount;
872
+ }
873
+ }
874
+ w._count = 0;
875
+ const Je = new Array(16).fill(0).join("");
876
+ class Ze {
877
+ getId() {
878
+ return Je;
879
+ }
880
+ getRootId() {
881
+ }
882
+ error() {
883
+ }
884
+ stop() {
885
+ }
886
+ discard() {
887
+ }
888
+ terminate() {
889
+ }
890
+ getIsSampled() {
891
+ return !1;
892
+ }
893
+ getTraceHeaders(e) {
894
+ return {};
895
+ }
896
+ getStartTimestamp() {
897
+ }
898
+ getStartPerfTime() {
899
+ }
900
+ getStopPerfTime() {
901
+ }
902
+ getErrorCount() {
903
+ return 0;
904
+ }
905
+ getParentActivity() {
906
+ }
907
+ isExternal() {
908
+ return !1;
909
+ }
910
+ getExternalParentActivity() {
911
+ }
912
+ }
913
+ const et = Object.freeze(new Ze());
914
+ class tt {
915
+ getInstrumentedEventData(e, t, r, i) {
916
+ var s;
917
+ const n = {
918
+ ownerComponent: r.tagName,
919
+ parentComponent: ((s = r.parentElement) === null || s === void 0 ? void 0 : s.tagName) || void 0,
920
+ simplePath: o.getXpath(r)
921
+ };
922
+ switch (e) {
923
+ case 0:
924
+ n.baseEvent = t;
925
+ break;
926
+ case 1:
927
+ n.mouseEvent = t;
928
+ break;
929
+ }
930
+ return i && (n.userPayload = A.makePayload(i.schema, i.payload, !0)), n;
931
+ }
932
+ getEventData(e) {
933
+ return {
934
+ type: e.type
935
+ };
936
+ }
937
+ getMouseEventData(e) {
938
+ return {
939
+ altKey: e.altKey,
940
+ bubbles: e.bubbles,
941
+ button: e.button,
942
+ buttons: e.buttons,
943
+ cancelable: e.cancelable,
944
+ clientX: e.clientX,
945
+ clientY: e.clientY,
946
+ composed: e.composed,
947
+ defaultPrevented: e.defaultPrevented,
948
+ detail: e.detail,
949
+ eventPhase: e.eventPhase,
950
+ isTrusted: e.isTrusted,
951
+ timeStamp: e.timeStamp,
952
+ type: e.type,
953
+ ctrlKey: e.ctrlKey,
954
+ metaKey: e.metaKey,
955
+ movementX: e.movementX,
956
+ movementY: e.movementY,
957
+ offsetX: e.offsetX,
958
+ offsetY: e.offsetY,
959
+ pageX: e.pageX,
960
+ pageY: e.pageY,
961
+ screenX: e.screenX,
962
+ screenY: e.screenY,
963
+ shiftKey: e.shiftKey
964
+ };
965
+ }
966
+ }
967
+ const rt = new tt(), F = rt;
968
+ class ce {
969
+ constructor(e, t, r, i, s, n, a, u) {
970
+ this._name = e, this._ownerName = t, this._ownerAppName = r, this._tags = i, this._buckets = s, this._values = new Array(), this._createdOn = n === void 0 ? o.time().tsNow : n, a !== void 0 && (this._lastUpdatedOn = a), u !== void 0 && (this._values = u);
971
+ }
972
+ getName() {
973
+ return this._name;
974
+ }
975
+ getCreatedOn() {
976
+ return this._createdOn;
977
+ }
978
+ getLastUpdatedOn() {
979
+ return this._lastUpdatedOn;
980
+ }
981
+ getData() {
982
+ return this.values;
983
+ }
984
+ getBuckets() {
985
+ return this.buckets;
986
+ }
987
+ get buckets() {
988
+ return this._buckets.slice(0, this._buckets.length);
989
+ }
990
+ get values() {
991
+ return this._values.slice(0, this._values.length);
992
+ }
993
+ record(e) {
994
+ if (typeof e == "number") {
995
+ this._values.push(e), this._lastUpdatedOn = o.time().tsNow;
996
+ return;
997
+ }
998
+ throw new Error("BucketHistogram can only record numbers.");
999
+ }
1000
+ reset() {
1001
+ this._lastUpdatedOn = void 0, this._values = [];
1002
+ }
1003
+ getOwnerName() {
1004
+ return this._ownerName;
1005
+ }
1006
+ getOwnerAppName() {
1007
+ return this._ownerAppName;
1008
+ }
1009
+ getTags() {
1010
+ return this._tags;
1011
+ }
1012
+ }
1013
+ class he {
1014
+ constructor(e, t, r, i, s, n, a) {
1015
+ this._name = e, this._ownerName = t, this._ownerAppName = r, this._tags = i, this._values = new Array(), this._createdOn = s === void 0 ? o.time().tsNow : s, n !== void 0 && (this._lastUpdatedOn = n), a !== void 0 && (this._values = a);
1016
+ }
1017
+ getName() {
1018
+ return this._name;
1019
+ }
1020
+ getCreatedOn() {
1021
+ return this._createdOn;
1022
+ }
1023
+ getLastUpdatedOn() {
1024
+ return this._lastUpdatedOn;
1025
+ }
1026
+ getData() {
1027
+ return this.values;
1028
+ }
1029
+ get values() {
1030
+ return this._values.slice(0, this._values.length);
1031
+ }
1032
+ record(e) {
1033
+ if (typeof e == "number") {
1034
+ this._values.push(e), this._lastUpdatedOn = o.time().tsNow;
1035
+ return;
1036
+ }
1037
+ throw new Error("ValueRecorder can only record numbers.");
1038
+ }
1039
+ reset() {
1040
+ this._lastUpdatedOn = void 0, this._values = [];
1041
+ }
1042
+ getOwnerName() {
1043
+ return this._ownerName;
1044
+ }
1045
+ getOwnerAppName() {
1046
+ return this._ownerAppName;
1047
+ }
1048
+ getTags() {
1049
+ return this._tags;
1050
+ }
1051
+ }
1052
+ class U {
1053
+ constructor(e) {
1054
+ if (this._map = /* @__PURE__ */ new Map(), typeof e == "number" && e > 0) {
1055
+ this._maxSize = Math.ceil(e);
1056
+ return;
1057
+ }
1058
+ throw new Error("maxSize must be a positive number");
1059
+ }
1060
+ get maxSize() {
1061
+ return this._maxSize;
1062
+ }
1063
+ get(e) {
1064
+ return this._map.get(e);
1065
+ }
1066
+ has(e) {
1067
+ return this._map.has(e);
1068
+ }
1069
+ set(e, t) {
1070
+ return this.has(e) || this._map.size < this.maxSize ? (this._map.set(e, t), !0) : !1;
1071
+ }
1072
+ getElements() {
1073
+ return Array.from(this._map.values());
1074
+ }
1075
+ clear() {
1076
+ this._map.clear();
1077
+ }
1078
+ }
1079
+ const ee = 1e3, te = 500, re = 500;
1080
+ var E;
1081
+ (function(l) {
1082
+ l[l.Counter = 0] = "Counter", l[l.Percentile = 1] = "Percentile", l[l.BucketHistogram = 2] = "BucketHistogram";
1083
+ })(E || (E = {}));
1084
+ class fe {
1085
+ constructor(e, t) {
1086
+ this._ownerName = e, this._getOwnerAppName = t, this._upCounters = new U(ee), this._valueRecorders = new U(te), this._bucketHistograms = new U(re);
1087
+ }
1088
+ incrementCounter(e, t, r = !1, i = {}) {
1089
+ this._tagError(i, r), this._upCounter(e, i).increment(t);
1090
+ }
1091
+ trackValue(e, t, r = !1, i = {}) {
1092
+ this._tagError(i, r), this._valueRecorder(e, i).record(t);
1093
+ }
1094
+ bucketValue(e, t, r, i = !1, s = {}) {
1095
+ this._tagError(s, i), this._bucketHistogram(e, s, r).record(t);
1096
+ }
1097
+ _bucketHistogram(e, t, r) {
1098
+ const { key: i, sortedTags: s } = this._getKeyAndSortedTags(e, t, E.BucketHistogram);
1099
+ let n = this._bucketHistograms.get(i);
1100
+ if (!n && (n = new ce(e, this._ownerName, this._getOwnerAppName(), s, r), !this._bucketHistograms.set(i, n)))
1101
+ throw new Error(`Max size of ${re} exceeded for BucketHistograms`);
1102
+ return n;
1103
+ }
1104
+ _upCounter(e, t) {
1105
+ const { key: r, sortedTags: i } = this._getKeyAndSortedTags(e, t, E.Counter);
1106
+ let s = this._upCounters.get(r);
1107
+ if (!s && (s = new ne(e, this._ownerName, this._getOwnerAppName(), i), !this._upCounters.set(r, s)))
1108
+ throw new Error(`Max size of ${ee} exceeded for UpCounters`);
1109
+ return s;
1110
+ }
1111
+ _valueRecorder(e, t) {
1112
+ const { key: r, sortedTags: i } = this._getKeyAndSortedTags(e, t, E.Percentile);
1113
+ let s = this._valueRecorders.get(r);
1114
+ if (!s && (s = new he(e, this._ownerName, this._getOwnerAppName(), i), !this._valueRecorders.set(r, s)))
1115
+ throw new Error(`Max size of ${te} exceeded for ValueRecorders`);
1116
+ return s;
1117
+ }
1118
+ getUpCounters() {
1119
+ return this._upCounters.getElements();
1120
+ }
1121
+ getValueRecorders() {
1122
+ return this._valueRecorders.getElements();
1123
+ }
1124
+ getBucketHistograms() {
1125
+ return this._bucketHistograms.getElements();
1126
+ }
1127
+ _tagError(e, t) {
1128
+ e.status = t === !0 ? "error" : "success";
1129
+ }
1130
+ _getKeyAndSortedTags(e, t, r) {
1131
+ const i = Object.keys(t).sort().reduce((n, a) => (n[a] = t[a], n), {});
1132
+ return {
1133
+ key: `${E[r]}:${e}${JSON.stringify(i)}`,
1134
+ sortedTags: i
1135
+ };
1136
+ }
1137
+ }
1138
+ class it {
1139
+ constructor() {
1140
+ this.isMock = !0;
1141
+ }
1142
+ }
1143
+ const st = void 0, O = ["`"], pe = {
1144
+ internalError: "o11y-error"
1145
+ }, j = Object.freeze(Array.from(Object.values(pe))), X = /* @__PURE__ */ new WeakMap();
1146
+ class P {
1147
+ constructor(e, t) {
1148
+ this._nextGen = e, this._name = t, this._onActivityStoppedCallback = this._handleActivityStop.bind(this), this._onActivityErrorCallback = this._handleActivityError.bind(this);
1149
+ for (const i of O)
1150
+ if (this._name.indexOf(i) >= 0)
1151
+ throw new Error(`Name cannot include the reserved character "${i}"`);
1152
+ this._safety = new oe({
1153
+ increment: (i) => this._incrementError(i)
1154
+ }), this._metrics = this._initMetrics();
1155
+ const r = A.getOptions(Q, "Simple", "text");
1156
+ this._simpleTextMaxLength = r ? r["(meta.max_length)"] : Se;
1157
+ }
1158
+ _initMetrics() {
1159
+ return new fe(this.name, () => this._nextGen.appName || P.defaultAppName);
1160
+ }
1161
+ _incrementError(e = 1) {
1162
+ this._metrics.incrementCounter(pe.internalError, e, !0);
1163
+ }
1164
+ get name() {
1165
+ return this._name;
1166
+ }
1167
+ [Te](e, t, r) {
1168
+ const i = this[e];
1169
+ if (typeof i == "function") {
1170
+ X.set(this, r);
1171
+ try {
1172
+ i.apply(this, t);
1173
+ } finally {
1174
+ X.delete(this);
1175
+ }
1176
+ }
1177
+ }
1178
+ _wrapUserPayload(e, t, r = !1) {
1179
+ let i;
1180
+ return typeof e == "string" ? (i = Q, e ? t = {
1181
+ text: e.substring(0, this._simpleTextMaxLength)
1182
+ } : t = void 0) : i = e, A.makePayload(i, t, r);
1183
+ }
1184
+ _getEffectiveRootId(e) {
1185
+ var t, r;
1186
+ return (r = (t = e == null ? void 0 : e.instrumentationContext) === null || t === void 0 ? void 0 : t.rootId) !== null && r !== void 0 ? r : this._nextGen.getDefaultInstrumentationContext().rootId;
1187
+ }
1188
+ get internalInstrumentationContext() {
1189
+ return this._nextGen.getDefaultInstrumentationContext();
1190
+ }
1191
+ log(e, t, r) {
1192
+ this._safety.tryCatch(() => {
1193
+ const i = o.time().tsNow;
1194
+ o.requireArgument(e, "userSchemaOrText", ["object", "string"]), o.requireArgumentIfDefined(t, "userData", "object"), o.requireArgumentIfDefined(r, "options", "object");
1195
+ const s = this._wrapUserPayload(e, t);
1196
+ s != null && s.payload && this._logInternal(this.name, s.schema, s.payload, i, this._getEffectiveRootId(r));
1197
+ }, { op: "log" });
1198
+ }
1199
+ _logInternal(e, t, r, i, s) {
1200
+ const n = X.get(this), a = this._nextGen.addLog(e, t, r, i, s, n);
1201
+ if (!o.isProduction) {
1202
+ const u = L.getExtraFields(t, r);
1203
+ !o.isProduction && u.length > 0 && this.error("Extra fields", Ee, {
1204
+ extras: u
1205
+ });
1206
+ }
1207
+ return a;
1208
+ }
1209
+ error(e, t, r, i) {
1210
+ return this._safety.tryCatch(() => {
1211
+ o.requireArgumentIfDefined(t, "userSchemaOrText", [
1212
+ "object",
1213
+ "string"
1214
+ ]), o.requireArgumentIfDefined(r, "userData", "object"), o.requireArgumentIfDefined(i, "options", "object");
1215
+ const s = this._getEffectiveRootId(i);
1216
+ this._errorInternal(e, t, r, void 0, s);
1217
+ }, { op: "error" });
1218
+ }
1219
+ _errorInternal(e, t, r, i, s) {
1220
+ const n = o.time().tsNow;
1221
+ let a;
1222
+ if (e instanceof Error)
1223
+ a = e;
1224
+ else {
1225
+ let f;
1226
+ e == null || typeof e.toString != "function" ? f = "UNKNOWN" : f = e.toString(), a = new Error(f);
1227
+ }
1228
+ const u = this._wrapUserPayload(t, r, !0), h = {
1229
+ name: a.name,
1230
+ message: a.message,
1231
+ stack: a.stack,
1232
+ userPayload: u,
1233
+ activityId: i
1234
+ };
1235
+ return this._logInternal(this.name, xe, h, n, s);
1236
+ }
1237
+ startActivity(e, t) {
1238
+ return this._safety.tryCatchReturn(() => {
1239
+ var r;
1240
+ o.requireArgument(e, "name"), o.requireArgumentIfDefined(t, "options", "object");
1241
+ const i = o.validateParentActivityType(t == null ? void 0 : t.isExternal, t == null ? void 0 : t.parentActivity);
1242
+ let s, n = (t == null ? void 0 : t.perfStartOverride) !== void 0;
1243
+ const a = (r = t == null ? void 0 : t.instrumentationContext) === null || r === void 0 ? void 0 : r.rootId;
1244
+ a ? (n = !0, s = {
1245
+ rootId: a,
1246
+ isRootActivitySampled: t.instrumentationContext.isRootActivitySampled,
1247
+ isRootActivityExternalSampled: t.instrumentationContext.isRootActivityExternalSampled
1248
+ }) : s = this._nextGen.getDefaultInstrumentationContext();
1249
+ const u = t != null && t.isExternal ? s.isRootActivityExternalSampled : s.isRootActivitySampled;
1250
+ return new w(e, s.rootId, this._onActivityStoppedCallback, this._onActivityErrorCallback, st, t == null ? void 0 : t.id, u, t == null ? void 0 : t.perfStartOverride, n, t == null ? void 0 : t.isExternal, i);
1251
+ }, et, { op: "startActivity" });
1252
+ }
1253
+ getRootActivityHistoryEntryByTime(e) {
1254
+ let t;
1255
+ return this._safety.tryCatch(() => {
1256
+ t = this._nextGen.getRootActivityHistoryEntryByTime(e);
1257
+ }, { op: "getRootActivityHistoryEntryByTime" }), t;
1258
+ }
1259
+ _getActivityData(e) {
1260
+ var t, r;
1261
+ const i = this._wrapUserPayload(e.userSchemaOrText, e.userData, !0);
1262
+ return {
1263
+ id: e.id,
1264
+ name: e.name,
1265
+ duration: e.stopPerfTime - e.startPerfTime,
1266
+ stopReason: e.stopReason,
1267
+ userPayload: i,
1268
+ errorCount: e.errorCount,
1269
+ isSampled: e.isSampled,
1270
+ timerOverridden: e.timerOverridden,
1271
+ isRerooted: e.isRerooted,
1272
+ isExternal: e.isExternal,
1273
+ parentId: (t = e.parentActivity) === null || t === void 0 ? void 0 : t.getId(),
1274
+ externalParentId: (r = e.externalParentActivity) === null || r === void 0 ? void 0 : r.getId()
1275
+ };
1276
+ }
1277
+ _handleActivityStop(e) {
1278
+ if (e.stopReason === V)
1279
+ return;
1280
+ if (!e.isRoot && !e.noRerooting) {
1281
+ const r = this._nextGen.getRootActivityHistoryEntryByTime(e.startPerfTime);
1282
+ (!r && e.rootId !== void 0 || r && e.rootId !== r.id) && (e.rootId = r == null ? void 0 : r.id, e.isSampled = (r == null ? void 0 : r.isSampled) || !1, e.isRerooted = !0);
1283
+ }
1284
+ const t = this._getActivityData(e);
1285
+ this._logActivity(t, e.startTimestamp, e.rootId);
1286
+ }
1287
+ _logActivity(e, t, r) {
1288
+ this._logInternal(this.name, Pe, e, t, r);
1289
+ }
1290
+ _handleActivityError(e, t) {
1291
+ this._errorInternal(e, t.userSchemaOrText, t.userData, t.id, t.rootId);
1292
+ }
1293
+ domEvent(e, t, r, i, s) {
1294
+ this._safety.tryCatch(() => {
1295
+ var n;
1296
+ const a = o.time().tsNow;
1297
+ o.requireArgument(e, "event", [Event, it]), o.requireArgument(t, "handledBy", [HTMLElement, "object"]);
1298
+ let u;
1299
+ t instanceof HTMLElement ? u = t : (t = t, ((n = t.template) === null || n === void 0 ? void 0 : n.host) instanceof HTMLElement ? u = t.template.host : o.requireArgument(void 0, "handledBy"));
1300
+ const h = this._wrapUserPayload(r, i, !0), f = this._getEffectiveRootId(s);
1301
+ if (e.type === "click") {
1302
+ const _ = e, m = this._nextGen.getClickTracker();
1303
+ m && m.markEventHandled(_);
1304
+ const c = s == null ? void 0 : s.captureMouseData, p = F.getInstrumentedEventData(c ? 1 : 0, c ? F.getMouseEventData(_) : F.getEventData(_), u, h);
1305
+ p.auto = s == null ? void 0 : s._auto, this._logInternal(this.name, we, p, a, f);
1306
+ } else
1307
+ throw new Error(o.notImplemented);
1308
+ }, { op: "domEvent" });
1309
+ }
1310
+ _siftTags(e) {
1311
+ const t = Object.assign({}, e);
1312
+ return Object.entries(t).forEach(([r, i]) => {
1313
+ if (i === null)
1314
+ t[r] = "null";
1315
+ else if (i === "")
1316
+ t[r] = "empty";
1317
+ else if (Number.isNaN(i))
1318
+ t[r] = "NaN";
1319
+ else {
1320
+ const s = typeof i;
1321
+ ["number", "string", "boolean"].indexOf(s) === -1 && (t[r] = s);
1322
+ }
1323
+ }), t;
1324
+ }
1325
+ incrementCounter(e, t = 1, r = !1, i = {}) {
1326
+ this._safety.tryCatch(() => {
1327
+ o.requireArgument(e, "operation", "string"), o.checkForDenyListedValues(e, "operation", j), o.checkForReservedCharacters(e, "operation", O), o.requireArgument(t, "increment", "number"), o.requireArgument(r, "hasError", "boolean"), o.requireArgument(i, "tags", "object"), this._metrics.incrementCounter(e, t, r, this._siftTags(i));
1328
+ }, { op: "incrementCounter" });
1329
+ }
1330
+ trackValue(e, t, r = !1, i = {}) {
1331
+ this._safety.tryCatch(() => {
1332
+ o.requireArgument(e, "operation", "string"), o.checkForDenyListedValues(e, "operation", j), o.checkForReservedCharacters(e, "operation", O), o.requireArgument(t, "value", "number"), o.requireArgument(r, "hasError", "boolean"), o.requireArgument(i, "tags", "object"), this._metrics.trackValue(e, t, r, this._siftTags(i));
1333
+ }, { op: "trackValue" });
1334
+ }
1335
+ bucketValue(e, t, r = [], i = !1, s = {}) {
1336
+ this._safety.tryCatch(() => {
1337
+ o.requireArgument(e, "operation", "string"), o.checkForDenyListedValues(e, "operation", j), o.checkForReservedCharacters(e, "operation", O), o.requireArgument(t, "value", "number"), o.requireArgument(r, "buckets", Array), Object.entries(r).forEach(([n, a]) => {
1338
+ o.requireArgument(a, `Bucket value for '${n}'`, "number");
1339
+ }), o.requireArgument(i, "hasError", "boolean"), o.requireArgument(s, "tags", "object"), this._metrics.bucketValue(e, t, r, i, this._siftTags(s));
1340
+ }, { op: "bucketValue" });
1341
+ }
1342
+ getUpCounters() {
1343
+ return this._metrics.getUpCounters().filter((e) => e.getLastUpdatedOn());
1344
+ }
1345
+ getValueRecorders() {
1346
+ return this._metrics.getValueRecorders().filter((e) => e.getLastUpdatedOn());
1347
+ }
1348
+ getBucketHistograms() {
1349
+ return this._metrics.getBucketHistograms().filter((e) => e.getLastUpdatedOn());
1350
+ }
1351
+ registerForLogPrompt(e) {
1352
+ o.requireArgument(e, "listener", "function"), this._nextGen.registerForLogPrompt(e);
1353
+ }
1354
+ _getAsaOptions(e) {
1355
+ return e ? Object.assign({
1356
+ instrumentationContext: e == null ? void 0 : e.instrumentationContext
1357
+ }, e.startOptions) : void 0;
1358
+ }
1359
+ activity(e, t, r) {
1360
+ var i, s, n, a;
1361
+ const u = this._getAsaOptions(r), h = this.startActivity(e, u);
1362
+ try {
1363
+ return t(h);
1364
+ } catch (f) {
1365
+ throw h.error(f, (i = r == null ? void 0 : r.errorPayload) === null || i === void 0 ? void 0 : i.schema, (s = r == null ? void 0 : r.errorPayload) === null || s === void 0 ? void 0 : s.payload), f;
1366
+ } finally {
1367
+ h.stop((n = r == null ? void 0 : r.stopPayload) === null || n === void 0 ? void 0 : n.schema, (a = r == null ? void 0 : r.stopPayload) === null || a === void 0 ? void 0 : a.payload, r == null ? void 0 : r.stopOptions);
1368
+ }
1369
+ }
1370
+ activityAsync(e, t, r) {
1371
+ return B(this, null, function* () {
1372
+ var i, s, n, a;
1373
+ const u = this._getAsaOptions(r), h = this.startActivity(e, u);
1374
+ try {
1375
+ return yield t(h);
1376
+ } catch (f) {
1377
+ throw h.error(f, (i = r == null ? void 0 : r.errorPayload) === null || i === void 0 ? void 0 : i.schema, (s = r == null ? void 0 : r.errorPayload) === null || s === void 0 ? void 0 : s.payload), f;
1378
+ } finally {
1379
+ h.stop((n = r == null ? void 0 : r.stopPayload) === null || n === void 0 ? void 0 : n.schema, (a = r == null ? void 0 : r.stopPayload) === null || a === void 0 ? void 0 : a.payload, r == null ? void 0 : r.stopOptions);
1380
+ }
1381
+ });
1382
+ }
1383
+ invokeNetworkCallWithHeaders(e, t, r) {
1384
+ return d.setHeaders(r), e(...t);
1385
+ }
1386
+ }
1387
+ P.defaultAppName = "APP_NOT_REGISTERED";
1388
+ const nt = 0.1, ot = 20;
1389
+ class at {
1390
+ constructor(e) {
1391
+ if (this._historyMap = /* @__PURE__ */ new Map(), this._historyList = new Array(), o.requireArgumentIfDefined(e, "limit", "number")) {
1392
+ if (e = Math.ceil(e), e <= 0)
1393
+ throw new Error("Limit must be a positive number");
1394
+ } else
1395
+ e = ot;
1396
+ this._graceCount = Math.max(1, Math.floor(e * nt)), this._realLimit = 1 + e + this._graceCount;
1397
+ }
1398
+ add(e) {
1399
+ if (this._historyMap.has(e.id))
1400
+ throw new Error(`RootActivityHistoryImpl.add: entry already exists for rootId: ${e.id}`);
1401
+ this._historyMap.set(e.id, e), this._historyList.push(e), this._historyList.length === this._realLimit && this._historyList.splice(1, this._graceCount).forEach((r) => this._historyMap.delete(r.id));
1402
+ }
1403
+ get count() {
1404
+ return this._historyList.length;
1405
+ }
1406
+ findById(e) {
1407
+ return this._historyMap.get(e);
1408
+ }
1409
+ findByTime(e) {
1410
+ let t, r = Number.MAX_VALUE;
1411
+ for (const i of this._historyList) {
1412
+ const s = e - i.startPerfTime;
1413
+ s >= 0 && (i.stopPerfTime === void 0 || e < i.stopPerfTime) && s < r && (t = i, r = s);
1414
+ }
1415
+ return t;
1416
+ }
1417
+ }
1418
+ class dt extends w {
1419
+ constructor(e, t, r, i, s, n, a, u) {
1420
+ super(e, void 0, t, r, void 0, i || o.generateUniqueId(a != null ? a : 32), s, n), this._isRoot = !0, this._isExternalSampled = u;
1421
+ }
1422
+ get isExternalSampled() {
1423
+ var e;
1424
+ return (e = this._isExternalSampled) !== null && e !== void 0 ? e : !1;
1425
+ }
1426
+ set isExternalSampled(e) {
1427
+ this._isExternalSampled = e;
1428
+ }
1429
+ get preRootId() {
1430
+ return this._preRootId;
1431
+ }
1432
+ set preRootId(e) {
1433
+ this._preRootId = e;
1434
+ }
1435
+ _getDetail(e, t) {
1436
+ const r = super._getDetail(e, t);
1437
+ return r.isRoot = !0, r.preRootId = this.preRootId, r;
1438
+ }
1439
+ }
1440
+ const lt = new Array(32).fill(0).join("");
1441
+ class ut {
1442
+ getId() {
1443
+ return lt;
1444
+ }
1445
+ getRootId() {
1446
+ }
1447
+ error() {
1448
+ }
1449
+ stop() {
1450
+ }
1451
+ discard() {
1452
+ }
1453
+ terminate() {
1454
+ }
1455
+ getIsSampled() {
1456
+ return !1;
1457
+ }
1458
+ getTraceHeaders(e) {
1459
+ return {};
1460
+ }
1461
+ getStartTimestamp() {
1462
+ }
1463
+ getStartPerfTime() {
1464
+ }
1465
+ getStopPerfTime() {
1466
+ }
1467
+ getErrorCount() {
1468
+ return 0;
1469
+ }
1470
+ getParentActivity() {
1471
+ }
1472
+ isExternal() {
1473
+ return !1;
1474
+ }
1475
+ getExternalParentActivity() {
1476
+ }
1477
+ }
1478
+ const ct = Object.freeze(new ut());
1479
+ class ht extends P {
1480
+ constructor(e, t, r) {
1481
+ super(e, t), this._allowMulti = r, this._rootActivityHistory = new at(), this._onRootActivityStoppedCallback = this._handleRootActivityStop.bind(this);
1482
+ }
1483
+ startRootActivity(e, t, r, i, s) {
1484
+ return this._safety.tryCatchReturn(() => {
1485
+ if (o.requireArgument(e, "name"), (i == null ? void 0 : i.id) !== void 0)
1486
+ throw new Error("Cannot specify id for root activity, use rootId argument instead");
1487
+ const n = new dt(e, this._onRootActivityStoppedCallback, this._onActivityErrorCallback, t, r, i == null ? void 0 : i.perfStartOverride, this._nextGen.preferredRootIdLength, s);
1488
+ if (!this._allowMulti) {
1489
+ const a = {
1490
+ id: n.getId(),
1491
+ name: e,
1492
+ startPerfTime: n.getStartPerfTime(),
1493
+ isSampled: n.getIsSampled()
1494
+ };
1495
+ if (this._rootActivityHistory.add(a), this._singleRootActivity && !this._singleRootActivity.isStopped) {
1496
+ const u = this._singleRootActivity.getId();
1497
+ this._singleRootActivity.terminate(), n.preRootId = u;
1498
+ }
1499
+ this._singleRootActivity = n;
1500
+ }
1501
+ return n;
1502
+ }, ct, { op: "startRootActivity" });
1503
+ }
1504
+ _handleRootActivityStop(e) {
1505
+ const t = this._rootActivityHistory.findById(e.id);
1506
+ if (t && (t.stopPerfTime = e.stopPerfTime, t.startPerfTime = e.startPerfTime), e.stopReason === V)
1507
+ return;
1508
+ const r = this._getActivityData(e);
1509
+ this._logActivity(r, e.startTimestamp), this._singleRootActivity = void 0;
1510
+ }
1511
+ _getActivityData(e) {
1512
+ const t = super._getActivityData(e);
1513
+ return t.isRoot = e.isRoot, t.preRootId = e.preRootId, t;
1514
+ }
1515
+ getSingleRootActivityId() {
1516
+ var e;
1517
+ return (e = this._singleRootActivity) === null || e === void 0 ? void 0 : e.getId();
1518
+ }
1519
+ isSingleRootActivitySampled() {
1520
+ var e;
1521
+ return (e = this._singleRootActivity) === null || e === void 0 ? void 0 : e.getIsSampled();
1522
+ }
1523
+ isSingleRootActivityExternalSampled() {
1524
+ var e, t;
1525
+ return (t = (e = this._singleRootActivity) === null || e === void 0 ? void 0 : e.isExternalSampled) !== null && t !== void 0 ? t : !1;
1526
+ }
1527
+ _initMetrics() {
1528
+ return new fe(this.name, () => this.name);
1529
+ }
1530
+ getRootActivityHistoryEntry(e) {
1531
+ return this._rootActivityHistory.findByTime(e);
1532
+ }
1533
+ }
1534
+ const ft = 5;
1535
+ class pt {
1536
+ constructor(e, t) {
1537
+ this._instr = e, this._doc = t, this._isActive = !1, this._boundClickListener = this._clickListener.bind(this), o.requireArgument(e, "_instr"), o.requireArgument(t, "_doc");
1538
+ }
1539
+ activate() {
1540
+ this._isActive || (this._doc.addEventListener("click", this._boundClickListener, !0), this._isActive = !0);
1541
+ }
1542
+ deactivate() {
1543
+ this._isActive && (this._doc.removeEventListener("click", this._boundClickListener, !0), this._isActive = !1);
1544
+ }
1545
+ markEventHandled(e) {
1546
+ this._ignoredEvent = e;
1547
+ }
1548
+ _clickListener(e) {
1549
+ var t;
1550
+ let r = (t = e.composedPath) === null || t === void 0 ? void 0 : t.call(e);
1551
+ (!r || !r.length) && (r = e.path);
1552
+ const i = this._getClickableElement(r);
1553
+ i && setTimeout(() => {
1554
+ e !== this._ignoredEvent && this._instr.domEvent(e, i, void 0, void 0, {
1555
+ _auto: !0
1556
+ });
1557
+ });
1558
+ }
1559
+ _getClickableElement(e) {
1560
+ var t, r;
1561
+ const i = e ? Math.min(e.length, ft) : 0;
1562
+ for (let s = 0; s < i; s += 1) {
1563
+ const n = e[s], a = (t = n.tagName) === null || t === void 0 ? void 0 : t.toLowerCase();
1564
+ if (a === "a" || a === "button")
1565
+ return n;
1566
+ if (a === "input") {
1567
+ const u = n;
1568
+ if (((r = u.type) === null || r === void 0 ? void 0 : r.toLowerCase()) === "button")
1569
+ return u;
1570
+ }
1571
+ }
1572
+ }
1573
+ }
1574
+ const me = "o11y:receiver";
1575
+ var z;
1576
+ (function(l) {
1577
+ l[l.Unknown = 0] = "Unknown", l[l.Opening = 1] = "Opening";
1578
+ })(z || (z = {}));
1579
+ class mt {
1580
+ constructor(e, t, r) {
1581
+ this._logCallback = e, this._metricsCallback = t, this._commErrorCallback = r, this._senders = /* @__PURE__ */ new Map(), o.requireArgument(this._logCallback, "_logCallback", "function"), o.requireArgument(this._metricsCallback, "_metricsCallback", "function"), o.requireArgument(this._commErrorCallback, "_commErrorCallback", "function");
1582
+ }
1583
+ openComms(e) {
1584
+ if (o.requireArgument(e, "sender", "object"), !this._senders.has(e)) {
1585
+ const t = new MessageChannel(), r = {
1586
+ state: z.Opening,
1587
+ port: t.port1
1588
+ };
1589
+ this._senders.set(e, r), r.port.onmessage = this._messagePortEventHandler.bind(this), r.port.onmessageerror = this._messagePortErrorHandler.bind(this), e.postMessage({
1590
+ from: me,
1591
+ type: _e
1592
+ }, "*", [t.port2]);
1593
+ }
1594
+ }
1595
+ closeComms(e) {
1596
+ const t = this._senders.get(e);
1597
+ t && (t.port.onmessage = void 0, t.port.onmessageerror = void 0, this._senders.delete(e));
1598
+ }
1599
+ _messagePortEventHandler(e) {
1600
+ e.data.type === ge ? this._logCallback(e.data.data) : e.data.type === ve && this._metricsCallback(e.data.data);
1601
+ }
1602
+ _messagePortErrorHandler() {
1603
+ this._commErrorCallback();
1604
+ }
1605
+ }
1606
+ const _e = "handshake", ge = "log", ve = "metrics";
1607
+ class _t {
1608
+ constructor(e, t) {
1609
+ this._self = e, this._allowedOrigins = t, this._messageEventHandlerFunc = this._messageEventHandler.bind(this), this._handshakeComplete = !1, this._logBuffer = [], this._metricsBuffer = [], o.requireArgument(this._self, "_self", "object"), o.requireArgumentIfDefined(t, "allowedOrigins", Array), this._self.addEventListener("message", this._messageEventHandlerFunc);
1610
+ }
1611
+ _messageEventHandler(e) {
1612
+ e.data.from === me && e.data.type === _e && e.ports[0] instanceof MessagePort && o.isAllowedOrigin(e.origin, this._allowedOrigins) && (this._handshakeComplete = !0, this._self.removeEventListener("message", this._messageEventHandlerFunc), this._otherPort = e.ports[0], this._emptyBuffers());
1613
+ }
1614
+ sendLog(e) {
1615
+ this._handshakeComplete ? this._otherPort.postMessage({
1616
+ type: ge,
1617
+ data: e
1618
+ }) : this._logBuffer.push(e);
1619
+ }
1620
+ sendMetrics(e) {
1621
+ this._handshakeComplete ? this._otherPort.postMessage({
1622
+ type: ve,
1623
+ data: e
1624
+ }) : this._metricsBuffer.push(e);
1625
+ }
1626
+ _emptyBuffers() {
1627
+ this._logBuffer.forEach((e) => this.sendLog(e)), this._metricsBuffer.forEach((e) => this.sendMetrics(e)), this._logBuffer = void 0, this._metricsBuffer = void 0;
1628
+ }
1629
+ }
1630
+ class gt {
1631
+ constructor() {
1632
+ this._upCounters = [], this._valueRecorders = [], this._bucketHistograms = [];
1633
+ }
1634
+ add(e) {
1635
+ var t, r, i;
1636
+ !((t = e.upCounters) === null || t === void 0) && t.length && this._upCounters.push(...e.upCounters.map((s) => new ne(s.name, s.ownerName, s.ownerAppName, k.getMetricsTags(s.tags), s.createdTimestamp, s.lastUpdatedTimestamp, s.value))), !((r = e.valueRecorders) === null || r === void 0) && r.length && this._valueRecorders.push(...e.valueRecorders.map((s) => new he(s.name, s.ownerName, s.ownerAppName, k.getMetricsTags(s.tags), s.createdTimestamp, s.lastUpdatedTimestamp, s.values))), !((i = e.bucketHistograms) === null || i === void 0) && i.length && this._bucketHistograms.push(...e.bucketHistograms.map((s) => new ce(s.name, s.ownerName, s.ownerAppName, k.getMetricsTags(s.tags), s.buckets, s.createdTimestamp, s.lastUpdatedTimestamp, s.values)));
1637
+ }
1638
+ getUpCounters() {
1639
+ return this._upCounters = this._upCounters.filter((e) => e.getLastUpdatedOn() !== void 0), this._upCounters;
1640
+ }
1641
+ getValueRecorders() {
1642
+ return this._valueRecorders = this._valueRecorders.filter((e) => e.getLastUpdatedOn() !== void 0), this._valueRecorders;
1643
+ }
1644
+ getBucketHistograms() {
1645
+ return this._bucketHistograms = this._bucketHistograms.filter((e) => e.getLastUpdatedOn() !== void 0), this._bucketHistograms;
1646
+ }
1647
+ }
1648
+ function vt(l) {
1649
+ return !!l && typeof l == "object" && "envelopeContents" in l && "error" in l;
1650
+ }
1651
+ const yt = 1e3;
1652
+ class bt {
1653
+ constructor(e, t) {
1654
+ this._connector = e, this._pollInterval = yt, o.requireArgument(e, "_connector", "object"), o.requireArgumentIfDefined(t, "_pollInterval", "number") && t > 0 && (this._pollInterval = t);
1655
+ }
1656
+ collect(e, t, r) {
1657
+ const i = {
1658
+ schema: e,
1659
+ data: t,
1660
+ logMeta: r
1661
+ };
1662
+ this._connector.sendLog(i);
1663
+ }
1664
+ receiveMetricsExtractors(e) {
1665
+ this._metricsExtractors = e, this._collectAndSendMetrics(), setInterval(this._collectAndSendMetrics.bind(this), this._pollInterval);
1666
+ }
1667
+ _collectAndSendMetrics() {
1668
+ const e = {
1669
+ upCounters: k.getUpCounters(this._metricsExtractors.getAllUpCounters()),
1670
+ valueRecorders: k.getValueRecorders(this._metricsExtractors.getAllValueRecorders()),
1671
+ bucketHistograms: k.getBucketHistograms(this._metricsExtractors.getAllBucketHistograms())
1672
+ };
1673
+ (e.upCounters.length || e.valueRecorders.length || e.bucketHistograms.length) && this._connector.sendMetrics(e);
1674
+ }
1675
+ }
1676
+ const ye = 80, Ct = 32, be = "_CUT", It = ye - be.length;
1677
+ function N() {
1678
+ }
1679
+ class q {
1680
+ get preferredRootIdLength() {
1681
+ return this._preferredRootIdLength;
1682
+ }
1683
+ get pagePayloadProvider() {
1684
+ return this._pagePayloadProvider;
1685
+ }
1686
+ set pagePayloadProvider(e) {
1687
+ this._pagePayloadProvider = e;
1688
+ }
1689
+ get appPayloadProvider() {
1690
+ return this._appPayloadProvider;
1691
+ }
1692
+ set appPayloadProvider(e) {
1693
+ this._appPayloadProvider = e;
1694
+ }
1695
+ constructor(e) {
1696
+ this._idleDetector = e, this._logCollectors = /* @__PURE__ */ new Set(), this._instruments = /* @__PURE__ */ new Map(), this._seqBySchema = /* @__PURE__ */ new Map(), this._sequence = 0, this._forceDisabledLogCollectors = /* @__PURE__ */ new Set(), this._logCollectorFailures = /* @__PURE__ */ new Map(), this._isBufferingEnabled = !1, this._buffer = [], this._logCollectionListeners = /* @__PURE__ */ new Set(), this._opMode = "default", this._isSender = !1, this._isReceiver = !1, this._decimalPoints = 2;
1697
+ }
1698
+ registerApp(e, t) {
1699
+ var r, i;
1700
+ if (o.requireArgument(e, "name", "string"), this._appInstr)
1701
+ throw new Error("An app has already been registered with instrumentation.");
1702
+ if (this._instruments.get(e))
1703
+ throw new Error(`The instrumentation name ${e} is already taken`);
1704
+ if (x.setOwnerAppName(e), this._initOpMode(t == null ? void 0 : t.operationMode), this._isSender = this._opMode === "sender", this._isReceiver = this._opMode === "receiver", (t == null ? void 0 : t.decimalPoints) !== void 0 && (this._decimalPoints = t.decimalPoints), this._preferredRootIdLength = (r = t == null ? void 0 : t.preferredRootIdLength) !== null && r !== void 0 ? r : Ct, this._clientSessionId = ((i = t == null ? void 0 : t.clientSessionId) === null || i === void 0 ? void 0 : i.toString()) || o.generateUniqueId(), this._appInstr = new ht(this, e, t == null ? void 0 : t.allowMultipleRootActivities), this._instruments.set(e, this._appInstr), this._isSender) {
1705
+ const a = new bt(new _t(window, t == null ? void 0 : t.allowedReceiverOrigins), t == null ? void 0 : t.senderMetricsPollingInterval);
1706
+ this.registerLogCollector(a), this.registerMetricsCollector(a);
1707
+ } else this._isReceiver && (this._metricsStore = new gt(), this._receiverConnector = new mt((a) => {
1708
+ a.logMeta.receiverClientSessionId = this._clientSessionId, a.logMeta.receiverRootId = this._appInstr.getSingleRootActivityId(), this._multiplex(a.schema, a.data, a.logMeta);
1709
+ }, (a) => {
1710
+ this._metricsStore.add(a);
1711
+ }, () => {
1712
+ this._appInstr.incrementCounter("o11y-error-receiver", 1, !0);
1713
+ }));
1714
+ this._isBufferingEnabled = !this._isSender && (t == null ? void 0 : t.enableBuffering);
1715
+ const n = new d(this.getInstrumentation("Network"), this._idleDetector);
1716
+ return {
1717
+ log: this._appInstr.log.bind(this._appInstr),
1718
+ error: this._appInstr.error.bind(this._appInstr),
1719
+ startActivity: this._appInstr.startActivity.bind(this._appInstr),
1720
+ domEvent: this._appInstr.domEvent.bind(this._appInstr),
1721
+ incrementCounter: this._appInstr.incrementCounter.bind(this._appInstr),
1722
+ trackValue: this._appInstr.trackValue.bind(this._appInstr),
1723
+ bucketValue: this._appInstr.bucketValue.bind(this._appInstr),
1724
+ networkInstrumentation: n.networkInstrumentation.bind(n),
1725
+ registerForLogPrompt: this._appInstr.registerForLogPrompt.bind(this._appInstr),
1726
+ activity: this._appInstr.activity.bind(this._appInstr),
1727
+ activityAsync: this._appInstr.activityAsync.bind(this._appInstr),
1728
+ invokeNetworkCallWithHeaders: this._appInstr.invokeNetworkCallWithHeaders.bind(this._appInstr),
1729
+ startRootActivity: this._appInstr.startRootActivity.bind(this._appInstr),
1730
+ registerLogCollector: this._isSender ? N : this.registerLogCollector.bind(this),
1731
+ registerMetricsCollector: this._isSender ? N : this.registerMetricsCollector.bind(this),
1732
+ activateClickTracker: this.activateClickTracker.bind(this),
1733
+ deactivateClickTracker: this.deactivateClickTracker.bind(this),
1734
+ disableBuffering: this.disableBuffering.bind(this),
1735
+ promptLogCollection: this.promptLogCollection.bind(this),
1736
+ getClientSessionId: this.getClientSessionId.bind(this),
1737
+ getOperationMode: this.getOperationMode.bind(this),
1738
+ startReceiving: this._isReceiver ? this._receiverConnector.openComms.bind(this._receiverConnector) : N,
1739
+ stopReceiving: this._isReceiver ? this._receiverConnector.closeComms.bind(this._receiverConnector) : N
1740
+ };
1741
+ }
1742
+ getInstrumentation(e) {
1743
+ o.requireArgument(e, "name", "string"), e.length > ye && (e = e.substring(0, It) + be);
1744
+ let t = this._instruments.get(e);
1745
+ if (!t)
1746
+ t = new P(this, e), this._instruments.set(e, t);
1747
+ else if (t === this._appInstr)
1748
+ throw new Error(`The instrumentation name ${e} is being used by the app.`);
1749
+ return t;
1750
+ }
1751
+ get appName() {
1752
+ var e;
1753
+ return (e = this._appInstr) === null || e === void 0 ? void 0 : e.name;
1754
+ }
1755
+ getRootActivityHistoryEntryByTime(e) {
1756
+ var t;
1757
+ return (t = this._appInstr) === null || t === void 0 ? void 0 : t.getRootActivityHistoryEntry(e);
1758
+ }
1759
+ addLog(e, t, r, i, s, n) {
1760
+ var a, u, h;
1761
+ L.checkInputs(t, r), this._sequence += 1;
1762
+ const f = A.isInternal(t), _ = f && (r != null && r.userPayload) ? r.userPayload.schema : t, m = A.getSchemaId(_);
1763
+ let c = this._seqBySchema.get(m) || 0;
1764
+ c += 1, this._seqBySchema.set(m, c);
1765
+ const p = {
1766
+ timestamp: i,
1767
+ rootId: s,
1768
+ sequence: this._sequence,
1769
+ schemaSequence: c,
1770
+ loggerName: e,
1771
+ pagePayload: void 0,
1772
+ appPayload: void 0,
1773
+ loggerAppName: this.appName,
1774
+ connectionType: o.getConnectionType(),
1775
+ clientSessionId: this._clientSessionId,
1776
+ age: o.getAge(i),
1777
+ tenantClass: n || void 0
1778
+ }, g = {
1779
+ schema: t,
1780
+ data: r,
1781
+ logMeta: p
1782
+ };
1783
+ if (p.pagePayload = L.getPayloadFromProvider(this.pagePayloadProvider, g), p.appPayload = L.getPayloadFromProvider(this.appPayloadProvider, g), this._isSender || (r = o.clone(r)), typeof this._decimalPoints == "number" && (o.roundNumbersInObject(r, this._decimalPoints), f && o.roundNumbersInObject((a = r.userPayload) === null || a === void 0 ? void 0 : a.payload, this._decimalPoints), o.roundNumbersInObject((u = p.pagePayload) === null || u === void 0 ? void 0 : u.payload, this._decimalPoints), o.roundNumbersInObject((h = p.appPayload) === null || h === void 0 ? void 0 : h.payload, this._decimalPoints)), this._isBufferingEnabled) {
1784
+ const C = {
1785
+ schema: t,
1786
+ data: r,
1787
+ logMeta: p
1788
+ };
1789
+ this._buffer.push(C);
1790
+ }
1791
+ return this._multiplex(t, r, p), this._sequence;
1792
+ }
1793
+ _multiplex(e, t, r) {
1794
+ const i = Array.from(this._logCollectors).filter((s) => {
1795
+ var n;
1796
+ return !this._forceDisabledLogCollectors.has(s) && !(!((n = s.getIsCollectDisabled) === null || n === void 0) && n.call(s));
1797
+ });
1798
+ if (i.length > 0)
1799
+ for (const s of i)
1800
+ try {
1801
+ this._collect(s, e, t, r) === "sync" && this._recordCollectorSuccess(s);
1802
+ } catch (n) {
1803
+ this._recordCollectorFailure(s, n);
1804
+ }
1805
+ }
1806
+ _collect(e, t, r, i) {
1807
+ const s = e.collect(t, r, i);
1808
+ return !s || typeof s.then != "function" ? "sync" : (Promise.resolve(s).then(() => this._recordCollectorSuccess(e), (n) => {
1809
+ vt(n) ? this._recordCollectorSuccess(e) : this._recordCollectorFailure(e, n);
1810
+ }), "async");
1811
+ }
1812
+ _recordCollectorSuccess(e) {
1813
+ const t = this._logCollectorFailures.get(e) || 0;
1814
+ t > 0 && this._logCollectorFailures.set(e, t - 1);
1815
+ }
1816
+ _recordCollectorFailure(e, t) {
1817
+ const r = (this._logCollectorFailures.get(e) || 0) + 1;
1818
+ r >= q._collectorFailureLimit ? (this._forceDisabledLogCollectors.add(e), this._appInstr && (typeof t == "string" || t instanceof Error) && this._appInstr.error(t)) : this._logCollectorFailures.set(e, r);
1819
+ }
1820
+ getBuffer() {
1821
+ return this._buffer;
1822
+ }
1823
+ disableBuffering() {
1824
+ this._isBufferingEnabled = !1, this._buffer = [];
1825
+ }
1826
+ getClickTracker() {
1827
+ return this._autoClickTracker;
1828
+ }
1829
+ getDefaultInstrumentationContext() {
1830
+ var e, t, r;
1831
+ return {
1832
+ rootId: (e = this._appInstr) === null || e === void 0 ? void 0 : e.getSingleRootActivityId(),
1833
+ isRootActivitySampled: (t = this._appInstr) === null || t === void 0 ? void 0 : t.isSingleRootActivitySampled(),
1834
+ isRootActivityExternalSampled: (r = this._appInstr) === null || r === void 0 ? void 0 : r.isSingleRootActivityExternalSampled()
1835
+ };
1836
+ }
1837
+ activateClickTracker() {
1838
+ typeof document != "undefined" && (this._autoClickTracker || (this._autoClickTracker = new pt(this._appInstr, document)), this._autoClickTracker.activate());
1839
+ }
1840
+ deactivateClickTracker() {
1841
+ this._autoClickTracker && (this._autoClickTracker.deactivate(), this._autoClickTracker = void 0);
1842
+ }
1843
+ registerLogCollector(e, t) {
1844
+ if (o.requireArgument(e, "collector"), !this._logCollectors.has(e) && (this._logCollectors.add(e), this._logCollectorFailures.set(e, 0), (!e.getIsCollectDisabled || !e.getIsCollectDisabled()) && (t != null && t.retroactive)))
1845
+ for (const r of this._buffer)
1846
+ this._collect(e, r.schema, r.data, r.logMeta);
1847
+ }
1848
+ registerMetricsCollector(e) {
1849
+ if (o.requireArgument(e, "collector"), this._metricsCollector)
1850
+ throw new Error("A metrics Collector is already registered.");
1851
+ this._metricsCollector = e, this._metricsCollector.receiveMetricsExtractors({
1852
+ getAllUpCounters: this._getAllUpCounters.bind(this),
1853
+ getAllValueRecorders: this._getAllValueRecorders.bind(this),
1854
+ getAllBucketHistograms: this._getAllBucketHistograms.bind(this)
1855
+ });
1856
+ }
1857
+ _getAllUpCounters() {
1858
+ var e;
1859
+ return (((e = this._metricsStore) === null || e === void 0 ? void 0 : e.getUpCounters()) || []).concat(Array.from(this._instruments.values()).map((t) => t.getUpCounters()).flat()).concat(x.getUpCounters());
1860
+ }
1861
+ _getAllValueRecorders() {
1862
+ var e;
1863
+ return (((e = this._metricsStore) === null || e === void 0 ? void 0 : e.getValueRecorders()) || []).concat(Array.from(this._instruments.values()).map((t) => t.getValueRecorders()).flat()).concat(x.getValueRecorders());
1864
+ }
1865
+ _getAllBucketHistograms() {
1866
+ var e;
1867
+ return (((e = this._metricsStore) === null || e === void 0 ? void 0 : e.getBucketHistograms()) || []).concat(Array.from(this._instruments.values()).map((t) => t.getBucketHistograms()).flat()).concat(x.getBucketHistograms());
1868
+ }
1869
+ registerForLogPrompt(e) {
1870
+ this._logCollectionListeners.add(e);
1871
+ }
1872
+ promptLogCollection(e) {
1873
+ for (const t of this._logCollectionListeners.keys())
1874
+ try {
1875
+ t(e);
1876
+ } catch (r) {
1877
+ if (!o.isProduction)
1878
+ throw r;
1879
+ }
1880
+ }
1881
+ getClientSessionId() {
1882
+ return this._clientSessionId;
1883
+ }
1884
+ _initOpMode(e) {
1885
+ if (typeof e == "function" && (e = e()), (e === void 0 || typeof window != "object") && (e = "default"), ["default", "receiver", "sender"].indexOf(e) >= 0)
1886
+ this._opMode = e;
1887
+ else
1888
+ throw new Error(`Invalid operation mode: ${e}`);
1889
+ }
1890
+ getOperationMode() {
1891
+ return this._opMode;
1892
+ }
1893
+ }
1894
+ q._collectorFailureLimit = 5;
1895
+ class At {
1896
+ get _lazyNextGen() {
1897
+ return this._nextgen || (this._nextgen = new q(this._idleDetector)), this._nextgen;
1898
+ }
1899
+ constructor(e) {
1900
+ this._idleDetector = e, o.requireArgument(e, "_idleDetector");
1901
+ }
1902
+ registerInstrumentedApp(e, t) {
1903
+ const r = this._lazyNextGen.registerApp(e, t);
1904
+ return t && (o.markProduction(t.isProduction), this._nextgen.appPayloadProvider = t.appPayloadProvider, this._nextgen.pagePayloadProvider = t.pagePayloadProvider), r;
1905
+ }
1906
+ getInstrumentation(e) {
1907
+ return this._lazyNextGen.getInstrumentation(e);
1908
+ }
1909
+ }
1910
+ const Tt = o.time.bind(o), St = "sfcore.customCmp.CustomComponentLog", Et = {
1911
+ Error: "Crimson",
1912
+ Activity: "CadetBlue",
1913
+ InstrumentedEvent: "DarkOliveGreen",
1914
+ O11ySample: "BlueViolet"
1915
+ }, kt = {
1916
+ Error: "white",
1917
+ Activity: "white",
1918
+ InstrumentedEvent: "white",
1919
+ O11ySample: "white"
1920
+ }, ie = "black", se = "Gainsboro";
1921
+ class Ot {
1922
+ constructor(e) {
1923
+ this._simpleFilters = /* @__PURE__ */ new Set(), this._regexFilters = [], e && this._log("ConsoleCollector", e);
1924
+ }
1925
+ collect(e, t, r) {
1926
+ const i = A.getSchemaId(e);
1927
+ if (!this._shouldLog(i))
1928
+ return;
1929
+ if (i === St) {
1930
+ this._logCustom(t);
1931
+ return;
1932
+ }
1933
+ let s, n, a;
1934
+ A.isInternal(e) ? (s = e.name, n = kt[e.name] || ie, a = Et[e.name] || se) : s = i, this._log(s, t, r, n, a);
1935
+ }
1936
+ _shouldLog(e) {
1937
+ return this._simpleFilters.size == 0 && this._regexFilters.length == 0 ? !0 : this._simpleFilters.has(e) || this._regexFilters.some((t) => t.test(e));
1938
+ }
1939
+ addFilter(e) {
1940
+ e instanceof RegExp ? this._regexFilters.push(e) : this._simpleFilters.add(e);
1941
+ }
1942
+ removeFilter(e) {
1943
+ if (e instanceof RegExp) {
1944
+ const t = this._regexFilters.findIndex((r) => r.source === e.source);
1945
+ t >= 0 && this._regexFilters.splice(t, 1);
1946
+ } else
1947
+ this._simpleFilters.delete(e);
1948
+ }
1949
+ clearFilters() {
1950
+ this._simpleFilters.clear(), this._regexFilters.splice(0, this._regexFilters.length);
1951
+ }
1952
+ getFilters() {
1953
+ return Array.from(this._simpleFilters).concat(this._regexFilters).sort();
1954
+ }
1955
+ _log(e, t, r, i = ie, s = se) {
1956
+ const n = `color:${i};background-color:${s}`;
1957
+ console.log(`%cO11Y%c ${e}`, "color:white;background-color:#FF6600;font-weight:bold", n, t || "", r || "");
1958
+ }
1959
+ _logCustom(e) {
1960
+ console.log("%clightning/logger", "color:white;background-color:#00a1e0;font-weight:bold", e || "");
1961
+ }
1962
+ }
1963
+ const Nt = "260.0.0", wt = new Le({
1964
+ logThreshold: 300,
1965
+ reportListener: (l) => {
1966
+ S == null || S.log(ke, l);
1967
+ },
1968
+ errorListener: (l, e) => {
1969
+ S == null || S.error(l, e);
1970
+ }
1971
+ }), D = new At(wt), Lt = D.registerInstrumentedApp.bind(D), Rt = D.getInstrumentation.bind(D), S = Rt("IdleDetector");
1972
+ export {
1973
+ Ot as ConsoleCollector,
1974
+ Nt as _version,
1975
+ Rt as getInstrumentation,
1976
+ wt as idleDetector,
1977
+ Lt as registerInstrumentedApp,
1978
+ Tt as time
1979
+ };