@telia-ace/knowledge-widget-plugins 1.1.1-rc.1 → 1.1.1-rc.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.
@@ -1,883 +0,0 @@
1
- var p = typeof globalThis < "u" && globalThis || typeof self < "u" && self || // eslint-disable-next-line no-undef
2
- typeof global < "u" && global || {}, b = {
3
- searchParams: "URLSearchParams" in p,
4
- iterable: "Symbol" in p && "iterator" in Symbol,
5
- blob: "FileReader" in p && "Blob" in p && function() {
6
- try {
7
- return new Blob(), !0;
8
- } catch {
9
- return !1;
10
- }
11
- }(),
12
- formData: "FormData" in p,
13
- arrayBuffer: "ArrayBuffer" in p
14
- };
15
- function ee(t) {
16
- return t && DataView.prototype.isPrototypeOf(t);
17
- }
18
- if (b.arrayBuffer)
19
- var te = [
20
- "[object Int8Array]",
21
- "[object Uint8Array]",
22
- "[object Uint8ClampedArray]",
23
- "[object Int16Array]",
24
- "[object Uint16Array]",
25
- "[object Int32Array]",
26
- "[object Uint32Array]",
27
- "[object Float32Array]",
28
- "[object Float64Array]"
29
- ], re = ArrayBuffer.isView || function(t) {
30
- return t && te.indexOf(Object.prototype.toString.call(t)) > -1;
31
- };
32
- function I(t) {
33
- if (typeof t != "string" && (t = String(t)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t) || t === "")
34
- throw new TypeError('Invalid character in header field name: "' + t + '"');
35
- return t.toLowerCase();
36
- }
37
- function F(t) {
38
- return typeof t != "string" && (t = String(t)), t;
39
- }
40
- function M(t) {
41
- var e = {
42
- next: function() {
43
- var r = t.shift();
44
- return { done: r === void 0, value: r };
45
- }
46
- };
47
- return b.iterable && (e[Symbol.iterator] = function() {
48
- return e;
49
- }), e;
50
- }
51
- function d(t) {
52
- this.map = {}, t instanceof d ? t.forEach(function(e, r) {
53
- this.append(r, e);
54
- }, this) : Array.isArray(t) ? t.forEach(function(e) {
55
- if (e.length != 2)
56
- throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + e.length);
57
- this.append(e[0], e[1]);
58
- }, this) : t && Object.getOwnPropertyNames(t).forEach(function(e) {
59
- this.append(e, t[e]);
60
- }, this);
61
- }
62
- d.prototype.append = function(t, e) {
63
- t = I(t), e = F(e);
64
- var r = this.map[t];
65
- this.map[t] = r ? r + ", " + e : e;
66
- };
67
- d.prototype.delete = function(t) {
68
- delete this.map[I(t)];
69
- };
70
- d.prototype.get = function(t) {
71
- return t = I(t), this.has(t) ? this.map[t] : null;
72
- };
73
- d.prototype.has = function(t) {
74
- return this.map.hasOwnProperty(I(t));
75
- };
76
- d.prototype.set = function(t, e) {
77
- this.map[I(t)] = F(e);
78
- };
79
- d.prototype.forEach = function(t, e) {
80
- for (var r in this.map)
81
- this.map.hasOwnProperty(r) && t.call(e, this.map[r], r, this);
82
- };
83
- d.prototype.keys = function() {
84
- var t = [];
85
- return this.forEach(function(e, r) {
86
- t.push(r);
87
- }), M(t);
88
- };
89
- d.prototype.values = function() {
90
- var t = [];
91
- return this.forEach(function(e) {
92
- t.push(e);
93
- }), M(t);
94
- };
95
- d.prototype.entries = function() {
96
- var t = [];
97
- return this.forEach(function(e, r) {
98
- t.push([r, e]);
99
- }), M(t);
100
- };
101
- b.iterable && (d.prototype[Symbol.iterator] = d.prototype.entries);
102
- function q(t) {
103
- if (!t._noBody) {
104
- if (t.bodyUsed)
105
- return Promise.reject(new TypeError("Already read"));
106
- t.bodyUsed = !0;
107
- }
108
- }
109
- function W(t) {
110
- return new Promise(function(e, r) {
111
- t.onload = function() {
112
- e(t.result);
113
- }, t.onerror = function() {
114
- r(t.error);
115
- };
116
- });
117
- }
118
- function ne(t) {
119
- var e = new FileReader(), r = W(e);
120
- return e.readAsArrayBuffer(t), r;
121
- }
122
- function se(t) {
123
- var e = new FileReader(), r = W(e), n = /charset=([A-Za-z0-9_-]+)/.exec(t.type), o = n ? n[1] : "utf-8";
124
- return e.readAsText(t, o), r;
125
- }
126
- function oe(t) {
127
- for (var e = new Uint8Array(t), r = new Array(e.length), n = 0; n < e.length; n++)
128
- r[n] = String.fromCharCode(e[n]);
129
- return r.join("");
130
- }
131
- function V(t) {
132
- if (t.slice)
133
- return t.slice(0);
134
- var e = new Uint8Array(t.byteLength);
135
- return e.set(new Uint8Array(t)), e.buffer;
136
- }
137
- function K() {
138
- return this.bodyUsed = !1, this._initBody = function(t) {
139
- this.bodyUsed = this.bodyUsed, this._bodyInit = t, t ? typeof t == "string" ? this._bodyText = t : b.blob && Blob.prototype.isPrototypeOf(t) ? this._bodyBlob = t : b.formData && FormData.prototype.isPrototypeOf(t) ? this._bodyFormData = t : b.searchParams && URLSearchParams.prototype.isPrototypeOf(t) ? this._bodyText = t.toString() : b.arrayBuffer && b.blob && ee(t) ? (this._bodyArrayBuffer = V(t.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : b.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(t) || re(t)) ? this._bodyArrayBuffer = V(t) : this._bodyText = t = Object.prototype.toString.call(t) : (this._noBody = !0, this._bodyText = ""), this.headers.get("content-type") || (typeof t == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : b.searchParams && URLSearchParams.prototype.isPrototypeOf(t) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
140
- }, b.blob && (this.blob = function() {
141
- var t = q(this);
142
- if (t)
143
- return t;
144
- if (this._bodyBlob)
145
- return Promise.resolve(this._bodyBlob);
146
- if (this._bodyArrayBuffer)
147
- return Promise.resolve(new Blob([this._bodyArrayBuffer]));
148
- if (this._bodyFormData)
149
- throw new Error("could not read FormData body as blob");
150
- return Promise.resolve(new Blob([this._bodyText]));
151
- }), this.arrayBuffer = function() {
152
- if (this._bodyArrayBuffer) {
153
- var t = q(this);
154
- return t || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
155
- this._bodyArrayBuffer.buffer.slice(
156
- this._bodyArrayBuffer.byteOffset,
157
- this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
158
- )
159
- ) : Promise.resolve(this._bodyArrayBuffer));
160
- } else {
161
- if (b.blob)
162
- return this.blob().then(ne);
163
- throw new Error("could not read as ArrayBuffer");
164
- }
165
- }, this.text = function() {
166
- var t = q(this);
167
- if (t)
168
- return t;
169
- if (this._bodyBlob)
170
- return se(this._bodyBlob);
171
- if (this._bodyArrayBuffer)
172
- return Promise.resolve(oe(this._bodyArrayBuffer));
173
- if (this._bodyFormData)
174
- throw new Error("could not read FormData body as text");
175
- return Promise.resolve(this._bodyText);
176
- }, b.formData && (this.formData = function() {
177
- return this.text().then(ce);
178
- }), this.json = function() {
179
- return this.text().then(JSON.parse);
180
- }, this;
181
- }
182
- var ie = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
183
- function ae(t) {
184
- var e = t.toUpperCase();
185
- return ie.indexOf(e) > -1 ? e : t;
186
- }
187
- function j(t, e) {
188
- if (!(this instanceof j))
189
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
190
- e = e || {};
191
- var r = e.body;
192
- if (t instanceof j) {
193
- if (t.bodyUsed)
194
- throw new TypeError("Already read");
195
- this.url = t.url, this.credentials = t.credentials, e.headers || (this.headers = new d(t.headers)), this.method = t.method, this.mode = t.mode, this.signal = t.signal, !r && t._bodyInit != null && (r = t._bodyInit, t.bodyUsed = !0);
196
- } else
197
- this.url = String(t);
198
- if (this.credentials = e.credentials || this.credentials || "same-origin", (e.headers || !this.headers) && (this.headers = new d(e.headers)), this.method = ae(e.method || this.method || "GET"), this.mode = e.mode || this.mode || null, this.signal = e.signal || this.signal || function() {
199
- if ("AbortController" in p) {
200
- var s = new AbortController();
201
- return s.signal;
202
- }
203
- }(), this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
204
- throw new TypeError("Body not allowed for GET or HEAD requests");
205
- if (this._initBody(r), (this.method === "GET" || this.method === "HEAD") && (e.cache === "no-store" || e.cache === "no-cache")) {
206
- var n = /([?&])_=[^&]*/;
207
- if (n.test(this.url))
208
- this.url = this.url.replace(n, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
209
- else {
210
- var o = /\?/;
211
- this.url += (o.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
212
- }
213
- }
214
- }
215
- j.prototype.clone = function() {
216
- return new j(this, { body: this._bodyInit });
217
- };
218
- function ce(t) {
219
- var e = new FormData();
220
- return t.trim().split("&").forEach(function(r) {
221
- if (r) {
222
- var n = r.split("="), o = n.shift().replace(/\+/g, " "), s = n.join("=").replace(/\+/g, " ");
223
- e.append(decodeURIComponent(o), decodeURIComponent(s));
224
- }
225
- }), e;
226
- }
227
- function he(t) {
228
- var e = new d(), r = t.replace(/\r?\n[\t ]+/g, " ");
229
- return r.split("\r").map(function(n) {
230
- return n.indexOf(`
231
- `) === 0 ? n.substr(1, n.length) : n;
232
- }).forEach(function(n) {
233
- var o = n.split(":"), s = o.shift().trim();
234
- if (s) {
235
- var a = o.join(":").trim();
236
- try {
237
- e.append(s, a);
238
- } catch (c) {
239
- console.warn("Response " + c.message);
240
- }
241
- }
242
- }), e;
243
- }
244
- K.call(j.prototype);
245
- function P(t, e) {
246
- if (!(this instanceof P))
247
- throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
248
- if (e || (e = {}), this.type = "default", this.status = e.status === void 0 ? 200 : e.status, this.status < 200 || this.status > 599)
249
- throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
250
- this.ok = this.status >= 200 && this.status < 300, this.statusText = e.statusText === void 0 ? "" : "" + e.statusText, this.headers = new d(e.headers), this.url = e.url || "", this._initBody(t);
251
- }
252
- K.call(P.prototype);
253
- P.prototype.clone = function() {
254
- return new P(this._bodyInit, {
255
- status: this.status,
256
- statusText: this.statusText,
257
- headers: new d(this.headers),
258
- url: this.url
259
- });
260
- };
261
- P.error = function() {
262
- var t = new P(null, { status: 200, statusText: "" });
263
- return t.status = 0, t.type = "error", t;
264
- };
265
- var ue = [301, 302, 303, 307, 308];
266
- P.redirect = function(t, e) {
267
- if (ue.indexOf(e) === -1)
268
- throw new RangeError("Invalid status code");
269
- return new P(null, { status: e, headers: { location: t } });
270
- };
271
- var A = p.DOMException;
272
- try {
273
- new A();
274
- } catch {
275
- A = function(e, r) {
276
- this.message = e, this.name = r;
277
- var n = Error(e);
278
- this.stack = n.stack;
279
- }, A.prototype = Object.create(Error.prototype), A.prototype.constructor = A;
280
- }
281
- function Y(t, e) {
282
- return new Promise(function(r, n) {
283
- var o = new j(t, e);
284
- if (o.signal && o.signal.aborted)
285
- return n(new A("Aborted", "AbortError"));
286
- var s = new XMLHttpRequest();
287
- function a() {
288
- s.abort();
289
- }
290
- s.onload = function() {
291
- var i = {
292
- statusText: s.statusText,
293
- headers: he(s.getAllResponseHeaders() || "")
294
- };
295
- o.url.startsWith("file://") && (s.status < 200 || s.status > 599) ? i.status = 200 : i.status = s.status, i.url = "responseURL" in s ? s.responseURL : i.headers.get("X-Request-URL");
296
- var u = "response" in s ? s.response : s.responseText;
297
- setTimeout(function() {
298
- r(new P(u, i));
299
- }, 0);
300
- }, s.onerror = function() {
301
- setTimeout(function() {
302
- n(new TypeError("Network request failed"));
303
- }, 0);
304
- }, s.ontimeout = function() {
305
- setTimeout(function() {
306
- n(new TypeError("Network request timed out"));
307
- }, 0);
308
- }, s.onabort = function() {
309
- setTimeout(function() {
310
- n(new A("Aborted", "AbortError"));
311
- }, 0);
312
- };
313
- function c(i) {
314
- try {
315
- return i === "" && p.location.href ? p.location.href : i;
316
- } catch {
317
- return i;
318
- }
319
- }
320
- if (s.open(o.method, c(o.url), !0), o.credentials === "include" ? s.withCredentials = !0 : o.credentials === "omit" && (s.withCredentials = !1), "responseType" in s && (b.blob ? s.responseType = "blob" : b.arrayBuffer && (s.responseType = "arraybuffer")), e && typeof e.headers == "object" && !(e.headers instanceof d || p.Headers && e.headers instanceof p.Headers)) {
321
- var h = [];
322
- Object.getOwnPropertyNames(e.headers).forEach(function(i) {
323
- h.push(I(i)), s.setRequestHeader(i, F(e.headers[i]));
324
- }), o.headers.forEach(function(i, u) {
325
- h.indexOf(u) === -1 && s.setRequestHeader(u, i);
326
- });
327
- } else
328
- o.headers.forEach(function(i, u) {
329
- s.setRequestHeader(u, i);
330
- });
331
- o.signal && (o.signal.addEventListener("abort", a), s.onreadystatechange = function() {
332
- s.readyState === 4 && o.signal.removeEventListener("abort", a);
333
- }), s.send(typeof o._bodyInit > "u" ? null : o._bodyInit);
334
- });
335
- }
336
- Y.polyfill = !0;
337
- p.fetch || (p.fetch = Y, p.Headers = d, p.Request = j, p.Response = P);
338
- self.fetch.bind(self);
339
- const H = "functional", U = "Humany__parameters";
340
- function fe(t) {
341
- const e = {};
342
- return t && Object.keys(t).forEach((r) => {
343
- const n = t[r];
344
- (_(n) === "array" ? n : [n]).forEach((o) => {
345
- typeof e[r] > "u" && (e[r] = []), e[r].push(o);
346
- });
347
- }), e;
348
- }
349
- class le {
350
- constructor(e, r) {
351
- this.isLoaded = !!e, this.parameters = fe(e), r && typeof r.get == "function" && (this.container = r);
352
- }
353
- getAll() {
354
- return this.ensureIsLoaded(), l(!0, {}, this.parameters);
355
- }
356
- add(e, r) {
357
- this.ensureIsLoaded(), this.parameters[e] || (this.parameters[e] = []), this.parameters[e].push(r), this.persist();
358
- }
359
- set(e, r) {
360
- this.ensureIsLoaded(), this.parameters[e] = [r], this.persist();
361
- }
362
- remove(e, r) {
363
- if (this.ensureIsLoaded(), typeof r > "u")
364
- delete this.parameters[e];
365
- else {
366
- const n = this.parameters[e] || [];
367
- n.forEach((o, s) => {
368
- o === r && n.splice(s, 1);
369
- }), this.parameters[e] = n;
370
- }
371
- this.persist();
372
- }
373
- clear() {
374
- this.ensureIsLoaded(), this.parameters = {}, this.persist();
375
- }
376
- persist() {
377
- try {
378
- N(this.container).indexOf(H) > -1 ? O(U, this.parameters, 1) : O(U, "", -1);
379
- } catch (e) {
380
- window.console && window.console.warn && window.console.warn("Error occured when persisting parameter bag.", e);
381
- }
382
- }
383
- ensureIsLoaded() {
384
- if (!this.isLoaded) {
385
- try {
386
- const e = G(U);
387
- this.parameters = e || {}, N(this.container).indexOf(H) === -1 && O(U, "", -1);
388
- } catch (e) {
389
- window.console && window.console.warn && window.console.warn("Error occured when loading parameter bag.", e);
390
- }
391
- this.isLoaded = !0;
392
- }
393
- }
394
- }
395
- function E() {
396
- return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
397
- }
398
- function z() {
399
- return E() + E() + "-" + E() + "-" + E() + "-" + E() + "-" + E() + E() + E();
400
- }
401
- const Z = "analytical", $ = "Humany__clientId";
402
- let C = "";
403
- function de(t) {
404
- if (N(t).indexOf(Z) === -1)
405
- return O($, "", -1), C.length || (C = z()), C;
406
- const e = G($);
407
- return e || (C.length || (C = z()), O($, C, 1)), e || C;
408
- }
409
- function pe() {
410
- return "Default";
411
- }
412
- function ye(...t) {
413
- const e = window.location;
414
- return [t[0] !== !1 ? "http:" : e.protocol, "//", e.host, e.pathname].join("");
415
- }
416
- function be() {
417
- }
418
- const me = {
419
- "[object Array]": "array",
420
- "[object Boolean]": "boolean",
421
- "[object Date]": "date",
422
- "[object Function]": "function",
423
- "[object Number]": "number",
424
- "[object Object]": "object",
425
- "[object RegExp]": "regexp",
426
- "[object String]": "string"
427
- };
428
- function _(t) {
429
- return t == null ? t + "" : typeof t == "object" || typeof t == "function" ? me[{}.toString.call(t)] || "object" : typeof t;
430
- }
431
- function f(t) {
432
- return _(t) === "function";
433
- }
434
- function J(t) {
435
- let e;
436
- if (!t || _(t) !== "object" || t.nodeType)
437
- return !1;
438
- try {
439
- if (t.constructor && !Object.prototype.hasOwnProperty.call(t, "constructor") && !Object.prototype.hasOwnProperty.call(t.constructor.prototype, "isPrototypeOf"))
440
- return !1;
441
- } catch {
442
- return !1;
443
- }
444
- for (e in t)
445
- ;
446
- return e === void 0 || Object.prototype.hasOwnProperty.call(t, e);
447
- }
448
- function l(...t) {
449
- let e, r, n, o, s, a, c = t[0] || {}, h = 1;
450
- const i = t.length;
451
- let u = !1;
452
- for (typeof c == "boolean" && (u = c, c = t[1] || {}, h = 2), typeof c != "object" && !f(c) && (c = {}); h < i; h++)
453
- if ((e = t[h]) != null)
454
- for (r in e)
455
- n = c[r], o = e[r], c !== o && (u && o && (J(o) || (s = _(o) === "array")) ? (s ? (s = !1, a = n && _(n) === "array" ? n : []) : a = n && J(n) ? n : {}, c[r] = l(u, a, o)) : o !== void 0 && (c[r] = o));
456
- return c;
457
- }
458
- const G = (t) => {
459
- const e = new RegExp(`(?:^|;)\\s?${t}=(.*?)(?:;|$)`, "i"), r = document.cookie.match(e), n = r && r[1];
460
- if (n) {
461
- if (t === "Humany__clientId")
462
- try {
463
- return JSON.parse(n);
464
- } catch {
465
- const s = JSON.stringify(n);
466
- return JSON.parse(s);
467
- }
468
- return JSON.parse(n);
469
- }
470
- }, O = (t, e, r) => {
471
- const n = JSON.stringify(e).trim().replace(/^"+|"+$/g, ""), o = `${t}=${n}`, s = `expires=${ge(r)}`, a = "path=/", c = "SameSite=None", h = "Secure";
472
- return document.cookie = `${o}; ${s}; ${a}; ${c}; ${h}`;
473
- }, N = (t) => {
474
- const e = ["necessary"];
475
- if (!t)
476
- return e;
477
- const r = t.get("$widget");
478
- if (!r || !r.implementation || !r.implementation.tenant)
479
- return e;
480
- const {
481
- implementation: { tenant: n }
482
- } = r, o = G(`humany_${n}`);
483
- return !o || !o.storagePolicy || !o.storagePolicy.value || !Array.isArray(o.storagePolicy.value) || !o.storagePolicy.value.length ? e : o.storagePolicy.value;
484
- }, ge = (t = 1) => {
485
- const e = /* @__PURE__ */ new Date();
486
- return e.setTime(e.getTime() + t * 24 * 60 * 60 * 1e3), e.toUTCString();
487
- }, we = (t = ["necessary"]) => {
488
- t.indexOf(H) === -1 && O(U, "", -1), t.indexOf(Z) === -1 && O($, "", -1);
489
- };
490
- function k(t, e, r) {
491
- if (typeof e > "u" || typeof r > "u")
492
- return t;
493
- const n = t && t.indexOf("?") !== -1 ? "&" : "?";
494
- return `${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`;
495
- }
496
- const X = "p.";
497
- function ve(t, e) {
498
- let r = t;
499
- return Object.keys(e).forEach((n) => {
500
- const o = e[n];
501
- _(o) === "array" ? o.forEach((s) => {
502
- r = k(r, `${X}${n}`, s);
503
- }) : r = k(r, `${X}${n}`, o);
504
- }), r;
505
- }
506
- class Q {
507
- constructor(e, r) {
508
- l(!0, this, e, { _client: r });
509
- }
510
- }
511
- class D {
512
- constructor(e, r) {
513
- l(!0, this, e, { _client: r });
514
- }
515
- }
516
- function x(t, e, r, n) {
517
- const o = [];
518
- return t[e].forEach((s) => {
519
- const a = new r(s, n), c = s[e], h = _(c);
520
- s[e] && (h === "array" || h === "object") && (a[e] = x(s, e, r, n)), o.push(a);
521
- }), o;
522
- }
523
- class L {
524
- constructor(e, r) {
525
- l(!0, this, e, { _client: r });
526
- }
527
- }
528
- function T(t, e) {
529
- return f(t) ? e ? t.call(e) : t.call(window) : t;
530
- }
531
- function S(t, e, r, n) {
532
- let o = Promise.resolve(r);
533
- for (let s = 0, a = t.length; s < a; s++) {
534
- const c = t[s][e];
535
- f(c) && (o = o.then(() => c(r, n)));
536
- }
537
- return o;
538
- }
539
- class Pe {
540
- constructor(e, r = {}) {
541
- this.setBaseUrl(e), this.globalOptions = r, this.interceptors = r.interceptors || [];
542
- }
543
- constructUrl(e) {
544
- return this.baseUrl + e;
545
- }
546
- setBaseUrl(e) {
547
- this.baseUrl = e + (e[e.length - 1] !== "/" ? "/" : "");
548
- }
549
- request(e, r) {
550
- const n = l(!0, {}, this.globalOptions, r);
551
- let o = this.constructUrl(e);
552
- const s = this.interceptors;
553
- return n.credentials === "include" && (o = k(o, "credentials", "true")), new Promise((a, c) => {
554
- S(s, "request", { url: o, options: n }).then((h) => fetch(h.url, h.options).then((i) => ({ response: i, request: h }))).then(({ response: h, request: i }) => {
555
- if (h.ok) {
556
- const u = h;
557
- return h.json().then((w) => {
558
- S(s, "response", { response: h, json: w, request: i }).then(() => {
559
- n.envelope ? a({ json: w, response: u }) : a(w), S(s, "responseEnd", { response: h, json: w, request: i });
560
- });
561
- });
562
- } else
563
- S(s, "responseError", h).then((u) => {
564
- f(n.onError) && n.onError(u), c(u);
565
- });
566
- }).catch((h) => {
567
- S(s, "responseError", h).then((i) => {
568
- f(n.onError) && n.onError(i), c(i);
569
- });
570
- });
571
- });
572
- }
573
- }
574
- const Ee = Pe;
575
- /*!
576
- * Humany Service Client Library
577
- * Version: 2.0
578
- * Copyright 2017, Telia Company AB, http://www.humany.com/
579
- */
580
- class B {
581
- constructor(...e) {
582
- const r = e[1] || {};
583
- if (this.proxy = typeof e[0] == "string" ? new Ee(e[0]) : e[0], this.settings = l(!0, {}, B.defaults, e[1] || {}), this.parameters = new le(e[2], e[3]), this.current = { phrase: r.phrase }, this.guideCache = {}, this.feedbackTypes = {
584
- positive: "Positive",
585
- negative: "Negative",
586
- comment: "Comment"
587
- }, this.handoverTypes = {
588
- email: "Email",
589
- chat: "Chat",
590
- callback: "Callback",
591
- phone: "Phone",
592
- emailComplementary: "ComplementaryEmail",
593
- chatComplementary: "ComplementaryChat",
594
- callbackComplementary: "ComplementaryCallback",
595
- phoneComplementary: "ComplementaryPhone"
596
- }, this.subscriptions = [], e[3] && typeof e[3].get == "function") {
597
- this.container = e[3];
598
- const n = this.container.get("$widget");
599
- n && n.events && this.subscriptions.push(
600
- n.events.subscribe(
601
- "storage:policy-changed",
602
- (o, s) => we(s)
603
- )
604
- );
605
- }
606
- }
607
- getConfiguration() {
608
- return {
609
- language: T(this.settings.language, this),
610
- client: T(() => this.settings.client(this.container), this),
611
- funnel: T(this.settings.funnel, this),
612
- site: T(this.settings.site, this),
613
- reader: T(this.settings.reader, this),
614
- perspective: T(this.settings.perspective, this)
615
- };
616
- }
617
- customRequest(e, r, n = {}) {
618
- const o = n.configuration || {}, s = n.parameters;
619
- return e = this.constructPath(e, o, s), this.proxy.request(e, {
620
- method: r,
621
- body: n.body
622
- }).then((a) => (n.success && n.success(a), a)).catch((a) => (n.error && n.error(a), a));
623
- }
624
- constructPath(e, r, n = !0) {
625
- let o = e;
626
- const s = l(this.getConfiguration(), r);
627
- if (Object.keys(s).filter((a) => {
628
- const c = s[a];
629
- return c !== null && typeof c < "u";
630
- }).forEach((a) => o = k(o, a, T(s[a]))), n) {
631
- const a = n === !0 ? this.parameters.getAll() : n;
632
- o = ve(o, a);
633
- }
634
- return o;
635
- }
636
- match(...e) {
637
- const r = e[0];
638
- let n = {}, o, s;
639
- typeof e[1] == "object" ? (n = e[1] || {}, o = e[2], s = e[3]) : (o = e[1], s = e[2]);
640
- function a(y) {
641
- if (f(o)) {
642
- const v = this;
643
- y = this.settings.useProxyClasses && y ? (() => (y.Matches = x(y, "Matches", L, v), y))() : y, o(y);
644
- }
645
- return y;
646
- }
647
- function c(y) {
648
- f(s) && s(y);
649
- }
650
- const h = l(!0, this.getConfiguration(), this.settings.paging, n), i = {};
651
- let u = "GET";
652
- i.categories = h.categories || h.categoryId, i.language = h.language, i.phrase = r, i.attributes = h.attributes, i.skip = h.skip, i.take = h.take, i.reader = h.reader, i.disableNotices = h.disableNotices, i.tags = h.tags, i.includeCategories = h.includeCategories, i.groupByCategory = h.groupByCategory, n.statisticsDisabled || (u = "POST", i.funnel = h.funnel, i.client = h.client, i.site = h.site, this.current.phrase = r);
653
- const w = "guides";
654
- n.sorting && (i["sorting.type"] = n.sorting.type, i["sorting.direction"] = n.sorting.direction);
655
- const m = this.constructPath(w, i);
656
- return this.proxy.request(m, {
657
- method: u
658
- }).then(a.bind(this)).catch(c.bind(this));
659
- }
660
- getGuide(...e) {
661
- const r = e[0];
662
- let n, o = {}, s, a;
663
- typeof e[1] == "function" ? (s = e[1], a = e[2]) : typeof e[1] == "object" ? (o = e[1] || {}, s = e[2], a = e[3]) : typeof e[1] == "string" ? (n = e[1], typeof e[2] == "function" ? (s = e[2], a = e[3]) : (o = e[2] || {}, s = e[3], a = e[4])) : !e[1] && typeof e[2] == "function" && (s = e[2], a = e[3]);
664
- function c(v) {
665
- if (f(s)) {
666
- const g = this.settings.useProxyClasses && v ? new L(v, this) : v;
667
- this.guideCache[g.Id] = g, s(g);
668
- }
669
- return v;
670
- }
671
- function h(v) {
672
- return f(a) && a(v), Promise.reject(v);
673
- }
674
- const i = l(!0, this.getConfiguration(), o), u = {};
675
- let w = "GET";
676
- u.connectionId = n || i.connectionId, u.perspective = i.perspective, u.reader = i.reader, u.phrase = this.current.phrase, this.parameters.remove("LastGuideId"), this.parameters.add("LastGuideId", r);
677
- let m = `guides/${r}`;
678
- u.connectionId && (m += `/${u.connectionId}`);
679
- let y = "";
680
- return !o.statisticsDisabled && !u.connectionId ? (w = "POST", y = this.constructPath(m, l({}, this.current, o))) : y = this.constructPath(m, l({}, this.current, o), !1), this.proxy.request(y, {
681
- method: w
682
- }).then(c.bind(this)).catch(h.bind(this));
683
- }
684
- getCategories(...e) {
685
- let r = {}, n, o;
686
- typeof e[0] == "object" ? (r = e[0] || {}, n = e[1], o = e[2]) : (n = e[0], o = e[1]);
687
- function s(i) {
688
- if (f(n)) {
689
- const u = this;
690
- i = this.settings.useProxyClasses && i ? (() => (i.Children = x(i, "Children", Q, u), i))() : i, n(i);
691
- }
692
- return i;
693
- }
694
- function a(i) {
695
- f(o) && o(i);
696
- }
697
- let c = "categories";
698
- r.categoryId && (c += "/" + r.categoryId);
699
- const h = this.constructPath(c, l({}, this.current, r));
700
- return this.proxy.request(h, {
701
- method: "GET"
702
- }).then(s.bind(this)).catch(a.bind(this));
703
- }
704
- answer(...e) {
705
- const r = e[0], n = e[1];
706
- let o = {}, s, a, c;
707
- typeof e[2] == "object" ? (o = e[2] || {}, s = e[3], a = e[4]) : (s = e[2], a = e[3]);
708
- const h = !!o.persist;
709
- function i() {
710
- !h && c && this.parameters.remove(
711
- c.Condition.ParameterName,
712
- c.Condition.Value
713
- );
714
- }
715
- function u(g) {
716
- if (i(), f(s)) {
717
- const R = this.settings.useProxyClasses && g ? new L(g, this) : g;
718
- this.guideCache[R.Id] = R, s(R);
719
- }
720
- }
721
- function w(g) {
722
- i(), f(a) && a(g);
723
- }
724
- const m = this.guideCache[r];
725
- m.Options && m.Options.forEach((g) => {
726
- this.parameters.remove(g.Condition.ParameterName, g.Condition.Value), g.ConnectionId === n && (c = g);
727
- }), this.parameters.add(c.Condition.ParameterName, c.Condition.Value);
728
- const y = `guides/${r}/${n}`, v = this.constructPath(y, l({}, this.current, o));
729
- return this.proxy.request(v, {
730
- method: "GET"
731
- }).then(u.bind(this)).catch(w.bind(this));
732
- }
733
- giveFeedback(...e) {
734
- const r = e[0];
735
- let n, o, s = {}, a, c;
736
- typeof e[2] == "string" ? (n = e[1], o = e[2], typeof e[3] == "object" ? (s = e[3] || {}, a = e[4], c = e[5]) : (a = e[3], c = e[4])) : (o = e[1], typeof e[2] == "object" && (s = e[2] || {}, a = e[3], c = e[4]));
737
- function h(m) {
738
- return f(a) && a(m), m;
739
- }
740
- function i(m) {
741
- return f(c) && c(m), m;
742
- }
743
- const u = `guides/${r}${n ? "/" + n : ""}/feedback`, w = this.constructPath(u, l({}, s, { feedbackType: o }));
744
- return this.proxy.request(w, {
745
- method: "POST"
746
- }).then(h.bind(this)).catch(i.bind(this));
747
- }
748
- completeContactMethod(...e) {
749
- const r = e[0];
750
- let n = {}, o, s;
751
- typeof e[1] == "object" ? (n = e[1], o = e[2], s = e[3]) : (o = e[1], s = e[2]);
752
- function a(u) {
753
- f(o) && o(u);
754
- }
755
- function c(u) {
756
- f(s) && s(u);
757
- }
758
- const h = `contactmethods/${r}/completed`, i = this.constructPath(h, n);
759
- return this.proxy.request(i, {
760
- method: "PUT"
761
- }).then(a.bind(this)).catch(c.bind(this));
762
- }
763
- getContactMethod(...e) {
764
- const r = e[0];
765
- let n = {}, o, s;
766
- typeof e[1] == "object" ? (n = e[1], o = e[2], s = e[3]) : (o = e[1], s = e[2]);
767
- function a(u) {
768
- if (f(o))
769
- o(u.ContactMethod);
770
- else
771
- return u;
772
- }
773
- function c(u) {
774
- if (f(s))
775
- s(u);
776
- else
777
- return u;
778
- }
779
- const h = `contactmethods/${r}`, i = this.constructPath(h, l({}, this.current, n));
780
- return this.proxy.request(i, {
781
- method: "GET"
782
- }).then(a.bind(this)).catch(c.bind(this));
783
- }
784
- contactMethods(...e) {
785
- let r, n = {}, o, s;
786
- typeof e[0] == "number" ? (r = e[0], n = e[1] || {}, o = e[2], s = e[3]) : typeof e[0] == "object" ? (n = e[0] || {}, o = e[1], s = e[2]) : (o = e[0], s = e[1]);
787
- function a(u) {
788
- return f(o) && (u = this.settings.useProxyClasses && u ? (() => (u.Matches = x(u, "Matches", D), u))() : u, o(u)), u;
789
- }
790
- function c(u) {
791
- return f(s) && s(u), u;
792
- }
793
- const h = r ? `guides/${r}/contactmethods` : "contactmethods", i = this.constructPath(h, l({}, this.current, n));
794
- return this.proxy.request(i, {
795
- method: "GET"
796
- }).then(a.bind(this)).catch(c.bind(this));
797
- }
798
- contacts(...e) {
799
- let r, n = {}, o, s;
800
- typeof e[0] == "number" ? (r = e[0], typeof e[1] == "object" ? (n = e[1], o = e[2], s = e[3]) : (o = e[1], s = e[2])) : typeof e[0] == "object" ? (n = e[0] || {}, o = e[1], s = e[2]) : (o = e[0], s = e[1]);
801
- function a(i) {
802
- if (f(o))
803
- i && this.settings.useProxyClasses && (i.Children && (i.Children = x(i, "Children", Q)), i.Matches && (i.Matches = x(i, "Matches", D)), i.Highlighted && (i.Highlighted = x(i, "Highlighted", D))), o(i);
804
- else
805
- return i;
806
- }
807
- function c(i) {
808
- if (f(s))
809
- s(i);
810
- else
811
- return i;
812
- }
813
- const h = this.constructPath(`contacts/${r || ""}`, l({}, this.current, n));
814
- return this.proxy.request(h, {
815
- method: "GET"
816
- }).then(a.bind(this)).catch(c.bind(this));
817
- }
818
- getSettings(e) {
819
- const r = this.constructPath("config", this.current);
820
- return this.proxy.request(r, {
821
- method: "GET"
822
- }).then(e);
823
- }
824
- getAuthorized(e, r) {
825
- const n = this.constructPath("interfaceauthorized", this.current);
826
- return this.proxy.request(n, {
827
- method: "GET",
828
- credentials: "include"
829
- }).then(e).catch(r);
830
- }
831
- submitForm(e, r, n, o, s) {
832
- let a = "forms/" + e;
833
- return n && (a += "/" + n), a = this.constructPath("config", l({}, this.current, r)), this.proxy.request(a, "POST", r, o, s);
834
- }
835
- getTab(e, r, n, o) {
836
- var s = arguments;
837
- typeof s[1] == "object" ? (r = s[1], n = s[2], o = s[3]) : (r = {}, n = s[1], o = s[2]);
838
- const a = `tabs/${e}`;
839
- return this.proxy.request(a, {
840
- method: "GET"
841
- }).then(n).catch(o);
842
- }
843
- dispose() {
844
- this.subscriptions.forEach((e) => e());
845
- }
846
- }
847
- B.feedbackTypes = {
848
- positive: "Positive",
849
- negative: "Negative",
850
- comment: "Comment"
851
- };
852
- B.handoverTypes = {
853
- email: "Email",
854
- chat: "Chat",
855
- callback: "Callback",
856
- phone: "Phone",
857
- emailComplementary: "ComplementaryEmail",
858
- chatComplementary: "ComplementaryChat",
859
- callbackComplementary: "ComplementaryCallback",
860
- phoneComplementary: "ComplementaryPhone"
861
- };
862
- B.defaults = {
863
- client: de,
864
- funnel: pe,
865
- site: ye,
866
- language: be,
867
- paging: {
868
- skip: 0,
869
- take: 10
870
- },
871
- useProxyClasses: !1
872
- };
873
- B.version = "1.0";
874
- const Ce = B;
875
- export {
876
- Ce as ServiceClient,
877
- Ee as ServiceProxy,
878
- ve as appendParameters,
879
- k as appendQueryString,
880
- G as getCookie,
881
- N as getStoragePolicyConsent,
882
- O as setCookie
883
- };