@edusight/notification-widget 1.0.41 → 1.0.44

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.
package/dist/index.esm.js CHANGED
@@ -1,52 +1,52 @@
1
- import { jsx as u, jsxs as A } from "react/jsx-runtime";
2
- import { NotificationClient as $ } from "@edusight/notification-sdk";
3
- import F, { useState as v, useCallback as T, useEffect as k, Component as j, createContext as J, useReducer as G, useRef as Q, useContext as X } from "react";
4
- import { io as Y } from "socket.io-client";
5
- import { u as Z, c as K } from "./hooks-S0z2_-4B.js";
6
- import { M as ee, a as te, C as x, B as P, S as ne, I as re, L as ie } from "./components-CWbjrQKA.js";
7
- import { N as Ce, P as ve } from "./components-CWbjrQKA.js";
8
- const oe = () => window.__notificationSDK?.client, ae = ({
1
+ import { jsx as f, jsxs as A } from "react/jsx-runtime";
2
+ import { NotificationClient as G } from "@edusight/notification-sdk";
3
+ import L, { useState as v, useCallback as T, useEffect as k, Component as Q, createContext as X, useReducer as Y, useRef as Z, useContext as ee } from "react";
4
+ import { io as te } from "socket.io-client";
5
+ import { u as ne, c as P } from "./hooks-S0z2_-4B.js";
6
+ import { M as re, a as ie, C as D, B as R, S as oe, I as ae, L as se } from "./components-DUT08KJF.js";
7
+ import { N as Oe, P as xe } from "./components-DUT08KJF.js";
8
+ const ce = () => window.__notificationSDK?.client, le = ({
9
9
  onPreferencesLoaded: t,
10
10
  onError: n
11
11
  }) => {
12
- const f = oe(), [h, a] = v(!0), [l, s] = v(null), [r, d] = v(null), m = T(async () => {
12
+ const u = ce(), [h, a] = v(!0), [d, s] = v(null), [r, l] = v(null), y = T(async () => {
13
13
  try {
14
- if (a(!0), s(null), !f)
14
+ if (a(!0), s(null), !u)
15
15
  throw new Error("Notification client not available");
16
16
  const p = window.__notificationSDK?.config;
17
17
  if (!p)
18
18
  throw new Error("SDK configuration not available");
19
- const { subscriberId: E, tenantId: I, environmentId: b } = p;
20
- if (!E || !I || !b)
19
+ const { subscriberId: g, tenantId: b, environmentId: I } = p;
20
+ if (!g || !b || !I)
21
21
  throw new Error("SubscriberId, TenantId or EnvironmentId not available in config");
22
- const w = await f.preferences.get(
23
- I,
24
- E,
25
- b
22
+ const S = await u.preferences.get(
23
+ b,
24
+ g,
25
+ I
26
26
  );
27
27
  let c = null;
28
28
  try {
29
- c = await f.preferences.getSchedule(
30
- I,
31
- E,
32
- b
29
+ c = await u.preferences.getSchedule(
30
+ b,
31
+ g,
32
+ I
33
33
  );
34
34
  } catch {
35
35
  }
36
36
  const N = {
37
37
  channels: {
38
- email: w.emailEnabled ?? !0,
39
- push: w.pushEnabled ?? !0,
40
- sms: w.smsEnabled ?? !1,
41
- inApp: w.inAppEnabled ?? !0
38
+ email: S.emailEnabled ?? !0,
39
+ push: S.pushEnabled ?? !0,
40
+ sms: S.smsEnabled ?? !1,
41
+ inApp: S.inAppEnabled ?? !0
42
42
  },
43
43
  subscriptions: [],
44
44
  deliverySchedule: {
45
45
  enabled: c?.isEnabled || !1,
46
46
  timezone: "UTC",
47
47
  quietHours: {
48
- start: w.quietHoursStart ?? "22:00",
49
- end: w.quietHoursEnd ?? "08:00"
48
+ start: S.quietHoursStart ?? "22:00",
49
+ end: S.quietHoursEnd ?? "08:00"
50
50
  },
51
51
  weekdays: c?.weeklySchedule ? [
52
52
  !!c.weeklySchedule.monday,
@@ -60,7 +60,7 @@ const oe = () => window.__notificationSDK?.client, ae = ({
60
60
  weeklySchedule: c?.weeklySchedule || void 0
61
61
  }
62
62
  };
63
- w.categories && Object.entries(w.categories).forEach(([C, _]) => {
63
+ S.categories && Object.entries(S.categories).forEach(([C, _]) => {
64
64
  N.subscriptions.push({
65
65
  workflowId: C,
66
66
  name: C,
@@ -72,11 +72,11 @@ const oe = () => window.__notificationSDK?.client, ae = ({
72
72
  inApp: _.inAppEnabled ?? !0
73
73
  }
74
74
  });
75
- }), d(N), t(N);
75
+ }), l(N), t(N);
76
76
  } catch (p) {
77
- const E = p instanceof Error ? p : new Error("Failed to load preferences");
78
- p?.response?.status === 404 || p?.status === 404 || (s(E), n?.(E));
79
- const b = {
77
+ const g = p instanceof Error ? p : new Error("Failed to load preferences");
78
+ p?.response?.status === 404 || p?.status === 404 || (s(g), n?.(g));
79
+ const I = {
80
80
  channels: {
81
81
  email: !0,
82
82
  push: !0,
@@ -94,62 +94,62 @@ const oe = () => window.__notificationSDK?.client, ae = ({
94
94
  weekdays: [!0, !0, !0, !0, !0, !1, !1]
95
95
  }
96
96
  };
97
- d(b), t(b);
97
+ l(I), t(I);
98
98
  } finally {
99
99
  a(!1);
100
100
  }
101
- }, [f, t, n]);
101
+ }, [u, t, n]);
102
102
  return k(() => {
103
- f && m();
104
- }, [f, m]), {
103
+ u && y();
104
+ }, [u, y]), {
105
105
  isLoading: h,
106
- error: l,
106
+ error: d,
107
107
  preferences: r
108
108
  };
109
- }, se = () => window.__notificationSDK?.client, ce = () => {
110
- const t = se(), [n, f] = v([]), [h, a] = v(!1), [l, s] = v(!0), [r, d] = v(0), m = 5, p = T(async () => {
111
- if (!(!t || h || !l))
109
+ }, de = () => window.__notificationSDK?.client, fe = () => {
110
+ const t = de(), [n, u] = v([]), [h, a] = v(!1), [d, s] = v(!0), [r, l] = v(0), y = 5, p = T(async () => {
111
+ if (!(!t || h || !d))
112
112
  try {
113
113
  a(!0);
114
- const I = window.__notificationSDK?.config;
115
- if (!I) return;
116
- const b = await t.preferences.listSpecific(
117
- I.tenantId,
118
- I.subscriberId,
114
+ const b = window.__notificationSDK?.config;
115
+ if (!b) return;
116
+ const I = await t.preferences.listSpecific(
117
+ b.tenantId,
118
+ b.subscriberId,
119
119
  {
120
120
  includeWorkflows: !0,
121
121
  includeTemplates: !1,
122
122
  activeOnly: !0,
123
- limit: m,
123
+ limit: y,
124
124
  offset: r
125
125
  }
126
- ), w = (b.items || []).map((c) => ({
126
+ ), S = (I.items || []).map((c) => ({
127
127
  workflowId: c.identifier,
128
128
  name: c.name,
129
129
  enabled: c.preference.enabled,
130
130
  channels: c.preference.channels
131
131
  }));
132
- f((c) => {
133
- const N = new Set(c.map((_) => _.workflowId)), C = w.filter((_) => !N.has(_.workflowId));
132
+ u((c) => {
133
+ const N = new Set(c.map((_) => _.workflowId)), C = S.filter((_) => !N.has(_.workflowId));
134
134
  return [...c, ...C];
135
- }), d((c) => c + m), (w.length < m || b.total !== void 0 && n.length + w.length >= b.total) && s(!1);
135
+ }), l((c) => c + y), (S.length < y || I.total !== void 0 && n.length + S.length >= I.total) && s(!1);
136
136
  } catch {
137
137
  } finally {
138
138
  a(!1);
139
139
  }
140
- }, [t, r, l, h, n.length]);
140
+ }, [t, r, d, h, n.length]);
141
141
  return k(() => {
142
142
  t && r === 0 && n.length === 0 && p();
143
143
  }, [t, p, r, n.length]), {
144
144
  specificPreferences: n,
145
145
  isLoading: h,
146
- hasMore: l,
146
+ hasMore: d,
147
147
  loadMore: p,
148
148
  refetch: async () => {
149
- f([]), d(0), s(!0);
149
+ u([]), l(0), s(!0);
150
150
  }
151
151
  };
152
- }, de = ({ error: t, onRetry: n }) => /* @__PURE__ */ A(
152
+ }, ue = ({ error: t, onRetry: n }) => /* @__PURE__ */ A(
153
153
  "div",
154
154
  {
155
155
  className: "p-4 bg-[var(--widget-error)]/10 border border-[var(--widget-error)]/20 rounded-lg",
@@ -157,12 +157,12 @@ const oe = () => window.__notificationSDK?.client, ae = ({
157
157
  "data-testid": "error-boundary-fallback",
158
158
  children: [
159
159
  /* @__PURE__ */ A("div", { className: "flex items-center mb-2", children: [
160
- /* @__PURE__ */ u(ee, { className: "w-6 h-6 text-[var(--widget-error)] mr-2", "aria-hidden": "true" }),
161
- /* @__PURE__ */ u("h3", { className: "text-sm font-medium text-[var(--widget-error)]", children: "Something went wrong" })
160
+ /* @__PURE__ */ f(re, { className: "w-6 h-6 text-[var(--widget-error)] mr-2", "aria-hidden": "true" }),
161
+ /* @__PURE__ */ f("h3", { className: "text-sm font-medium text-[var(--widget-error)]", children: "Something went wrong" })
162
162
  ] }),
163
- /* @__PURE__ */ u("p", { className: "text-sm mb-3 text-[var(--widget-error)]/80", children: "The notification widget encountered an error and couldn't load properly." }),
163
+ /* @__PURE__ */ f("p", { className: "text-sm mb-3 text-[var(--widget-error)]/80", children: "The notification widget encountered an error and couldn't load properly." }),
164
164
  process.env.NODE_ENV === "development" && t && /* @__PURE__ */ A("details", { className: "mb-3", children: [
165
- /* @__PURE__ */ u("summary", { className: "text-xs cursor-pointer text-[var(--widget-error)] hover:text-[var(--widget-error)]/80 transition-colors", children: "Error details (development only)" }),
165
+ /* @__PURE__ */ f("summary", { className: "text-xs cursor-pointer text-[var(--widget-error)] hover:text-[var(--widget-error)]/80 transition-colors", children: "Error details (development only)" }),
166
166
  /* @__PURE__ */ A("pre", { className: "mt-2 text-xs bg-[var(--widget-error)]/5 p-2 rounded overflow-auto max-h-32 text-[var(--widget-error)]", children: [
167
167
  t.message,
168
168
  t.stack && `
@@ -178,7 +178,7 @@ ${t.stack}`
178
178
  onClick: n,
179
179
  "data-testid": "error-retry-button",
180
180
  children: [
181
- /* @__PURE__ */ u(te, { className: "mr-1 w-4 h-4", "aria-hidden": "true" }),
181
+ /* @__PURE__ */ f(ie, { className: "mr-1 w-4 h-4", "aria-hidden": "true" }),
182
182
  "Try again"
183
183
  ]
184
184
  }
@@ -186,7 +186,7 @@ ${t.stack}`
186
186
  ]
187
187
  }
188
188
  );
189
- class le extends j {
189
+ class pe extends Q {
190
190
  constructor(n) {
191
191
  super(n), this.handleRetry = () => {
192
192
  this.setState({
@@ -206,21 +206,21 @@ class le extends j {
206
206
  error: n
207
207
  };
208
208
  }
209
- componentDidCatch(n, f) {
209
+ componentDidCatch(n, u) {
210
210
  this.setState({
211
- errorInfo: f
212
- }), this.props.onError && this.props.onError(n, f);
211
+ errorInfo: u
212
+ }), this.props.onError && this.props.onError(n, u);
213
213
  }
214
214
  render() {
215
- return this.state.hasError ? /* @__PURE__ */ u(de, { error: this.state.error, onRetry: this.handleRetry }) : this.props.children;
215
+ return this.state.hasError ? /* @__PURE__ */ f(ue, { error: this.state.error, onRetry: this.handleRetry }) : this.props.children;
216
216
  }
217
217
  }
218
- const L = J(null), ue = () => {
219
- const t = X(L);
218
+ const U = X(null), me = () => {
219
+ const t = ee(U);
220
220
  if (!t)
221
221
  throw new Error("useSDK must be used within a NotificationWidget");
222
222
  return t;
223
- }, fe = {
223
+ }, he = {
224
224
  notifications: [],
225
225
  unreadCount: 0,
226
226
  preferences: {
@@ -251,11 +251,11 @@ const L = J(null), ue = () => {
251
251
  connected: !1,
252
252
  reconnecting: !1
253
253
  }
254
- }, pe = ({
254
+ }, we = ({
255
255
  config: t,
256
256
  children: n
257
257
  }) => {
258
- const [f, h] = F.useState({
258
+ const [u, h] = L.useState({
259
259
  client: null,
260
260
  isInitialized: !1,
261
261
  error: null
@@ -273,7 +273,7 @@ const L = J(null), ue = () => {
273
273
  });
274
274
  return;
275
275
  }
276
- const r = new $({
276
+ const r = new G({
277
277
  apiUrl: t.baseUrl,
278
278
  apiKey: t.apiKey,
279
279
  tenantId: t.tenantId,
@@ -294,37 +294,37 @@ const L = J(null), ue = () => {
294
294
  })(), () => {
295
295
  a = !1;
296
296
  };
297
- }, [t]), /* @__PURE__ */ u(L.Provider, { value: f, children: n });
298
- }, he = (t, n) => {
297
+ }, [t]), /* @__PURE__ */ f(U.Provider, { value: u, children: n });
298
+ }, ye = (t, n) => {
299
299
  switch (n.type) {
300
300
  case "SET_NOTIFICATIONS":
301
301
  return {
302
302
  ...t,
303
303
  notifications: n.payload,
304
- unreadCount: n.payload.filter((l) => !l.isRead).length
304
+ unreadCount: n.payload.filter((d) => !d.isRead).length
305
305
  };
306
306
  case "ADD_NOTIFICATION":
307
- const f = [n.payload, ...t.notifications];
307
+ const u = [n.payload, ...t.notifications];
308
308
  return {
309
309
  ...t,
310
- notifications: f,
311
- unreadCount: f.filter((l) => !l.isRead).length
310
+ notifications: u,
311
+ unreadCount: u.filter((d) => !d.isRead).length
312
312
  };
313
313
  case "UPDATE_NOTIFICATION":
314
314
  const h = t.notifications.map(
315
- (l) => l.id === n.payload.id ? { ...l, ...n.payload.updates } : l
315
+ (d) => d.id === n.payload.id ? { ...d, ...n.payload.updates } : d
316
316
  );
317
317
  return {
318
318
  ...t,
319
319
  notifications: h,
320
- unreadCount: h.filter((l) => !l.isRead).length
320
+ unreadCount: h.filter((d) => !d.isRead).length
321
321
  };
322
322
  case "DELETE_NOTIFICATION":
323
- const a = t.notifications.filter((l) => l.id !== n.payload);
323
+ const a = t.notifications.filter((d) => d.id !== n.payload);
324
324
  return {
325
325
  ...t,
326
326
  notifications: a,
327
- unreadCount: a.filter((l) => !l.isRead).length
327
+ unreadCount: a.filter((d) => !d.isRead).length
328
328
  };
329
329
  case "SET_PREFERENCES":
330
330
  return {
@@ -344,52 +344,52 @@ const L = J(null), ue = () => {
344
344
  default:
345
345
  return t;
346
346
  }
347
- }, me = ({
347
+ }, Se = ({
348
348
  position: t = "right",
349
349
  size: n = "medium",
350
- theme: f = "light",
350
+ theme: u = "light",
351
351
  className: h = "",
352
352
  onError: a,
353
- onMorePreferencesClick: l
353
+ onMorePreferencesClick: d
354
354
  }) => {
355
- const [s, r] = G(he, fe), { client: d, isInitialized: m, error: p } = ue(), E = Q(null), I = T((e) => {
355
+ const [s, r] = Y(ye, he), { client: l, isInitialized: y, error: p } = me(), g = Z(null), b = T((e) => {
356
356
  r({
357
357
  type: "SET_PREFERENCES",
358
358
  payload: e
359
359
  });
360
- }, []), b = T(
360
+ }, []), I = T(
361
361
  (e) => {
362
362
  a && a(e);
363
363
  },
364
364
  [a]
365
- ), { error: w } = ae({
366
- onPreferencesLoaded: I,
367
- onError: b
365
+ ), { error: S } = le({
366
+ onPreferencesLoaded: b,
367
+ onError: I
368
368
  }), {
369
369
  specificPreferences: c,
370
370
  isLoading: N,
371
371
  hasMore: C,
372
372
  loadMore: _
373
- } = ce(), {
374
- updatePreference: U,
375
- isSaving: D,
376
- error: R
377
- } = Z({
373
+ } = fe(), {
374
+ updatePreference: W,
375
+ isSaving: K,
376
+ error: F
377
+ } = ne({
378
378
  preferences: s.preferences,
379
- onPreferencesChange: I,
380
- onError: b
379
+ onPreferencesChange: b,
380
+ onError: I
381
381
  });
382
382
  k(() => {
383
383
  if (c.length > 0) {
384
384
  const i = [...s.preferences.subscriptions];
385
385
  let o = !1;
386
- c.forEach((g) => {
387
- const y = i.findIndex((S) => S.workflowId === g.workflowId);
388
- if (y === -1)
389
- i.push(g), o = !0;
386
+ c.forEach((E) => {
387
+ const m = i.findIndex((w) => w.workflowId === E.workflowId);
388
+ if (m === -1)
389
+ i.push(E), o = !0;
390
390
  else {
391
- const S = i[y];
392
- S.name === S.workflowId && g.name && g.name !== g.workflowId && (i[y] = { ...S, name: g.name }, o = !0);
391
+ const w = i[m];
392
+ w.name === w.workflowId && E.name && E.name !== E.workflowId && (i[m] = { ...w, name: E.name }, o = !0);
393
393
  }
394
394
  }), o && r({
395
395
  type: "SET_PREFERENCES",
@@ -400,18 +400,18 @@ const L = J(null), ue = () => {
400
400
  });
401
401
  }
402
402
  }, [c]);
403
- const W = F.useMemo(() => c.map((e) => s.preferences.subscriptions.find((o) => o.workflowId === e.workflowId) || e), [c, s.preferences.subscriptions]), O = T((e) => {
403
+ const M = L.useMemo(() => c.map((e) => s.preferences.subscriptions.find((o) => o.workflowId === e.workflowId) || e), [c, s.preferences.subscriptions]), x = T((e) => {
404
404
  try {
405
- const i = K();
405
+ const i = P();
406
406
  switch (e.type) {
407
407
  case "notification_received": {
408
408
  const o = e.data;
409
409
  if (!i.validateWebSocketPayload(o))
410
410
  break;
411
- const g = i.toWidgetNotificationFromWebSocket(o);
411
+ const E = i.toWidgetNotificationFromWebSocket(o);
412
412
  r({
413
413
  type: "ADD_NOTIFICATION",
414
- payload: g
414
+ payload: E
415
415
  });
416
416
  break;
417
417
  }
@@ -440,8 +440,8 @@ const L = J(null), ue = () => {
440
440
  }
441
441
  } catch {
442
442
  }
443
- }, []), M = T(async () => {
444
- if (!(!d || !m || E.current))
443
+ }, []), B = T(async () => {
444
+ if (!(!l || !y || g.current))
445
445
  try {
446
446
  r({
447
447
  type: "SET_WEBSOCKET_STATE",
@@ -450,61 +450,70 @@ const L = J(null), ue = () => {
450
450
  const e = window.__notificationSDK?.config;
451
451
  if (!e)
452
452
  throw new Error("SDK configuration not available for WebSocket connection");
453
- const g = `${d.getApiHost()}/v1/notifications`, y = Y(g, {
453
+ const E = `${l.getApiHost()}/v1/notifications`, m = te(E, {
454
454
  query: {
455
455
  tenantId: e.tenantId,
456
456
  subscriberId: e.subscriberId,
457
457
  environmentId: e.environmentId
458
458
  },
459
- transports: ["websocket"],
459
+ transports: ["websocket", "polling"],
460
460
  autoConnect: !1,
461
461
  reconnection: !0,
462
462
  reconnectionAttempts: 10,
463
463
  reconnectionDelay: 1e3,
464
464
  reconnectionDelayMax: 5e3
465
465
  });
466
- E.current = y, y.on("notification", (S) => {
467
- O({
466
+ g.current = m;
467
+ let w = null;
468
+ const j = () => {
469
+ w && clearInterval(w), w = setInterval(() => {
470
+ m.connected && m.emit("ping", { timestamp: Date.now() });
471
+ }, 3e3);
472
+ }, J = () => {
473
+ w && (clearInterval(w), w = null);
474
+ };
475
+ m.on("notification", (O) => {
476
+ x({
468
477
  type: "notification_received",
469
- data: S
478
+ data: O
470
479
  });
471
- }), y.on("connect", () => {
480
+ }), m.on("connect", () => {
472
481
  r({
473
482
  type: "SET_WEBSOCKET_STATE",
474
483
  payload: { connected: !0, reconnecting: !1 }
475
- });
476
- }), y.on("disconnect", (S) => {
484
+ }), j();
485
+ }), m.on("disconnect", (O) => {
477
486
  r({
478
487
  type: "SET_WEBSOCKET_STATE",
479
488
  payload: { connected: !1, reconnecting: !1 }
480
- });
481
- }), y.on("reconnect_attempt", (S) => {
489
+ }), J();
490
+ }), m.on("reconnect_attempt", (O) => {
482
491
  r({
483
492
  type: "SET_WEBSOCKET_STATE",
484
493
  payload: { connected: !1, reconnecting: !0 }
485
494
  });
486
- }), y.on("connect_error", (S) => {
495
+ }), m.on("connect_error", (O) => {
487
496
  r({
488
497
  type: "SET_WEBSOCKET_STATE",
489
498
  payload: { connected: !1, reconnecting: !1 }
490
- }), a && a(S);
491
- }), y.connect();
499
+ }), a && a(O);
500
+ }), m.connect();
492
501
  } catch (e) {
493
502
  r({
494
503
  type: "SET_WEBSOCKET_STATE",
495
504
  payload: { connected: !1, reconnecting: !1 }
496
505
  }), a && a(e);
497
506
  }
498
- }, [d, m, O, a]), B = T(() => {
499
- if (E.current)
507
+ }, [l, y, x, a]), V = T(() => {
508
+ if (g.current)
500
509
  try {
501
- E.current.disconnect && E.current.disconnect(), E.current = null, r({
510
+ g.current.disconnect && g.current.disconnect(), g.current = null, r({
502
511
  type: "SET_WEBSOCKET_STATE",
503
512
  payload: { connected: !1, reconnecting: !1 }
504
513
  });
505
514
  } catch {
506
515
  }
507
- }, []), V = T(() => {
516
+ }, []), H = T(() => {
508
517
  r({
509
518
  type: "SET_UI_STATE",
510
519
  payload: { isOpen: !s.ui.isOpen }
@@ -519,9 +528,9 @@ const L = J(null), ue = () => {
519
528
  type: "SET_UI_STATE",
520
529
  payload: { currentView: e }
521
530
  });
522
- }, []), H = T(
531
+ }, []), $ = T(
523
532
  async (e, i) => {
524
- if (!d || !m)
533
+ if (!l || !y)
525
534
  return;
526
535
  const o = window.__notificationSDK?.config;
527
536
  if (o) {
@@ -530,7 +539,7 @@ const L = J(null), ue = () => {
530
539
  try {
531
540
  switch (i.type) {
532
541
  case "mark_read":
533
- await d.inbox.markAsRead(
542
+ await l.inbox.markAsRead(
534
543
  e,
535
544
  o.tenantId,
536
545
  o.environmentId,
@@ -538,7 +547,7 @@ const L = J(null), ue = () => {
538
547
  );
539
548
  break;
540
549
  case "mark_unread":
541
- await d.inbox.markAsUnread(
550
+ await l.inbox.markAsUnread(
542
551
  e,
543
552
  o.tenantId,
544
553
  o.environmentId,
@@ -546,7 +555,7 @@ const L = J(null), ue = () => {
546
555
  );
547
556
  break;
548
557
  case "archive":
549
- await d.inbox.archive(
558
+ await l.inbox.archive(
550
559
  e,
551
560
  o.tenantId,
552
561
  o.environmentId,
@@ -554,7 +563,7 @@ const L = J(null), ue = () => {
554
563
  );
555
564
  break;
556
565
  case "delete":
557
- await d.inbox.delete(
566
+ await l.inbox.delete(
558
567
  e,
559
568
  o.tenantId,
560
569
  o.environmentId,
@@ -591,15 +600,15 @@ const L = J(null), ue = () => {
591
600
  });
592
601
  break;
593
602
  }
594
- } catch (g) {
595
- a && a(g);
603
+ } catch (E) {
604
+ a && a(E);
596
605
  }
597
606
  }
598
607
  },
599
- [d]
608
+ [l]
600
609
  );
601
610
  return k(() => {
602
- if (!d || !m) return;
611
+ if (!l || !y) return;
603
612
  (async () => {
604
613
  try {
605
614
  r({
@@ -609,7 +618,7 @@ const L = J(null), ue = () => {
609
618
  const i = window.__notificationSDK?.config;
610
619
  if (!i)
611
620
  throw new Error("SDK configuration not available");
612
- const o = K(), y = ((await d.inbox.getRenderedNotifications(
621
+ const o = P(), m = ((await l.inbox.getRenderedNotifications(
613
622
  {
614
623
  channel: "in_app",
615
624
  limit: 50,
@@ -619,11 +628,11 @@ const L = J(null), ue = () => {
619
628
  i.environmentId,
620
629
  i.subscriberId
621
630
  ))?.items || []).map(
622
- (S) => o.toWidgetNotification(S)
631
+ (w) => o.toWidgetNotification(w)
623
632
  );
624
633
  r({
625
634
  type: "SET_NOTIFICATIONS",
626
- payload: y
635
+ payload: m
627
636
  }), r({
628
637
  type: "SET_UI_STATE",
629
638
  payload: { isLoading: !1, error: null }
@@ -638,16 +647,16 @@ const L = J(null), ue = () => {
638
647
  }), a && a(i);
639
648
  }
640
649
  })();
641
- }, [d, m, a]), k(() => (d && m && M(), () => {
642
- B();
643
- }), [d]), k(() => {
644
- if (!d || !m || s.websocket.connected) return;
650
+ }, [l, y, a]), k(() => (l && y && B(), () => {
651
+ V();
652
+ }), [l]), k(() => {
653
+ if (!l || !y || s.websocket.connected) return;
645
654
  const e = setInterval(async () => {
646
655
  try {
647
656
  const i = window.__notificationSDK?.config;
648
657
  if (!i)
649
658
  return;
650
- const o = K(), y = ((await d.inbox.getRenderedNotifications(
659
+ const o = P(), m = ((await l.inbox.getRenderedNotifications(
651
660
  {
652
661
  channel: "in_app",
653
662
  limit: 50,
@@ -657,68 +666,68 @@ const L = J(null), ue = () => {
657
666
  i.environmentId,
658
667
  i.subscriberId
659
668
  ))?.items || []).map(
660
- (S) => o.toWidgetNotification(S)
669
+ (w) => o.toWidgetNotification(w)
661
670
  );
662
671
  r({
663
672
  type: "SET_NOTIFICATIONS",
664
- payload: y
673
+ payload: m
665
674
  });
666
675
  } catch {
667
676
  }
668
677
  }, 3e4);
669
678
  return () => clearInterval(e);
670
- }, [d, s.websocket.connected]), k(() => {
679
+ }, [l, s.websocket.connected]), k(() => {
671
680
  const e = (i) => {
672
681
  if (i.key === "notification_widget_sync" && i.newValue)
673
682
  try {
674
683
  const o = JSON.parse(i.newValue);
675
- O(o);
684
+ x(o);
676
685
  } catch {
677
686
  }
678
687
  };
679
688
  return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
680
- }, [O]), k(() => {
689
+ }, [x]), k(() => {
681
690
  r({
682
691
  type: "SET_UI_STATE",
683
- payload: { isLoading: D }
692
+ payload: { isLoading: K }
684
693
  });
685
- }, [D]), k(() => {
686
- const e = p || R || w;
694
+ }, [K]), k(() => {
695
+ const e = p || F || S;
687
696
  e && r({
688
697
  type: "SET_UI_STATE",
689
698
  payload: { error: e }
690
699
  });
691
- }, [p, R, w]), !m && !p ? /* @__PURE__ */ u(
700
+ }, [p, F, S]), !y && !p ? /* @__PURE__ */ f(
692
701
  "div",
693
702
  {
694
703
  className: `mx-widget-root relative inline-block ${h}`,
695
704
  "data-mx-widget": "root",
696
705
  "data-widget-size": n || "small",
697
- "data-theme": f,
706
+ "data-theme": u,
698
707
  "data-testid": "notification-widget",
699
- children: /* @__PURE__ */ u(x, { componentName: "BellComponent", children: /* @__PURE__ */ u(P, { unreadCount: 0, onClick: () => {
708
+ children: /* @__PURE__ */ f(D, { componentName: "BellComponent", children: /* @__PURE__ */ f(R, { unreadCount: 0, onClick: () => {
700
709
  }, size: n, disabled: !0 }) })
701
710
  }
702
- ) : p ? /* @__PURE__ */ u(
711
+ ) : p ? /* @__PURE__ */ f(
703
712
  "div",
704
713
  {
705
714
  className: `mx-widget-root relative inline-block ${h}`,
706
715
  "data-mx-widget": "root",
707
716
  "data-widget-size": n || "small",
708
- "data-theme": f,
717
+ "data-theme": u,
709
718
  "data-testid": "notification-widget",
710
- children: /* @__PURE__ */ u(
711
- x,
719
+ children: /* @__PURE__ */ f(
720
+ D,
712
721
  {
713
722
  componentName: "BellComponent",
714
- fallback: /* @__PURE__ */ u(
715
- ne,
723
+ fallback: /* @__PURE__ */ f(
724
+ oe,
716
725
  {
717
726
  error: p.message,
718
727
  onRetry: () => window.location.reload()
719
728
  }
720
729
  ),
721
- children: /* @__PURE__ */ u(P, { unreadCount: 0, onClick: () => {
730
+ children: /* @__PURE__ */ f(R, { unreadCount: 0, onClick: () => {
722
731
  }, size: n, disabled: !0 })
723
732
  }
724
733
  )
@@ -726,28 +735,28 @@ const L = J(null), ue = () => {
726
735
  ) : /* @__PURE__ */ A(
727
736
  "div",
728
737
  {
729
- className: `mx-widget-root relative inline-block ${h}`,
738
+ className: `mx-widget-root min-w-[20rem] relative inline-block ${h}`,
730
739
  "data-mx-widget": "root",
731
740
  "data-widget-size": n || "small",
732
- "data-theme": f,
741
+ "data-theme": u,
733
742
  "data-testid": "notification-widget",
734
743
  children: [
735
- /* @__PURE__ */ u(x, { componentName: "BellComponent", children: /* @__PURE__ */ u(
736
- P,
744
+ /* @__PURE__ */ f(D, { componentName: "BellComponent", children: /* @__PURE__ */ f(
745
+ R,
737
746
  {
738
747
  unreadCount: s.unreadCount,
739
- onClick: V,
748
+ onClick: H,
740
749
  size: n,
741
750
  disabled: s.ui.isLoading
742
751
  }
743
752
  ) }),
744
- /* @__PURE__ */ u(
745
- x,
753
+ /* @__PURE__ */ f(
754
+ D,
746
755
  {
747
756
  componentName: "InboxPopover",
748
- fallback: /* @__PURE__ */ u(ie, { message: "Unable to load notifications" }),
749
- children: /* @__PURE__ */ u(
750
- re,
757
+ fallback: /* @__PURE__ */ f(se, { message: "Unable to load notifications" }),
758
+ children: /* @__PURE__ */ f(
759
+ ae,
751
760
  {
752
761
  isOpen: s.ui.isOpen,
753
762
  onClose: q,
@@ -755,15 +764,15 @@ const L = J(null), ue = () => {
755
764
  currentView: s.ui.currentView,
756
765
  onViewChange: z,
757
766
  notifications: s.notifications,
758
- onNotificationAction: H,
767
+ onNotificationAction: $,
759
768
  preferences: s.preferences,
760
- onPreferenceChange: U,
761
- isPreferencesLoading: D,
762
- specificPreferences: W,
769
+ onPreferenceChange: W,
770
+ isPreferencesLoading: K,
771
+ specificPreferences: M,
763
772
  onLoadMoreSpecific: _,
764
773
  hasMoreSpecific: C,
765
774
  isListLoading: N,
766
- onMorePreferencesClick: l
775
+ onMorePreferencesClick: d
767
776
  }
768
777
  )
769
778
  }
@@ -771,15 +780,15 @@ const L = J(null), ue = () => {
771
780
  ]
772
781
  }
773
782
  );
774
- }, Ie = ({ sdkConfig: t, ...n }) => /* @__PURE__ */ u(le, { onError: n.onError, children: /* @__PURE__ */ u(pe, { config: t, children: /* @__PURE__ */ u(me, { ...n }) }) }), Te = "3.0.0", _e = "@edusight/notification-widget";
783
+ }, ke = ({ sdkConfig: t, ...n }) => /* @__PURE__ */ f(pe, { onError: n.onError, children: /* @__PURE__ */ f(we, { config: t, children: /* @__PURE__ */ f(Se, { ...n }) }) }), Ne = "3.0.0", Ce = "@edusight/notification-widget";
775
784
  export {
776
- P as BellComponent,
777
- re as InboxPopover,
778
- Ce as NotificationItem,
779
- Ie as NotificationWidget,
780
- le as NotificationWidgetErrorBoundary,
781
- ve as PreferencesView,
782
- Te as VERSION,
783
- _e as WIDGET_NAME
785
+ R as BellComponent,
786
+ ae as InboxPopover,
787
+ Oe as NotificationItem,
788
+ ke as NotificationWidget,
789
+ pe as NotificationWidgetErrorBoundary,
790
+ xe as PreferencesView,
791
+ Ne as VERSION,
792
+ Ce as WIDGET_NAME
784
793
  };
785
794
  //# sourceMappingURL=index.esm.js.map