@braze/web-sdk 5.3.1 → 5.4.0

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.
Files changed (83) hide show
  1. package/index.d.ts +20 -4
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +10 -10
  4. package/shared-lib/indexed-db-adapter.js +1 -1
  5. package/shared-lib/logger.js +2 -2
  6. package/shared-lib/supported-options.js +9 -8
  7. package/src/Card/display/card-display.js +59 -58
  8. package/src/Core/index.js +1 -0
  9. package/src/Core/is-initialized.js +4 -0
  10. package/src/InAppMessage/display/html-message-display-utils.js +172 -0
  11. package/src/InAppMessage/display/html-message-to-html.js +54 -219
  12. package/src/InAppMessage/display/in-app-message-to-html.js +78 -76
  13. package/src/InAppMessage/display/modal-utils.js +7 -7
  14. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  15. package/src/InAppMessage/in-app-message-factory.js +4 -4
  16. package/src/InAppMessage/in-app-message-manager.js +56 -56
  17. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  18. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  19. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  20. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  21. package/src/InAppMessage/models/full-screen-message.js +2 -2
  22. package/src/InAppMessage/models/html-message.js +2 -2
  23. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  24. package/src/InAppMessage/models/in-app-message.js +26 -26
  25. package/src/InAppMessage/models/modal-message.js +2 -2
  26. package/src/InAppMessage/models/slide-up-message.js +4 -4
  27. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  28. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  29. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  30. package/src/InAppMessage/ui/show-in-app-message.js +47 -45
  31. package/src/InAppMessage/utils/in-app-message-utils.js +1 -18
  32. package/src/Push/is-push-blocked.js +2 -2
  33. package/src/Push/is-push-permission-granted.js +2 -2
  34. package/src/Push/is-push-supported.js +2 -2
  35. package/src/Push/push-manager-factory.js +2 -1
  36. package/src/Push/push-manager.js +80 -92
  37. package/src/Push/utils/push-utils.js +12 -12
  38. package/src/User/user-manager.js +3 -3
  39. package/src/User/user.js +19 -19
  40. package/src/common/event-logger.js +4 -4
  41. package/src/common/feed-display.js +25 -24
  42. package/src/l10n/l10n-manager-factory.js +7 -7
  43. package/src/l10n/l10n-manager.js +15 -5
  44. package/src/managers/auth-manager.js +1 -1
  45. package/src/managers/braze-instance.js +54 -52
  46. package/src/managers/device-manager.js +19 -19
  47. package/src/managers/network-manager.js +100 -100
  48. package/src/managers/server-config-manager.js +7 -7
  49. package/src/managers/session-manager.js +4 -4
  50. package/src/managers/storage-manager-factory.js +4 -4
  51. package/src/managers/storage-manager.js +18 -18
  52. package/src/models/backend-errors.js +5 -5
  53. package/src/models/braze-event.js +10 -10
  54. package/src/models/device.js +3 -3
  55. package/src/models/server-config.js +7 -7
  56. package/src/request-controller.js +77 -77
  57. package/src/triggers/models/custom-event-data.js +2 -2
  58. package/src/triggers/models/custom-event-property-data.js +4 -4
  59. package/src/triggers/models/filter-set.js +3 -3
  60. package/src/triggers/models/filter.js +9 -9
  61. package/src/triggers/models/in-app-message-click-data.js +8 -8
  62. package/src/triggers/models/purchase-data.js +2 -2
  63. package/src/triggers/models/purchase-property-data.js +4 -4
  64. package/src/triggers/models/push-click-data.js +3 -3
  65. package/src/triggers/models/trigger-condition.js +39 -39
  66. package/src/triggers/models/trigger.js +12 -12
  67. package/src/triggers/triggers-provider-factory.js +1 -1
  68. package/src/triggers/triggers-provider.js +15 -15
  69. package/src/ui/js/attach-css.js +1 -1
  70. package/src/ui/js/feed-css.js +1 -1
  71. package/src/ui/js/iam-css.js +1 -1
  72. package/src/util/base-device-parser.js +7 -7
  73. package/src/util/braze-actions.js +4 -4
  74. package/src/util/browser-detector.js +21 -21
  75. package/src/util/client-hints-parser.js +3 -3
  76. package/src/util/component-utils.js +15 -14
  77. package/src/util/date-utils.js +2 -2
  78. package/src/util/dom-utils.js +3 -3
  79. package/src/util/net.js +2 -2
  80. package/src/util/request-header-utils.js +8 -8
  81. package/src/util/user-agent-parser.js +3 -3
  82. package/src/util/validation-utils.js +17 -17
  83. package/src/util/window-utils.js +1 -1
