@everymatrix/nuts-inbox-widget 0.0.9 → 1.44.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 (35) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/nuts-inbox-widget.cjs.js +1 -1
  3. package/dist/cjs/nuts-inbox-widget_3.cjs.entry.js +476 -449
  4. package/dist/collection/api/methods/index.js +135 -0
  5. package/dist/collection/api/methods/types.js +1 -0
  6. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.css +5 -0
  7. package/dist/collection/components/nuts-inbox-widget/nuts-inbox-widget.js +100 -123
  8. package/dist/collection/components/nuts-notification/constants.js +1 -0
  9. package/dist/collection/components/nuts-notification/nuts-notification.css +26 -11
  10. package/dist/collection/components/nuts-notification/nuts-notification.js +158 -100
  11. package/dist/collection/components/nuts-popover/nuts-popover.css +43 -0
  12. package/dist/collection/components/nuts-popover/nuts-popover.js +122 -61
  13. package/dist/collection/types/nuts-inbox-widget.types.js +0 -8
  14. package/dist/collection/utils/locale.utils.js +12 -4
  15. package/dist/collection/utils/utils.js +16 -0
  16. package/dist/components/nuts-inbox-widget.js +55 -235
  17. package/dist/components/nuts-notification2.js +278 -84
  18. package/dist/components/nuts-popover2.js +61 -45
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/nuts-inbox-widget.js +1 -1
  21. package/dist/esm/nuts-inbox-widget_3.entry.js +477 -450
  22. package/dist/nuts-inbox-widget/nuts-inbox-widget.esm.js +1 -1
  23. package/dist/nuts-inbox-widget/p-d0db9d2d.entry.js +1 -0
  24. package/dist/types/api/methods/index.d.ts +7 -0
  25. package/dist/types/api/methods/types.d.ts +65 -0
  26. package/dist/types/components/nuts-inbox-widget/nuts-inbox-widget.d.ts +20 -11
  27. package/dist/types/components/nuts-notification/constants.d.ts +1 -0
  28. package/dist/types/components/nuts-notification/nuts-notification.d.ts +18 -6
  29. package/dist/types/components/nuts-popover/nuts-popover.d.ts +17 -2
  30. package/dist/types/components.d.ts +50 -2
  31. package/dist/types/types/nuts-inbox-widget.types.d.ts +4 -7
  32. package/dist/types/utils/utils.d.ts +2 -0
  33. package/package.json +4 -1
  34. package/dist/nuts-inbox-widget/p-4788b3e5.entry.js +0 -1
  35. /package/dist/types/Users/{raul.vasile/workspace/everymatrix → adrian.pripon/Documents/Work}/widgets-stencil/packages/nuts-inbox-widget/.stencil/packages/nuts-inbox-widget/stencil.config.d.ts +0 -0
@@ -1,35 +1,4 @@
1
- import { g as getElement, r as registerInstance, c as createEvent, h } from './index-722b5754.js';
2
-
3
- /******************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
-
18
- function __decorate(decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- }
24
-
25
- function __metadata(metadataKey, metadataValue) {
26
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
27
- }
28
-
29
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
30
- var e = new Error(message);
31
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
- };
1
+ import { r as registerInstance, c as createEvent, h, g as getElement } from './index-722b5754.js';
33
2
 
34
3
  const DEFAULT_LANGUAGE = 'en';
35
4
  const SUPPORTED_LANGUAGES = ['hu', 'en'];
@@ -39,19 +8,27 @@ const TRANSLATIONS = {
39
8
  noMessages: 'Nothing new to see here yet',
40
9
  markAllAsRead: 'Mark all as read',
41
10
  markAsRead: 'Mark as read',
42
- removeMessage: 'Remove the message'
11
+ markAsUnread: 'Mark as unread',
12
+ removeMessage: 'Remove the message',
13
+ next: 'Next',
14
+ prev: 'Previous',
43
15
  },
44
16
  hu: {
45
17
  notifications: 'értesítéseket',
46
18
  noMessages: 'Itt még semmi újat nem látni',
47
19
  markAllAsRead: 'összes megjelölése olvasottként',
48
20
  markAsRead: 'Jelöld olvasottként',
49
- removeMessage: 'Távolítsa el az üzenetet'
50
- }
21
+ markAsUnread: 'Megjelölés olvasatlanként',
22
+ removeMessage: 'Távolítsa el az üzenetet',
23
+ next: 'Következő',
24
+ prev: 'Előző',
25
+ },
51
26
  };
52
27
  const translate$1 = (key, customLang, values) => {
53
28
  const lang = customLang;
54
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
29
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang)
30
+ ? lang
31
+ : DEFAULT_LANGUAGE][key];
55
32
  if (values !== undefined) {
56
33
  for (const [key, value] of Object.entries(values.values)) {
57
34
  const regex = new RegExp(`{${key}}`, 'g');
@@ -2621,11 +2598,11 @@ class BinaryReconstructor {
2621
2598
  }
2622
2599
 
2623
2600
  const parser = /*#__PURE__*/Object.freeze({
2624
- __proto__: null,
2625
- protocol: protocol,
2626
- get PacketType () { return PacketType; },
2627
- Encoder: Encoder,
2628
- Decoder: Decoder
2601
+ __proto__: null,
2602
+ protocol: protocol,
2603
+ get PacketType () { return PacketType; },
2604
+ Encoder: Encoder,
2605
+ Decoder: Decoder
2629
2606
  });
2630
2607
 
