@knocklabs/client 0.18.0 → 0.18.2

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,53 +1,53 @@
1
- var v = Object.defineProperty;
2
- var G = (a, e, t) => e in a ? v(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var d = (a, e, t) => G(a, typeof e != "symbol" ? e + "" : e, t);
4
- import { Store as _ } from "@tanstack/store";
5
- import { URLPattern as b } from "urlpattern-polyfill";
6
- import { byKey as C, mockDefaultGroup as I, formatFilters as g, findDefaultGroup as m, DEFAULT_GROUP_KEY as p, checkIfThrottled as w, SelectionResult as E, newUrl as A, predicateUrlRules as R, predicateUrlPatterns as L } from "./helpers.mjs";
7
- const P = 50, D = 30 * 1e3, T = 3, k = {
1
+ var _ = Object.defineProperty;
2
+ var b = (a, e, t) => e in a ? _(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var d = (a, e, t) => b(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Store as C } from "@tanstack/store";
5
+ import { URLPattern as I } from "urlpattern-polyfill";
6
+ import { byKey as w, mockDefaultGroup as E, formatFilters as g, formatState as p, findDefaultGroup as S, DEFAULT_GROUP_KEY as k, checkIfThrottled as R, formatGroupStage as f, SelectionResult as A, newUrl as L, predicateUrlRules as P, predicateUrlPatterns as $ } from "./helpers.mjs";
7
+ const D = 50, T = 30 * 1e3, O = 3, G = {
8
8
  GUIDE_KEY: "knock_guide_key",
9
9
  PREVIEW_SESSION_ID: "knock_preview_session_id"
10
10
  }, l = () => {
11
11
  if (typeof window < "u")
12
12
  return window;
13
- }, O = (a) => `/v1/users/${a}/guides`, f = () => {
13
+ }, K = (a) => `/v1/users/${a}/guides`, y = () => {
14
14
  const a = l();
15
15
  if (!a)
16
16
  return { forcedGuideKey: null, previewSessionId: null };
17
- const e = new URLSearchParams(a.location.search), t = e.get(k.GUIDE_KEY), s = e.get(k.PREVIEW_SESSION_ID);
17
+ const e = new URLSearchParams(a.location.search), t = e.get(G.GUIDE_KEY), s = e.get(G.PREVIEW_SESSION_ID);
18
18
  return { forcedGuideKey: t, previewSessionId: s };
19
- }, y = (a, e = {}) => {
20
- const t = new E(), s = m(a.guideGroups);
19
+ }, m = (a, e = {}) => {
20
+ const t = new A(), s = S(a.guideGroups);
21
21
  if (!s) return t;
22
- const i = [...s.display_sequence], n = a.location;
22
+ const i = [...s.display_sequence], r = a.location;
23
23
  if (a.debug.forcedGuideKey) {
24
- const r = i.indexOf(a.debug.forcedGuideKey);
25
- r > -1 && i.splice(r, 1), i.unshift(a.debug.forcedGuideKey);
24
+ const n = i.indexOf(a.debug.forcedGuideKey);
25
+ n > -1 && i.splice(n, 1), i.unshift(a.debug.forcedGuideKey);
26
26
  }
27
- for (const [r, o] of i.entries()) {
27
+ for (const [n, o] of i.entries()) {
28
28
  let u = a.guides[o];
29
- a.debug.forcedGuideKey === o && a.previewGuides[o] && (u = a.previewGuides[o]), !(!u || !K(u, {
30
- location: n,
29
+ a.debug.forcedGuideKey === o && a.previewGuides[o] && (u = a.previewGuides[o]), !(!u || !F(u, {
30
+ location: r,
31
31
  filters: e,
32
32
  debug: a.debug
33
- })) && t.set(r, u);
33
+ })) && t.set(n, u);
34
34
  }
35
35
  return t.metadata = { guideGroup: s }, t;
36
- }, K = (a, { location: e, filters: t = {}, debug: s = {} }) => {
36
+ }, F = (a, { location: e, filters: t = {}, debug: s = {} }) => {
37
37
  if (t.type && t.type !== a.type || t.key && t.key !== a.key)
38
38
  return !1;
39
39
  if (s.forcedGuideKey === a.key)
40
40
  return !0;
41
41
  if (!a.active || a.steps.every((o) => !!o.message.archived_at))
42
42
  return !1;
43
- const i = e ? A(e) : void 0, n = a.activation_url_rules || [], r = a.activation_url_patterns || [];
44
- if (i && n.length > 0) {
45
- if (!R(i, n)) return !1;
46
- } else if (i && r.length > 0 && !L(i, r))
43
+ const i = e ? L(e) : void 0, r = a.activation_url_rules || [], n = a.activation_url_patterns || [];
44
+ if (i && r.length > 0) {
45
+ if (!P(i, r)) return !1;
46
+ } else if (i && n.length > 0 && !$(i, n))
47
47
  return !1;
48
48
  return !0;
49
49
  };
50
- class j {
50
+ class x {
51
51
  constructor(e, t, s = {}, i = {}) {
52
52
  d(this, "store");
53
53
  // Phoenix channels for real time guide updates over websocket
@@ -77,8 +77,8 @@ class j {
77
77
  if (!(e != null && e.location)) return;
78
78
  const t = e.location.href;
79
79
  if (this.store.state.location === t) return;
80
- this.knock.log(`[Guide] Handle Location change: ${t}`);
81
- const s = this.store.state.debug, i = f();
80
+ this.knock.log(`[Guide] Detected a location change: ${t}`);
81
+ const s = this.store.state.debug, i = y();
82
82
  this.setLocation(t, { debug: i }), this.checkDebugStateChanged(
83
83
  s,
84
84
  i
@@ -87,28 +87,28 @@ class j {
87
87
  ), this.fetch(), this.subscribe());
88
88
  });
89
89
  this.knock = e, this.channelId = t, this.targetParams = s, this.options = i;
90
- const { trackLocationFromWindow: n = !0 } = i, r = l(), o = n ? r == null ? void 0 : r.location.href : void 0, u = f();
91
- this.store = new _({
90
+ const {
91
+ trackLocationFromWindow: r = !0,
92
+ throttleCheckInterval: n = T
93
+ } = i, o = l(), u = r ? o == null ? void 0 : o.location.href : void 0, h = y();
94
+ this.store = new C({
92
95
  guideGroups: [],
93
96
  guideGroupDisplayLogs: {},
94
97
  guides: {},
95
98
  previewGuides: {},
96
99
  queries: {},
97
- location: o,
100
+ location: u,
98
101
  // Increment to update the state store and trigger re-selection.
99
102
  counter: 0,
100
- debug: u
103
+ debug: h
101
104
  });
102
105
  const { socket: c } = this.knock.client();
103
- this.socket = c, this.socketChannelTopic = `guides:${t}`, n && this.listenForLocationChangesFromWindow(), this.startCounterInterval(), this.knock.log("[Guide] Initialized a guide client");
106
+ this.socket = c, this.socketChannelTopic = `guides:${t}`, r && this.listenForLocationChangesFromWindow(), n && this.startCounterInterval(n), this.knock.log("[Guide] Initialized a guide client");
104
107
  }
105
108
  incrementCounter() {
106
109
  this.knock.log("[Guide] Incrementing the counter"), this.store.setState((e) => ({ ...e, counter: e.counter + 1 }));
107
110
  }
108
- startCounterInterval() {
109
- const {
110
- throttleCheckInterval: e = D
111
- } = this.options;
111
+ startCounterInterval(e) {
112
112
  this.counterIntervalId = setInterval(() => {
113
113
  this.knock.log("[Guide] Counter interval tick"), !(this.stage && this.stage.status !== "closed") && this.incrementCounter();
114
114
  }, e);
@@ -120,33 +120,34 @@ class j {
120
120
  this.unsubscribe(), this.removeEventListeners(), this.clearGroupStage(), this.clearCounterInterval();
121
121
  }
122
122
  async fetch(e) {
123
- this.knock.failIfNotAuthenticated(), this.knock.log("[Guide] Loading all eligible guides");
123
+ this.knock.log("[Guide] .fetch"), this.knock.failIfNotAuthenticated();
124
124
  const t = this.buildQueryParams(e == null ? void 0 : e.filters), s = this.formatQueryKey(t), i = this.store.state.queries[s];
125
125
  if (i)
126
126
  return i;
127
- this.store.setState((r) => ({
128
- ...r,
129
- queries: { ...r.queries, [s]: { status: "loading" } }
127
+ this.store.setState((n) => ({
128
+ ...n,
129
+ queries: { ...n.queries, [s]: { status: "loading" } }
130
130
  }));
131
- let n;
131
+ let r;
132
132
  try {
133
- const r = await this.knock.user.getGuides(this.channelId, t);
134
- n = { status: "ok" };
135
- const { entries: o, guide_groups: u, guide_group_display_logs: c } = r;
136
- this.store.setState((h) => ({
137
- ...h,
138
- guideGroups: (u == null ? void 0 : u.length) > 0 ? u : [I(o)],
139
- guideGroupDisplayLogs: c || {},
140
- guides: C(o.map((S) => this.localCopy(S))),
141
- queries: { ...h.queries, [s]: n }
133
+ this.knock.log("[Guide] Fetching all eligible guides");
134
+ const n = await this.knock.user.getGuides(this.channelId, t);
135
+ r = { status: "ok" };
136
+ const { entries: o, guide_groups: u, guide_group_display_logs: h } = n;
137
+ this.knock.log("[Guide] Loading fetched guides"), this.store.setState((c) => ({
138
+ ...c,
139
+ guideGroups: (u == null ? void 0 : u.length) > 0 ? u : [E(o)],
140
+ guideGroupDisplayLogs: h || {},
141
+ guides: w(o.map((v) => this.localCopy(v))),
142
+ queries: { ...c.queries, [s]: r }
142
143
  }));
143
- } catch (r) {
144
- n = { status: "error", error: r }, this.store.setState((o) => ({
144
+ } catch (n) {
145
+ r = { status: "error", error: n }, this.store.setState((o) => ({
145
146
  ...o,
146
- queries: { ...o.queries, [s]: n }
147
+ queries: { ...o.queries, [s]: r }
147
148
  }));
148
149
  }
149
- return n;
150
+ return r;
150
151
  }
151
152
  subscribe() {
152
153
  if (!this.socket) return;
@@ -158,7 +159,7 @@ class j {
158
159
  preview_session_id: e.previewSessionId || void 0
159
160
  }, s = this.socket.channel(this.socketChannelTopic, t);
160
161
  for (const i of this.socketEventTypes)
161
- s.on(i, (n) => this.handleSocketEvent(n));
162
+ s.on(i, (r) => this.handleSocketEvent(r));
162
163
  ["closed", "errored"].includes(s.state) && (this.subscribeRetryCount = 0, s.join().receive("ok", () => {
163
164
  this.knock.log("[Guide] Successfully joined channel");
164
165
  }).receive("error", (i) => {
@@ -170,7 +171,7 @@ class j {
170
171
  })), this.socketChannel = s;
171
172
  }
172
173
  handleChannelJoinError() {
173
- if (this.subscribeRetryCount >= T) {
174
+ if (this.subscribeRetryCount >= O) {
174
175
  this.knock.log(
175
176
  `[Guide] Channel join max retry limit reached: ${this.subscribeRetryCount}`
176
177
  ), this.unsubscribe();
@@ -205,9 +206,9 @@ class j {
205
206
  }
206
207
  }
207
208
  setLocation(e, t = {}) {
208
- this.clearGroupStage(), this.store.setState((s) => {
209
- var n;
210
- const i = (n = t == null ? void 0 : t.debug) != null && n.previewSessionId ? s.previewGuides : {};
209
+ this.knock.log(`[Guide] .setLocation (loc=${e})`), this.clearGroupStage(), this.knock.log("[Guide] Updating the tracked location"), this.store.setState((s) => {
210
+ var r;
211
+ const i = (r = t == null ? void 0 : t.debug) != null && r.previewSessionId ? s.previewGuides : {};
211
212
  return {
212
213
  ...s,
213
214
  ...t,
@@ -220,44 +221,62 @@ class j {
220
221
  // Store selector
221
222
  //
222
223
  selectGuides(e, t = {}) {
223
- if (Object.keys(e.guides).length === 0 && Object.keys(e.previewGuides).length === 0)
224
- return [];
225
- this.knock.log(`[Guide] Selecting guides for: ${g(t)}`);
226
- const s = y(e, t);
224
+ if (this.knock.log(
225
+ `[Guide] .selectGuides (filters: ${g(t)}; state: ${p(e)})`
226
+ ), Object.keys(e.guides).length === 0 && Object.keys(e.previewGuides).length === 0)
227
+ return this.knock.log("[Guide] Exiting selection (no guides)"), [];
228
+ const s = m(e, t);
227
229
  return s.size === 0 ? (this.knock.log("[Guide] Selection returned zero result"), []) : [...s.values()];
228
230
  }
229
231
  selectGuide(e, t = {}) {
230
- if (Object.keys(e.guides).length === 0 && Object.keys(e.previewGuides).length === 0)
232
+ if (this.knock.log(
233
+ `[Guide] .selectGuide (filters: ${g(t)}; state: ${p(e)})`
234
+ ), Object.keys(e.guides).length === 0 && Object.keys(e.previewGuides).length === 0) {
235
+ this.knock.log("[Guide] Exiting selection (no guides)");
231
236
  return;
232
- this.knock.log(`[Guide] Selecting a guide for: ${g(t)}`);
233
- const s = y(e, t);
237
+ }
238
+ const s = m(e, t);
234
239
  if (s.size === 0) {
235
- this.knock.log("[Guide] Selection returned zero result");
240
+ this.knock.log("[Guide] Selection found zero result");
236
241
  return;
237
242
  }
238
- const [i, n] = [...s][0];
239
- if (n.bypass_global_group_limit)
240
- return n;
241
- const r = m(e.guideGroups), o = e.guideGroupDisplayLogs[p];
242
- if (!(r && r.display_interval && o && w(
243
+ const [i, r] = [...s][0];
244
+ if (this.knock.log(
245
+ `[Guide] Selection found: \`${r.key}\` (total: ${s.size})`
246
+ ), r.bypass_global_group_limit)
247
+ return this.knock.log(`[Guide] Returning the unthrottled guide: ${r.key}`), r;
248
+ const n = S(e.guideGroups), o = e.guideGroupDisplayLogs[k];
249
+ if (n && n.display_interval && o && R(
243
250
  o,
244
- r.display_interval
245
- )))
246
- switch (this.stage || (this.stage = this.openGroupStage()), this.stage.status) {
247
- case "open": {
248
- this.knock.log(`[Guide] Addng to the group stage: ${n.key}`), this.stage.ordered[i] = n.key;
249
- return;
250
- }
251
- case "patch":
252
- return this.knock.log(`[Guide] Patching the group stage: ${n.key}`), this.stage.ordered[i] = n.key, this.stage.resolved === n.key ? n : void 0;
253
- case "closed":
254
- return this.stage.resolved === n.key ? n : void 0;
251
+ n.display_interval
252
+ )) {
253
+ this.knock.log(`[Guide] Throttling the selected guide: ${r.key}`);
254
+ return;
255
+ }
256
+ switch (this.stage || (this.stage = this.openGroupStage()), this.stage.status) {
257
+ case "open": {
258
+ this.knock.log(`[Guide] Addng to the group stage: ${r.key}`), this.stage.ordered[i] = r.key;
259
+ return;
260
+ }
261
+ case "patch": {
262
+ this.knock.log(`[Guide] Patching the group stage: ${r.key}`), this.stage.ordered[i] = r.key;
263
+ const u = this.stage.resolved === r.key ? r : void 0;
264
+ return this.knock.log(
265
+ `[Guide] Returning \`${u == null ? void 0 : u.key}\` (stage: ${f(this.stage)})`
266
+ ), u;
255
267
  }
268
+ case "closed": {
269
+ const u = this.stage.resolved === r.key ? r : void 0;
270
+ return this.knock.log(
271
+ `[Guide] Returning \`${u == null ? void 0 : u.key}\` (stage: ${f(this.stage)})`
272
+ ), u;
273
+ }
274
+ }
256
275
  }
257
276
  openGroupStage() {
258
277
  this.knock.log("[Guide] Opening a new group stage");
259
278
  const {
260
- orderResolutionDuration: e = P
279
+ orderResolutionDuration: e = D
261
280
  } = this.options, t = setTimeout(() => {
262
281
  this.closePendingGroupStage(), this.incrementCounter();
263
282
  }, e);
@@ -270,12 +289,14 @@ class j {
270
289
  // Close the current non-closed stage to resolve the prevailing guide up next
271
290
  // for display amongst the ones that have been staged.
272
291
  closePendingGroupStage() {
273
- if (!this.stage || this.stage.status === "closed") return;
274
- this.knock.log("[Guide] Closing the current group stage"), this.ensureClearTimeout();
292
+ if (this.knock.log("[Guide] .closePendingGroupStage"), !this.stage || this.stage.status === "closed") return;
293
+ this.ensureClearTimeout();
275
294
  let e;
276
295
  return this.store.state.debug.forcedGuideKey && (e = this.stage.ordered.find(
277
296
  (t) => t === this.store.state.debug.forcedGuideKey
278
- )), e || (e = this.stage.ordered.find((t) => t !== void 0)), this.stage = {
297
+ )), e || (e = this.stage.ordered.find((t) => t !== void 0)), this.knock.log(
298
+ `[Guide] Closing the current group stage: resolved=${e}`
299
+ ), this.stage = {
279
300
  ...this.stage,
280
301
  status: "closed",
281
302
  resolved: e,
@@ -289,12 +310,11 @@ class j {
289
310
  // Note, must be called ahead of updating the state store.
290
311
  patchClosedGroupStage() {
291
312
  var s;
292
- if (((s = this.stage) == null ? void 0 : s.status) !== "closed") return;
293
- this.knock.log("[Guide] Patching the current group stage");
313
+ if (this.knock.log("[Guide] .patchClosedGroupStage"), ((s = this.stage) == null ? void 0 : s.status) !== "closed") return;
294
314
  const { orderResolutionDuration: e = 0 } = this.options, t = setTimeout(() => {
295
315
  this.closePendingGroupStage(), this.incrementCounter();
296
316
  }, e);
297
- return this.ensureClearTimeout(), this.stage = {
317
+ return this.ensureClearTimeout(), this.knock.log("[Guide] Patching the current group stage"), this.stage = {
298
318
  ...this.stage,
299
319
  status: "patch",
300
320
  ordered: [],
@@ -302,7 +322,7 @@ class j {
302
322
  }, this.stage;
303
323
  }
304
324
  clearGroupStage() {
305
- this.stage && (this.knock.log("[Guide] Clearing the current group stage"), this.ensureClearTimeout(), this.stage = void 0);
325
+ this.knock.log("[Guide] .clearGroupStage"), this.stage && (this.knock.log("[Guide] Clearing the current group stage"), this.ensureClearTimeout(), this.stage = void 0);
306
326
  }
307
327
  ensureClearTimeout() {
308
328
  var e;
@@ -341,18 +361,18 @@ class j {
341
361
  }
342
362
  async markAsInteracted(e, t, s) {
343
363
  this.knock.log(
344
- `[Guide] Marking as interacted (Guide key: ${e.key}, Step ref:${t.ref})`
364
+ `[Guide] Marking as interacted (Guide key: ${e.key}; Step ref:${t.ref})`
345
365
  );
346
- const i = (/* @__PURE__ */ new Date()).toISOString(), n = this.setStepMessageAttrs(e.key, t.ref, {
366
+ const i = (/* @__PURE__ */ new Date()).toISOString(), r = this.setStepMessageAttrs(e.key, t.ref, {
347
367
  read_at: i,
348
368
  interacted_at: i
349
369
  });
350
- if (!n) return;
351
- const r = {
352
- ...this.buildEngagementEventBaseParams(e, n),
370
+ if (!r) return;
371
+ const n = {
372
+ ...this.buildEngagementEventBaseParams(e, r),
353
373
  metadata: s
354
374
  };
355
- return this.knock.user.markGuideStepAs("interacted", r), n;
375
+ return this.knock.user.markGuideStepAs("interacted", n), r;
356
376
  }
357
377
  async markAsArchived(e, t) {
358
378
  if (t.message.archived_at) return;
@@ -383,9 +403,9 @@ class j {
383
403
  return t.store.state.debug.forcedGuideKey === this.key ? this.steps[0] : this.steps.find((i) => !i.message.archived_at);
384
404
  }
385
405
  };
386
- return s.getStep = s.getStep.bind(s), s.steps = e.steps.map(({ message: i, ...n }) => {
387
- const r = {
388
- ...n,
406
+ return s.getStep = s.getStep.bind(s), s.steps = e.steps.map(({ message: i, ...r }) => {
407
+ const n = {
408
+ ...r,
389
409
  message: { ...i },
390
410
  markAsSeen() {
391
411
  if (!this.message.seen_at)
@@ -399,10 +419,10 @@ class j {
399
419
  return t.markAsArchived(s, this);
400
420
  }
401
421
  };
402
- return r.markAsSeen = r.markAsSeen.bind(r), r.markAsInteracted = r.markAsInteracted.bind(r), r.markAsArchived = r.markAsArchived.bind(r), r;
422
+ return n.markAsSeen = n.markAsSeen.bind(n), n.markAsInteracted = n.markAsInteracted.bind(n), n.markAsArchived = n.markAsArchived.bind(n), n;
403
423
  }), s.activation_url_patterns = e.activation_url_patterns.map((i) => ({
404
424
  ...i,
405
- pattern: new b({ pathname: i.pathname })
425
+ pattern: new I({ pathname: i.pathname })
406
426
  })), s;
407
427
  }
408
428
  buildQueryParams(e = {}) {
@@ -413,29 +433,29 @@ class j {
413
433
  this.store.state.debug.forcedGuideKey && (t.force_all_guides = !0);
414
434
  let i = Object.fromEntries(
415
435
  Object.entries(t).filter(
416
- ([n, r]) => r != null
436
+ ([r, n]) => n != null
417
437
  )
418
438
  );
419
439
  return i = i.data ? { ...i, data: JSON.stringify(i.data) } : i, i;
420
440
  }
421
441
  formatQueryKey(e) {
422
442
  const s = Object.keys(e).sort().map(
423
- (n) => `${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`
424
- ).join("&"), i = O(this.knock.userId);
443
+ (r) => `${encodeURIComponent(r)}=${encodeURIComponent(e[r])}`
444
+ ).join("&"), i = K(this.knock.userId);
425
445
  return s ? `${i}?${s}` : i;
426
446
  }
427
447
  setStepMessageAttrs(e, t, s) {
428
448
  let i;
429
- return s.archived_at && this.clearGroupStage(), this.store.setState((n) => {
430
- const r = n.guides[e];
431
- if (!r) return n;
432
- const o = r.steps.map((h) => (h.ref !== t || (h.message = { ...h.message, ...s }, i = h), h));
433
- r.steps = o;
434
- const u = { ...n.guides, [r.key]: r }, c = s.archived_at && !r.bypass_global_group_limit ? {
435
- ...n.guideGroupDisplayLogs,
436
- [p]: s.archived_at
437
- } : n.guideGroupDisplayLogs;
438
- return { ...n, guides: u, guideGroupDisplayLogs: c };
449
+ return s.archived_at && this.clearGroupStage(), this.store.setState((r) => {
450
+ const n = r.guides[e];
451
+ if (!n) return r;
452
+ const o = n.steps.map((c) => (c.ref !== t || (c.message = { ...c.message, ...s }, i = c), c));
453
+ n.steps = o;
454
+ const u = { ...r.guides, [n.key]: n }, h = s.archived_at && !n.bypass_global_group_limit ? {
455
+ ...r.guideGroupDisplayLogs,
456
+ [k]: s.archived_at
457
+ } : r.guideGroupDisplayLogs;
458
+ return { ...r, guides: u, guideGroupDisplayLogs: h };
439
459
  }), i;
440
460
  }
441
461
  buildEngagementEventBaseParams(e, t) {
@@ -465,17 +485,17 @@ class j {
465
485
  data: e
466
486
  }) {
467
487
  this.patchClosedGroupStage(), this.store.setState((t) => {
468
- const s = [e.guide_group], i = e.guide_group.display_sequence_unthrottled || [], n = e.guide_group.display_sequence_throttled || [];
469
- let r = t.guides;
470
- return r = i.reduce((o, u) => {
488
+ const s = [e.guide_group], i = e.guide_group.display_sequence_unthrottled || [], r = e.guide_group.display_sequence_throttled || [];
489
+ let n = t.guides;
490
+ return n = i.reduce((o, u) => {
471
491
  if (!o[u]) return o;
472
- const c = { ...o[u], bypass_global_group_limit: !0 };
473
- return { ...o, [u]: c };
474
- }, r), r = n.reduce((o, u) => {
492
+ const h = { ...o[u], bypass_global_group_limit: !0 };
493
+ return { ...o, [u]: h };
494
+ }, n), n = r.reduce((o, u) => {
475
495
  if (!o[u]) return o;
476
- const c = { ...o[u], bypass_global_group_limit: !1 };
477
- return { ...o, [u]: c };
478
- }, r), { ...t, guides: r, guideGroups: s };
496
+ const h = { ...o[u], bypass_global_group_limit: !1 };
497
+ return { ...o, [u]: h };
498
+ }, n), { ...t, guides: n, guideGroups: s };
479
499
  });
480
500
  }
481
501
  updatePreviewGuide({ data: e }) {
@@ -496,14 +516,14 @@ class j {
496
516
  e.addEventListener("popstate", this.handleLocationChange), e.addEventListener("hashchange", this.handleLocationChange);
497
517
  const t = e.history.pushState, s = e.history.replaceState;
498
518
  e.history.pushState = new Proxy(t, {
499
- apply: (i, n, r) => {
500
- Reflect.apply(i, n, r), setTimeout(() => {
519
+ apply: (i, r, n) => {
520
+ Reflect.apply(i, r, n), setTimeout(() => {
501
521
  this.handleLocationChange();
502
522
  }, 0);
503
523
  }
504
524
  }), e.history.replaceState = new Proxy(s, {
505
- apply: (i, n, r) => {
506
- Reflect.apply(i, n, r), setTimeout(() => {
525
+ apply: (i, r, n) => {
526
+ Reflect.apply(i, r, n), setTimeout(() => {
507
527
  this.handleLocationChange();
508
528
  }, 0);
509
529
  }
@@ -519,8 +539,8 @@ class j {
519
539
  }
520
540
  }
521
541
  export {
522
- k as DEBUG_QUERY_PARAMS,
523
- j as KnockGuideClient,
524
- O as guidesApiRootPath
542
+ G as DEBUG_QUERY_PARAMS,
543
+ x as KnockGuideClient,
544
+ K as guidesApiRootPath
525
545
  };
526
546
  //# sourceMappingURL=client.mjs.map