@@ -11,13 +11,14 @@ import {
11
11
  WindowUtils as eo,
12
12
  } from "../../util/window-utils.js";
13
13
  import { isURIJavascriptOrData as R } from "../../util/url-utils.js";
14
- import { KeyCodes as lt } from "../../util/key-codes.js";
14
+ import { KeyCodes as mt } from "../../util/key-codes.js";
15
15
  import { setupInAppMessageUI as ss } from "../../ui/js/index.js";
16
16
  import { logger as r } from "../../../shared-lib/index.js";
17
17
  import { toRgba as ie } from "../../util/color-utils.js";
18
18
  import { BRAZE_MUST_BE_INITIALIZED_ERROR as _ } from "../../common/constants.js";
19
19
  import { isIFrame as It } from "../utils/in-app-message-utils.js";
20
- export function showInAppMessage(t, s, o) {
20
+ import ue from "../../l10n/l10n-manager-factory.js";
21
+ export function showInAppMessage(t, o, s) {
21
22
  if (!e.X()) return;
22
23
  if ((ss(), null == t)) return !1;
23
24
  if (t instanceof ControlMessage)
@@ -39,8 +40,8 @@ export function showInAppMessage(t, s, o) {
39
40
  ),
40
41
  !1
41
42
  );
42
- if ((null == s && (s = document.body), t.ze())) {
43
- if (s.querySelectorAll(".ab-modal-interactions").length > 0)
43
+ if ((null == o && (o = document.body), t.$e())) {
44
+ if (o.querySelectorAll(".ab-modal-interactions").length > 0)
44
45
  return (
45
46
  r.info(
46
47
  `Cannot show in-app message ${t.message} because another message is being shown.`,
@@ -56,14 +57,14 @@ export function showInAppMessage(t, s, o) {
56
57
  (e === fe.LANDSCAPE &&
57
58
  t.orientation === InAppMessage.Orientation.PORTRAIT)
58
59
  ) {
59
- const s = e === fe.PORTRAIT ? "portrait" : "landscape",
60
- o =
60
+ const o = e === fe.PORTRAIT ? "portrait" : "landscape",
61
+ s =
61
62
  t.orientation === InAppMessage.Orientation.PORTRAIT
62
63
  ? "portrait"
63
64
  : "landscape";
64
65
  return (
65
66
  r.info(
66
- `Not showing ${o} in-app message ${t.message} because the screen is currently ${s}`,
67
+ `Not showing ${s} in-app message ${t.message} because the screen is currently ${o}`,
67
68
  ),
68
69
  !1
69
70
  );
@@ -72,11 +73,11 @@ export function showInAppMessage(t, s, o) {
72
73
  if (!e.tr()) {
73
74
  let e = !1;
74
75
  if (t.buttons && t.buttons.length > 0) {
75
- const s = t.buttons;
76
- for (let t = 0; t < s.length; t++)
77
- if (s[t].clickAction === InAppMessage.ClickAction.URI) {
78
- const o = s[t].uri;
79
- e = R(o);
76
+ const o = t.buttons;
77
+ for (let t = 0; t < o.length; t++)
78
+ if (o[t].clickAction === InAppMessage.ClickAction.URI) {
79
+ const s = o[t].uri;
80
+ e = R(s);
80
81
  }
81
82
  } else t.clickAction === InAppMessage.ClickAction.URI && (e = R(t.uri));
82
83
  if (e)
@@ -92,16 +93,16 @@ export function showInAppMessage(t, s, o) {
92
93
  ((n.className = "ab-iam-root v3"),
93
94
  (n.className += me(t)),
94
95
  n.setAttribute("role", "complementary"),
95
- t.xe() && (n.id = t.htmlId),
96
+ t.Ce() && (n.id = t.htmlId),
96
97
  e.nn(L.jo) && (n.style.zIndex = (e.nn(L.jo) + 1).toString()),
97
- s.appendChild(n),
98
- t.Ce())
98
+ o.appendChild(n),
99
+ t.ve())
99
100
  ) {
100
- const s = document.createElement("style");
101
- (s.innerHTML = t.css),
102
- (s.id = t.ve()),
103
- null != e.nn(L.bo) && s.setAttribute("nonce", e.nn(L.bo)),
104
- document.getElementsByTagName("head")[0].appendChild(s);
101
+ const o = document.createElement("style");
102
+ (o.innerHTML = t.css),
103
+ (o.id = t.we()),
104
+ null != e.nn(L.bo) && o.setAttribute("nonce", e.nn(L.bo)),
105
+ document.getElementsByTagName("head")[0].appendChild(o);
105
106
  }
106
107
  const a = t instanceof SlideUpMessage,
107
108
  l = ce(
@@ -111,57 +112,57 @@ export function showInAppMessage(t, s, o) {
111
112
  e.so() ? t.showFeed() : r.error(_);
112
113
  });
113
114
  },
114
- (s) => {
115
- if (t.ze() && t.do()) {
116
- const o = document.createElement("div");
115
+ (o) => {
116
+ if (t.$e() && t.do()) {
117
+ const s = document.createElement("div");
117
118
  if (
118
- ((o.className = "ab-page-blocker"),
119
- t.Ce() || (o.style.backgroundColor = ie(t.frameColor)),
120
- e.nn(L.jo) && (o.style.zIndex = e.nn(L.jo).toString()),
121
- n.appendChild(o),
119
+ ((s.className = "ab-page-blocker"),
120
+ t.ve() || (s.style.backgroundColor = ie(t.frameColor)),
121
+ e.nn(L.jo) && (s.style.zIndex = e.nn(L.jo).toString()),
122
+ n.appendChild(s),
122
123
  !e.nn(L.Lh))
123
124
  ) {
124
125
  const e = new Date().valueOf();
125
- o.onclick = (o) => {
126
+ s.onclick = (s) => {
126
127
  new Date().valueOf() - e > InAppMessage.fh &&
127
- (t.Ae(s), o.stopPropagation());
128
+ (t.Cr(o), s.stopPropagation());
128
129
  };
129
130
  }
130
- n.appendChild(s), s.focus(), t.Oh(n);
131
+ n.appendChild(o), o.focus(), t.Oh(n);
131
132
  } else if (a) {
132
133
  const e = document.querySelectorAll(".ab-slideup");
133
- let o = null;
134
+ let s = null;
134
135
  for (let t = e.length - 1; t >= 0; t--)
135
- if (e[t] !== s) {
136
- o = e[t];
136
+ if (e[t] !== o) {
137
+ s = e[t];
137
138
  break;
138
139
  }
139
140
  if (t.slideFrom === InAppMessage.SlideFrom.TOP) {
140
141
  let e = 0;
141
- null != o && (e = o.offsetTop + o.offsetHeight),
142
- (s.style.top = Math.max(e, 0) + "px");
142
+ null != s && (e = s.offsetTop + s.offsetHeight),
143
+ (o.style.top = Math.max(e, 0) + "px");
143
144
  } else {
144
145
  let e = 0;
145
- null != o &&
146
+ null != s &&
146
147
  (e =
147
148
  (window.innerHeight || document.documentElement.clientHeight) -
148
- o.offsetTop),
149
- (s.style.bottom = Math.max(e, 0) + "px");
149
+ s.offsetTop),
150
+ (o.style.bottom = Math.max(e, 0) + "px");
150
151
  }
151
152
  } else if (i && !e.nn(L.Lh)) {
152
153
  const e = t;
153
- It(s) &&
154
- s.contentWindow &&
155
- s.contentWindow.addEventListener("keydown", function (t) {
156
- t.keyCode === lt.mh && e.closeMessage();
154
+ It(o) &&
155
+ o.contentWindow &&
156
+ o.contentWindow.addEventListener("keydown", function (t) {
157
+ t.keyCode === mt.mh && e.closeMessage();
157
158
  });
158
159
  }
159
160
  logInAppMessageImpression(t),
160
161
  t.dismissType === InAppMessage.DismissType.AUTO_DISMISS &&
161
162
  setTimeout(() => {
162
- n.contains(s) && t.Ae(s);
163
+ n.contains(o) && t.Cr(o);
163
164
  }, t.duration),
164
- "function" == typeof o && o();
165
+ "function" == typeof s && s();
165
166
  },
166
167
  (e) => {
167
168
  r.info(e);
@@ -169,7 +170,8 @@ export function showInAppMessage(t, s, o) {
169
170
  e.nn(L.ho),
170
171
  e.nn(L.jo),
171
172
  e.nn(L.bo),
172
- s,
173
+ o,
174
+ ue.m().wo(),
173
175
  );
174
176
  return (i || a) && (n.appendChild(l), t.Oh(n)), !0;
175
177
  }
@@ -1,18 +1 @@
1
- export const isIFrame = (o) => null !== o && "IFRAME" === o.tagName;
2
- export function nodeScriptReplace(o) {
3
- var n;
4
- if ("SCRIPT" === o.tagName)
5
- null === (n = o.parentNode) ||
6
- void 0 === n ||
7
- n.replaceChild(
8
- (function (o) {
9
- const n = document.createElement("script");
10
- n.text = o.innerHTML;
11
- for (const e of o.attributes) n.setAttribute(e.name, e.value);
12
- return n;
13
- })(o),
14
- o,
15
- );
16
- else for (const n of o.childNodes) nodeScriptReplace(n);
17
- return o;
18
- }
1
+ export const isIFrame = (e) => null !== e && "IFRAME" === e.tagName;
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushBlocked() {
4
- if (e.X()) return vt.isPushBlocked();
4
+ if (e.X()) return yt.isPushBlocked();
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushPermissionGranted() {
4
- if (e.X()) return vt.isPushPermissionGranted();
4
+ if (e.X()) return yt.isPushPermissionGranted();
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import e from "../managers/braze-instance.js";
2
- import vt from "./utils/push-utils.js";
2
+ import yt from "./utils/push-utils.js";
3
3
  export function isPushSupported() {
4
- if (e.X()) return vt.isPushSupported();
4
+ if (e.X()) return yt.isPushSupported();
5
5
  }
@@ -13,9 +13,10 @@ const na = {
13
13
  e.Hs(),
14
14
  e.nn(L.wa),
15
15
  e.nn(L.ya),
16
- e.ir(),
17
16
  e.nn(L.Ma),
17
+ e.ir(),
18
18
  e.nn(L._a),
19
+ e.nn(L.ka),
19
20
  e.l(),
20
21
  )),
21
22
  na.i
@@ -3,37 +3,37 @@ import ti from "../models/push-token.js";
3
3
  import { logger as r, EncodingUtils as ei } from "../../shared-lib/index.js";
4
4
  import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
5
5
  import { User } from "../User/index.js";
6
- import { WindowUtils as eo } from "../util/window-utils.js";
7
- import vt from "./utils/push-utils.js";
6
+ import yt from "./utils/push-utils.js";
8
7
  import { getErrorMessage as si } from "../util/error-utils.js";
9
8
  export default class ea {
10
- constructor(i, t, e, s, r, n, o, u, a, c) {
9
+ constructor(i, t, e, s, r, n, o, u, a, h, c) {
11
10
  (this.sn = i),
12
11
  (this.rn = t),
13
12
  (this.on = e),
14
13
  (this.un = r),
15
14
  (this.an = n),
16
- (this.yt = o),
17
- (this.cn = u),
18
- (this.hn = a),
15
+ (this.hn = o),
16
+ (this.yt = u),
17
+ (this.cn = a),
18
+ (this.fn = h),
19
19
  (this.u = c),
20
20
  (this.sn = i),
21
21
  (this.rn = t),
22
22
  (this.on = e),
23
- (this.fn = s + "/safari/" + t),
23
+ (this.ln = s + "/safari/" + t),
24
24
  (this.un = r || "/service-worker.js"),
25
- (this.an = n),
26
- (this.yt = o),
27
- (this.cn = u || !1),
28
- (this.hn = a || !1),
25
+ (this.hn = o),
26
+ (this.yt = u),
27
+ (this.cn = a || !1),
28
+ (this.fn = h || !1),
29
29
  (this.u = c),
30
- (this.ln = vt.dn()),
31
- (this.pn = vt.bn());
30
+ (this.dn = yt.pn()),
31
+ (this.bn = yt.yn());
32
32
  }
33
33
  mn() {
34
- return this.hn;
34
+ return this.fn;
35
35
  }
36
- yn(i, t, e, s, n) {
36
+ gn(i, t, e, s, n) {
37
37
  i.unsubscribe()
38
38
  .then((i) => {
39
39
  i
@@ -46,7 +46,7 @@ export default class ea {
46
46
  "function" == typeof n && n(!1);
47
47
  });
48
48
  }
49
- gn(i, t, e) {
49
+ wn(i, t, e) {
50
50
  var s;
51
51
  const n = ((i) => {
52
52
  if ("string" == typeof i) return i;
@@ -55,9 +55,9 @@ export default class ea {
55
55
  let t = i.endpoint;
56
56
  const e = i;
57
57
  return (
58
- e.wn &&
59
- -1 === i.endpoint.indexOf(e.wn) &&
60
- (t = i.endpoint + "/" + e.wn),
58
+ e.kn &&
59
+ -1 === i.endpoint.indexOf(e.kn) &&
60
+ (t = i.endpoint + "/" + e.kn),
61
61
  t
62
62
  );
63
63
  })(i);
@@ -73,7 +73,7 @@ export default class ea {
73
73
  } catch (i) {
74
74
  r.error(si(i));
75
75
  }
76
- const c = ((i) => {
76
+ const h = ((i) => {
77
77
  let t;
78
78
  return i.options &&
79
79
  (t = i.options.applicationServerKey) &&
@@ -84,25 +84,25 @@ export default class ea {
84
84
  .replace(/\//g, "_")
85
85
  : null;
86
86
  })(a);
87
- null === (s = this.sn) || void 0 === s || s.kn(n, t, o, u, c),
87
+ null === (s = this.sn) || void 0 === s || s.Pn(n, t, o, u, h),
88
88
  n && "function" == typeof e && e(n, o, u);
89
89
  }
90
- Pn() {
90
+ Dn() {
91
91
  var i;
92
- null === (i = this.sn) || void 0 === i || i.Dn(!0);
92
+ null === (i = this.sn) || void 0 === i || i.Sn(!0);
93
93
  }
94
- Sn(i, t) {
94
+ An(i, t) {
95
95
  var e;
96
- null === (e = this.sn) || void 0 === e || e.Dn(!1),
96
+ null === (e = this.sn) || void 0 === e || e.Sn(!1),
97
97
  r.info(i),
98
98
  "function" == typeof t && t(!1);
99
99
  }
100
- An(i, t, e, s) {
100
+ jn(i, t, e, s) {
101
101
  var n;
102
102
  if ("default" === t.permission)
103
103
  try {
104
104
  window.safari.pushNotification.requestPermission(
105
- this.fn,
105
+ this.ln,
106
106
  i,
107
107
  {
108
108
  api_key: this.rn,
@@ -116,21 +116,21 @@ export default class ea {
116
116
  this.sn.setPushNotificationSubscriptionType(
117
117
  User.NotificationSubscriptionTypes.OPTED_IN,
118
118
  ),
119
- this.An(i, t, e, s);
119
+ this.jn(i, t, e, s);
120
120
  },
121
121
  );
122
122
  } catch (i) {
123
- this.Sn("Could not request permission for push: " + i, s);
123
+ this.An("Could not request permission for push: " + i, s);
124
124
  }
125
125
  else
126
126
  "denied" === t.permission
127
- ? this.Sn(
127
+ ? this.An(
128
128
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
129
129
  s,
130
130
  )
131
131
  : "granted" === t.permission &&
132
132
  (r.info("Device successfully subscribed to push."),
133
- this.gn(t.deviceToken, new Date(), e));
133
+ this.wn(t.deviceToken, new Date(), e));
134
134
  }
135
135
  requestPermission(i, t, e) {
136
136
  const s = (s) => {
@@ -166,61 +166,49 @@ export default class ea {
166
166
  .subscribe(n)
167
167
  .then((i) => {
168
168
  r.info("Device successfully subscribed to push."),
169
- this.gn(i, new Date(), e);
169
+ this.wn(i, new Date(), e);
170
170
  })
171
171
  .catch((i) => {
172
- vt.isPushBlocked()
172
+ yt.isPushBlocked()
173
173
  ? (r.info("Permission for push notifications was denied."),
174
174
  "function" == typeof s && s(!1))
175
175
  : (r.error("Push subscription failed: " + i),
176
176
  "function" == typeof s && s(!0));
177
177
  });
178
178
  }
179
- jn() {
180
- return this.cn
181
- ? navigator.serviceWorker.getRegistration(this.un)
182
- : navigator.serviceWorker.register(this.un).then(() =>
183
- navigator.serviceWorker.ready.then(
184
- (i) => (
185
- i &&
186
- "function" == typeof i.update &&
187
- i.update().catch((i) => {
188
- r.info("ServiceWorker update failed: " + i);
189
- }),
190
- i
191
- ),
192
- ),
193
- );
179
+ xn() {
180
+ if (this.cn) return navigator.serviceWorker.getRegistration(this.un);
181
+ const i = this.an ? { scope: this.an } : void 0;
182
+ return navigator.serviceWorker.register(this.un, i).then(() =>
183
+ navigator.serviceWorker.ready.then(
184
+ (i) => (
185
+ i &&
186
+ "function" == typeof i.update &&
187
+ i.update().catch((i) => {
188
+ r.info("ServiceWorker update failed: " + i);
189
+ }),
190
+ i
191
+ ),
192
+ ),
193
+ );
194
194
  }
195
- xn(i) {
195
+ Nn(i) {
196
196
  this.cn ||
197
197
  (i.unregister(), r.info("Service worker successfully unregistered."));
198
198
  }
199
199
  subscribe(i, t) {
200
- if (!vt.isPushSupported())
201
- return r.info(ea.Nn), void ("function" == typeof t && t(!1));
202
- if (this.ln) {
200
+ if (!yt.isPushSupported())
201
+ return r.info(ea.Un), void ("function" == typeof t && t(!1));
202
+ if (this.dn) {
203
203
  if (!this.cn && null != window.location) {
204
204
  let i = this.un;
205
205
  -1 === i.indexOf(window.location.host) &&
206
206
  (i = window.location.host + i),
207
207
  -1 === i.indexOf(window.location.protocol) &&
208
208
  (i = window.location.protocol + "//" + i);
209
- const e = i.substr(0, i.lastIndexOf("/") + 1);
210
- if (0 !== eo.Un().indexOf(e))
211
- return (
212
- r.error(
213
- "Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from " +
214
- window.location.pathname +
215
- " but service worker is at " +
216
- i +
217
- ")",
218
- ),
219
- void ("function" == typeof t && t(!0))
220
- );
221
209
  }
222
- if (vt.isPushBlocked())
223
- return void this.Sn(
210
+ if (yt.isPushBlocked())
211
+ return void this.An(
224
212
  "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
225
213
  t,
226
214
  );
@@ -239,20 +227,20 @@ export default class ea {
239
227
  },
240
228
  s = () => {
241
229
  let i = "Permission for push notifications was ignored.";
242
- vt.isPushBlocked() &&
230
+ yt.isPushBlocked() &&
243
231
  (i +=
244
232
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
245
233
  r.info(i),
246
234
  "function" == typeof t && t(!0);
247
235
  },
248
- n = vt.isPushPermissionGranted(),
236
+ n = yt.isPushPermissionGranted(),
249
237
  u = () => {
250
238
  !n &&
251
239
  this.sn &&
252
240
  this.sn.setPushNotificationSubscriptionType(
253
241
  User.NotificationSubscriptionTypes.OPTED_IN,
254
242
  ),
255
- this.jn()
243
+ this.xn()
256
244
  .then((e) => {
257
245
  if (null == e)
258
246
  return (
@@ -275,7 +263,7 @@ export default class ea {
275
263
  ) {
276
264
  let n,
277
265
  a = null,
278
- c = null;
266
+ h = null;
279
267
  if ((this.u && (n = this.u.j(o.C.In)), n && !j(n))) {
280
268
  let i;
281
269
  try {
@@ -287,8 +275,8 @@ export default class ea {
287
275
  isNaN(i.getTime()) ||
288
276
  0 === i.getTime() ||
289
277
  ((a = i),
290
- (c = new Date(a)),
291
- c.setMonth(a.getMonth() + 6));
278
+ (h = new Date(a)),
279
+ h.setMonth(a.getMonth() + 6));
292
280
  }
293
281
  null != u &&
294
282
  s.options &&
@@ -303,30 +291,30 @@ export default class ea {
303
291
  : r.info(
304
292
  "Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription.",
305
293
  ),
306
- this.yn(s, e, u, i, t))
294
+ this.gn(s, e, u, i, t))
307
295
  : s.expirationTime &&
308
296
  new Date(s.expirationTime).valueOf() <=
309
297
  new Date().valueOf()
310
298
  ? (r.info(
311
299
  "Push subscription is expired, creating new subscription.",
312
300
  ),
313
- this.yn(s, e, u, i, t))
301
+ this.gn(s, e, u, i, t))
314
302
  : n && j(n)
315
- ? this.yn(s, e, u, i, t)
316
- : null == c
303
+ ? this.gn(s, e, u, i, t)
304
+ : null == h
317
305
  ? (r.info(
318
306
  "No push subscription creation date found, creating new subscription.",
319
307
  ),
320
- this.yn(s, e, u, i, t))
321
- : c.valueOf() <= new Date().valueOf()
308
+ this.gn(s, e, u, i, t))
309
+ : h.valueOf() <= new Date().valueOf()
322
310
  ? (r.info(
323
311
  "Push subscription older than 6 months, creating new subscription.",
324
312
  ),
325
- this.yn(s, e, u, i, t))
313
+ this.gn(s, e, u, i, t))
326
314
  : (r.info(
327
315
  "Device already subscribed to push, sending existing subscription to backend.",
328
316
  ),
329
- this.gn(s, a, i));
317
+ this.wn(s, a, i));
330
318
  } else this.vn(e, u, i, t);
331
319
  })
332
320
  .catch((i) => {
@@ -338,29 +326,29 @@ export default class ea {
338
326
  });
339
327
  };
340
328
  this.requestPermission(u, s, e);
341
- } else if (this.pn) {
342
- if (null == this.an || "" === this.an)
329
+ } else if (this.bn) {
330
+ if (null == this.hn || "" === this.hn)
343
331
  return (
344
332
  r.error(
345
333
  "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
346
334
  ),
347
335
  void ("function" == typeof t && t(!0))
348
336
  );
349
- const e = window.safari.pushNotification.permission(this.an);
350
- this.An(this.an, e, i, t);
337
+ const e = window.safari.pushNotification.permission(this.hn);
338
+ this.jn(this.hn, e, i, t);
351
339
  }
352
340
  }
353
341
  unsubscribe(i, t) {
354
- if (!vt.isPushSupported())
355
- return r.info(ea.Nn), void ("function" == typeof t && t());
356
- this.ln
342
+ if (!yt.isPushSupported())
343
+ return r.info(ea.Un), void ("function" == typeof t && t());
344
+ this.dn
357
345
  ? navigator.serviceWorker.getRegistration(this.un).then((e) => {
358
346
  e
359
347
  ? e.pushManager
360
348
  .getSubscription()
361
349
  .then((s) => {
362
350
  s
363
- ? (this.Pn(),
351
+ ? (this.Dn(),
364
352
  s
365
353
  .unsubscribe()
366
354
  .then((s) => {
@@ -373,7 +361,7 @@ export default class ea {
373
361
  "Failed to unsubscribe device from push.",
374
362
  ),
375
363
  "function" == typeof t && t()),
376
- this.xn(e);
364
+ this.Nn(e);
377
365
  })
378
366
  .catch((i) => {
379
367
  r.error("Push unsubscription error: " + i),
@@ -389,10 +377,10 @@ export default class ea {
389
377
  : (r.info("Device already unsubscribed from push."),
390
378
  "function" == typeof i && i());
391
379
  })
392
- : this.pn &&
393
- (this.Pn(),
380
+ : this.bn &&
381
+ (this.Dn(),
394
382
  r.info("Device unsubscribed from push."),
395
383
  "function" == typeof i && i());
396
384
  }
397
385
  }
398
- ea.Nn = "Push notifications are not supported in this browser.";
386
+ ea.Un = "Push notifications are not supported in this browser.";
@@ -1,36 +1,36 @@
1
- const vt = {
2
- dn: () =>
1
+ const yt = {
2
+ pn: () =>
3
3
  "serviceWorker" in navigator &&
4
4
  "undefined" != typeof ServiceWorkerRegistration &&
5
5
  "showNotification" in ServiceWorkerRegistration.prototype &&
6
6
  "PushManager" in window,
7
- bn: () =>
7
+ yn: () =>
8
8
  "safari" in window &&
9
9
  "pushNotification" in window.safari &&
10
10
  "function" == typeof window.safari.pushNotification.permission &&
11
11
  "function" == typeof window.safari.pushNotification.requestPermission,
12
- isPushSupported: () => vt.dn() || vt.bn(),
12
+ isPushSupported: () => yt.pn() || yt.yn(),
13
13
  isPushBlocked: () => {
14
14
  const i =
15
- vt.isPushSupported() &&
15
+ yt.isPushSupported() &&
16
16
  "Notification" in window &&
17
17
  null != window.Notification &&
18
18
  null != window.Notification.permission &&
19
19
  "denied" === window.Notification.permission,
20
20
  n =
21
- vt.isPushSupported() &&
21
+ yt.isPushSupported() &&
22
22
  (!("Notification" in window) || null == window.Notification);
23
23
  return i || n;
24
24
  },
25
25
  isPushPermissionGranted: () =>
26
- vt.isPushSupported() &&
26
+ yt.isPushSupported() &&
27
27
  "Notification" in window &&
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- Vi: () =>
32
- !vt.isPushBlocked() &&
33
- vt.isPushSupported() &&
34
- !vt.isPushPermissionGranted(),
31
+ Qi: () =>
32
+ !yt.isPushBlocked() &&
33
+ yt.isPushSupported() &&
34
+ !yt.isPushPermissionGranted(),
35
35
  };
36
- export default vt;
36
+ export default yt;