2631
2608
  function on(obj, ev, fn) {
@@ -3931,100 +3908,160 @@ Object.assign(lookup, {
3931
3908
  connect: lookup,
3932
3909
  });
3933
3910
 
3934
- const ClickOutsideOptionsDefaults = {
3935
- triggerEvents: "click",
3936
- exclude: ""
3911
+ const initializeSession = async ({ baseUrl, body, headers, }) => {
3912
+ var _a;
3913
+ const url = new URL(`${baseUrl}/widgets/session/initialize`);
3914
+ const localHeaders = new Headers(headers);
3915
+ localHeaders.append('Content-Type', 'application/json');
3916
+ const options = {
3917
+ method: 'POST',
3918
+ body: JSON.stringify(body),
3919
+ headers: localHeaders,
3920
+ };
3921
+ try {
3922
+ const res = await fetch(url.href, options);
3923
+ const data = await res.json();
3924
+ const newToken = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.token;
3925
+ headers.append('Widget-Authorization', `Bearer ${newToken}`);
3926
+ const unseenCounter = await getUnseenCount({
3927
+ baseUrl,
3928
+ headers,
3929
+ });
3930
+ return {
3931
+ token: newToken,
3932
+ unseenCounter,
3933
+ };
3934
+ }
3935
+ catch (error) {
3936
+ console.log(error);
3937
+ return {
3938
+ token: null,
3939
+ unseenCounter: 0,
3940
+ };
3941
+ }
3937
3942
  };
3938
- /**
3939
- * Call this function as soon as the click outside of annotated method's host is done.
3940
- * @example
3941
- ```
3942
- @ClickOutside()
3943
- callback() {
3944
- // this will run when click outside of element (host component) is done.
3945
- }
3946
- ```
3947
- */
3948
- function ClickOutside(opt = ClickOutsideOptionsDefaults) {
3949
- return (proto, methodName) => {
3950
- const { connectedCallback, disconnectedCallback } = proto;
3951
- proto.connectedCallback = function () {
3952
- const host = getElement(this);
3953
- const method = this[methodName];
3954
- registerClickOutside(this, host, method, opt);
3955
- return connectedCallback && connectedCallback.call(this);
3956
- };
3957
- proto.disconnectedCallback = function () {
3958
- const host = getElement(this);
3959
- const method = this[methodName];
3960
- removeClickOutside(this, host, method, opt);
3961
- return disconnectedCallback && disconnectedCallback.call(this);
3962
- };
3943
+ const getUnseenCount = async ({ baseUrl, headers, }) => {
3944
+ var _a;
3945
+ const url = new URL(`${baseUrl}/widgets/notifications/unseen?limit=100`);
3946
+ const options = {
3947
+ method: 'GET',
3948
+ headers,
3949
+ };
3950
+ try {
3951
+ const res = await fetch(url.href, options);
3952
+ const data = await res.json();
3953
+ const unseenCount = ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.count) || 0;
3954
+ return unseenCount;
3955
+ }
3956
+ catch (error) {
3957
+ console.log(error);
3958
+ return 0;
3959
+ }
3960
+ };
3961
+ const deleteMessage = async ({ baseUrl, headers, messageId, }) => {
3962
+ const url = new URL(`${baseUrl}/widgets/messages/${messageId}`);
3963
+ const options = {
3964
+ method: 'DELETE',
3965
+ headers,
3966
+ };
3967
+ try {
3968
+ await fetch(url.href, options);
3969
+ return false;
3970
+ }
3971
+ catch (error) {
3972
+ console.log(error);
3973
+ return true;
3974
+ }
3975
+ };
3976
+ const markAsRead = async ({ baseUrl, body, headers, unread, }) => {
3977
+ const url = new URL(`${baseUrl}/widgets/messages/markAs`);
3978
+ const localHeaders = new Headers(headers);
3979
+ localHeaders.append('Content-Type', 'application/json');
3980
+ const options = {
3981
+ method: 'POST',
3982
+ headers: localHeaders,
3983
+ body: JSON.stringify(body),
3984
+ };
3985
+ try {
3986
+ const res = await fetch(url.href, options);
3987
+ const data = await res.json();
3988
+ return {
3989
+ messageSeen: data.data[0].seen,
3990
+ messageRead: data.data[0].read,
3991
+ showSettingsModal: false,
3963
3992
  };
3964
- }
3965
- /**
3966
- * Register callback function for HTMLElement to be executed when user clicks outside of element.
3967
- * @example
3968
- ```
3969
- <span
3970
- ref={spanEl => registerClickOutside(this, spanEl, () => this.test())}>
3971
- Hello, World!
3972
- </span>;
3973
- ```
3974
- */
3975
- function registerClickOutside(component, element, callback, opt = ClickOutsideOptionsDefaults) {
3976
- const excludedNodes = getExcludedNodes(opt);
3977
- getTriggerEvents(opt).forEach(triggerEvent => {
3978
- window.addEventListener(triggerEvent, (e) => {
3979
- initClickOutside(e, component, element, callback, excludedNodes);
3980
- }, false);
3981
- });
3982
- }
3983
- /**
3984
- * Remove click outside callback function for HTMLElement.
3985
- */
3986
- function removeClickOutside(component, element, callback, opt = ClickOutsideOptionsDefaults) {
3987
- getTriggerEvents(opt).forEach(triggerEvent => {
3988
- window.removeEventListener(triggerEvent, (e) => {
3989
- initClickOutside(e, component, element, callback);
3990
- }, false);
3991
- });
3992
- }
3993
- function initClickOutside(event, component, element, callback, excludedNodes) {
3994
- const target = event.target;
3995
- if (!element.contains(target) && !isExcluded(target, excludedNodes)) {
3996
- callback.call(component);
3997
- }
3998
- }
3999
- function getTriggerEvents(opt) {
4000
- if (opt.triggerEvents) {
4001
- return opt.triggerEvents.split(",").map(e => e.trim());
4002
- }
4003
- return ["click"];
4004
- }
4005
- function getExcludedNodes(opt) {
4006
- if (opt.exclude) {
4007
- try {
4008
- return Array.from(document.querySelectorAll(opt.exclude));
4009
- }
4010
- catch (err) {
4011
- console.warn(`@ClickOutside: Exclude: '${opt.exclude}' will not be evaluated. Check your exclude selector syntax.`, err);
4012
- }
4013
- }
4014
- return;
4015
- }
4016
- function isExcluded(target, excudedNodes) {
4017
- if (target && excudedNodes) {
4018
- for (let excludedNode of excudedNodes) {
4019
- if (excludedNode.contains(target)) {
4020
- return true;
4021
- }
4022
- }
4023
- }
3993
+ }
3994
+ catch (err) {
3995
+ console.error('err', err);
3996
+ return {
3997
+ messageSeen: unread,
3998
+ messageRead: unread,
3999
+ showSettingsModal: true,
4000
+ };
4001
+ }
4002
+ };
4003
+ const getNotifications = async ({ baseUrl, headers, page, }) => {
4004
+ const url = new URL(`${baseUrl}/widgets/notifications/feed`);
4005
+ url.searchParams.append('page', page.toString());
4006
+ const options = {
4007
+ method: 'GET',
4008
+ headers,
4009
+ };
4010
+ try {
4011
+ const res = await fetch(url.href, options);
4012
+ const data = await res.json();
4013
+ return {
4014
+ isLoading: false,
4015
+ numberOfNotifications: data.totalCount,
4016
+ notifications: data.data,
4017
+ };
4018
+ }
4019
+ catch (error) {
4020
+ console.log(error);
4021
+ return {
4022
+ isLoading: false,
4023
+ numberOfNotifications: 0,
4024
+ notifications: [],
4025
+ };
4026
+ }
4027
+ };
4028
+ const markAllAsRead = async ({ baseUrl, headers, }) => {
4029
+ const url = new URL(`${baseUrl}/widgets/messages/read`);
4030
+ const localHeaders = new Headers(headers);
4031
+ localHeaders.append('Content-Type', 'application/json');
4032
+ const options = {
4033
+ method: 'POST',
4034
+ body: JSON.stringify({}),
4035
+ headers: localHeaders,
4036
+ };
4037
+ try {
4038
+ await fetch(url.href, options);
4039
+ return true;
4040
+ }
4041
+ catch (error) {
4042
+ console.log(error);
4024
4043
  return false;
4025
- }
4044
+ }
4045
+ };
4046
+
4047
+ const createAuthHeaders = (token, sessionId, admin) => {
4048
+ const headers = new Headers();
4049
+ if (token) {
4050
+ headers.append('Widget-Authorization', `Bearer ${token}`);
4051
+ }
4052
+ if (admin) {
4053
+ headers.append('Authorization', sessionId);
4054
+ }
4055
+ return headers;
4056
+ };
4057
+ const truncate = (str, n) => {
4058
+ if (!str || n < 0) {
4059
+ return;
4060
+ }
4061
+ return str.length > n ? str.slice(0, n - 1) + '...' : str;
4062
+ };
4026
4063
 
4027
- const nutsInboxWidgetCss = ":host{display:block;font-family:\"Roboto\", \"Arial\", sans-serif}.BellIconWrapper{width:100%;height:40px;display:flex}.BellIcon{width:40px;height:40px;display:flex}";
4064
+ const nutsInboxWidgetCss = ":host{display:block;font-family:\"Roboto\", \"Arial\", sans-serif}.BellIconWrapper{width:100%;height:40px;display:flex}.BellIconWrapper :hover{cursor:pointer}.BellIcon{width:40px;height:40px;display:flex;justify-content:center;align-items:center}";
4028
4065
 
4029
4066
  const NutsInboxWidget = class {
4030
4067
  constructor(hostRef) {
@@ -4055,10 +4092,20 @@ const NutsInboxWidget = class {
4055
4092
  * Translations via URL
4056
4093
  */
4057
4094
  this.translationUrl = '';
4058
- this.isLoading = true;
4095
+ this.isLoading = false;
4059
4096
  this.popoverVisible = false;
4060
- this.ssEndpoint = 'https://nts.everymatrix.com/ss';
4061
4097
  this.token = null;
4098
+ this.baseUrl = `${this.backendUrl}/v1/${this.operatorId}`;
4099
+ this.initializeSessionBody = {
4100
+ applicationIdentifier: this.applicationIdentifier,
4101
+ subscriberId: this.subscriberId || `${this.operatorId}-${this.userId}`,
4102
+ hmacHash: null,
4103
+ };
4104
+ this.defaultHeaders = createAuthHeaders(this.token, this.sessionId, this.admin);
4105
+ this.togglePopover = () => {
4106
+ this.popoverVisible = !this.popoverVisible;
4107
+ window.postMessage({ type: 'nuts-popover-isVisible', value: this.popoverVisible }, window.location.href);
4108
+ };
4062
4109
  this.setClientStyling = () => {
4063
4110
  let sheet = document.createElement('style');
4064
4111
  sheet.innerHTML = this.clientStyling;
@@ -4072,28 +4119,40 @@ const NutsInboxWidget = class {
4072
4119
  .then((data) => {
4073
4120
  cssFile.innerHTML = data;
4074
4121
  this.clientStyling = data;
4075
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
4122
+ setTimeout(() => {
4123
+ this.stylingContainer.prepend(cssFile);
4124
+ }, 1);
4076
4125
  })
4077
4126
  .catch((err) => {
4078
4127
  console.log('error ', err);
4079
4128
  });
4080
4129
  };
4081
- }
4082
- paramChangeHandler(newValue, oldValue) {
4083
- if (newValue != oldValue) {
4084
- if (this.userId && this.sessionId && this.operatorId) {
4085
- this.callSS();
4086
- }
4087
- }
4130
+ this.assignRefToStylingContainer = (ref) => {
4131
+ this.stylingContainer = ref;
4132
+ };
4133
+ this.assignRefToBell = (ref) => {
4134
+ this.bellIconRef = ref;
4135
+ };
4088
4136
  }
4089
4137
  initializeHandler(newValue, oldValue) {
4090
4138
  if (newValue != oldValue) {
4091
4139
  if (this.userId && this.operatorId && this.applicationIdentifier) {
4092
- this.initializeSession();
4140
+ initializeSession({
4141
+ baseUrl: this.baseUrl,
4142
+ body: this.initializeSessionBody,
4143
+ headers: this.defaultHeaders,
4144
+ }).then((initializeSessionResult) => {
4145
+ this.token = initializeSessionResult.token;
4146
+ this.unseenCount = initializeSessionResult.unseenCounter;
4147
+ this.setupSocket();
4148
+ });
4093
4149
  }
4094
4150
  }
4095
4151
  }
4096
- clickOutsideHandle() {
4152
+ clickOutsideHandle(ev) {
4153
+ if (ev.composedPath().some((elem) => this.el === elem)) {
4154
+ return;
4155
+ }
4097
4156
  this.popoverVisible = false;
4098
4157
  window.postMessage({ type: 'nuts-popover-isVisible', value: this.popoverVisible }, window.location.href);
4099
4158
  }
@@ -4105,33 +4164,6 @@ const NutsInboxWidget = class {
4105
4164
  this.bellIconRef.style.justifyContent = 'flex-end';
4106
4165
  }
4107
4166
  }
4108
- callSS() {
4109
- const url = new URL(`${this.ssEndpoint}/v1/${this.operatorId}/subscribers/${this.userId}/initialize`);
4110
- const headers = new Headers();
4111
- headers.append('authorization', this.sessionId);
4112
- headers.append('Content-Type', 'application/json');
4113
- const body = {
4114
- deviceId: this.deviceId,
4115
- language: this.language
4116
- };
4117
- const options = {
4118
- method: 'POST',
4119
- headers,
4120
- body: JSON.stringify(body)
4121
- };
4122
- fetch(url.href, options)
4123
- .then((res) => {
4124
- if (res.status < 300) {
4125
- return res.json();
4126
- }
4127
- })
4128
- .catch((err) => {
4129
- console.error('There was an error while trying to connect to the Notification System', err);
4130
- })
4131
- .finally(() => {
4132
- this.isLoading = false;
4133
- });
4134
- }
4135
4167
  setupSocket() {
4136
4168
  if (this.token) {
4137
4169
  this.socketRef = lookup(this.socketUrl, {
@@ -4153,63 +4185,21 @@ const NutsInboxWidget = class {
4153
4185
  });
4154
4186
  this.socketRef.on('unseen_count_changed', (data) => {
4155
4187
  this.unseenCount = data.unseenCount;
4156
- this.unseenCount > 0 && window.postMessage({ type: 'nuts-new-notifications', value: this.unseenCount }, window.location.href);
4188
+ this.unseenCount > 0 &&
4189
+ window.postMessage({ type: 'nuts-new-notifications', value: this.unseenCount }, window.location.href);
4157
4190
  });
4158
4191
  }
4159
4192
  }
4160
- getUnseenCounter() {
4161
- let url = new URL(`${this.backendUrl}/v1/widgets/notifications/unseen?limit=100`);
4162
- const headers = new Headers();
4163
- headers.append('Authorization', `Bearer ${this.token || ''}`);
4164
- const options = {
4165
- method: 'GET',
4166
- headers,
4167
- };
4168
- fetch(url.href, options)
4169
- .then((res) => res.json())
4170
- .then((data) => {
4171
- this.unseenCount = data.data.count;
4172
- });
4173
- }
4174
- async initializeSession() {
4175
- return new Promise((resolve, reject) => {
4176
- let url = new URL(`${this.backendUrl}/v1/widgets/session/initialize`);
4177
- const headers = new Headers();
4178
- headers.append('Authorization', `Bearer ${this.token || ''}`);
4179
- headers.append('Content-Type', 'application/json');
4180
- const body = {
4181
- applicationIdentifier: this.applicationIdentifier,
4182
- subscriberId: `${this.operatorId}-${this.userId}`,
4183
- hmacHash: null
4184
- };
4185
- const options = {
4186
- method: 'POST',
4187
- body: JSON.stringify(body),
4188
- headers,
4189
- };
4190
- fetch(url.href, options)
4191
- .then(res => res.json())
4192
- .then((data) => {
4193
- this.token = data.data.token;
4194
- this.setupSocket();
4195
- this.getUnseenCounter();
4196
- resolve(data);
4197
- })
4198
- .catch((err) => {
4199
- reject(err);
4200
- });
4201
- });
4202
- }
4203
- togglePopover() {
4204
- this.popoverVisible = !this.popoverVisible;
4205
- window.postMessage({ type: 'nuts-popover-isVisible', value: this.popoverVisible }, window.location.href);
4206
- }
4207
4193
  async connectedCallback() {
4208
4194
  if (this.userId && this.operatorId && this.applicationIdentifier) {
4209
- this.initializeSession();
4210
- }
4211
- if (this.userId && this.operatorId && this.sessionId) {
4212
- this.callSS();
4195
+ const initializeSessionResult = await initializeSession({
4196
+ baseUrl: this.baseUrl,
4197
+ headers: this.defaultHeaders,
4198
+ body: this.initializeSessionBody,
4199
+ });
4200
+ this.token = initializeSessionResult.token;
4201
+ this.unseenCount = initializeSessionResult.unseenCounter;
4202
+ this.setupSocket();
4213
4203
  }
4214
4204
  if (this.clientStylingUrl) {
4215
4205
  this.setClientStylingURL();
@@ -4230,26 +4220,19 @@ const NutsInboxWidget = class {
4230
4220
  this.positionIcon();
4231
4221
  }
4232
4222
  renderBellIcon() {
4233
- return (h("div", { onClick: () => this.togglePopover(), class: "BellIcon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", fill: "currentColor", class: "bi bi-bell", viewBox: "0 0 16 16" }, " ", h("path", { d: "M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z" }), " "), this.unseenCount > 0 ? h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", class: "nc-bell-button-dot css-0 css-1eg2znq" }, h("rect", { x: "1.5", y: "1.5", width: "13", height: "13", rx: "6.5", fill: "url(#paint0_linear_1722_2699)", stroke: "#1E1E26", "stroke-width": "3" }), h("defs", null, h("linearGradient", { id: "paint0_linear_1722_2699", x1: "8", y1: "13", x2: "8", y2: "3", gradientUnits: "userSpaceOnUse" }, h("stop", { "stop-color": "#FF512F" }), h("stop", { offset: "1", "stop-color": "#DD2476" })))) : ''));
4223
+ return (h("div", { onClick: this.togglePopover, class: "BellIcon" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", fill: "currentColor", class: "bi bi-bell", viewBox: "0 0 16 16" }, ' ', h("path", { d: "M8 16a2 2 0 0 0 2-2H6a2 2 0 0 0 2 2zM8 1.918l-.797.161A4.002 4.002 0 0 0 4 6c0 .628-.134 2.197-.459 3.742-.16.767-.376 1.566-.663 2.258h10.244c-.287-.692-.502-1.49-.663-2.258C12.134 8.197 12 6.628 12 6a4.002 4.002 0 0 0-3.203-3.92L8 1.917zM14.22 12c.223.447.481.801.78 1H1c.299-.199.557-.553.78-1C2.68 10.2 3 6.88 3 6c0-2.42 1.72-4.44 4.005-4.901a1 1 0 1 1 1.99 0A5.002 5.002 0 0 1 13 6c0 .88.32 4.2 1.22 6z" }), ' '), this.unseenCount > 0 ? (h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", class: "nc-bell-button-dot css-0 css-1eg2znq" }, h("rect", { x: "1.5", y: "1.5", width: "13", height: "13", rx: "6.5", fill: "url(#paint0_linear_1722_2699)", stroke: "#1E1E26", "stroke-width": "3" }), h("defs", null, h("linearGradient", { id: "paint0_linear_1722_2699", x1: "8", y1: "13", x2: "8", y2: "3", gradientUnits: "userSpaceOnUse" }, h("stop", { "stop-color": "#FF512F" }), h("stop", { offset: "1", "stop-color": "#DD2476" }))))) : ('')));
4234
4224
  }
4235
4225
  render() {
4236
- return (h("div", { ref: el => this.stylingContainer = el, class: "Wrapper" }, h("div", { ref: el => this.bellIconRef = el, class: "BellIconWrapper" }, !this.isLoading && this.renderBellIcon()), this.popoverVisible && h("nuts-popover", { "notification-action": this.notificationAction, "unseen-count": this.unseenCount, token: this.token, "backend-url": this.backendUrl, "operator-id": this.operatorId, "user-id": this.userId, language: this.language, "client-styling": this.clientStyling, "translation-url": this.translationUrl })));
4226
+ return (h("div", { ref: this.assignRefToStylingContainer, class: "Wrapper" }, h("div", { ref: this.assignRefToBell, class: "BellIconWrapper" }, !this.isLoading && this.renderBellIcon()), this.popoverVisible && (h("nuts-popover", { "notification-action": this.notificationAction, sessionId: this.sessionId, admin: this.admin, "unseen-count": this.unseenCount, token: this.token, "backend-url": this.backendUrl, "operator-id": this.operatorId, "user-id": this.userId, language: this.language, "client-styling": this.clientStyling, "translation-url": this.translationUrl }))));
4237
4227
  }
4228
+ get el() { return getElement(this); }
4238
4229
  static get watchers() { return {
4239
- "userId": ["paramChangeHandler", "initializeHandler"],
4240
- "sessionId": ["paramChangeHandler"],
4241
- "operatorId": ["paramChangeHandler", "initializeHandler"],
4242
- "deviceId": ["paramChangeHandler"],
4230
+ "userId": ["initializeHandler"],
4231
+ "operatorId": ["initializeHandler"],
4243
4232
  "applicationIdentifier": ["initializeHandler"],
4244
4233
  "translationUrl": ["handleNewTranslations"]
4245
4234
  }; }
4246
4235
  };
4247
- __decorate([
4248
- ClickOutside(),
4249
- __metadata("design:type", Function),
4250
- __metadata("design:paramtypes", []),
4251
- __metadata("design:returntype", void 0)
4252
- ], NutsInboxWidget.prototype, "clickOutsideHandle", null);
4253
4236
  NutsInboxWidget.style = nutsInboxWidgetCss;
4254
4237
 
4255
4238
  function _typeof(o) {
@@ -39776,100 +39759,100 @@ var locale = {
39776
39759
  // This file is generated automatically by `scripts/build/indices.ts`. Please, don't change it.
39777
39760
 
39778
39761
  const dateFnsLocales = /*#__PURE__*/Object.freeze({
39779
- __proto__: null,
39780
- af: locale$1r,
39781
- ar: locale$1q,
39782
- arDZ: locale$1p,
39783
- arEG: locale$1o,
39784
- arMA: locale$1n,
39785
- arSA: locale$1m,
39786
- arTN: locale$1l,
39787
- az: locale$1k,
39788
- be: locale$1j,
39789
- beTarask: locale$1i,
39790
- bg: locale$1h,
39791
- bn: locale$1g,
39792
- bs: locale$1f,
39793
- ca: locale$1e,
39794
- cs: locale$1d,
39795
- cy: locale$1c,
39796
- da: locale$1b,
39797
- de: locale$1a,
39798
- deAT: locale$19,
39799
- el: locale$18,
39800
- enAU: locale$17,
39801
- enCA: locale$16,
39802
- enGB: locale$15,
39803
- enIE: locale$14,
39804
- enIN: locale$13,
39805
- enNZ: locale$12,
39806
- enUS: locale$1s,
39807
- enZA: locale$11,
39808
- eo: locale$10,
39809
- es: locale$$,
39810
- et: locale$_,
39811
- eu: locale$Z,
39812
- faIR: locale$Y,
39813
- fi: locale$X,
39814
- fr: locale$W,
39815
- frCA: locale$V,
39816
- frCH: locale$U,
39817
- fy: locale$T,
39818
- gd: locale$S,
39819
- gl: locale$R,
39820
- gu: locale$Q,
39821
- he: locale$P,
39822
- hi: locale$O,
39823
- hr: locale$N,
39824
- ht: locale$M,
39825
- hu: locale$L,
39826
- hy: locale$K,
39827
- id: locale$J,
39828
- is: locale$I,
39829
- it: locale$H,
39830
- itCH: locale$G,
39831
- ja: locale$F,
39832
- jaHira: locale$E,
39833
- ka: locale$D,
39834
- kk: locale$C,
39835
- km: locale$B,
39836
- kn: locale$A,
39837
- ko: locale$z,
39838
- lb: locale$y,
39839
- lt: locale$x,
39840
- lv: locale$w,
39841
- mk: locale$v,
39842
- mn: locale$u,
39843
- ms: locale$t,
39844
- mt: locale$s,
39845
- nb: locale$r,
39846
- nl: locale$q,
39847
- nlBE: locale$p,
39848
- nn: locale$o,
39849
- oc: locale$n,
39850
- pl: locale$m,
39851
- pt: locale$l,
39852
- ptBR: locale$k,
39853
- ro: locale$j,
39854
- ru: locale$i,
39855
- sk: locale$h,
39856
- sl: locale$g,
39857
- sq: locale$f,
39858
- sr: locale$e,
39859
- srLatn: locale$d,
39860
- sv: locale$c,
39861
- ta: locale$b,
39862
- te: locale$a,
39863
- th: locale$9,
39864
- tr: locale$8,
39865
- ug: locale$7,
39866
- uk: locale$6,
39867
- uz: locale$5,
39868
- uzCyrl: locale$4,
39869
- vi: locale$3,
39870
- zhCN: locale$2,
39871
- zhHK: locale$1,
39872
- zhTW: locale
39762
+ __proto__: null,
39763
+ af: locale$1r,
39764
+ ar: locale$1q,
39765
+ arDZ: locale$1p,
39766
+ arEG: locale$1o,
39767
+ arMA: locale$1n,
39768
+ arSA: locale$1m,
39769
+ arTN: locale$1l,
39770
+ az: locale$1k,
39771
+ be: locale$1j,
39772
+ beTarask: locale$1i,
39773
+ bg: locale$1h,
39774
+ bn: locale$1g,
39775
+ bs: locale$1f,
39776
+ ca: locale$1e,
39777
+ cs: locale$1d,
39778
+ cy: locale$1c,
39779
+ da: locale$1b,
39780
+ de: locale$1a,
39781
+ deAT: locale$19,
39782
+ el: locale$18,
39783
+ enAU: locale$17,
39784
+ enCA: locale$16,
39785
+ enGB: locale$15,
39786
+ enIE: locale$14,
39787
+ enIN: locale$13,
39788
+ enNZ: locale$12,
39789
+ enUS: locale$1s,
39790
+ enZA: locale$11,
39791
+ eo: locale$10,
39792
+ es: locale$$,
39793
+ et: locale$_,
39794
+ eu: locale$Z,
39795
+ faIR: locale$Y,
39796
+ fi: locale$X,
39797
+ fr: locale$W,
39798
+ frCA: locale$V,
39799
+ frCH: locale$U,
39800
+ fy: locale$T,
39801
+ gd: locale$S,
39802
+ gl: locale$R,
39803
+ gu: locale$Q,
39804
+ he: locale$P,
39805
+ hi: locale$O,
39806
+ hr: locale$N,
39807
+ ht: locale$M,
39808
+ hu: locale$L,
39809
+ hy: locale$K,
39810
+ id: locale$J,
39811
+ is: locale$I,
39812
+ it: locale$H,
39813
+ itCH: locale$G,
39814
+ ja: locale$F,
39815
+ jaHira: locale$E,
39816
+ ka: locale$D,
39817
+ kk: locale$C,
39818
+ km: locale$B,
39819
+ kn: locale$A,
39820
+ ko: locale$z,
39821
+ lb: locale$y,
39822
+ lt: locale$x,
39823
+ lv: locale$w,
39824
+ mk: locale$v,
39825
+ mn: locale$u,
39826
+ ms: locale$t,
39827
+ mt: locale$s,
39828
+ nb: locale$r,
39829
+ nl: locale$q,
39830
+ nlBE: locale$p,
39831
+ nn: locale$o,
39832
+ oc: locale$n,
39833
+ pl: locale$m,
39834
+ pt: locale$l,
39835
+ ptBR: locale$k,
39836
+ ro: locale$j,
39837
+ ru: locale$i,
39838
+ sk: locale$h,
39839
+ sl: locale$g,
39840
+ sq: locale$f,
39841
+ sr: locale$e,
39842
+ srLatn: locale$d,
39843
+ sv: locale$c,
39844
+ ta: locale$b,
39845
+ te: locale$a,
39846
+ th: locale$9,
39847
+ tr: locale$8,
39848
+ ug: locale$7,
39849
+ uk: locale$6,
39850
+ uz: locale$5,
39851
+ uzCyrl: locale$4,
39852
+ vi: locale$3,
39853
+ zhCN: locale$2,
39854
+ zhHK: locale$1,
39855
+ zhTW: locale
39873
39856
  });
39874
39857
 
39875
39858
  // This icon file is generated automatically.
@@ -39878,6 +39861,9 @@ var CheckCircleFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 8
39878
39861
  // This icon file is generated automatically.
39879
39862
  var CloseCircleFilled = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" } }] }, "name": "close-circle", "theme": "filled" };
39880
39863
 
39864
+ // This icon file is generated automatically.
39865
+ var DownOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" } }] }, "name": "down", "theme": "outlined" };
39866
+
39881
39867
  // This icon file is generated automatically.
39882
39868
  var InfoCircleFilled = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, "name": "info-circle", "theme": "filled" };
39883
39869
 
@@ -39935,26 +39921,45 @@ function renderAbstractNodeToSVGElement(node, options) {
39935
39921
  return "<".concat(node.tag).concat(attrsToken, " />");
39936
39922
  }
39937
39923
 
39938
- const nutsNotificationCss = ":host{display:block}p{display:block;margin-block-start:0em;margin-block-end:0em;margin-inline-start:0px;margin-inline-end:0px}.NotificationContainer{animation:show 600ms 100ms cubic-bezier(0.38, 0.97, 0.56, 0.76) forwards;opacity:0;transform-origin:top center;padding:15px;position:relative;display:flex;line-height:20px;justify-content:flex-start;align-items:center;border-radius:7px;margin:10px 15px;color:var(--emfe-w-color-white, white);background:var(--emfe-w-color-gray-400, #23232b);font-weight:400;font-size:14px}@keyframes show{100%{opacity:1;transform:none}}.NotificationContainer .AvatarContainer{margin-right:10px;width:40px;min-width:40px;height:40px;border-radius:50%;display:flex;justify-content:center;align-items:center;font-size:40px;border:1px solid var(--emfe-w-color-gray-200, #525266);overflow:hidden}.NotificationContainer .AvatarContainer .Avatar{box-sizing:border-box;position:relative;display:flex;user-select:none;overflow:hidden;width:38px;min-width:38px;height:38px;border-radius:32px;text-decoration:none;border:0px;background-color:transparent;padding:0px;justify-content:center;align-items:center}.NotificationContainer .AvatarContainer .Avatar .AvatarImage{object-fit:cover;width:100%;height:100%;display:block}.NotificationContainer .AvatarContainer .Avatar svg{object-fit:cover;display:block}.NotificationContainer .ContentContainer{display:flex;flex-direction:column}.NotificationContainer .Date{min-width:55px;font-size:12px;font-weight:400;opacity:0.5;line-height:14.4px;color:var(--emfe-w-color-gray-200, #525266)}.NotificationContainer .Settings{opacity:0;margin-left:auto;cursor:pointer}.NotificationContainer:hover .Settings{opacity:0.5}.Unseen::before{content:\"\";position:absolute;inset:0px;width:5px;border-radius:7px 0px 0px 7px;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%)}.Unseen:hover .UnseenButton{opacity:0;width:0px}.SettingsDropdown{z-index:999;position:absolute;background:var(--emfe-w-color-gray-400, #292933);box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 20px;border-radius:7px;padding:4px;border:none;transition-property:opacity;transition-duration:150ms;transition-timing-function:ease;opacity:1;width:max-content;display:flex;flex-direction:column;margin-left:195px;margin-top:-30px}.SettingsDropdown svg{margin-right:10px}.SettingsDropdown button{font-family:inherit;border:0px;background-color:transparent;outline:0px;width:100%;text-align:left;text-decoration:none;box-sizing:border-box;padding:10px 12px;cursor:pointer;border-radius:7px;display:flex;align-items:center;color:var(--emfe-w-color-white, white);font-weight:400;font-size:14px}.SettingsDropdown button:hover{background:var(--emfe-w-color-gray-300, #3d3d4d);transition:300ms}";
39924
+ const MAX_NOTIFICATION_TEXT_LENGTH = 150;
39925
+
39926
+ const nutsNotificationCss = ":host{display:block}p{display:block;margin-block-start:0em;margin-block-end:0em;margin-inline-start:0px;margin-inline-end:0px}.NotificationContainer{animation:show 600ms 100ms cubic-bezier(0.38, 0.97, 0.56, 0.76) forwards;opacity:0;transform-origin:top center;padding:15px;position:relative;display:flex;line-height:20px;justify-content:space-between;align-items:flex-start;border-radius:7px;margin:10px 15px;color:var(--emfe-w-color-white, white);background:var(--emfe-w-color-gray-400, #23232b);font-weight:400;font-size:14px;gap:8px;cursor:pointer}@keyframes show{100%{opacity:1;transform:none}}.NotificationContainer .AvatarContainer{margin-right:10px;width:40px;min-width:40px;height:40px;border-radius:50%;display:flex;justify-content:center;align-items:center;font-size:40px;border:1px solid var(--emfe-w-color-gray-200, #525266);overflow:hidden}.NotificationContainer .AvatarContainer .Avatar{box-sizing:border-box;position:relative;display:flex;user-select:none;overflow:hidden;width:38px;min-width:38px;height:38px;border-radius:32px;text-decoration:none;border:0px;background-color:transparent;padding:0px;justify-content:center;align-items:center}.NotificationContainer .AvatarContainer .Avatar .AvatarImage{object-fit:cover;width:100%;height:100%;display:block}.NotificationContainer .AvatarContainer .Avatar svg{object-fit:cover;display:block}.NotificationContainer .ContentContainer{display:flex;flex-direction:column;word-break:break-all}.NotificationContainer .RightActionsContainer{display:flex;flex-direction:column}.NotificationContainer .FlipX{transform:rotateX(180deg) translate(0, 4px)}.NotificationContainer .AccordionArrow{margin-left:4px;transition-duration:0.2s;transition-property:transform}.NotificationContainer .Date{min-width:55px;font-size:12px;font-weight:400;opacity:0.5;line-height:14.4px;color:var(--emfe-w-color-gray-200, #525266)}.NotificationContainer .Settings{opacity:0.5;display:inline;cursor:pointer}.Unseen::before{content:\"\";position:absolute;inset:0px;width:5px;border-radius:7px 0px 0px 7px;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%)}.Unseen:hover .UnseenButton{display:none}.SettingsDropdown{z-index:999;position:absolute;background:var(--emfe-w-color-gray-400, #292933);box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 20px;border-radius:7px;padding:4px;border:none;transition-property:opacity;transition-duration:150ms;transition-timing-function:ease;opacity:1;width:max-content;display:flex;flex-direction:column;right:50px;top:50px}.SettingsDropdown svg{margin-right:10px}.SettingsDropdown button{font-family:inherit;border:0px;background-color:transparent;outline:0px;width:100%;text-align:left;text-decoration:none;box-sizing:border-box;padding:10px 12px;cursor:pointer;border-radius:7px;display:flex;align-items:center;color:var(--emfe-w-color-white, white);font-weight:400;font-size:14px}.SettingsDropdown button:hover{background:var(--emfe-w-color-gray-300, #3d3d4d);transition:300ms}.Wrapper{position:relative}";
39939
39927
 
39940
39928
  const systemIcons = {
39941
39929
  warning: {
39942
- icon: renderIconDefinitionToSVGElement(WarningFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#FFF000' } }),
39930
+ icon: renderIconDefinitionToSVGElement(WarningFilled, {
39931
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#FFF000' },
39932
+ }),
39943
39933
  },
39944
39934
  info: {
39945
- icon: renderIconDefinitionToSVGElement(InfoCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#0000FF' } }),
39935
+ icon: renderIconDefinitionToSVGElement(InfoCircleFilled, {
39936
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#0000FF' },
39937
+ }),
39946
39938
  },
39947
39939
  up: {
39948
- icon: renderIconDefinitionToSVGElement(UpCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' } }),
39940
+ icon: renderIconDefinitionToSVGElement(UpCircleFilled, {
39941
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' },
39942
+ }),
39949
39943
  },
39950
39944
  question: {
39951
- icon: renderIconDefinitionToSVGElement(QuestionCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' } }),
39945
+ icon: renderIconDefinitionToSVGElement(QuestionCircleFilled, {
39946
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#A1A1B2' },
39947
+ }),
39952
39948
  },
39953
39949
  success: {
39954
- icon: renderIconDefinitionToSVGElement(CheckCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#4D9980' } }),
39950
+ icon: renderIconDefinitionToSVGElement(CheckCircleFilled, {
39951
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#4D9980' },
39952
+ }),
39955
39953
  },
39956
39954
  error: {
39957
- icon: renderIconDefinitionToSVGElement(CloseCircleFilled, { extraSVGAttrs: { width: '20px', height: '20px', fill: '#E54545' } }),
39955
+ icon: renderIconDefinitionToSVGElement(CloseCircleFilled, {
39956
+ extraSVGAttrs: { width: '20px', height: '20px', fill: '#E54545' },
39957
+ }),
39958
+ },
39959
+ arrowDown: {
39960
+ icon: renderIconDefinitionToSVGElement(DownOutlined, {
39961
+ extraSVGAttrs: { width: '16px', height: '16px', fill: '#A1A1B2' },
39962
+ }),
39958
39963
  },
39959
39964
  };
39960
39965
  const dateFnsLocale = (lang) => {
@@ -39976,6 +39981,68 @@ const NutsNotification = class {
39976
39981
  this.showSettingsModal = false;
39977
39982
  this.messageSeen = false;
39978
39983
  this.messageRead = false;
39984
+ this.toggleSettingsModal = (e) => {
39985
+ e.stopImmediatePropagation();
39986
+ this.showSettingsModal = !this.showSettingsModal;
39987
+ this.settingsOpened.emit(this.messageId);
39988
+ };
39989
+ this.toggleNotificationRead = async (event) => {
39990
+ event === null || event === void 0 ? void 0 : event.stopImmediatePropagation();
39991
+ const unread = this.messageRead;
39992
+ const markAsReadBody = {
39993
+ messageId: `${this.messageId}`,
39994
+ mark: {
39995
+ seen: !unread,
39996
+ read: !unread,
39997
+ },
39998
+ };
39999
+ const notificationData = await markAsRead({
40000
+ baseUrl: this.baseUrl,
40001
+ body: markAsReadBody,
40002
+ headers: this.defaultHeaders,
40003
+ unread,
40004
+ });
40005
+ this.messageRead = notificationData.messageRead;
40006
+ this.messageSeen = notificationData.messageSeen;
40007
+ this.showSettingsModal = notificationData.showSettingsModal;
40008
+ };
40009
+ this.deleteNotification = async () => {
40010
+ const deleteMessageResponse = await deleteMessage({
40011
+ baseUrl: this.baseUrl,
40012
+ headers: this.defaultHeaders,
40013
+ messageId: this.messageId,
40014
+ });
40015
+ this.showSettingsModal = deleteMessageResponse;
40016
+ if (deleteMessageResponse) {
40017
+ return;
40018
+ }
40019
+ this.messageDeteled.emit(this.messageId);
40020
+ };
40021
+ this.notificationActionHandler = () => {
40022
+ var _a, _b, _c;
40023
+ if (this.notificationAction == 'default' || !this.notificationAction) {
40024
+ if (this.redirectUrl.length > 0) {
40025
+ window.location.href = this.redirectUrl;
40026
+ }
40027
+ }
40028
+ if (this.notificationAction == 'postMessage') {
40029
+ window.postMessage({ type: 'NotificationRedirect', url: this.redirectUrl }, window.location.href);
40030
+ }
40031
+ if (!this.messageRead) {
40032
+ this.toggleNotificationRead();
40033
+ }
40034
+ if (((_a = this.content) === null || _a === void 0 ? void 0 : _a.length) <= MAX_NOTIFICATION_TEXT_LENGTH) {
40035
+ return;
40036
+ }
40037
+ if (((_b = this.displayedContent) === null || _b === void 0 ? void 0 : _b.length) !== ((_c = this.content) === null || _c === void 0 ? void 0 : _c.length) &&
40038
+ this.displayedContent !== this.content) {
40039
+ this.displayedContent = this.content;
40040
+ this.dropdownArrowRef.classList.add('FlipX');
40041
+ return;
40042
+ }
40043
+ this.displayedContent = truncate(this.content, MAX_NOTIFICATION_TEXT_LENGTH);
40044
+ this.dropdownArrowRef.classList.remove('FlipX');
40045
+ };
39979
40046
  this.setClientStyling = () => {
39980
40047
  let sheet = document.createElement('style');
39981
40048
  sheet.innerHTML = this.clientStyling;
@@ -39988,12 +40055,20 @@ const NutsNotification = class {
39988
40055
  .then((res) => res.text())
39989
40056
  .then((data) => {
39990
40057
  cssFile.innerHTML = data;
39991
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
40058
+ setTimeout(() => {
40059
+ this.stylingContainer.prepend(cssFile);
40060
+ }, 1);
39992
40061
  })
39993
40062
  .catch((err) => {
39994
40063
  console.log('error ', err);
39995
40064
  });
39996
40065
  };
40066
+ this.assignRefToStylingContainer = (ref) => {
40067
+ this.stylingContainer = ref;
40068
+ };
40069
+ this.assignRefToDropdownArrow = (ref) => {
40070
+ this.dropdownArrowRef = ref;
40071
+ };
39997
40072
  }
39998
40073
  allNotificationsReadHandler() {
39999
40074
  this.messageSeen = true;
@@ -40015,78 +40090,16 @@ const NutsNotification = class {
40015
40090
  connectedCallback() {
40016
40091
  this.messageSeen = this.seen;
40017
40092
  this.messageRead = this.read;
40018
- }
40019
- deleteMessage(messageId) {
40020
- let url = new URL(`${this.backendUrl}/v1/widgets/messages/${messageId}`);
40021
- const headers = new Headers();
40022
- headers.append('Authorization', `Bearer ${this.token || ''}`);
40023
- const options = {
40024
- method: 'DELETE',
40025
- headers,
40026
- };
40027
- fetch(url.href, options)
40028
- .then((res) => res.json())
40029
- .then(() => {
40030
- this.showSettingsModal = false;
40031
- this.messageDeteled.emit(messageId);
40032
- })
40033
- .catch((err) => {
40034
- console.error('err', err);
40035
- });
40036
- }
40037
- markAsRead(messageId) {
40038
- let url = new URL(`${this.backendUrl}/v1/widgets/messages/markAs`);
40039
- const headers = new Headers();
40040
- headers.append('Authorization', `Bearer ${this.token || ''}`);
40041
- headers.append('Content-Type', 'application/json');
40042
- const body = {
40043
- messageId: `${messageId}`,
40044
- mark: {
40045
- seen: true,
40046
- read: true
40047
- }
40048
- };
40049
- const options = {
40050
- method: 'POST',
40051
- headers,
40052
- body: JSON.stringify(body)
40053
- };
40054
- fetch(url.href, options)
40055
- .then((res) => res.json())
40056
- .then((response) => {
40057
- this.messageSeen = response.data[0].seen;
40058
- this.messageRead = response.data[0].read;
40059
- this.showSettingsModal = false;
40060
- })
40061
- .catch((err) => {
40062
- console.error('err', err);
40063
- });
40064
- }
40065
- toggleSettingsModal(e) {
40066
- e.stopImmediatePropagation();
40067
- this.showSettingsModal = !this.showSettingsModal;
40068
- if (this.showSettingsModal) {
40069
- let rect = this.settingsButtonRef.getBoundingClientRect();
40070
- this.settingsModalRef.style.left = `${rect.left}px`;
40071
- this.settingsModalRef.style.top = `${rect.top}px`;
40072
- this.settingsOpened.emit(this.messageId);
40073
- }
40074
- }
40075
- notificationActionHandler() {
40076
- if (this.notificationAction == 'default' || !this.notificationAction) {
40077
- if (this.redirectUrl.length > 0) {
40078
- window.location.href = this.redirectUrl;
40079
- }
40080
- }
40081
- if (this.notificationAction == 'postMessage') {
40082
- window.postMessage({ type: 'NotificationRedirect', url: this.redirectUrl }, window.location.href);
40083
- }
40093
+ this.displayedContent = truncate(this.content, MAX_NOTIFICATION_TEXT_LENGTH);
40094
+ this.defaultHeaders = createAuthHeaders(this.token, this.sessionId, this.admin);
40095
+ this.baseUrl = `${this.backendUrl}/v1/${this.operatorId}`;
40084
40096
  }
40085
40097
  render() {
40086
- var _a;
40087
- return (h("div", null, h("div", { class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: el => this.stylingContainer = el, onClick: () => this.notificationActionHandler() }, this.badge ? h("div", { class: "AvatarContainer" }, h("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ?
40088
- h("div", { innerHTML: systemIcons[this.badge].icon }) :
40089
- h("img", { class: "AvatarImage", src: this.badge }))) : '', h("div", { class: "ContentContainer" }, h("p", null, this.content), h("p", { class: "Date" }, formatDistanceToNow(new Date(this.date), { addSuffix: true, locale: dateFnsLocale(this.language) }))), h("div", { class: "Settings", onClick: (e) => this.toggleSettingsModal(e), ref: el => this.settingsButtonRef = el }, h("svg", { width: "30", height: "30", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), this.messageSeen ? '' : h("div", { class: "UnseenButton" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "10px", height: "10px", viewBox: "0 0 16 16", fill: "none" }, h("rect", { x: "1.5", y: "1.5", width: "13", height: "13", rx: "6.5", fill: "url(#paint0_linear_1722_2699)", stroke: "#1E1E26", "stroke-width": "3" }), h("defs", null, h("linearGradient", { id: "paint0_linear_1722_2699", x1: "8", y1: "13", x2: "8", y2: "3", gradientUnits: "userSpaceOnUse" }, h("stop", { "stop-color": "#FF512F" }), h("stop", { offset: "1", "stop-color": "#DD2476" })))))), this.showSettingsModal ? h("div", { class: "SettingsDropdown", ref: el => this.settingsModalRef = el }, h("button", { onClick: () => this.markAsRead(this.messageId) }, h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1('markAsRead', this.language)), h("button", { onClick: () => this.deleteMessage(this.messageId) }, h("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language))) : ''));
40098
+ var _a, _b;
40099
+ return (h("div", { class: "Wrapper" }, h("div", { class: 'NotificationContainer' + (this.messageSeen ? '' : ' Unseen'), ref: this.assignRefToStylingContainer, onClick: this.notificationActionHandler }, this.badge ? (h("div", { class: "AvatarContainer" }, h("div", { class: "Avatar" }, ((_a = systemIcons[this.badge]) === null || _a === void 0 ? void 0 : _a.icon) ? (h("div", { innerHTML: systemIcons[this.badge].icon })) : (h("img", { class: "AvatarImage", src: this.badge }))))) : (''), h("div", { class: "ContentContainer" }, h("p", null, this.displayedContent), h("p", { class: "Date" }, formatDistanceToNow(new Date(this.date), {
40100
+ addSuffix: true,
40101
+ locale: dateFnsLocale(this.language),
40102
+ }))), h("div", { class: "RightActionsContainer" }, h("div", { class: "Settings", onClick: this.toggleSettingsModal }, h("svg", { width: "24", height: "24", viewBox: "0 0 30 30", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M20.625 15.5C20.625 16.5547 21.4453 17.375 22.5 17.375C23.5156 17.375 24.375 16.5547 24.375 15.5C24.375 14.4844 23.5156 13.625 22.5 13.625C21.4453 13.625 20.625 14.4844 20.625 15.5ZM9.375 15.5C9.375 14.4844 8.51562 13.625 7.5 13.625C6.44531 13.625 5.625 14.4844 5.625 15.5C5.625 16.5547 6.44531 17.375 7.5 17.375C8.51562 17.375 9.375 16.5547 9.375 15.5ZM16.875 15.5C16.875 14.4844 16.0156 13.625 15 13.625C13.9453 13.625 13.125 14.4844 13.125 15.5C13.125 16.5547 13.9453 17.375 15 17.375C16.0156 17.375 16.875 16.5547 16.875 15.5Z", fill: "currentColor" }))), ((_b = this.content) === null || _b === void 0 ? void 0 : _b.length) > MAX_NOTIFICATION_TEXT_LENGTH && (h("div", { class: "AccordionArrow", innerHTML: systemIcons.arrowDown.icon, ref: this.assignRefToDropdownArrow })))), this.showSettingsModal ? (h("div", { class: "SettingsDropdown" }, h("button", { onClick: this.toggleNotificationRead }, h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M14.9434 5.17969C14.2109 4.59375 13.625 4.125 10.1387 1.60547C9.64062 1.25391 8.67383 0.375 8 0.375V0.404297C7.9707 0.404297 7.9707 0.375 7.9707 0.375C7.29688 0.375 6.33008 1.25391 5.83203 1.60547C2.3457 4.125 1.75977 4.59375 1.02734 5.17969C0.675781 5.44336 0.5 5.85352 0.5 6.26367V13.9688C0.5 14.7598 1.11523 15.375 1.90625 15.375H14.0938C14.8555 15.375 15.5 14.7598 15.5 13.9688V6.26367C15.5 5.85352 15.2949 5.44336 14.9434 5.17969ZM9.37695 11.1562C8.9668 11.4785 8.46875 11.6543 8 11.6543C7.50195 11.6543 7.00391 11.4785 6.59375 11.1562L2.375 7.8457V6.49805C2.99023 6 3.72266 5.44336 6.94531 3.12891C7.0332 3.04102 7.15039 2.95312 7.26758 2.86523C7.41406 2.74805 7.73633 2.48438 8 2.33789C8.23438 2.48438 8.55664 2.74805 8.70312 2.86523C8.82031 2.95312 8.9375 3.04102 9.02539 3.12891C12.2188 5.44336 12.9805 6 13.625 6.49805V7.8457L9.37695 11.1562Z", fill: "currentColor" })), translate$1(this.messageRead ? 'markAsUnread' : 'markAsRead', this.language)), h("button", { onClick: this.deleteNotification }, h("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M4.375 15.4375C4.375 16.1758 4.94922 16.75 5.6875 16.75H13.5625C14.2734 16.75 14.875 16.1758 14.875 15.4375V6.25H4.375V15.4375ZM11.8125 8.4375C11.8125 8.21875 12.0039 8 12.25 8C12.4688 8 12.6875 8.21875 12.6875 8.4375V14.5625C12.6875 14.8086 12.4688 15 12.25 15C12.0039 15 11.8125 14.8086 11.8125 14.5625V8.4375ZM9.1875 8.4375C9.1875 8.21875 9.37891 8 9.625 8C9.84375 8 10.0625 8.21875 10.0625 8.4375V14.5625C10.0625 14.8086 9.84375 15 9.625 15C9.37891 15 9.1875 14.8086 9.1875 14.5625V8.4375ZM6.5625 8.4375C6.5625 8.21875 6.75391 8 7 8C7.21875 8 7.4375 8.21875 7.4375 8.4375V14.5625C7.4375 14.8086 7.21875 15 7 15C6.75391 15 6.5625 14.8086 6.5625 14.5625V8.4375ZM15.3125 3.625H12.25L11.9219 2.99609C11.8398 2.85938 11.7031 2.75 11.5391 2.75H7.68359C7.51953 2.75 7.38281 2.85938 7.30078 2.99609L7 3.625H3.9375C3.69141 3.625 3.5 3.84375 3.5 4.0625V4.9375C3.5 5.18359 3.69141 5.375 3.9375 5.375H15.3125C15.5312 5.375 15.75 5.18359 15.75 4.9375V4.0625C15.75 3.84375 15.5312 3.625 15.3125 3.625Z", fill: "currentColor" })), translate$1('removeMessage', this.language)))) : ('')));
40090
40103
  }
40091
40104
  static get watchers() { return {
40092
40105
  "translationUrl": ["handleNewTranslations"]
@@ -40094,7 +40107,7 @@ const NutsNotification = class {
40094
40107
  };
40095
40108
  NutsNotification.style = nutsNotificationCss;
40096
40109
 
40097
- const nutsPopoverCss = ":host{display:block}.Popover{padding:15px 0px;border-radius:7px;box-shadow:var(--emfe-w-color-gray-400, rgba(0, 0, 0, 0.2)) 0px 5px 20px;background:var(--emfe-w-color-gray-300, #1e1e26);margin:0px;font-family:inherit;color:var(--emfe-w-color-gray-200, #333737);direction:ltr;width:420px;z-index:999}.Popover .Header{display:flex;justify-content:space-between;padding:0 20px 10px 20px;box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 5px -5px}.Popover .Header .Title{color:var(--emfe-w-color-white, white);font-size:20px;font-style:normal;font-weight:700;line-height:24px;text-align:center;padding-left:10px}.Popover .Header .Title .UnseenCounter{text-decoration:none;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;text-transform:uppercase;border-radius:10px;letter-spacing:0.25px;text-overflow:ellipsis;overflow:hidden;padding:0px;margin-left:10px;width:25px;height:20px;pointer-events:none;border:none;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%);font-family:inherit;line-height:14px;color:var(--emfe-w-color-white, white);font-weight:bold;font-size:12px}.Popover .Header .MarkAsRead{margin-top:5px;margin-right:10px;font-size:14px;font-style:normal;font-weight:400;line-height:17px;color:var(--emfe-w-color-gray-150, #828299);cursor:pointer;pointer-events:auto;opacity:0.5}.Popover .Header .MarkAsRead:hover{opacity:0.7;transition:250ms}.Popover .NotificationList{height:400px;overflow:auto}.Popover .NotificationList .NoMessages{display:flex;justify-content:center;flex-direction:column;align-items:center;height:100%}.Popover .NotificationList .NoMessages p{color:var(--emfe-w-color-white, #fff);opacity:0.7}";
40110
+ const nutsPopoverCss = ":host{display:block}.Popover{padding:15px 0px;border-radius:7px;box-shadow:var(--emfe-w-color-gray-400, rgba(0, 0, 0, 0.2)) 0px 5px 20px;background:var(--emfe-w-color-gray-300, #1e1e26);margin:0px;font-family:inherit;color:var(--emfe-w-color-gray-200, #333737);direction:ltr;width:420px;z-index:999;position:absolute;right:0}.Popover .Header{display:flex;justify-content:space-between;padding:0 20px 10px 20px;box-shadow:var(--emfe-w-color-gray-20, rgba(0, 0, 0, 0.2)) 0px 5px 5px -5px}.Popover .Header .Title{color:var(--emfe-w-color-white, white);font-size:20px;font-style:normal;font-weight:700;line-height:24px;text-align:center;padding-left:10px}.Popover .Header .Title .UnseenCounter{text-decoration:none;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;text-transform:uppercase;border-radius:10px;letter-spacing:0.25px;text-overflow:ellipsis;overflow:hidden;padding:0px;margin-left:10px;width:25px;height:20px;pointer-events:none;border:none;background:linear-gradient(0deg, var(--emfe-w-color-secondary-20, #ff512f) 0%, var(--emfe-w-color-secondary, #dd2476) 100%);font-family:inherit;line-height:14px;color:var(--emfe-w-color-white, white);font-weight:bold;font-size:12px}.Popover .Header .MarkAsRead{margin-top:5px;margin-right:10px;font-size:14px;font-style:normal;font-weight:400;line-height:17px;color:var(--emfe-w-color-gray-150, #828299);cursor:pointer;pointer-events:auto;opacity:0.5}.Popover .Header .MarkAsRead:hover{opacity:0.7;transition:250ms}.Popover .NotificationList{height:400px;overflow:auto;box-shadow:0px 20px 10px -20px rgba(0, 0, 0, 0.45) inset, 0px -20px 10px -20px rgba(0, 0, 0, 0.45) inset}.Popover .NotificationList .NoMessages{display:flex;justify-content:center;flex-direction:column;align-items:center;height:100%}.Popover .NotificationList .NoMessages p{color:var(--emfe-w-color-white, #fff);opacity:0.7}.Popover .Pagination{display:flex;justify-content:space-around;margin-top:13px}.Popover .Pagination .Button{width:43%}.Popover .Pagination .Button button{font-family:inherit;border:0px;background-color:transparent;outline:0px;width:100%;text-align:left;text-decoration:none;box-sizing:border-box;padding:10px 12px;cursor:pointer;border-radius:7px;display:flex;align-items:center;color:var(--emfe-w-color-white, white);font-weight:400;font-size:14px;justify-content:center}.Popover .Pagination .Button button svg{width:15px;height:15px;fill:white}.Popover .Pagination .Button button:disabled{cursor:default;opacity:0.5}.Popover .Pagination .Button button:hover:enabled{background:var(--emfe-w-color-gray-300, #3d3d4d);transition:300ms}";
40098
40111
 
40099
40112
  const NutsPopover = class {
40100
40113
  constructor(hostRef) {
@@ -40110,6 +40123,25 @@ const NutsPopover = class {
40110
40123
  this.translationUrl = '';
40111
40124
  this.isLoading = true;
40112
40125
  this.showMarkAll = false;
40126
+ this.currentPage = 0;
40127
+ this.updateNotificationsDataAfterPageChange = (getNotificationsData) => {
40128
+ this.isLoading = getNotificationsData.isLoading;
40129
+ this.notifications = getNotificationsData.notifications;
40130
+ };
40131
+ this.nextPage = async () => {
40132
+ getNotifications({
40133
+ baseUrl: this.baseUrl,
40134
+ headers: this.defaultHeaders,
40135
+ page: ++this.currentPage,
40136
+ }).then((data) => this.updateNotificationsDataAfterPageChange(data));
40137
+ };
40138
+ this.prevPage = () => {
40139
+ getNotifications({
40140
+ baseUrl: this.baseUrl,
40141
+ headers: this.defaultHeaders,
40142
+ page: --this.currentPage,
40143
+ }).then((data) => this.updateNotificationsDataAfterPageChange(data));
40144
+ };
40113
40145
  this.setClientStyling = () => {
40114
40146
  let sheet = document.createElement('style');
40115
40147
  sheet.innerHTML = this.clientStyling;
@@ -40122,21 +40154,43 @@ const NutsPopover = class {
40122
40154
  .then((res) => res.text())
40123
40155
  .then((data) => {
40124
40156
  cssFile.innerHTML = data;
40125
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
40157
+ setTimeout(() => {
40158
+ this.stylingContainer.prepend(cssFile);
40159
+ }, 1);
40126
40160
  })
40127
40161
  .catch((err) => {
40128
40162
  console.log('error ', err);
40129
40163
  });
40130
40164
  };
40165
+ this.markAllNotificationsAsRead = async () => {
40166
+ const markedAllNotificationsAsRead = await markAllAsRead({
40167
+ baseUrl: this.baseUrl,
40168
+ headers: this.defaultHeaders,
40169
+ });
40170
+ if (markedAllNotificationsAsRead) {
40171
+ this.allNotificationsRead.emit();
40172
+ }
40173
+ };
40174
+ this.assignRefToStylingContainer = (ref) => {
40175
+ this.stylingContainer = ref;
40176
+ };
40131
40177
  }
40132
40178
  messageDeteledHandler(event) {
40133
40179
  this.notifications = this.notifications.filter((item) => {
40134
40180
  return item._id != event.detail;
40135
40181
  });
40136
- this.getNotifications();
40182
+ getNotifications({
40183
+ baseUrl: this.baseUrl,
40184
+ headers: this.defaultHeaders,
40185
+ page: this.currentPage,
40186
+ }).then((data) => this.updateNotificationsDataAfterPageChange(data));
40137
40187
  }
40138
40188
  newNotificationHandler(event) {
40139
- this.notifications = [event.detail, ...this.notifications];
40189
+ if (Array.isArray(this.notifications)) {
40190
+ this.notifications = [event.detail, ...this.notifications];
40191
+ return;
40192
+ }
40193
+ this.notifications = [event.detail];
40140
40194
  }
40141
40195
  unseenCountHandler(newValue) {
40142
40196
  if (newValue == 0) {
@@ -40157,52 +40211,25 @@ const NutsPopover = class {
40157
40211
  await getTranslations(this.translationUrl);
40158
40212
  }
40159
40213
  }
40160
- getNotifications() {
40161
- let url = new URL(`${this.backendUrl}/v1/widgets/notifications/feed`);
40162
- const headers = new Headers();
40163
- headers.append('Authorization', `Bearer ${this.token || ''}`);
40164
- headers.append('Content-Type', 'application/json');
40165
- url.searchParams.append('page', '0');
40166
- const options = {
40167
- method: 'GET',
40168
- headers,
40169
- };
40170
- fetch(url.href, options)
40171
- .then((res) => res.json())
40172
- .then((response) => {
40173
- this.isLoading = false;
40174
- this.notifications = response.data;
40175
- });
40176
- }
40177
- markAllAsRead() {
40178
- let url = new URL(`${this.backendUrl}/v1/widgets/messages/read`);
40179
- const headers = new Headers();
40180
- headers.append('Authorization', `Bearer ${this.token || ''}`);
40181
- const options = {
40182
- method: 'POST',
40183
- body: JSON.stringify({}),
40184
- headers,
40185
- };
40186
- fetch(url.href, options)
40187
- .then((res) => res.json())
40188
- .then(() => {
40189
- this.allNotificationsRead.emit();
40190
- })
40191
- .catch((err) => {
40192
- console.error('err', err);
40193
- });
40194
- }
40195
40214
  connectedCallback() {
40196
- this.getNotifications();
40215
+ this.baseUrl = `${this.backendUrl}/v1/${this.operatorId}`;
40216
+ this.defaultHeaders = createAuthHeaders(this.token, this.sessionId, this.admin);
40217
+ getNotifications({
40218
+ baseUrl: this.baseUrl,
40219
+ headers: this.defaultHeaders,
40220
+ page: this.currentPage,
40221
+ }).then((data) => this.updateNotificationsDataAfterPageChange(data));
40197
40222
  if (this.unseenCount != 0) {
40198
40223
  this.showMarkAll = true;
40199
40224
  }
40200
40225
  }
40201
40226
  render() {
40202
- return (h("div", { class: "Popover", ref: el => this.stylingContainer = el }, h("div", { class: "Header" }, h("div", { class: "Title" }, translate$1('notifications', this.language), this.unseenCount > 0 ? h("div", { class: "UnseenCounter" }, this.unseenCount) : ''), this.showMarkAll ? h("div", { class: "MarkAsRead", onClick: () => this.markAllAsRead() }, translate$1('markAllAsRead', this.language)) : ''), h("div", { class: "NotificationList" }, !this.isLoading && (this.notifications.length > 0 ? this.notifications.map((item) => {
40203
- var _a;
40204
- return (h("nuts-notification", { "client-styling": this.clientStyling, key: item.id, "user-id": this.userId, "operator-id": this.operatorId, content: item.content, "message-id": item.id, badge: ((_a = item.actor) === null || _a === void 0 ? void 0 : _a.data) || '', date: item.createdAt, read: item.read, seen: item.seen, language: this.language, "notification-action": this.notificationAction, token: this.token, "backend-url": this.backendUrl, "redirect-url": item.cta.data.url, "translation-url": this.translationUrl }));
40205
- }) : h("div", { class: "NoMessages" }, h("svg", { width: "120", height: "108", viewBox: "0 0 120 108", fill: "none" }, h("circle", { cx: "11.3191", cy: "30.7872", r: "6.31915", stroke: "#3D3D4D", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("ellipse", { cx: "60.117", cy: "27.9787", rx: "5.96809", ry: "5.61702", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M79.5424 49.4934C79.5424 44.1598 77.6437 39.0446 74.2641 35.2732C70.8844 31.5017 66.3006 29.3829 61.5211 29.3829C56.7415 29.3829 52.1578 31.5017 48.7781 35.2732C45.3985 39.0446 43.4998 44.1598 43.4998 49.4934C43.4998 72.9557 34.4892 79.6592 34.4892 79.6592H88.553C88.553 79.6592 79.5424 72.9557 79.5424 49.4934Z", fill: "#292933" }), h("path", { d: "M68.8995 81.7552C68.1496 83.551 67.0731 85.0417 65.778 86.0779C64.4828 87.1141 63.0144 87.6595 61.5198 87.6595C60.0252 87.6595 58.5568 87.1141 57.2617 86.0779C55.9665 85.0417 54.8901 83.551 54.1401 81.7552", fill: "#292933" }), h("path", { d: "M81.2976 50.2203C81.2976 68.2545 87.2222 76.7327 90.2814 79.9083C90.7671 80.4126 90.3802 81.4764 89.68 81.4764C88.0927 81.4764 86.5488 81.4764 85.0422 81.4764M68.5814 82.946C67.6854 84.8068 66.3993 86.3513 64.8518 87.425C63.3044 88.4987 61.5499 89.0638 59.7641 89.0638C57.9783 89.0638 56.2239 88.4987 54.6765 87.425C53.129 86.3513 51.8429 84.8068 50.9468 82.946M79.712 42.3723C78.6394 39.8192 77.0439 37.4727 74.991 35.4861C70.953 31.5783 65.4763 29.3829 59.7656 29.3829C54.055 29.3829 48.5783 31.5783 44.5403 35.4861C43.3681 36.6205 42.345 37.8722 41.4832 39.2127C40.4958 40.7487 39.7202 42.4013 39.1747 44.1276C38.5563 46.0847 38.2337 48.1364 38.2337 50.2203C38.2337 53.2503 38.0665 56.0106 37.7737 58.5212M34.8401 70.7608C32.9874 75.4551 30.7688 78.331 29.2526 79.9055C28.767 80.4099 29.155 81.4764 29.8551 81.4764C47.1962 81.4764 59.3571 81.4764 74.1593 81.4764", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M55.6345 59.0737C55.1665 59.7144 54.4949 60.2462 53.6868 60.6159C52.8787 60.9855 51.9625 61.1801 51.0299 61.1801C50.0973 61.1801 49.1811 60.9855 48.373 60.6159C47.5649 60.2462 46.8933 59.7144 46.4254 59.0737", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M73.1877 59.0737C72.7197 59.7144 72.0481 60.2462 71.24 60.6159C70.4319 60.9855 69.5157 61.1801 68.5831 61.1801C67.6506 61.1801 66.7344 60.9855 65.9263 60.6159C65.1182 60.2462 64.4465 59.7144 63.9786 59.0737", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("circle", { cx: "107.511", cy: "56.0638", r: "7.02128", stroke: "#3D3D4D", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("circle", { cx: "16.4252", cy: "58.1703", r: "4.21277", fill: "#3D3D4D" }), h("ellipse", { cx: "59.9573", cy: "104.511", rx: "25.2766", ry: "2.80851", fill: "#3D3D4D" }), h("path", { d: "M81.5317 18.1489H88.553L81.5317 25.1702H88.553", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M96.6807 2H106.51L96.6807 11.8298H106.51", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", null, translate$1('noMessages', this.language)))))));
40227
+ return (h("div", { class: "Popover", ref: this.assignRefToStylingContainer }, h("div", { class: "Header" }, h("div", { class: "Title" }, translate$1('notifications', this.language), this.unseenCount > 0 ? (h("div", { class: "UnseenCounter" }, this.unseenCount)) : ('')), this.showMarkAll ? (h("div", { class: "MarkAsRead", onClick: this.markAllNotificationsAsRead }, translate$1('markAllAsRead', this.language))) : ('')), h("div", { class: "NotificationList" }, !this.isLoading &&
40228
+ (this.notifications.length > 0 ? (this.notifications.map((item) => {
40229
+ var _a;
40230
+ return (h("nuts-notification", { "client-styling": this.clientStyling, key: item.id, "user-id": this.userId, "operator-id": this.operatorId, content: item.content, "message-id": item.id, badge: ((_a = item.actor) === null || _a === void 0 ? void 0 : _a.data) || '', admin: this.admin, sessionId: this.sessionId, date: item.createdAt, read: item.read, seen: item.seen, language: this.language, "notification-action": this.notificationAction, token: this.token, "backend-url": this.backendUrl, "redirect-url": item.cta.data.url, "translation-url": this.translationUrl }));
40231
+ })) : (h("div", { class: "NoMessages" }, h("svg", { width: "120", height: "108", viewBox: "0 0 120 108", fill: "none" }, h("circle", { cx: "11.3191", cy: "30.7872", r: "6.31915", stroke: "#3D3D4D", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("ellipse", { cx: "60.117", cy: "27.9787", rx: "5.96809", ry: "5.61702", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M79.5424 49.4934C79.5424 44.1598 77.6437 39.0446 74.2641 35.2732C70.8844 31.5017 66.3006 29.3829 61.5211 29.3829C56.7415 29.3829 52.1578 31.5017 48.7781 35.2732C45.3985 39.0446 43.4998 44.1598 43.4998 49.4934C43.4998 72.9557 34.4892 79.6592 34.4892 79.6592H88.553C88.553 79.6592 79.5424 72.9557 79.5424 49.4934Z", fill: "#292933" }), h("path", { d: "M68.8995 81.7552C68.1496 83.551 67.0731 85.0417 65.778 86.0779C64.4828 87.1141 63.0144 87.6595 61.5198 87.6595C60.0252 87.6595 58.5568 87.1141 57.2617 86.0779C55.9665 85.0417 54.8901 83.551 54.1401 81.7552", fill: "#292933" }), h("path", { d: "M81.2976 50.2203C81.2976 68.2545 87.2222 76.7327 90.2814 79.9083C90.7671 80.4126 90.3802 81.4764 89.68 81.4764C88.0927 81.4764 86.5488 81.4764 85.0422 81.4764M68.5814 82.946C67.6854 84.8068 66.3993 86.3513 64.8518 87.425C63.3044 88.4987 61.5499 89.0638 59.7641 89.0638C57.9783 89.0638 56.2239 88.4987 54.6765 87.425C53.129 86.3513 51.8429 84.8068 50.9468 82.946M79.712 42.3723C78.6394 39.8192 77.0439 37.4727 74.991 35.4861C70.953 31.5783 65.4763 29.3829 59.7656 29.3829C54.055 29.3829 48.5783 31.5783 44.5403 35.4861C43.3681 36.6205 42.345 37.8722 41.4832 39.2127C40.4958 40.7487 39.7202 42.4013 39.1747 44.1276C38.5563 46.0847 38.2337 48.1364 38.2337 50.2203C38.2337 53.2503 38.0665 56.0106 37.7737 58.5212M34.8401 70.7608C32.9874 75.4551 30.7688 78.331 29.2526 79.9055C28.767 80.4099 29.155 81.4764 29.8551 81.4764C47.1962 81.4764 59.3571 81.4764 74.1593 81.4764", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M55.6345 59.0737C55.1665 59.7144 54.4949 60.2462 53.6868 60.6159C52.8787 60.9855 51.9625 61.1801 51.0299 61.1801C50.0973 61.1801 49.1811 60.9855 48.373 60.6159C47.5649 60.2462 46.8933 59.7144 46.4254 59.0737", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M73.1877 59.0737C72.7197 59.7144 72.0481 60.2462 71.24 60.6159C70.4319 60.9855 69.5157 61.1801 68.5831 61.1801C67.6506 61.1801 66.7344 60.9855 65.9263 60.6159C65.1182 60.2462 64.4465 59.7144 63.9786 59.0737", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("circle", { cx: "107.511", cy: "56.0638", r: "7.02128", stroke: "#3D3D4D", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("circle", { cx: "16.4252", cy: "58.1703", r: "4.21277", fill: "#3D3D4D" }), h("ellipse", { cx: "59.9573", cy: "104.511", rx: "25.2766", ry: "2.80851", fill: "#3D3D4D" }), h("path", { d: "M81.5317 18.1489H88.553L81.5317 25.1702H88.553", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" }), h("path", { d: "M96.6807 2H106.51L96.6807 11.8298H106.51", stroke: "#828299", "stroke-width": "3.5", "stroke-linecap": "round", "stroke-linejoin": "round" })), h("p", null, translate$1('noMessages', this.language)))))), !this.isLoading &&
40232
+ (this.notifications.length >= 10 || this.currentPage !== 0) ? (h("div", { class: "Pagination" }, h("div", { class: "Button" }, h("button", { disabled: this.currentPage <= 0, onClick: this.prevPage }, h("svg", { class: "svg-icon", viewBox: "0 0 20 20" }, h("path", { d: "M8.388,10.049l4.76-4.873c0.303-0.31,0.297-0.804-0.012-1.105c-0.309-0.304-0.803-0.293-1.105,0.012L6.726,9.516c-0.303,0.31-0.296,0.805,0.012,1.105l5.433,5.307c0.152,0.148,0.35,0.223,0.547,0.223c0.203,0,0.406-0.08,0.559-0.236c0.303-0.309,0.295-0.803-0.012-1.104L8.388,10.049z" })), translate$1('prev', this.language))), h("div", { class: "Button" }, h("button", { disabled: this.notifications.length < 10, onClick: this.nextPage }, translate$1('next', this.language), h("svg", { class: "svg-icon", viewBox: "0 0 20 20" }, h("path", { d: "M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z" })))))) : ('')));
40206
40233
  }
40207
40234
  static get watchers() { return {
40208
40235
  "unseenCount": ["unseenCountHandler"],