@telia-ace/widget-utilities 1.0.0 → 1.0.3
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/LICENSE.txt +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/append-class-names.d.ts +0 -0
- package/{lib-esm → dist}/batch.d.ts +0 -0
- package/{lib-esm → dist}/camilize.d.ts +0 -0
- package/{lib-esm → dist}/category-trail.d.ts +0 -0
- package/{lib-esm → dist}/create-params.d.ts +0 -0
- package/{lib-esm → dist}/data-uri-to-blob.d.ts +0 -0
- package/{lib-esm → dist}/debug.d.ts +0 -0
- package/{lib-esm → dist}/deep-clone.d.ts +0 -0
- package/{lib-esm → dist}/find-and-activate-stored-widgets.d.ts +0 -0
- package/{lib-esm → dist}/find-category-by-id.d.ts +0 -0
- package/{lib-esm → dist}/format-date.d.ts +0 -0
- package/{lib-esm → dist}/format-url.d.ts +0 -0
- package/{lib-esm → dist}/get-cookie.d.ts +0 -0
- package/{lib-esm → dist}/has-non-empty-categories.d.ts +0 -0
- package/{lib-esm → dist}/hash.d.ts +0 -0
- package/{lib-esm → dist}/html-parent-contains.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +802 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/is-anchor-link.d.ts +0 -0
- package/{lib-esm → dist}/kebab-case.d.ts +0 -0
- package/{lib-esm → dist}/lock.d.ts +0 -0
- package/{lib-esm → dist}/merge-deep.d.ts +0 -0
- package/{lib-esm → dist}/notify-data-loaded.d.ts +0 -0
- package/{lib-esm → dist}/remove-null-and-undefined-values.d.ts +0 -0
- package/{lib-esm → dist}/set-cookie.d.ts +0 -0
- package/{lib-esm → dist}/shallow-compare.d.ts +0 -0
- package/{lib-esm → dist}/uuid.d.ts +0 -0
- package/{lib-esm → dist}/wait-for.d.ts +0 -0
- package/package.json +36 -35
- package/lib/append-class-names.d.ts +0 -6
- package/lib/append-class-names.js +0 -84
- package/lib/batch.d.ts +0 -4
- package/lib/batch.js +0 -38
- package/lib/camilize.d.ts +0 -1
- package/lib/camilize.js +0 -29
- package/lib/category-trail.d.ts +0 -14
- package/lib/category-trail.js +0 -96
- package/lib/create-params.d.ts +0 -21
- package/lib/create-params.js +0 -108
- package/lib/data-uri-to-blob.d.ts +0 -2
- package/lib/data-uri-to-blob.js +0 -20
- package/lib/debug.d.ts +0 -52
- package/lib/debug.js +0 -155
- package/lib/deep-clone.d.ts +0 -2
- package/lib/deep-clone.js +0 -21
- package/lib/find-and-activate-stored-widgets.d.ts +0 -9
- package/lib/find-and-activate-stored-widgets.js +0 -27
- package/lib/find-category-by-id.d.ts +0 -6
- package/lib/find-category-by-id.js +0 -89
- package/lib/format-date.d.ts +0 -2
- package/lib/format-date.js +0 -23
- package/lib/format-url.d.ts +0 -2
- package/lib/format-url.js +0 -111
- package/lib/get-cookie.d.ts +0 -1
- package/lib/get-cookie.js +0 -18
- package/lib/has-non-empty-categories.d.ts +0 -2
- package/lib/has-non-empty-categories.js +0 -23
- package/lib/hash.d.ts +0 -1
- package/lib/hash.js +0 -16
- package/lib/html-parent-contains.d.ts +0 -7
- package/lib/html-parent-contains.js +0 -21
- package/lib/index.d.ts +0 -27
- package/lib/index.js +0 -57
- package/lib/is-anchor-link.d.ts +0 -2
- package/lib/is-anchor-link.js +0 -9
- package/lib/kebab-case.d.ts +0 -1
- package/lib/kebab-case.js +0 -9
- package/lib/lock.d.ts +0 -9
- package/lib/lock.js +0 -78
- package/lib/merge-deep.d.ts +0 -7
- package/lib/merge-deep.js +0 -72
- package/lib/notify-data-loaded.d.ts +0 -6
- package/lib/notify-data-loaded.js +0 -96
- package/lib/remove-null-and-undefined-values.d.ts +0 -6
- package/lib/remove-null-and-undefined-values.js +0 -12
- package/lib/set-cookie.d.ts +0 -1
- package/lib/set-cookie.js +0 -12
- package/lib/shallow-compare.d.ts +0 -6
- package/lib/shallow-compare.js +0 -25
- package/lib/uuid.d.ts +0 -1
- package/lib/uuid.js +0 -12
- package/lib/wait-for.d.ts +0 -20
- package/lib/wait-for.js +0 -52
- package/lib-esm/append-class-names.js +0 -77
- package/lib-esm/batch.js +0 -36
- package/lib-esm/camilize.js +0 -26
- package/lib-esm/category-trail.js +0 -87
- package/lib-esm/create-params.js +0 -105
- package/lib-esm/data-uri-to-blob.js +0 -18
- package/lib-esm/debug.js +0 -151
- package/lib-esm/deep-clone.js +0 -19
- package/lib-esm/find-and-activate-stored-widgets.js +0 -25
- package/lib-esm/find-category-by-id.js +0 -87
- package/lib-esm/format-date.js +0 -21
- package/lib-esm/format-url.js +0 -109
- package/lib-esm/get-cookie.js +0 -15
- package/lib-esm/has-non-empty-categories.js +0 -18
- package/lib-esm/hash.js +0 -13
- package/lib-esm/html-parent-contains.js +0 -19
- package/lib-esm/index.js +0 -24
- package/lib-esm/is-anchor-link.js +0 -7
- package/lib-esm/kebab-case.js +0 -6
- package/lib-esm/lock.js +0 -75
- package/lib-esm/merge-deep.js +0 -67
- package/lib-esm/notify-data-loaded.js +0 -94
- package/lib-esm/remove-null-and-undefined-values.js +0 -10
- package/lib-esm/set-cookie.js +0 -9
- package/lib-esm/shallow-compare.js +0 -23
- package/lib-esm/uuid.js +0 -9
- package/lib-esm/wait-for.js +0 -50
package/dist/index.js
ADDED
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
+
target[prop] = source[prop];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
function uniqueClassArray(classNames) {
|
|
17
|
+
const classArray = [];
|
|
18
|
+
classNames.forEach((c) => {
|
|
19
|
+
if (classArray.indexOf(c) === -1) {
|
|
20
|
+
classArray.push(c);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return classArray;
|
|
24
|
+
}
|
|
25
|
+
function append(className1 = "", className2 = "") {
|
|
26
|
+
const classNames = className1.split(" ").concat(className2.split(" "));
|
|
27
|
+
return uniqueClassArray(classNames).join(" ").trim();
|
|
28
|
+
}
|
|
29
|
+
function handleFunctionArgument(expression, classes) {
|
|
30
|
+
if (Boolean(expression)) {
|
|
31
|
+
if (typeof classes === "string") {
|
|
32
|
+
return classes;
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(classes)) {
|
|
35
|
+
let className = "";
|
|
36
|
+
classes.forEach((c) => className = append(className, c));
|
|
37
|
+
return className;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function appendClassNames(...args) {
|
|
42
|
+
let className = "";
|
|
43
|
+
if (args.length) {
|
|
44
|
+
args.forEach((argument) => {
|
|
45
|
+
if (typeof argument === "string") {
|
|
46
|
+
className = append(className, argument);
|
|
47
|
+
} else if (Array.isArray(argument)) {
|
|
48
|
+
className = append(className, handleFunctionArgument(...argument));
|
|
49
|
+
} else
|
|
50
|
+
;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return className;
|
|
54
|
+
}
|
|
55
|
+
const createBatch = (delay, createFallback) => {
|
|
56
|
+
let timeout;
|
|
57
|
+
let queue = [];
|
|
58
|
+
return (fn) => {
|
|
59
|
+
clearTimeout(timeout);
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
queue.push([fn, resolve, reject]);
|
|
62
|
+
timeout = setTimeout(() => {
|
|
63
|
+
let acc = createFallback();
|
|
64
|
+
queue.forEach(([fn2, resolve2, reject2]) => {
|
|
65
|
+
acc = fn2(acc);
|
|
66
|
+
});
|
|
67
|
+
queue = [];
|
|
68
|
+
resolve(acc);
|
|
69
|
+
}, delay);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
function camilize(obj) {
|
|
74
|
+
const camilizedObject = {};
|
|
75
|
+
if (typeof obj === "number" || typeof obj === "string") {
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
for (const prop in obj) {
|
|
79
|
+
if (obj.hasOwnProperty(prop)) {
|
|
80
|
+
const p = obj[prop];
|
|
81
|
+
const camilizedProp = prop.substring(0, 1).toLowerCase() + prop.substring(1);
|
|
82
|
+
if (Object.prototype.toString.call(p) === "[object Array]") {
|
|
83
|
+
camilizedObject[camilizedProp] = [];
|
|
84
|
+
for (let i = 0, c = p.length; i < c; i++) {
|
|
85
|
+
camilizedObject[camilizedProp].push(camilize(p[i]));
|
|
86
|
+
}
|
|
87
|
+
} else if (p !== null && typeof p === "object") {
|
|
88
|
+
camilizedObject[camilizedProp] = camilize(p);
|
|
89
|
+
} else {
|
|
90
|
+
camilizedObject[camilizedProp] = p;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return camilizedObject;
|
|
95
|
+
}
|
|
96
|
+
function createParams(args = {}) {
|
|
97
|
+
const _a = args, {
|
|
98
|
+
phrase = "",
|
|
99
|
+
category,
|
|
100
|
+
guideCategory,
|
|
101
|
+
contactCategory,
|
|
102
|
+
take,
|
|
103
|
+
connectionKey,
|
|
104
|
+
accordion,
|
|
105
|
+
id,
|
|
106
|
+
uriName,
|
|
107
|
+
sorting,
|
|
108
|
+
tag,
|
|
109
|
+
tagId,
|
|
110
|
+
tagTitle
|
|
111
|
+
} = _a, other = __objRest(_a, [
|
|
112
|
+
"phrase",
|
|
113
|
+
"category",
|
|
114
|
+
"guideCategory",
|
|
115
|
+
"contactCategory",
|
|
116
|
+
"take",
|
|
117
|
+
"connectionKey",
|
|
118
|
+
"accordion",
|
|
119
|
+
"id",
|
|
120
|
+
"uriName",
|
|
121
|
+
"sorting",
|
|
122
|
+
"tag",
|
|
123
|
+
"tagId",
|
|
124
|
+
"tagTitle"
|
|
125
|
+
]);
|
|
126
|
+
const params = {};
|
|
127
|
+
Object.keys(other).forEach((k) => {
|
|
128
|
+
if (typeof args[k] === "string") {
|
|
129
|
+
params[k] = args[k];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
if (typeof phrase === "string" && phrase.length) {
|
|
133
|
+
params.phrase = phrase;
|
|
134
|
+
}
|
|
135
|
+
if (phrase === null) {
|
|
136
|
+
params.phrase = phrase;
|
|
137
|
+
}
|
|
138
|
+
if (typeof guideCategory === "string" && guideCategory !== "0") {
|
|
139
|
+
params.guideCategory = guideCategory;
|
|
140
|
+
}
|
|
141
|
+
if (typeof guideCategory === "number" && guideCategory !== 0) {
|
|
142
|
+
params.guideCategory = guideCategory;
|
|
143
|
+
}
|
|
144
|
+
if (typeof guideCategory === "object" && guideCategory !== null) {
|
|
145
|
+
if (typeof guideCategory.id === "string" && guideCategory.id !== "0") {
|
|
146
|
+
params.guideCategory = guideCategory.id;
|
|
147
|
+
}
|
|
148
|
+
if (typeof guideCategory.id === "number" && guideCategory.id !== 0) {
|
|
149
|
+
params.guideCategory = guideCategory.id;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (typeof contactCategory === "string" && contactCategory !== "0") {
|
|
153
|
+
params.contactCategory = contactCategory;
|
|
154
|
+
}
|
|
155
|
+
if (typeof contactCategory === "number" && contactCategory !== 0) {
|
|
156
|
+
params.contactCategory = contactCategory;
|
|
157
|
+
}
|
|
158
|
+
if (typeof contactCategory === "object" && contactCategory !== null) {
|
|
159
|
+
if (typeof contactCategory.id === "string" && contactCategory.id !== "0") {
|
|
160
|
+
params.contactCategory = contactCategory.id;
|
|
161
|
+
}
|
|
162
|
+
if (typeof contactCategory.id === "number" && contactCategory.id !== 0) {
|
|
163
|
+
params.contactCategory = contactCategory.id;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (typeof category === "string" && category !== "0") {
|
|
167
|
+
params.category = category;
|
|
168
|
+
}
|
|
169
|
+
if (typeof category === "number" && category !== 0) {
|
|
170
|
+
params.category = category;
|
|
171
|
+
}
|
|
172
|
+
if (typeof category === "object" && category !== null) {
|
|
173
|
+
if (typeof category.id === "string" && category.id !== "0") {
|
|
174
|
+
params.category = category.id;
|
|
175
|
+
}
|
|
176
|
+
if (typeof category.id === "number" && category.id !== 0) {
|
|
177
|
+
params.category = category.id;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (id) {
|
|
181
|
+
params.id = id;
|
|
182
|
+
}
|
|
183
|
+
if (uriName && (!!+params.category || !!+params.guideCategory || !!+params.guide || !!+params.contactCategory || !!+params.contactMethod)) {
|
|
184
|
+
params.uriName = uriName;
|
|
185
|
+
}
|
|
186
|
+
if (connectionKey) {
|
|
187
|
+
params.connectionKey = connectionKey;
|
|
188
|
+
}
|
|
189
|
+
if (take) {
|
|
190
|
+
params.take = take;
|
|
191
|
+
}
|
|
192
|
+
if (sorting) {
|
|
193
|
+
params.sorting = sorting;
|
|
194
|
+
}
|
|
195
|
+
if (typeof accordion === "string" && accordion.length > 0) {
|
|
196
|
+
params.accordion = accordion;
|
|
197
|
+
}
|
|
198
|
+
if (typeof tag === "string" && tag !== "0") {
|
|
199
|
+
params.tag = tag;
|
|
200
|
+
}
|
|
201
|
+
if (typeof tag === "number" && tag !== 0) {
|
|
202
|
+
params.tag = tag;
|
|
203
|
+
}
|
|
204
|
+
if (typeof tagId === "string" || typeof tagId === "number") {
|
|
205
|
+
params.tagId = tagId;
|
|
206
|
+
}
|
|
207
|
+
if (typeof tagTitle === "string") {
|
|
208
|
+
params.tagTitle = tagTitle;
|
|
209
|
+
}
|
|
210
|
+
return params;
|
|
211
|
+
}
|
|
212
|
+
function* processData(data) {
|
|
213
|
+
if (!data) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
for (let i = 0; i < data.length; i++) {
|
|
217
|
+
const val = data[i];
|
|
218
|
+
yield val;
|
|
219
|
+
if (val.items) {
|
|
220
|
+
yield* processData(val.items);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const findCategoryById = (id, categories) => {
|
|
225
|
+
const it = processData(categories);
|
|
226
|
+
let res = it.next();
|
|
227
|
+
let found = null;
|
|
228
|
+
while (!res.done) {
|
|
229
|
+
if (res.value.id === id) {
|
|
230
|
+
found = res.value;
|
|
231
|
+
}
|
|
232
|
+
res = it.next();
|
|
233
|
+
}
|
|
234
|
+
return found;
|
|
235
|
+
};
|
|
236
|
+
const formatUrl = (url) => {
|
|
237
|
+
if (!url) {
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
const replacements = [
|
|
241
|
+
{ from: /[äæǽ]+/gi, to: "ae" },
|
|
242
|
+
{ from: /[öœ]+/gi, to: "oe" },
|
|
243
|
+
{ from: /[ü]+/gi, to: "ue" },
|
|
244
|
+
{ from: /[Ä]+/gi, to: "Ae" },
|
|
245
|
+
{ from: /[Ü]+/gi, to: "Ue" },
|
|
246
|
+
{ from: /[Ö]+/gi, to: "Oe" },
|
|
247
|
+
{ from: /[ÀÁÂÃÄÅǺĀĂĄǍΑΆẢẠẦẪẨẬẰẮẴẲẶА]+/gi, to: "A" },
|
|
248
|
+
{ from: /[àáâãåǻāăąǎªαάảạầấẫẩậằắẵẳặа]+/gi, to: "a" },
|
|
249
|
+
{ from: /[Б]+/gi, to: "B" },
|
|
250
|
+
{ from: /[б]+/gi, to: "b" },
|
|
251
|
+
{ from: /[ÇĆĈĊČ]+/gi, to: "C" },
|
|
252
|
+
{ from: /[çćĉċč]+/gi, to: "c" },
|
|
253
|
+
{ from: /[Д]+/gi, to: "D" },
|
|
254
|
+
{ from: /[д]+/gi, to: "d" },
|
|
255
|
+
{ from: /[ÐĎĐΔ]+/gi, to: "Dj" },
|
|
256
|
+
{ from: /[ðďđδ]+/gi, to: "dj" },
|
|
257
|
+
{ from: /[ÈÉÊËĒĔĖĘĚΕΈẼẺẸỀẾỄỂỆЕЭ]+/gi, to: "E" },
|
|
258
|
+
{ from: /[èéêëēĕėęěέεẽẻẹềếễểệеэ]+/gi, to: "e" },
|
|
259
|
+
{ from: /[Ф]+/gi, to: "F" },
|
|
260
|
+
{ from: /[ф]+/gi, to: "f" },
|
|
261
|
+
{ from: /[ĜĞĠĢΓГҐ]+/gi, to: "G" },
|
|
262
|
+
{ from: /[ĝğġģγгґ]+/gi, to: "g" },
|
|
263
|
+
{ from: /[ĤĦ]+/gi, to: "H" },
|
|
264
|
+
{ from: /[ĥħ]+/gi, to: "h" },
|
|
265
|
+
{ from: /[ÌÍÎÏĨĪĬǏĮİΗΉΊΙΪỈỊИЫ]+/gi, to: "I" },
|
|
266
|
+
{ from: /[ìíîïĩīĭǐįıηήίιϊỉịиыї]+/gi, to: "i" },
|
|
267
|
+
{ from: /[Ĵ]+/gi, to: "J" },
|
|
268
|
+
{ from: /[ĵ]+/gi, to: "j" },
|
|
269
|
+
{ from: /[ĶΚК]+/gi, to: "K" },
|
|
270
|
+
{ from: /[ķκк]+/gi, to: "k" },
|
|
271
|
+
{ from: /[ĹĻĽĿŁΛЛ]+/gi, to: "L" },
|
|
272
|
+
{ from: /[ĺļľŀłλл]+/gi, to: "l" },
|
|
273
|
+
{ from: /[М]+/gi, to: "M" },
|
|
274
|
+
{ from: /[м]+/gi, to: "m" },
|
|
275
|
+
{ from: /[ÑŃŅŇΝН]+/gi, to: "N" },
|
|
276
|
+
{ from: /[ñńņňʼnνн]+/gi, to: "n" },
|
|
277
|
+
{ from: /[ÒÓÔÕŌŎǑŐƠØǾΟΌΩΏỎỌỒỐỖỔỘỜỚỠỞỢО]+/gi, to: "O" },
|
|
278
|
+
{ from: /[òóôõōŏǒőơøǿºοόωώỏọồốỗổộờớỡởợо]+/gi, to: "o" },
|
|
279
|
+
{ from: /[П]+/gi, to: "P" },
|
|
280
|
+
{ from: /[п]+/gi, to: "p" },
|
|
281
|
+
{ from: /[ŔŖŘΡР]+/gi, to: "R" },
|
|
282
|
+
{ from: /[ŕŗřρр]+/gi, to: "r" },
|
|
283
|
+
{ from: /[ŚŜŞȘŠΣС]+/gi, to: "S" },
|
|
284
|
+
{ from: /[śŝşșšſσςс]+/gi, to: "s" },
|
|
285
|
+
{ from: /[ȚŢŤŦτТ]+/gi, to: "T" },
|
|
286
|
+
{ from: /[țţťŧт]+/gi, to: "t" },
|
|
287
|
+
{ from: /[ÙÚÛŨŪŬŮŰŲƯǓǕǗǙǛŨỦỤỪỨỮỬỰУ]+/gi, to: "U" },
|
|
288
|
+
{ from: /[ùúûũūŭůűųưǔǖǘǚǜυύϋủụừứữửựу]+/gi, to: "u" },
|
|
289
|
+
{ from: /[ÝŸŶΥΎΫỲỸỶỴЙ]+/gi, to: "Y" },
|
|
290
|
+
{ from: /[ýÿŷỳỹỷỵй]+/gi, to: "y" },
|
|
291
|
+
{ from: /[В]+/gi, to: "V" },
|
|
292
|
+
{ from: /[в]+/gi, to: "v" },
|
|
293
|
+
{ from: /[Ŵ]+/gi, to: "W" },
|
|
294
|
+
{ from: /[ŵ]+/gi, to: "w" },
|
|
295
|
+
{ from: /[ŹŻŽΖЗ]+/gi, to: "Z" },
|
|
296
|
+
{ from: /[źżžζз]+/gi, to: "z" },
|
|
297
|
+
{ from: /[ÆǼ]+/gi, to: "AE" },
|
|
298
|
+
{ from: /[ß]+/gi, to: "ss" },
|
|
299
|
+
{ from: /[IJ]+/gi, to: "IJ" },
|
|
300
|
+
{ from: /[ij]+/gi, to: "ij" },
|
|
301
|
+
{ from: /[Œ]+/gi, to: "OE" },
|
|
302
|
+
{ from: /[ƒ]+/gi, to: "f" },
|
|
303
|
+
{ from: /[ξ]+/gi, to: "ks" },
|
|
304
|
+
{ from: /[π]+/gi, to: "p" },
|
|
305
|
+
{ from: /[β]+/gi, to: "v" },
|
|
306
|
+
{ from: /[μ]+/gi, to: "m" },
|
|
307
|
+
{ from: /[ψ]+/gi, to: "ps" },
|
|
308
|
+
{ from: /[Ё]+/gi, to: "Yo" },
|
|
309
|
+
{ from: /[ё]+/gi, to: "yo" },
|
|
310
|
+
{ from: /[Є]+/gi, to: "Ye" },
|
|
311
|
+
{ from: /[є]+/gi, to: "ye" },
|
|
312
|
+
{ from: /[Ї]+/gi, to: "Yi" },
|
|
313
|
+
{ from: /[Ж]+/gi, to: "Zh" },
|
|
314
|
+
{ from: /[ж]+/gi, to: "zh" },
|
|
315
|
+
{ from: /[Х]+/gi, to: "Kh" },
|
|
316
|
+
{ from: /[х]+/gi, to: "kh" },
|
|
317
|
+
{ from: /[Ц]+/gi, to: "Ts" },
|
|
318
|
+
{ from: /[ц]+/gi, to: "ts" },
|
|
319
|
+
{ from: /[Ч]+/gi, to: "Ch" },
|
|
320
|
+
{ from: /[ч]+/gi, to: "ch" },
|
|
321
|
+
{ from: /[Ш]+/gi, to: "Sh" },
|
|
322
|
+
{ from: /[ш]+/gi, to: "sh" },
|
|
323
|
+
{ from: /[Щ]+/gi, to: "Shch" },
|
|
324
|
+
{ from: /[щ]+/gi, to: "shch" },
|
|
325
|
+
{ from: /[ЪъЬь]+/gi, to: "" },
|
|
326
|
+
{ from: /[Ю]+/gi, to: "Yu" },
|
|
327
|
+
{ from: /[ю]+/gi, to: "yu" },
|
|
328
|
+
{ from: /[Я]+/gi, to: "Ya" },
|
|
329
|
+
{ from: /[я]+/gi, to: "ya" }
|
|
330
|
+
];
|
|
331
|
+
const alphanumericExpression = /[^a-zA-Z0-9]+/g;
|
|
332
|
+
const trailingDashExpression = /[-]$/;
|
|
333
|
+
let parsed = url;
|
|
334
|
+
for (const i in replacements) {
|
|
335
|
+
if (replacements.hasOwnProperty(i) && replacements[i].from.test(url)) {
|
|
336
|
+
parsed = parsed.replace(replacements[i].from, replacements[i].to);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
parsed = parsed.replace(alphanumericExpression, "-");
|
|
340
|
+
parsed = parsed.replace(trailingDashExpression, "");
|
|
341
|
+
parsed = parsed.toLowerCase();
|
|
342
|
+
return parsed || "humany";
|
|
343
|
+
};
|
|
344
|
+
function childParentStructure(items, structure = {}, parent) {
|
|
345
|
+
items.forEach((item) => {
|
|
346
|
+
if (parent) {
|
|
347
|
+
structure[+item.id] = parent;
|
|
348
|
+
}
|
|
349
|
+
if (item.items) {
|
|
350
|
+
childParentStructure(item.items, structure, item.id);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
return structure;
|
|
354
|
+
}
|
|
355
|
+
function categoryTrail(id, items, ids = [id], structure = childParentStructure(items)) {
|
|
356
|
+
const addAncestors = (id2) => {
|
|
357
|
+
const parentId2 = structure[+id2];
|
|
358
|
+
if (parentId2) {
|
|
359
|
+
ids.unshift(parentId2);
|
|
360
|
+
addAncestors(parentId2);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
const parentId = structure[+id];
|
|
364
|
+
if (parentId) {
|
|
365
|
+
ids.unshift(parentId);
|
|
366
|
+
addAncestors(parentId);
|
|
367
|
+
}
|
|
368
|
+
return ids;
|
|
369
|
+
}
|
|
370
|
+
const getCategoryTrailAsObjects = (trail, categories) => {
|
|
371
|
+
if (typeof trail === "undefined" || typeof categories === "undefined") {
|
|
372
|
+
return /* @__PURE__ */ new Map();
|
|
373
|
+
}
|
|
374
|
+
return new Map(trail.map((categoryId) => {
|
|
375
|
+
const category = findCategoryById(categoryId, categories);
|
|
376
|
+
return [categoryId, category];
|
|
377
|
+
}));
|
|
378
|
+
};
|
|
379
|
+
const buildCategoryTrail = (routeName, categoryIds, container, dataType = "guide-categories") => {
|
|
380
|
+
return container.getAsync("dataClient").then((dataClient) => {
|
|
381
|
+
return dataClient.fetch(dataType, { expandCategories: "descendants" }).then(({ categories }) => {
|
|
382
|
+
const buildTrail = (id) => {
|
|
383
|
+
const trail = categoryTrail(id, categories);
|
|
384
|
+
const objectTrail = getCategoryTrailAsObjects(trail, categories);
|
|
385
|
+
const result = [];
|
|
386
|
+
trail.forEach((categoryId) => {
|
|
387
|
+
const category = objectTrail.get(categoryId);
|
|
388
|
+
if (category) {
|
|
389
|
+
result.push({
|
|
390
|
+
routeName,
|
|
391
|
+
title: category.title,
|
|
392
|
+
symbol: category.symbol,
|
|
393
|
+
id: category.id,
|
|
394
|
+
routeParams: dataType === "contact-method-categories" ? createParams({
|
|
395
|
+
contactCategory: category.id,
|
|
396
|
+
uriName: formatUrl(category.title)
|
|
397
|
+
}) : createParams({
|
|
398
|
+
guideCategory: category.id,
|
|
399
|
+
uriName: formatUrl(category.title)
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
return result;
|
|
405
|
+
};
|
|
406
|
+
if (Array.isArray(categoryIds)) {
|
|
407
|
+
return categoryIds.reduce((acc, id) => {
|
|
408
|
+
const result = buildTrail(id);
|
|
409
|
+
if (result.length > 0) {
|
|
410
|
+
acc.push(result);
|
|
411
|
+
}
|
|
412
|
+
return acc;
|
|
413
|
+
}, []);
|
|
414
|
+
}
|
|
415
|
+
return buildTrail(categoryIds);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
const dataURItoBlob = (dataURI) => {
|
|
420
|
+
let byteString;
|
|
421
|
+
let mimestring;
|
|
422
|
+
if (dataURI.split(",")[0].indexOf("base64") !== -1) {
|
|
423
|
+
byteString = atob(dataURI.split(",")[1]);
|
|
424
|
+
} else {
|
|
425
|
+
byteString = decodeURI(dataURI.split(",")[1]);
|
|
426
|
+
}
|
|
427
|
+
mimestring = dataURI.split(",")[0].split(":")[1].split(";")[0];
|
|
428
|
+
const content = [];
|
|
429
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
430
|
+
content[i] = byteString.charCodeAt(i);
|
|
431
|
+
}
|
|
432
|
+
return new Blob([new Uint8Array(content)], { type: mimestring });
|
|
433
|
+
};
|
|
434
|
+
function debugLog(...args) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
const print = (print2, msgOrObj, ...args) => {
|
|
438
|
+
if (typeof msgOrObj === "string") {
|
|
439
|
+
return print2(`[humany] ${msgOrObj}`, ...args);
|
|
440
|
+
}
|
|
441
|
+
return print2(msgOrObj, ...args);
|
|
442
|
+
};
|
|
443
|
+
const _Logger = class {
|
|
444
|
+
constructor() {
|
|
445
|
+
this.keys = [];
|
|
446
|
+
this.log = (key, ...args) => this.lookup(key, () => _Logger.log(...args));
|
|
447
|
+
this.warn = (key, ...args) => this.lookup(key, () => _Logger.warn(...args));
|
|
448
|
+
this.error = (key, ...args) => this.lookup(key, () => _Logger.error(...args));
|
|
449
|
+
this.info = (key, ...args) => this.lookup(key, () => _Logger.info(...args));
|
|
450
|
+
}
|
|
451
|
+
lookup(key, fn) {
|
|
452
|
+
if (this.keys.indexOf(key) === -1) {
|
|
453
|
+
this.keys.push(key);
|
|
454
|
+
fn();
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
let Logger = _Logger;
|
|
459
|
+
Logger.log = (...args) => print(console.log, ...args);
|
|
460
|
+
Logger.warn = (...args) => print(console.warn, ...args);
|
|
461
|
+
Logger.error = (...args) => print(console.error, ...args);
|
|
462
|
+
Logger.info = (...args) => print(console.info, ...args);
|
|
463
|
+
const deepClone = (data) => {
|
|
464
|
+
let out = {};
|
|
465
|
+
let value;
|
|
466
|
+
let key;
|
|
467
|
+
if (typeof data !== "object" || data === null) {
|
|
468
|
+
return data;
|
|
469
|
+
}
|
|
470
|
+
out = Array.isArray(data) ? [] : {};
|
|
471
|
+
for (key in data) {
|
|
472
|
+
value = data[key];
|
|
473
|
+
out[key] = typeof value === "object" && value !== null ? deepClone(value) : value;
|
|
474
|
+
}
|
|
475
|
+
return out;
|
|
476
|
+
};
|
|
477
|
+
var findAndActivateStoredWidgets = (implementation) => {
|
|
478
|
+
if (!implementation) {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
const implementationStorage = localStorage.getItem(`humany_${hash(implementation.tenant + implementation.name)}`);
|
|
482
|
+
if (implementationStorage) {
|
|
483
|
+
const { activeStickyWidget } = JSON.parse(implementationStorage);
|
|
484
|
+
if (activeStickyWidget && activeStickyWidget.value) {
|
|
485
|
+
const widget = implementation.widgets.get(activeStickyWidget.value);
|
|
486
|
+
if (widget) {
|
|
487
|
+
const el = document.createElement("a");
|
|
488
|
+
el.setAttribute("href", `//${implementation.bindings[0]}/${activeStickyWidget.value}`);
|
|
489
|
+
document.body.appendChild(el);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
var formatDate = (date, includeTime = false) => {
|
|
495
|
+
const d = new Date(date);
|
|
496
|
+
let month = `${d.getMonth() + 1}`;
|
|
497
|
+
let day = `${d.getDate()}`;
|
|
498
|
+
const year = d.getFullYear();
|
|
499
|
+
if (month.length < 2)
|
|
500
|
+
month = `0${month}`;
|
|
501
|
+
if (day.length < 2)
|
|
502
|
+
day = `0${day}`;
|
|
503
|
+
if (includeTime) {
|
|
504
|
+
let hours = `${d.getHours()}`;
|
|
505
|
+
let minutes = `${d.getMinutes()}`;
|
|
506
|
+
if (hours.length < 2)
|
|
507
|
+
hours = `0${hours}`;
|
|
508
|
+
if (minutes.length < 2)
|
|
509
|
+
minutes = `0${minutes}`;
|
|
510
|
+
return `${[year, month, day].join("-")} ${[hours, minutes].join(":")}`;
|
|
511
|
+
}
|
|
512
|
+
return [year, month, day].join("-");
|
|
513
|
+
};
|
|
514
|
+
function getCookie(cookieName) {
|
|
515
|
+
const documentCookie = document.cookie;
|
|
516
|
+
if (documentCookie.length > 0) {
|
|
517
|
+
let start = documentCookie.indexOf(`${cookieName}=`);
|
|
518
|
+
if (start !== -1) {
|
|
519
|
+
start = start + cookieName.length + 1;
|
|
520
|
+
let end = documentCookie.indexOf(";", start);
|
|
521
|
+
if (end === -1) {
|
|
522
|
+
end = documentCookie.length;
|
|
523
|
+
}
|
|
524
|
+
return unescape(documentCookie.substring(start, end));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
function hash(s) {
|
|
530
|
+
let hash2 = 0;
|
|
531
|
+
if (s.length === 0) {
|
|
532
|
+
return hash2.toString();
|
|
533
|
+
}
|
|
534
|
+
for (let i = 0; i < s.length; i++) {
|
|
535
|
+
const char = s.charCodeAt(i);
|
|
536
|
+
hash2 = (hash2 << 5) - hash2 + char;
|
|
537
|
+
hash2 = hash2 & hash2;
|
|
538
|
+
}
|
|
539
|
+
return hash2.toString();
|
|
540
|
+
}
|
|
541
|
+
var htmlParentContains = (parent, child) => {
|
|
542
|
+
if (!parent || !child) {
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
let node = child.parentNode;
|
|
546
|
+
let hasChild = false;
|
|
547
|
+
while (node !== null) {
|
|
548
|
+
if (node === parent) {
|
|
549
|
+
hasChild = true;
|
|
550
|
+
}
|
|
551
|
+
node = node.parentNode;
|
|
552
|
+
}
|
|
553
|
+
return hasChild;
|
|
554
|
+
};
|
|
555
|
+
function kebabCase(string) {
|
|
556
|
+
return string.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\s+/g, "-").toLowerCase();
|
|
557
|
+
}
|
|
558
|
+
class Queue {
|
|
559
|
+
constructor(lockWarningTime, lockErrorTime) {
|
|
560
|
+
this.lockWarningTime = lockWarningTime;
|
|
561
|
+
this.lockErrorTime = lockErrorTime;
|
|
562
|
+
this.tasks = [];
|
|
563
|
+
this.current = Promise.resolve();
|
|
564
|
+
this.next = this.next.bind(this);
|
|
565
|
+
}
|
|
566
|
+
add(task, resolve, reject, done) {
|
|
567
|
+
this.tasks.push({ task, resolve, reject, done });
|
|
568
|
+
this.next();
|
|
569
|
+
}
|
|
570
|
+
next() {
|
|
571
|
+
this.current = this.current.then(() => {
|
|
572
|
+
const next = this.tasks.shift();
|
|
573
|
+
if (next) {
|
|
574
|
+
let errorTimeout;
|
|
575
|
+
const warningTimeout = setTimeout(() => {
|
|
576
|
+
errorTimeout = setTimeout(() => {
|
|
577
|
+
next.reject("lock timeout exceeded");
|
|
578
|
+
}, this.lockErrorTime);
|
|
579
|
+
}, this.lockWarningTime);
|
|
580
|
+
const taskPromise = Promise.resolve(next.task()).then((result) => {
|
|
581
|
+
clearTimeout(warningTimeout);
|
|
582
|
+
clearTimeout(errorTimeout);
|
|
583
|
+
return result;
|
|
584
|
+
});
|
|
585
|
+
return Promise.resolve(taskPromise).then(this.next).then(() => taskPromise.then((data) => {
|
|
586
|
+
next.done();
|
|
587
|
+
next.resolve(data);
|
|
588
|
+
})).catch((reason) => {
|
|
589
|
+
next.done();
|
|
590
|
+
next.reject(reason);
|
|
591
|
+
return this.next();
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
return Promise.resolve();
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const locks = /* @__PURE__ */ new WeakMap();
|
|
599
|
+
function lock(key, lockWarningTime = 5e3, lockErrorTime = 1e3) {
|
|
600
|
+
if (!locks.has(key)) {
|
|
601
|
+
locks.set(key, new Queue(lockWarningTime, lockErrorTime));
|
|
602
|
+
}
|
|
603
|
+
return (task) => {
|
|
604
|
+
return new Promise((resolve, reject) => {
|
|
605
|
+
const queue = locks.get(key);
|
|
606
|
+
queue.add(task, resolve, reject, () => {
|
|
607
|
+
if (!queue.tasks.length) {
|
|
608
|
+
locks.delete(key);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
const isObject = (item) => {
|
|
615
|
+
return !!item && typeof item === "object" && !Array.isArray(item);
|
|
616
|
+
};
|
|
617
|
+
const mergeDeep = (target, ...sources) => {
|
|
618
|
+
const clonedTarget = deepClone(target);
|
|
619
|
+
const clonedSources = deepClone(sources);
|
|
620
|
+
return mergeDeepRecursive(clonedTarget, ...clonedSources);
|
|
621
|
+
};
|
|
622
|
+
const mergeDeepRecursive = (target, ...sources) => {
|
|
623
|
+
if (!sources.length)
|
|
624
|
+
return target;
|
|
625
|
+
const source = sources.shift();
|
|
626
|
+
if (isObject(target) && isObject(source)) {
|
|
627
|
+
for (const key in source) {
|
|
628
|
+
if (isObject(source[key])) {
|
|
629
|
+
if (!target[key])
|
|
630
|
+
Object.assign(target, { [key]: {} });
|
|
631
|
+
mergeDeepRecursive(target[key], source[key]);
|
|
632
|
+
} else {
|
|
633
|
+
Object.assign(target, { [key]: source[key] });
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return mergeDeepRecursive(target, ...sources);
|
|
638
|
+
};
|
|
639
|
+
const watchForLoadingComplete = (container, widgetDOMElement) => {
|
|
640
|
+
const isLoading = () => widgetDOMElement.querySelectorAll("[data-loading=true]").length > 0;
|
|
641
|
+
const complete = () => {
|
|
642
|
+
let dispatched = false;
|
|
643
|
+
return () => {
|
|
644
|
+
if (dispatched) {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
const widget = container.get("$widget");
|
|
648
|
+
widget.events.dispatch("widget:data-loaded", {
|
|
649
|
+
element: widgetDOMElement
|
|
650
|
+
});
|
|
651
|
+
dispatched = true;
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
const handleComplete = complete();
|
|
655
|
+
if (!isLoading()) {
|
|
656
|
+
return handleComplete();
|
|
657
|
+
}
|
|
658
|
+
const observer = new MutationObserver((mutations, observer2) => {
|
|
659
|
+
const check = mutations.find((mutation) => mutation.type === "attributes" && mutation.attributeName === "data-loading");
|
|
660
|
+
if (check && !isLoading()) {
|
|
661
|
+
observer2.disconnect();
|
|
662
|
+
handleComplete();
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
observer.observe(widgetDOMElement, {
|
|
666
|
+
attributes: true,
|
|
667
|
+
childList: true,
|
|
668
|
+
subtree: true
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
const notifyDataLoaded = (viewOutletContainer, widgetDOMElement) => {
|
|
672
|
+
const widget = viewOutletContainer.get("$widget");
|
|
673
|
+
widget.container.getAsync("components").then((components) => {
|
|
674
|
+
components.events.subscribeOnce("components:component-model-initialized", () => {
|
|
675
|
+
let waitingFor = components.nodes.visible.reduce((acc, node) => {
|
|
676
|
+
if (!node.name || !node.type || node.type === "view" || node.type === "root" || node.attributes.layout.size === "none" || widgetDOMElement.querySelector(`[data-name="${node.name}"]`)) {
|
|
677
|
+
return acc;
|
|
678
|
+
}
|
|
679
|
+
acc.push(node.name);
|
|
680
|
+
return acc;
|
|
681
|
+
}, []);
|
|
682
|
+
let complete = false;
|
|
683
|
+
const observer = new MutationObserver((mutations, observer2) => {
|
|
684
|
+
mutations.forEach((mutation) => {
|
|
685
|
+
if (mutation.addedNodes) {
|
|
686
|
+
const componentElements = Array.from(mutation.addedNodes).reduce((acc, element) => {
|
|
687
|
+
const dataName = element.getAttribute && element.getAttribute("data-name");
|
|
688
|
+
if (dataName && waitingFor.indexOf(dataName) > -1) {
|
|
689
|
+
acc.push(dataName);
|
|
690
|
+
}
|
|
691
|
+
return acc;
|
|
692
|
+
}, []);
|
|
693
|
+
waitingFor = waitingFor.filter((name) => {
|
|
694
|
+
return componentElements.indexOf(name) === -1;
|
|
695
|
+
});
|
|
696
|
+
if (!complete && waitingFor.length === 0) {
|
|
697
|
+
complete = true;
|
|
698
|
+
watchForLoadingComplete(viewOutletContainer, widgetDOMElement);
|
|
699
|
+
observer2.disconnect();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
observer.observe(widgetDOMElement, {
|
|
705
|
+
attributes: false,
|
|
706
|
+
characterData: false,
|
|
707
|
+
childList: true,
|
|
708
|
+
subtree: true,
|
|
709
|
+
attributeOldValue: false,
|
|
710
|
+
characterDataOldValue: false
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
const removeNullAndUndefinedValues = (object = {}) => {
|
|
716
|
+
Object.keys(object).forEach((key) => {
|
|
717
|
+
if (object[key] === null || typeof object[key] === "undefined") {
|
|
718
|
+
delete object[key];
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
return object;
|
|
722
|
+
};
|
|
723
|
+
function setCookie(cookieName, value, days) {
|
|
724
|
+
let expires = "";
|
|
725
|
+
if (days) {
|
|
726
|
+
const date = new Date();
|
|
727
|
+
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
|
|
728
|
+
expires = `; expires=${date.toUTCString()}`;
|
|
729
|
+
}
|
|
730
|
+
document.cookie = `${cookieName}=${value}${expires}; path=/`;
|
|
731
|
+
}
|
|
732
|
+
var shallowCompare = (a, b) => {
|
|
733
|
+
let equal = true;
|
|
734
|
+
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
const missingKey = Object.keys(a).some((key) => {
|
|
738
|
+
const found = Object.keys(b).some((bKey) => {
|
|
739
|
+
return key === bKey;
|
|
740
|
+
});
|
|
741
|
+
return !found;
|
|
742
|
+
});
|
|
743
|
+
if (missingKey) {
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
Object.keys(a).forEach((key) => {
|
|
747
|
+
if (equal) {
|
|
748
|
+
const c = typeof a[key] === "undefined" ? "" : a[key];
|
|
749
|
+
const d = typeof b[key] === "undefined" ? "" : b[key];
|
|
750
|
+
equal = c.toString() === d.toString();
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
return equal;
|
|
754
|
+
};
|
|
755
|
+
const s4 = () => {
|
|
756
|
+
return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
757
|
+
};
|
|
758
|
+
function uuid() {
|
|
759
|
+
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
|
|
760
|
+
}
|
|
761
|
+
class WaitFor {
|
|
762
|
+
constructor(options) {
|
|
763
|
+
this.queue = [];
|
|
764
|
+
this.queueAttemptCalls = 0;
|
|
765
|
+
this.callCount = 5;
|
|
766
|
+
this.add = (action) => {
|
|
767
|
+
this.queue.push(action);
|
|
768
|
+
this.queueAttempt = setInterval(this.processQueue, 1e3);
|
|
769
|
+
};
|
|
770
|
+
this.processQueue = () => {
|
|
771
|
+
if (this.queue.length > 0) {
|
|
772
|
+
const indexOfActionsEmitted = [];
|
|
773
|
+
this.queue.forEach((queuedAction, index) => {
|
|
774
|
+
const evaluate = queuedAction();
|
|
775
|
+
if (typeof evaluate === "function") {
|
|
776
|
+
evaluate();
|
|
777
|
+
indexOfActionsEmitted.push(index);
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
this.queue = this.queue.filter((_, index) => {
|
|
781
|
+
if (indexOfActionsEmitted.indexOf(index) > -1) {
|
|
782
|
+
return false;
|
|
783
|
+
}
|
|
784
|
+
return true;
|
|
785
|
+
});
|
|
786
|
+
if (this.queueAttempt) {
|
|
787
|
+
clearInterval(this.queueAttempt);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (this.queueAttemptCalls > this.callCount) {
|
|
791
|
+
clearInterval(this.queueAttempt);
|
|
792
|
+
this.queueAttemptCalls = 0;
|
|
793
|
+
}
|
|
794
|
+
this.queueAttemptCalls = this.queueAttemptCalls + 1;
|
|
795
|
+
};
|
|
796
|
+
if (options && options.callCount) {
|
|
797
|
+
this.callCount = options.callCount;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
export { Logger, WaitFor, appendClassNames, buildCategoryTrail, camilize, categoryTrail, createBatch, createParams, dataURItoBlob, debugLog, deepClone, findAndActivateStoredWidgets, findCategoryById, formatDate, formatUrl, getCategoryTrailAsObjects, getCookie, hash, htmlParentContains, kebabCase, lock, mergeDeep, notifyDataLoaded, removeNullAndUndefinedValues, setCookie, shallowCompare, uuid };
|
|
802
|
+
//# sourceMappingURL=index.js.map
|