@epigraph/epigraph-std-lib 4.5.5-alpha → 4.7.0-alpha

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,82 +1,126 @@
1
- var o = /* @__PURE__ */ ((s) => (s.UNAVAILABLE = "unavailable", s.AVAILABLE = "available", s.RESTRICTED = "restricted", s))(o || {});
2
- const p = Symbol("data"), l = Symbol("next"), N = class v {
3
- constructor(e) {
4
- this[p] = e, this[l] = null;
1
+ var c = /* @__PURE__ */ ((n) => (n.UNAVAILABLE = "unavailable", n.AVAILABLE = "available", n.RESTRICTED = "restricted", n))(c || {});
2
+ const g = Symbol("data"), d = Symbol("next"), P = class v {
3
+ constructor(t) {
4
+ this[g] = t, this[d] = null;
5
5
  }
6
6
  get data() {
7
- return this[p];
7
+ return this[g];
8
8
  }
9
- set next(e) {
10
- if (!(e instanceof v) && e !== null)
9
+ set next(t) {
10
+ if (!(t instanceof v) && t !== null)
11
11
  throw new Error(
12
12
  "This node is not an instance of the custom class 'Node'."
13
13
  );
14
- this[l] = e;
14
+ this[d] = t;
15
15
  }
16
16
  get next() {
17
- return this[l];
17
+ return this[d];
18
18
  }
19
19
  };
20
- let g = N;
21
- const d = Symbol("head");
22
- class P {
20
+ let E = P;
21
+ const p = Symbol("head");
22
+ class O {
23
23
  constructor() {
24
- this[d] = null;
24
+ this[p] = null;
25
25
  }
26
- set head(e) {
27
- this[d] = e;
26
+ set head(t) {
27
+ this[p] = t;
28
28
  }
29
29
  get head() {
30
- return this[d];
30
+ return this[p];
31
31
  }
32
- addToTail(e) {
33
- let t = this.head;
34
- if (t) {
35
- for (; t.next !== null; )
36
- t = t?.next;
37
- return t.next = new g(e);
32
+ addToTail(t) {
33
+ let e = this.head;
34
+ if (e) {
35
+ for (; e.next !== null; )
36
+ e = e?.next;
37
+ return e.next = new E(t);
38
38
  }
39
- return this.head = new g(e);
39
+ return this.head = new E(t);
40
40
  }
41
41
  removeHead() {
42
- const e = this.head;
43
- if (e)
44
- return this.head = e.next, e.data;
42
+ const t = this.head;
43
+ if (t)
44
+ return this.head = t.next, t.data;
45
45
  }
46
46
  }
47
- const _ = Symbol("queue"), h = Symbol("size");
48
- class m {
47
+ const m = Symbol("queue"), _ = Symbol("size");
48
+ class N {
49
49
  constructor() {
50
- this[_] = new P(), this[h] = 0;
50
+ this[m] = new O(), this[_] = 0;
51
51
  }
52
52
  get queue() {
53
- return this[_];
53
+ return this[m];
54
54
  }
55
55
  get size() {
56
- return this[h];
56
+ return this[_];
57
57
  }
58
- enqueue(e) {
59
- this.queue.addToTail(e), this[h]++;
58
+ enqueue(t) {
59
+ this.queue.addToTail(t), this[_]++;
60
60
  }
61
61
  dequeue() {
62
- const e = this.queue.removeHead();
63
- return this[h]--, e;
62
+ const t = this.queue.removeHead();
63
+ return this[_]--, t;
64
64
  }
65
65
  }
66
- class I {
66
+ class u {
67
+ static {
68
+ this.NOTIFICATION_NAME = "epg-notification";
69
+ }
70
+ static {
71
+ this.ACTION_SEND_EVENT = "send-event";
72
+ }
73
+ static {
74
+ this.ACTION_INITIALIZED = "initialized";
75
+ }
76
+ static {
77
+ this.ACTION_FAILED_INITIALIZATION = "initialization-failed";
78
+ }
79
+ constructor(t, e, i, s, r, o) {
80
+ this._pluginName = t, this._trackingId = e, this._experienceId = i, this._solution = s, this._initializer = r, this._status = o;
81
+ }
82
+ updateStatus(t) {
83
+ this._status = t;
84
+ }
85
+ updateInitializer(t) {
86
+ this._initializer = t;
87
+ }
88
+ notify(t, e) {
89
+ console.log("Notifying", t, e);
90
+ const i = {
91
+ pluginName: this._pluginName,
92
+ trackingId: this._trackingId,
93
+ experienceId: this._experienceId,
94
+ solution: this._solution,
95
+ initializer: this._initializer,
96
+ status: this._status,
97
+ action: t,
98
+ eventDetails: e
99
+ };
100
+ window.dispatchEvent(new CustomEvent("epg-notification", { detail: i }));
101
+ }
102
+ }
103
+ class S {
67
104
  constructor({
68
- trackingID: e,
69
- experienceID: t,
70
- solution: n,
71
- verboseLogging: i = !1
105
+ trackingID: t,
106
+ experienceID: e,
107
+ solution: i,
108
+ verboseLogging: s = !1
72
109
  }) {
73
- this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.__initializationAttempts = 0, this.__lastInitializationAttempt = performance.now(), this.__maxInitializationAttempts = 10, this.__initializationRetryDelay = 2e3, this.__isInitialized = !1, this.__initializationMethod = "NONE", this.__nexusFailureReported = !1, this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = e, this.experienceID = t, this.solution = n, this.verboseLogging = i, this.__queue = new m(), this.initializePlugin();
110
+ this.__status = c.UNAVAILABLE, this.__sentEventCount = 0, this.__initializationAttempts = 0, this.__lastInitializationAttempt = performance.now(), this.__maxInitializationAttempts = 10, this.__initializationRetryDelay = 2e3, this.__isInitialized = !1, this.__initializationMethod = "NONE", this.__nexusFailureReported = !1, this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = t, this.experienceID = e, this.solution = i, this.verboseLogging = s, this.__queue = new N(), this.__epigraphNotifier = new u(
111
+ this.pluginName,
112
+ this.pluginName,
113
+ this.experienceID,
114
+ this.solution,
115
+ this.__initializationMethod,
116
+ this.__status
117
+ ), this.initializePlugin();
74
118
  }
75
119
  getStatus() {
76
120
  return this.__status;
77
121
  }
78
- setStatus(e) {
79
- this.__status = e;
122
+ setStatus(t) {
123
+ this.__status = t, this.__epigraphNotifier.updateStatus(t);
80
124
  }
81
125
  getPendingEventCount() {
82
126
  return this.__queue.size;
@@ -102,9 +146,9 @@ class I {
102
146
  * @param analyticsEvent
103
147
  * @param consent boolean Whether consent is granted
104
148
  */
105
- async sendEvent(e, t) {
106
- if (this.__queue.enqueue(e), !t) {
107
- this.__status = o.RESTRICTED;
149
+ async sendEvent(t, e) {
150
+ if (this.__queue.enqueue(t), !e) {
151
+ this.__status = c.RESTRICTED;
108
152
  return;
109
153
  }
110
154
  if (!this.__isInitialized) {
@@ -113,41 +157,41 @@ class I {
113
157
  }
114
158
  try {
115
159
  await this.dequeueAndSendEvents();
116
- } catch (n) {
117
- this.logger(n), await this.reportFailureToNexus("EVENT_SEND_ERROR", n?.toString() || "Unknown error");
160
+ } catch (i) {
161
+ this.logger(i), await this.reportFailureToNexus("EVENT_SEND_ERROR", i?.toString() || "Unknown error");
118
162
  }
119
163
  }
120
164
  initializePlugin() {
121
165
  if (this.__isInitialized)
122
166
  return;
123
167
  if (this.__initializationAttempts >= this.__maxInitializationAttempts) {
124
- this.__nexusFailureReported || (this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS", "Maximum initialization attempts reached"), this.__nexusFailureReported = !0);
168
+ this.__nexusFailureReported || (this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS", "Maximum initialization attempts reached"), this.__nexusFailureReported = !0, this.__epigraphNotifier.notify(u.ACTION_FAILED_INITIALIZATION, {}));
125
169
  return;
126
170
  }
127
- const e = performance.now();
128
- if (this.__initializationAttempts > 0 && e - this.__lastInitializationAttempt < this.__initializationRetryDelay)
171
+ const t = performance.now();
172
+ if (this.__initializationAttempts > 0 && t - this.__lastInitializationAttempt < this.__initializationRetryDelay)
129
173
  return;
130
- this.__lastInitializationAttempt = e, this.__initializationAttempts++;
131
- const t = this.detectAndSetupAnalytics();
132
- t.success ? (this.__isInitialized = !0, this.__status = o.AVAILABLE, this.__initializationMethod = t.method, this.dataLayerName = t.dataLayerName, this.dataLayer = window[this.dataLayerName], this.logger(`Successfully initialized ${t.method} with dataLayer: ${this.dataLayerName}`), this.__queue.size > 0 && this.dequeueAndSendEvents()) : (this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${t.error}`), this.__initializationAttempts < this.__maxInitializationAttempts && setTimeout(() => {
174
+ this.__lastInitializationAttempt = t, this.__initializationAttempts++;
175
+ const e = this.detectAndSetupAnalytics();
176
+ e.success ? (this.__isInitialized = !0, this.__status = c.AVAILABLE, this.__initializationMethod = e.method, this.dataLayerName = e.dataLayerName, this.dataLayer = window[this.dataLayerName], this.logger(`Successfully initialized ${e.method} with dataLayer: ${this.dataLayerName}`), this.__epigraphNotifier.notify(u.ACTION_INITIALIZED, {}), this.__queue.size > 0 && this.dequeueAndSendEvents()) : (this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${e.error}`), this.__initializationAttempts < this.__maxInitializationAttempts && setTimeout(() => {
133
177
  this.initializePlugin();
134
178
  }, this.__initializationRetryDelay));
135
179
  }
136
180
  detectAndSetupAnalytics() {
137
- const e = this.detectGTM();
138
- if (e)
139
- return this.logger(`GTM detected with container ID: ${e.containerId}`), {
181
+ const t = this.detectGTM();
182
+ if (t)
183
+ return this.logger(`GTM detected with container ID: ${t.containerId}`), this.__epigraphNotifier.updateInitializer("GTM"), {
140
184
  success: !0,
141
185
  method: "GTM",
142
- dataLayerName: e.dataLayerName
186
+ dataLayerName: t.dataLayerName
143
187
  };
144
- const t = this.findGA4Info(this.trackingID);
145
- if (t) {
146
- const n = t.l || "dataLayer";
147
- return this.logger(`GA4 script found, setting up with dataLayer: ${n}`), {
188
+ const e = this.findGA4Info(this.trackingID);
189
+ if (e) {
190
+ const i = e.l || "dataLayer";
191
+ return this.logger(`GA4 script found, setting up with dataLayer: ${i}`), this.__epigraphNotifier.updateInitializer("GA4"), {
148
192
  success: !0,
149
193
  method: "GA4",
150
- dataLayerName: n
194
+ dataLayerName: i
151
195
  };
152
196
  }
153
197
  return {
@@ -158,16 +202,16 @@ class I {
158
202
  };
159
203
  }
160
204
  detectGTM() {
161
- const e = document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');
162
- for (const t of Array.from(e)) {
163
- const n = t.getAttribute("src");
164
- if (n) {
165
- const i = n.match(/gtm\.js\?id=([^&]+)/);
166
- if (i && i.length > 0) {
167
- const r = n.match(/&l=([^&]+)/), u = r ? r[1] : "dataLayer";
205
+ const t = document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');
206
+ for (const e of Array.from(t)) {
207
+ const i = e.getAttribute("src");
208
+ if (i) {
209
+ const s = i.match(/gtm\.js\?id=([^&]+)/);
210
+ if (s && s.length > 0) {
211
+ const r = i.match(/&l=([^&]+)/), o = r ? r[1] : "dataLayer";
168
212
  return {
169
- containerId: i[1],
170
- dataLayerName: u
213
+ containerId: s[1],
214
+ dataLayerName: o
171
215
  };
172
216
  }
173
217
  }
@@ -181,13 +225,13 @@ class I {
181
225
  async dequeueAndSendEvents() {
182
226
  if (!this.__isInitialized || !this.dataLayer)
183
227
  return;
184
- let e = this.__queue.size;
185
- for (let t = 0; t < e; t++) {
186
- const n = this.__queue.dequeue();
228
+ let t = this.__queue.size;
229
+ for (let e = 0; e < t; e++) {
230
+ const i = this.__queue.dequeue();
187
231
  try {
188
- this.__initializationMethod === "GTM" ? (this.sendGTMEvent(n), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)) : this.__initializationMethod === "GA4" ? (this.sendGA4Event(n), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)) : this.__queue.enqueue(n);
189
- } catch (i) {
190
- this.logger(`Error sending event ${n.eventName}: ${i}`), this.__queue.enqueue(n);
232
+ this.__initializationMethod === "GTM" ? (this.sendGTMEvent(i), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${i.eventName}`)) : this.__initializationMethod === "GA4" ? (this.sendGA4Event(i), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${i.eventName}`)) : this.__queue.enqueue(i);
233
+ } catch (s) {
234
+ this.logger(`Error sending event ${i.eventName}: ${s}`), this.__queue.enqueue(i);
191
235
  }
192
236
  }
193
237
  }
@@ -196,18 +240,20 @@ class I {
196
240
  * @param event
197
241
  * @private
198
242
  */
199
- async sendGTMEvent(e) {
200
- let t = e.getGTMParameters(this.solution, this.experienceID, this.trackingID);
201
- this.isValidPayload(t) || (t = await this.convertGTMParametersToEpgEventTag(e.eventName, t)), this.dataLayer && this.dataLayer.push(t);
243
+ async sendGTMEvent(t) {
244
+ let e = t.getGTMParameters(this.solution, this.experienceID, this.trackingID);
245
+ const i = e;
246
+ this.isValidPayload(e) || (e = await this.convertGTMParametersToEpgEventTag(t.eventName, e)), this.dataLayer && (this.dataLayer.push(e), this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, i));
202
247
  }
203
248
  /**
204
249
  * Send events to GA4 via Google Analytics 4.
205
250
  * @param event
206
251
  * @private
207
252
  */
208
- async sendGA4Event(e) {
209
- let t = e.getGa4Parameters(this.solution, this.experienceID, this.trackingID);
210
- this.isValidPayload(t) || (t = await this.convertGA4ParametersToEpgEventTag(t)), window.gtag("event", e.eventName, t);
253
+ async sendGA4Event(t) {
254
+ let e = t.getGa4Parameters(this.solution, this.experienceID, this.trackingID);
255
+ const i = e;
256
+ this.isValidPayload(e) || (e = await this.convertGA4ParametersToEpgEventTag(e)), window.gtag("event", t.eventName, e), this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, i);
211
257
  }
212
258
  /**
213
259
  * Validates a payload by checking its parameter count and the constraints of parameter names and values.
@@ -217,11 +263,11 @@ class I {
217
263
  * The keys represent parameter names and the values represent parameter values.
218
264
  * @return {boolean} Returns true if the payload meets the validation criteria; false otherwise.
219
265
  */
220
- isValidPayload(e) {
221
- if (Object.keys(e).length >= 25)
266
+ isValidPayload(t) {
267
+ if (Object.keys(t).length >= 25)
222
268
  return !1;
223
- for (const [i, r] of Object.entries(e))
224
- if (i !== "items" && (i.length > 40 || String(r).length > 100))
269
+ for (const [s, r] of Object.entries(t))
270
+ if (s !== "items" && (s.length > 40 || String(r).length > 100))
225
271
  return !1;
226
272
  return !0;
227
273
  }
@@ -233,16 +279,16 @@ class I {
233
279
  * @param {Record<string, unknown>} parameterPayload - A key-value pair object containing the parameters to be converted.
234
280
  * @return {Promise<Record<string, unknown>>} A promise that resolves to an object containing the event name and the generated EPG event tag, or the original payload upon failure.
235
281
  */
236
- async convertGTMParametersToEpgEventTag(e, t) {
282
+ async convertGTMParametersToEpgEventTag(t, e) {
237
283
  try {
238
- let n = await this.sendGA4LongParameters(t);
284
+ let i = await this.sendGA4LongParameters(e);
239
285
  return {
240
- event: e,
241
- epg_event_tag: n,
286
+ event: t,
287
+ epg_event_tag: i,
242
288
  send_to: this.trackingID
243
289
  };
244
290
  } catch {
245
- return t;
291
+ return e;
246
292
  }
247
293
  }
248
294
  /**
@@ -251,100 +297,107 @@ class I {
251
297
  * @param {Record<string, unknown>} parameterPayload - The GA4 parameters to be converted.
252
298
  * @return {Promise<Record<string, any>>} A promise resolving to an object containing the EPG event tag or the original payload if the conversion fails.
253
299
  */
254
- async convertGA4ParametersToEpgEventTag(e) {
300
+ async convertGA4ParametersToEpgEventTag(t) {
255
301
  try {
256
302
  return {
257
- epg_event_tag: await this.sendGA4LongParameters(e),
303
+ epg_event_tag: await this.sendGA4LongParameters(t),
258
304
  send_to: this.trackingID
259
305
  };
260
306
  } catch {
261
- return e;
307
+ return t;
262
308
  }
263
309
  }
264
310
  /**
265
311
  * Checks if verboseLogging is enabled, then logs the error
266
312
  * @param err
267
313
  */
268
- logger(e) {
269
- this.verboseLogging && console.warn(e);
314
+ logger(t) {
315
+ this.verboseLogging && console.warn(t);
270
316
  }
271
- async sendGA4LongParameters(e) {
272
- const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = { parameters: e };
317
+ async sendGA4LongParameters(t) {
318
+ const e = "https://api.myepigraph.com/api/analytics/ga4/custom", i = { parameters: t };
273
319
  try {
274
- const i = await fetch(t, {
320
+ const s = await fetch(e, {
275
321
  method: "POST",
276
322
  // Assuming it's a POST request, adjust if necessary
277
323
  headers: {
278
324
  "Content-Type": "application/json",
279
325
  Accept: "application/json"
280
326
  },
281
- body: JSON.stringify(n)
327
+ body: JSON.stringify(i)
282
328
  });
283
- return i.ok ? (await i.json())?.id ?? "" : "";
329
+ return s.ok ? (await s.json())?.id ?? "" : "";
284
330
  } catch {
285
331
  return "";
286
332
  }
287
333
  }
288
- async reportFailureToNexus(e, t) {
334
+ async reportFailureToNexus(t, e) {
289
335
  try {
290
- const n = {
336
+ const i = {
291
337
  plugin: "GA4",
292
338
  trackingId: this.trackingID,
293
339
  solution: this.solution,
294
340
  experienceId: this.experienceID,
295
- failureType: e,
296
- errorMessage: t,
341
+ failureType: t,
342
+ errorMessage: e,
297
343
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
298
344
  url: window.location.href,
299
345
  userAgent: navigator.userAgent
300
346
  };
301
- this.logger(`Failure reported to Nexus: ${JSON.stringify(n)}`);
302
- } catch (n) {
303
- this.logger(`Error reporting failure to Nexus: ${n}`);
347
+ this.logger(`Failure reported to Nexus: ${JSON.stringify(i)}`);
348
+ } catch (i) {
349
+ this.logger(`Error reporting failure to Nexus: ${i}`);
304
350
  }
305
351
  }
306
- findGA4Info(e) {
307
- if (window.google_tag_manager && window.google_tag_manager[e]) {
308
- const n = window.google_tag_manager[e];
309
- if (n && n.dataLayerName)
352
+ findGA4Info(t) {
353
+ if (window.google_tag_manager && window.google_tag_manager[t]) {
354
+ const i = window.google_tag_manager[t];
355
+ if (i && i.dataLayerName)
310
356
  return {
311
357
  fullSrc: "",
312
- id: e,
313
- l: n.dataLayerName
358
+ id: t,
359
+ l: i.dataLayerName
314
360
  };
315
361
  }
316
- const t = document.querySelectorAll("script[src]");
317
- for (const n of t) {
318
- const i = n.getAttribute("src");
319
- if (i && i.includes(e)) {
320
- const r = new URL(i, location.href), u = Object.fromEntries(r.searchParams.entries());
362
+ const e = document.querySelectorAll("script[src]");
363
+ for (const i of e) {
364
+ const s = i.getAttribute("src");
365
+ if (s && s.includes(t)) {
366
+ const r = new URL(s, location.href), o = Object.fromEntries(r.searchParams.entries());
321
367
  return {
322
368
  fullSrc: r.href,
323
- id: u.id || void 0,
324
- l: u.l || void 0
369
+ id: o.id || void 0,
370
+ l: o.l || void 0
325
371
  };
326
372
  }
327
373
  }
328
374
  return null;
329
375
  }
330
376
  }
331
- class C {
377
+ class L {
332
378
  constructor({
333
- trackingID: e,
334
- experienceID: t,
335
- solution: n,
336
- sessionId: i,
379
+ trackingID: t,
380
+ experienceID: e,
381
+ solution: i,
382
+ sessionId: s,
337
383
  xPath: r,
338
- verboseLogging: u = !1,
384
+ verboseLogging: o = !1,
339
385
  sendToStaging: y = !1
340
386
  }) {
341
- this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.sessionId = i, this.xPath = r, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = e, this.experienceID = t, this.solution = n, this.verboseLogging = u, this.__queue = new m(), this.url = y ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event", this.__status = o.AVAILABLE;
387
+ this.__status = c.UNAVAILABLE, this.__sentEventCount = 0, this.sessionId = s, this.xPath = r, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = t, this.experienceID = e, this.solution = i, this.verboseLogging = o, this.__queue = new N(), this.url = y ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event", this.__status = c.AVAILABLE, this.__epigraphNotifier = new u(
388
+ this.pluginName,
389
+ this.trackingID,
390
+ this.experienceID,
391
+ this.solution,
392
+ "NEXUS",
393
+ this.__status
394
+ ), this.__epigraphNotifier.notify(u.ACTION_INITIALIZED, {});
342
395
  }
343
396
  getStatus() {
344
397
  return this.__status;
345
398
  }
346
- setStatus(e) {
347
- this.__status = e;
399
+ setStatus(t) {
400
+ this.__status = t, this.__epigraphNotifier.updateStatus(t);
348
401
  }
349
402
  getPendingEventCount() {
350
403
  return this.__queue.size;
@@ -360,22 +413,21 @@ class C {
360
413
  }
361
414
  setupPlugin() {
362
415
  }
363
- async sendEvent(e, t) {
364
- if (this.__queue.enqueue(e), !t) {
365
- this.__status = o.RESTRICTED;
416
+ async sendEvent(t, e) {
417
+ if (this.__queue.enqueue(t), !e) {
418
+ this.__status = c.RESTRICTED, this.__epigraphNotifier.updateStatus(this.__status);
366
419
  return;
367
420
  }
368
421
  await this.dequeueAndSendEvents();
369
422
  }
370
423
  async dequeueAndSendEvents() {
371
- for (let e = 0; e < this.__queue.size; e++) {
372
- const t = this.__queue.dequeue();
373
- t.customParameters.solution = this.solution;
374
- const n = {
375
- trackingID: this.trackingID,
424
+ for (let t = 0; t < this.__queue.size; t++) {
425
+ const e = this.__queue.dequeue(), i = {
426
+ send_to: this.trackingID,
376
427
  experience_id: this.experienceID,
377
- action: t.eventName,
378
- parameters: t.getNexusParameters()
428
+ solution: this.solution,
429
+ event: e.eventName,
430
+ parameters: e.getNexusParameters()
379
431
  };
380
432
  try {
381
433
  return (await fetch(this.url, {
@@ -388,8 +440,8 @@ class C {
388
440
  "EPG-XPATH": this.xPath,
389
441
  Origin: typeof window < "u" ? window.location.origin : ""
390
442
  },
391
- body: JSON.stringify(n)
392
- })).status === 200, "";
443
+ body: JSON.stringify(i)
444
+ })).ok && this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, i), "";
393
445
  } catch {
394
446
  return "";
395
447
  }
@@ -398,9 +450,9 @@ class C {
398
450
  return "";
399
451
  }
400
452
  }
401
- class A {
402
- constructor(e) {
403
- this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
453
+ class C {
454
+ constructor(t) {
455
+ this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = t, this.consent = !1, this.addConsentChangedListener();
404
456
  }
405
457
  /**
406
458
  * Checks to see if the user has consented. If this is false, it will block all analytics
@@ -409,9 +461,9 @@ class A {
409
461
  if (this.consentSet)
410
462
  return this.consent;
411
463
  if (window.OnetrustActiveGroups !== void 0) {
412
- let e = window.OnetrustActiveGroups;
413
- e !== void 0 && e.split(",").forEach((n) => {
414
- n === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
464
+ let t = window.OnetrustActiveGroups;
465
+ t !== void 0 && t.split(",").forEach((i) => {
466
+ i === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
415
467
  });
416
468
  }
417
469
  return this.consent;
@@ -424,223 +476,309 @@ class A {
424
476
  });
425
477
  }
426
478
  }
427
- var E = /* @__PURE__ */ ((s) => (s.OneTrust = "onetrust", s))(E || {});
479
+ var f = /* @__PURE__ */ ((n) => (n.OneTrust = "onetrust", n))(f || {});
428
480
  class a {
429
481
  constructor({
430
- eventName: e,
431
- interactiveEvent: t,
432
- customParameters: n
482
+ eventName: t,
483
+ interactiveEvent: e,
484
+ customParameters: i
433
485
  }) {
434
- this.eventName = e, this.interactiveEvent = t, this.customParameters = n;
486
+ this.eventName = t, this.interactiveEvent = e, this.customParameters = i;
435
487
  }
436
- getGa4Parameters(e, t, n) {
437
- let i = {
438
- solution: e,
439
- experience_id: t,
488
+ getGa4Parameters(t, e, i) {
489
+ let s = {
490
+ solution: t,
491
+ experience_id: e,
440
492
  interactive_event: this.interactiveEvent,
441
- send_to: n
493
+ send_to: i
442
494
  };
443
- return i = Object.assign(i, JSON.parse(JSON.stringify(this.customParameters))), i;
495
+ return s = Object.assign(s, JSON.parse(JSON.stringify(this.customParameters))), s;
444
496
  }
445
- getGTMParameters(e, t, n) {
446
- let i = {
447
- solution: e,
448
- experience_id: t,
497
+ getGTMParameters(t, e, i) {
498
+ let s = {
499
+ solution: t,
500
+ experience_id: e,
449
501
  event: this.eventName,
450
502
  interactive_event: this.interactiveEvent,
451
- send_to: n
503
+ send_to: i
452
504
  };
453
- return i = Object.assign(i, JSON.parse(JSON.stringify(this.customParameters))), i;
505
+ return s = Object.assign(s, JSON.parse(JSON.stringify(this.customParameters))), s;
454
506
  }
455
507
  getNexusParameters() {
456
- let e = {
508
+ let t = {
457
509
  interactive_event: this.interactiveEvent
458
510
  };
459
- return e = Object.assign(e, JSON.parse(JSON.stringify(this.customParameters))), e;
511
+ return t = Object.assign(t, JSON.parse(JSON.stringify(this.customParameters))), t;
460
512
  }
461
513
  }
514
+ const I = {
515
+ AR: "ar",
516
+ QR: "qr",
517
+ INFO: "info",
518
+ DOWNLOAD: "download",
519
+ PREVIEW_CART: "preview_cart",
520
+ HOTSPOT_PANEL: "hotspot_panel",
521
+ SHARE_MODAL: "share_modal",
522
+ RESTART_MODAL: "restart_modal",
523
+ REMOVE_MODAL: "remove_modal",
524
+ LOAD_PRECONFIG_MODAL: "load_preconfig_modal",
525
+ MOVE_MODAL: "move_modal",
526
+ OUT_OF_STOCK_MODAL: "out_of_stock_modal"
527
+ }, T = {
528
+ AUTO: "auto",
529
+ BUTTON: "button",
530
+ HOTSPOT: "hotspot",
531
+ GESTURE: "gesture"
532
+ }, l = {
533
+ USD: "USD",
534
+ EUR: "EUR",
535
+ GBP: "GBP",
536
+ CAD: "CAD"
537
+ };
462
538
  class w extends a {
463
- constructor(e = []) {
539
+ constructor(t) {
464
540
  super({
465
541
  eventName: "epigraph_ar_requested",
466
542
  interactiveEvent: !0,
467
543
  customParameters: {
468
- items: e
544
+ items: t
469
545
  }
470
546
  });
471
547
  }
472
548
  }
473
- class x extends a {
474
- constructor(e) {
549
+ class R extends a {
550
+ constructor(t) {
475
551
  super({
476
552
  eventName: "epigraph_module_loading",
477
553
  interactiveEvent: !1,
478
554
  customParameters: {
479
- is_pre_config: e
555
+ is_pre_config: t
480
556
  }
481
557
  });
482
558
  }
483
559
  }
484
- class S extends a {
485
- constructor(e, t) {
560
+ class x extends a {
561
+ constructor(t, e) {
486
562
  super({
487
563
  eventName: "epigraph_module_ready",
488
564
  interactiveEvent: !1,
489
565
  customParameters: {
490
- is_pre_config: e,
491
- load_time_ms: t
566
+ is_pre_config: t,
567
+ load_time_ms: e
492
568
  }
493
569
  });
494
570
  }
495
571
  }
496
- class T extends a {
497
- constructor(e, t, n) {
572
+ class D extends a {
573
+ constructor(t, e, i) {
498
574
  super({
499
575
  eventName: "epigraph_module_failed",
500
576
  interactiveEvent: !1,
501
577
  customParameters: {
502
- is_pre_config: e,
503
- load_time_ms: t,
504
- error_type: n
578
+ is_pre_config: t,
579
+ load_time_ms: e,
580
+ error_type: i
505
581
  }
506
582
  });
507
583
  }
508
584
  }
509
- class L extends a {
510
- constructor(e = []) {
585
+ class z extends a {
586
+ constructor(t) {
511
587
  super({
512
588
  eventName: "epigraph_module_closed",
513
589
  interactiveEvent: !0,
514
590
  customParameters: {
515
- items: e
591
+ items: t
516
592
  }
517
593
  });
518
594
  }
519
595
  }
520
- class z extends a {
521
- constructor(e, t = {}) {
596
+ class G extends a {
597
+ static {
598
+ this.SUPPORT_TYPE = {
599
+ AR: "ar",
600
+ QR: "qr",
601
+ WEBGL2: "webgl2"
602
+ };
603
+ }
604
+ constructor(t, e = {}) {
522
605
  super({
523
606
  eventName: "epigraph_support_detected",
524
607
  interactiveEvent: !1,
525
608
  customParameters: {
526
- support_type: e,
527
- device_capabilities: t
609
+ support_type: t,
610
+ device_capabilities: e
528
611
  }
529
612
  });
530
613
  }
531
614
  }
532
- class q extends a {
533
- constructor(e, t) {
615
+ class M extends a {
616
+ static {
617
+ this.BUTTON_TYPE = {
618
+ AR_VIEW: "ar_view",
619
+ DIMENSION_SHOW: "dimension_show",
620
+ DIMENSION_HIDE: "dimension_hide",
621
+ HOTSPOTS_SHOW: "hotspots_show",
622
+ HOTSPOTS_HIDE: "hotspots_hide",
623
+ HELP_SHOW: "help_show",
624
+ HELP_HIDE: "help_hide",
625
+ HOTSPOT_ENTER: "hotspot_enter",
626
+ HOTSPOT_EXIT: "hotspot_exit",
627
+ SHARE: "share",
628
+ PDF_DOWNLOAD: "pdf_download",
629
+ COPY: "copy",
630
+ RESTART: "restart",
631
+ INSTRUCTIONS_SHOW: "show_instructions",
632
+ REVIEW_CART: "review_cart",
633
+ // Need these?
634
+ SHOP_NOW: "shop_now",
635
+ SUB_CATEGORY: "sub_category",
636
+ NEXT_STEP: "next_step",
637
+ PREVIOUS_STEP: "previous_step"
638
+ };
639
+ }
640
+ constructor(t, e) {
534
641
  super({
535
642
  eventName: "epigraph_button_click",
536
643
  interactiveEvent: !0,
537
644
  customParameters: {
538
- button_type: e,
539
- button_name: t
645
+ button_type: t,
646
+ button_name: e
540
647
  }
541
648
  });
542
649
  }
543
650
  }
544
- class O extends a {
545
- constructor(e = [], t, n, i) {
651
+ class q extends a {
652
+ static {
653
+ this.PANEL_TYPE = I;
654
+ }
655
+ static {
656
+ this.TRIGGER_SOURCE = T;
657
+ }
658
+ constructor(t, e, i, s) {
546
659
  super({
547
660
  eventName: "epigraph_panel_opened",
548
661
  interactiveEvent: t,
549
662
  customParameters: {
550
- items: e,
551
- panel_type: n,
663
+ items: s,
664
+ panel_type: e,
552
665
  trigger_source: i
553
666
  }
554
667
  });
555
668
  }
556
669
  }
557
- class G extends a {
558
- constructor(e = [], t, n, i) {
670
+ class b extends a {
671
+ static {
672
+ this.PANEL_TYPE = I;
673
+ }
674
+ static {
675
+ this.TRIGGER_SOURCE = T;
676
+ }
677
+ constructor(t, e, i, s) {
559
678
  super({
560
679
  eventName: "epigraph_panel_closed",
561
680
  interactiveEvent: t,
562
681
  customParameters: {
563
- items: e,
564
- panel_type: n,
682
+ items: s,
683
+ panel_type: e,
565
684
  trigger_source: i
566
685
  }
567
686
  });
568
687
  }
569
688
  }
570
- class b extends a {
571
- constructor(e = []) {
689
+ class U extends a {
690
+ constructor(t) {
572
691
  super({
573
692
  eventName: "epigraph_add_to_favourites",
574
693
  interactiveEvent: !0,
575
694
  customParameters: {
576
- items: e
695
+ items: t
577
696
  }
578
697
  });
579
698
  }
580
699
  }
581
- class D extends a {
582
- constructor(e) {
700
+ class k extends a {
701
+ static {
702
+ this.ACTION_PERFORMED = {
703
+ ZOOM: "zoom",
704
+ ROTATE: "rotate"
705
+ };
706
+ }
707
+ constructor(t) {
583
708
  super({
584
709
  eventName: "epigraph_keyboard_interaction",
585
710
  interactiveEvent: !0,
586
711
  customParameters: {
587
- action_performed: e
712
+ action_performed: t
588
713
  }
589
714
  });
590
715
  }
591
716
  }
592
- class M extends a {
593
- constructor(e) {
717
+ class V extends a {
718
+ static {
719
+ this.INTERACTION_TYPE = {
720
+ ROTATE: "rotate",
721
+ ZOOM: "zoom",
722
+ PAN: "pan"
723
+ };
724
+ }
725
+ constructor(t) {
594
726
  super({
595
727
  eventName: "epigraph_touch_interaction",
596
728
  interactiveEvent: !0,
597
729
  customParameters: {
598
- interaction_type: e
730
+ interaction_type: t
599
731
  }
600
732
  });
601
733
  }
602
734
  }
603
- class R extends a {
604
- constructor(e = [], t, n, i, r) {
735
+ class $ extends a {
736
+ static {
737
+ this.CURRENCY = l;
738
+ }
739
+ constructor(t, e, i, s, r) {
605
740
  super({
606
741
  eventName: "epigraph_item_added",
607
742
  interactiveEvent: t,
608
743
  customParameters: {
609
- items: e,
610
- value: n,
744
+ items: r,
745
+ value: e,
611
746
  currency: i,
612
- quantity: r
747
+ quantity: s
613
748
  }
614
749
  });
615
750
  }
616
751
  }
617
- class $ extends a {
618
- constructor(e = []) {
752
+ class H extends a {
753
+ constructor(t) {
619
754
  super({
620
755
  eventName: "epigraph_item_moved",
621
756
  interactiveEvent: !0,
622
757
  customParameters: {
623
- items: e
758
+ items: t
624
759
  }
625
760
  });
626
761
  }
627
762
  }
628
- class k extends a {
629
- constructor(e = [], t, n, i) {
763
+ class F extends a {
764
+ static {
765
+ this.CURRENCY = l;
766
+ }
767
+ constructor(t, e, i, s) {
630
768
  super({
631
769
  eventName: "epigraph_item_removed",
632
770
  interactiveEvent: !0,
633
771
  customParameters: {
634
- items: e,
772
+ items: s,
635
773
  value: t,
636
- currency: n,
774
+ currency: e,
637
775
  quantity: i
638
776
  }
639
777
  });
640
778
  }
641
779
  }
642
- class j extends a {
643
- constructor(e = [], t) {
780
+ class B extends a {
781
+ constructor(t, e) {
644
782
  super({
645
783
  eventName: "epigraph_variant_changed",
646
784
  interactiveEvent: !0,
@@ -651,84 +789,90 @@ class j extends a {
651
789
  });
652
790
  }
653
791
  }
654
- class U extends a {
655
- constructor(e = [], t, n) {
792
+ class j extends a {
793
+ constructor(t, e, i) {
656
794
  super({
657
795
  eventName: "epigraph_content_shared",
658
796
  interactiveEvent: !0,
659
797
  customParameters: {
660
- items: e,
798
+ items: i,
661
799
  content_type: t,
662
- share_destination: n
800
+ share_destination: e
663
801
  }
664
802
  });
665
803
  }
666
804
  }
667
- class V extends a {
668
- constructor(e = [], t, n) {
805
+ class Y extends a {
806
+ static {
807
+ this.CURRENCY = l;
808
+ }
809
+ constructor(t, e, i) {
669
810
  super({
670
811
  eventName: "epigraph_checkout",
671
812
  interactiveEvent: !0,
672
813
  customParameters: {
673
- items: e,
814
+ items: i,
674
815
  value: t,
675
- currency: n
816
+ currency: e
676
817
  }
677
818
  });
678
819
  }
679
820
  }
680
- class F extends a {
681
- constructor(e = [], t, n) {
821
+ class W extends a {
822
+ static {
823
+ this.CURRENCY = l;
824
+ }
825
+ constructor(t, e, i) {
682
826
  super({
683
827
  eventName: "epigraph_conversion",
684
828
  interactiveEvent: !0,
685
829
  customParameters: {
686
- items: e,
830
+ items: i,
687
831
  value: t,
688
- currency: n
832
+ currency: e
689
833
  }
690
834
  });
691
835
  }
692
836
  }
693
- class B extends a {
694
- constructor(e) {
837
+ class J extends a {
838
+ constructor(t) {
695
839
  super({
696
840
  eventName: "epigraph_changeRate",
697
841
  interactiveEvent: !1,
698
842
  customParameters: {
699
- value: e
843
+ value: t
700
844
  }
701
845
  });
702
846
  }
703
847
  }
704
- class J extends a {
705
- constructor(e) {
848
+ class Z extends a {
849
+ constructor(t) {
706
850
  super({
707
851
  eventName: "epigraph_completionRate",
708
852
  interactiveEvent: !1,
709
853
  customParameters: {
710
- value: e
854
+ value: t
711
855
  }
712
856
  });
713
857
  }
714
858
  }
715
- class H extends a {
716
- constructor(e) {
859
+ class X extends a {
860
+ constructor(t) {
717
861
  super({
718
862
  eventName: "epigraph_engagementRate",
719
863
  interactiveEvent: !1,
720
864
  customParameters: {
721
- value: e
865
+ value: t
722
866
  }
723
867
  });
724
868
  }
725
869
  }
726
870
  class K extends a {
727
- constructor(e, t, n) {
871
+ constructor(t, e, i) {
728
872
  super({
729
- eventName: e,
730
- interactiveEvent: t,
731
- customParameters: n
873
+ eventName: t,
874
+ interactiveEvent: e,
875
+ customParameters: i
732
876
  });
733
877
  }
734
878
  }
@@ -748,18 +892,18 @@ class K extends a {
748
892
  * See the License for the specific language governing permissions and
749
893
  * limitations under the License.
750
894
  */
751
- var f;
752
- const c = Symbol("analyticsPluginsMap");
753
- f = c;
754
- class X {
755
- constructor(e, t) {
756
- this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, e && t && (this.__consentPlugin = this.buildConsentPlugin(e, t)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
757
- }
758
- __onConsentChangeFromEvent(e) {
759
- let t = e;
760
- this.__overrideConsent = t.detail.hasConsent;
761
- for (const n of this[c].values())
762
- this.__hasConsent() || n.setStatus(o.RESTRICTED);
895
+ var A;
896
+ const h = Symbol("analyticsPluginsMap");
897
+ A = h;
898
+ class Q {
899
+ constructor(t, e) {
900
+ this[A] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, t && e && (this.__consentPlugin = this.buildConsentPlugin(t, e)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
901
+ }
902
+ __onConsentChangeFromEvent(t) {
903
+ let e = t;
904
+ this.__overrideConsent = e.detail.hasConsent;
905
+ for (const i of this[h].values())
906
+ this.__hasConsent() || i.setStatus(c.RESTRICTED);
763
907
  }
764
908
  /**
765
909
  * Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
@@ -768,30 +912,30 @@ class X {
768
912
  *
769
913
  * @param plugin
770
914
  */
771
- addEventPlugin(e) {
772
- this[c].has(e.getUniquePluginIdentifier()) || (this[c].set(
773
- e.getUniquePluginIdentifier(),
774
- e
775
- ), e.setupPlugin());
915
+ addEventPlugin(t) {
916
+ this[h].has(t.getUniquePluginIdentifier()) || (this[h].set(
917
+ t.getUniquePluginIdentifier(),
918
+ t
919
+ ), t.setupPlugin());
776
920
  }
777
921
  /**
778
922
  * Resolves session consent by prioritizing this._overrideConsent and if not found,
779
923
  * getting the value from the consent plugin, if available.
780
- *
924
+ *
781
925
  * @returns {boolean} Whether the session has consent to track analytics or not.
782
926
  */
783
927
  __hasConsent() {
784
- let e = !0;
785
- return this.__overrideConsent !== void 0 ? (e = this.__overrideConsent, e) : (this.__consentPlugin && (e = this.__consentPlugin.hasConsent()), e);
928
+ let t = !0;
929
+ return this.__overrideConsent !== void 0 ? (t = this.__overrideConsent, t) : (this.__consentPlugin && (t = this.__consentPlugin.hasConsent()), t);
786
930
  }
787
931
  /**
788
932
  * Send an Event to all plugins
789
933
  *
790
934
  * @param eventData
791
935
  */
792
- sendEvent(e) {
793
- this[c].forEach((t) => {
794
- t.sendEvent(e, this.__hasConsent());
936
+ sendEvent(t) {
937
+ this[h].forEach((e) => {
938
+ e.sendEvent(t, this.__hasConsent());
795
939
  });
796
940
  }
797
941
  /**
@@ -800,37 +944,37 @@ class X {
800
944
  * @param consentIdentifier
801
945
  * @private
802
946
  */
803
- buildConsentPlugin(e, t) {
804
- return e.toLowerCase() === E.OneTrust.toLowerCase() ? new A(t) : null;
947
+ buildConsentPlugin(t, e) {
948
+ return t.toLowerCase() === f.OneTrust.toLowerCase() ? new C(e) : null;
805
949
  }
806
950
  }
807
951
  export {
808
- E as ConsentPluginNames,
809
- b as EpigraphAddToFavouritesEvent,
810
- X as EpigraphAnalytics,
952
+ f as ConsentPluginNames,
953
+ U as EpigraphAddToFavouritesEvent,
954
+ Q as EpigraphAnalytics,
811
955
  w as EpigraphArRequestedEvent,
812
- q as EpigraphButtonClickEvent,
813
- B as EpigraphChangeRateEvent,
814
- V as EpigraphCheckoutEvent,
815
- J as EpigraphCompletionRateEvent,
816
- U as EpigraphContentSharedEvent,
817
- F as EpigraphConversionEvent,
956
+ M as EpigraphButtonClickEvent,
957
+ J as EpigraphChangeRateEvent,
958
+ Y as EpigraphCheckoutEvent,
959
+ Z as EpigraphCompletionRateEvent,
960
+ j as EpigraphContentSharedEvent,
961
+ W as EpigraphConversionEvent,
818
962
  K as EpigraphCustomEvent,
819
- H as EpigraphEngagementRateEvent,
820
- R as EpigraphItemAddedEvent,
821
- $ as EpigraphItemMovedEvent,
822
- k as EpigraphItemRemovedEvent,
823
- D as EpigraphKeyboardInteractionEvent,
824
- L as EpigraphModuleClosedEvent,
825
- T as EpigraphModuleFailedEvent,
826
- x as EpigraphModuleLoadingEvent,
827
- S as EpigraphModuleReadyEvent,
828
- G as EpigraphPanelClosedEvent,
829
- O as EpigraphPanelOpenedEvent,
830
- z as EpigraphSupportDetectedEvent,
831
- M as EpigraphTouchInteractionEvent,
832
- j as EpigraphVariantChangedEvent,
833
- I as GA4AnalyticsPlugin,
834
- C as NexusAnalyticsPlugin,
835
- A as OneTrustConsentPlugin
963
+ X as EpigraphEngagementRateEvent,
964
+ $ as EpigraphItemAddedEvent,
965
+ H as EpigraphItemMovedEvent,
966
+ F as EpigraphItemRemovedEvent,
967
+ k as EpigraphKeyboardInteractionEvent,
968
+ z as EpigraphModuleClosedEvent,
969
+ D as EpigraphModuleFailedEvent,
970
+ R as EpigraphModuleLoadingEvent,
971
+ x as EpigraphModuleReadyEvent,
972
+ b as EpigraphPanelClosedEvent,
973
+ q as EpigraphPanelOpenedEvent,
974
+ G as EpigraphSupportDetectedEvent,
975
+ V as EpigraphTouchInteractionEvent,
976
+ B as EpigraphVariantChangedEvent,
977
+ S as GA4AnalyticsPlugin,
978
+ L as NexusAnalyticsPlugin,
979
+ C as OneTrustConsentPlugin
836
980
  };