@telia-ace/knowledge-data-client-flamingo 1.1.80 → 1.1.81-rc.1

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/index.mjs CHANGED
@@ -1,1317 +1,356 @@
1
- const K = (n, t, e, ...i) => {
2
- const s = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
3
- switch (t) {
1
+ const j = (s, e, t, ...n) => {
2
+ const i = `[${s.get("$environment").name || "webprovisions"}] ${t}`;
3
+ switch (e) {
4
4
  case "info":
5
- console.info(s, ...i);
5
+ console.info(i, ...n);
6
6
  break;
7
7
  case "warning":
8
- console.warn(s, ...i);
8
+ console.warn(i, ...n);
9
9
  break;
10
10
  case "error":
11
- console.error(s, ...i);
11
+ console.error(i, ...n);
12
12
  break;
13
13
  }
14
- }, St = (n) => {
15
- const t = n.container || n;
14
+ }, X = (s) => {
15
+ const e = s.container || s;
16
16
  return {
17
- info: (e, ...i) => K(t, "info", e, ...i),
18
- warn: (e, ...i) => K(t, "warning", e, ...i),
19
- error: (e, ...i) => K(t, "error", e, ...i)
17
+ info: (t, ...n) => j(e, "info", t, ...n),
18
+ warn: (t, ...n) => j(e, "warning", t, ...n),
19
+ error: (t, ...n) => j(e, "error", t, ...n)
20
20
  };
21
21
  };
22
- var T = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(T || {}), x = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(x || {});
23
- const qt = (n, t, e, i) => {
22
+ var G = /* @__PURE__ */ ((s) => (s.Implementation = "implementation", s.Widget = "widget", s))(G || {}), k = /* @__PURE__ */ ((s) => (s.Pre = "pre", s.Post = "post", s))(k || {});
23
+ const Z = (s, e, t, n) => {
24
24
  try {
25
- const s = new t(e, i);
25
+ const i = new e(t, n);
26
26
  return {
27
- name: n,
28
- invoke: (r, a) => {
29
- let o;
30
- return s[r] && (o = s[r].call(s, a)), Promise.resolve(o);
27
+ name: s,
28
+ invoke: (o, c) => {
29
+ let r;
30
+ return i[o] && (r = i[o].call(i, c)), Promise.resolve(r);
31
31
  },
32
- getInstance: () => s
32
+ getInstance: () => i
33
33
  };
34
- } catch (s) {
35
- if (s.message && s.message.indexOf("is not a constructor") >= 0)
34
+ } catch (i) {
35
+ if (i.message && i.message.indexOf("is not a constructor") >= 0)
36
36
  return {
37
- name: n,
38
- invoke: (r) => {
39
- let a;
40
- return r === "initialize" && (a = t(e, i)), Promise.resolve(a);
37
+ name: s,
38
+ invoke: (o) => {
39
+ let c;
40
+ return o === "initialize" && (c = e(t, n)), Promise.resolve(c);
41
41
  },
42
- getInstance: () => t
42
+ getInstance: () => e
43
43
  };
44
- throw s;
44
+ throw i;
45
45
  }
46
46
  };
47
- function dt(n, t) {
48
- return typeof n > "u" ? t : n;
47
+ function W(s, e) {
48
+ return typeof s > "u" ? e : s;
49
49
  }
50
- let Gt = class {
51
- constructor(t = {}) {
52
- this.part = t;
53
- }
54
- createCommand(t, e, i) {
55
- let s;
56
- typeof e == "function" ? s = {
57
- scope: T.Widget,
58
- stage: x.Post,
50
+ class ee {
51
+ constructor(e = {}) {
52
+ this.part = e;
53
+ }
54
+ createCommand(e, t, n) {
55
+ let i;
56
+ typeof t == "function" ? i = {
57
+ scope: G.Widget,
58
+ stage: k.Post,
59
59
  defaultArgs: void 0,
60
- handlerResolver: e
61
- } : s = {
62
- scope: dt(e.scope, T.Widget),
63
- stage: dt(e.stage, x.Post),
64
- defaultArgs: e.defaultArgs,
65
- handlerResolver: i
60
+ handlerResolver: t
61
+ } : i = {
62
+ scope: W(t.scope, G.Widget),
63
+ stage: W(t.stage, k.Post),
64
+ defaultArgs: t.defaultArgs,
65
+ handlerResolver: n
66
66
  };
67
- let r = this.part;
68
- const a = t.split(".");
69
- return a.forEach((o, c) => {
70
- c === a.length - 1 ? r[o] || (r[o] = () => s) : r = this.part[o] = this.part[o] || {};
67
+ let o = this.part;
68
+ const c = e.split(".");
69
+ return c.forEach((r, a) => {
70
+ a === c.length - 1 ? o[r] || (o[r] = () => i) : o = this.part[r] = this.part[r] || {};
71
71
  }), this;
72
72
  }
73
73
  get() {
74
74
  return this.part;
75
75
  }
76
- };
77
- const $t = (n) => {
78
- const t = new Gt({});
79
- return n(t), t.get();
80
- };
81
- $t((n) => {
82
- n.createCommand(
83
- "types.register",
84
- { scope: T.Implementation, stage: x.Pre },
85
- (t) => (e, i) => {
86
- t.container.get("$types")[e] = i;
87
- }
88
- ).createCommand(
89
- "type",
90
- { stage: x.Pre },
91
- (t) => (e) => {
92
- t.container.register("$type", e);
93
- }
94
- ).createCommand(
95
- "settings",
96
- { stage: x.Pre, defaultArgs: [null] },
97
- (t) => (e) => {
98
- t.events.dispatch(
99
- "settings:change",
100
- e,
101
- { bubbles: !0 }
102
- ), t.container.register("$settings", e);
103
- }
104
- ).createCommand(
105
- "plugin",
106
- { stage: x.Pre },
107
- (t) => (e, i, s) => {
108
- const { container: r } = t;
109
- let a = null, o = e, c = i;
110
- typeof e == "string" && (a = e, o = i, c = s);
111
- const h = (d) => {
112
- const { transformPluginSettings: g } = t.container.get("$environmentOptions"), u = g ? g(
113
- c || {},
114
- a,
115
- t.container,
116
- o
117
- ) : i;
118
- try {
119
- const p = qt(
120
- a,
121
- o,
122
- r,
123
- u
124
- );
125
- r.get("$plugins").push(p), d && p.invoke("initialize", null);
126
- } catch (p) {
127
- St(t).warn("Error when initializing plugin", p);
128
- }
129
- };
130
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
131
- }
132
- ).createCommand(
133
- "container.register",
134
- (t) => (e, i) => {
135
- t.container.register(e, i);
136
- }
137
- ).createCommand(
138
- "container.registerAsync",
139
- (t) => (e, i) => {
140
- t.container.registerAsync(e, i);
141
- }
142
- ).createCommand(
143
- "container.registerFactory",
144
- (t) => (e, i) => {
145
- t.container.registerFactory(e, i);
146
- }
147
- ).createCommand(
148
- "container.touch",
149
- (t) => (e, i) => {
150
- t.container.touch(e, i);
151
- }
152
- ).createCommand(
153
- "csp",
154
- {},
155
- (t) => (e) => {
156
- t.container.register("csp", e);
157
- }
158
- );
159
- });
160
- const Tt = $t((n) => {
161
- n.createCommand(
162
- "ready",
163
- { scope: T.Implementation, stage: x.Pre },
164
- (t) => (e) => {
165
- const { container: i } = t, s = i.owner;
166
- i.get("bootstrapping").ready ? e(s) : s.events.subscribeOnce("bootstrap:ready", () => {
167
- e(s);
168
- });
169
- }
170
- );
171
- }), J = /* @__PURE__ */ new WeakMap();
172
- function R() {
173
- return (n) => (J.has(n) || J.set(n, {}), J.get(n));
174
- }
175
- const X = (n, t, e, ...i) => {
176
- const s = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
177
- switch (t) {
178
- case "info":
179
- console.info(s, ...i);
180
- break;
181
- case "warning":
182
- console.warn(s, ...i);
183
- break;
184
- case "error":
185
- console.error(s, ...i);
186
- break;
187
- }
188
- }, v = (n) => {
189
- const t = n.container || n;
190
- return {
191
- info: (e, ...i) => X(t, "info", e, ...i),
192
- warn: (e, ...i) => X(t, "warning", e, ...i),
193
- error: (e, ...i) => X(t, "error", e, ...i)
194
- };
195
- }, m = R(), st = (() => {
196
- let n = 0;
197
- return () => ++n;
198
- })(), rt = (n, t, e) => {
199
- const i = m(n).touchQueue.get(t);
200
- i && i.forEach((s) => {
201
- s(e, n);
202
- });
203
- };
204
- class jt {
205
- constructor(t, e, i, s) {
206
- this.key = t, this.factory = e, this.parent = i, this.container = s, this.id = st(), this.resolved = !1, this.constructed = !1, this.async = !0;
207
- }
208
- resolve() {
209
- if (!this.constructed) {
210
- const t = this.factory(this.parent, this.container);
211
- return this.constructed = !0, this.value = Promise.resolve(t).then((e) => (this.resolved = !0, rt(this.container, this.key, e), e));
212
- }
213
- return this.value;
214
- }
215
- }
216
- class Dt {
217
- constructor(t, e, i, s) {
218
- this.key = t, this.value = e, this.parent = i, this.container = s, this.id = st(), this.async = !1, this.resolved = !1, this.constructed = !0, this.resolve = () => (this.resolved = !0, rt(this.container, this.key, this.value), this.value);
219
- }
220
- }
221
- class zt {
222
- constructor(t, e, i, s) {
223
- this.key = t, this.value = e, this.parent = i, this.container = s, this.id = st(), this.async = !1, this.resolved = !1, this.constructed = !1, this.resolve = () => {
224
- this.resolved = !0, this.constructed = !0;
225
- const r = this.value(this.parent, this.container);
226
- return rt(this.container, this.key, this.value), r;
227
- };
228
- }
229
- }
230
- let Ut = class Pt {
231
- /**
232
- * Creates a new instance of `Container`.
233
- * @param owner The object owning this inctance.
234
- * @param name Optional name for the container.
235
- * @param parent Parent container this should be a child of.
236
- */
237
- constructor(t, e, i) {
238
- this.owner = t, this.name = e, this.parent = i, m(this).resolvers = /* @__PURE__ */ new Map(), m(this).touchQueue = /* @__PURE__ */ new Map(), m(this).children = [];
239
- }
240
- /**
241
- * Deletes an existing resolver by its unique id.
242
- * @param id Resolver id.
243
- */
244
- delete(t) {
245
- const e = m(this).resolvers, i = Array.from(e.values()).find((s) => s.id === t);
246
- return i ? (m(this).touchQueue.delete(i.key), Promise.resolve(e.delete(i.key))) : this.parent ? this.parent.delete(t) : Promise.resolve(!1);
247
- }
248
- /**
249
- * Clears the `Container` and any child containers by deleteing all registered resolvers.
250
- */
251
- clear() {
252
- const t = m(this).resolvers, e = Array.from(t.values());
253
- return Promise.all(e.map((i) => {
254
- if (i.constructed)
255
- return Promise.resolve(i.resolve()).then((s) => {
256
- if (s !== null && typeof s == "object" && typeof s.dispose == "function")
257
- return s.dispose.call(s, this, i);
258
- });
259
- })).then(() => {
260
- e.forEach((i) => this.delete(i.id)), m(this).children.forEach((i) => i.clear());
261
- });
262
- }
263
- /**
264
- * Detaches this `Container` instance from its parent, allowing it to be garbage-collected.
265
- */
266
- detach() {
267
- if (this.parent) {
268
- const t = m(this.parent).children, e = t.indexOf(this);
269
- e > -1 && (t.splice(e, 1), delete this.parent);
270
- }
271
- }
272
- /**
273
- * Provides a way of touching a value in the `Container` without forcing it to be resolved.
274
- * @param key Key of the resolved value to touch.
275
- * @param handler Handler function for touching the resolved value.
276
- */
277
- touch(t, e) {
278
- const i = m(this).resolvers.get(t);
279
- if (i && i.constructed)
280
- Promise.resolve(i.resolve()).then((s) => {
281
- e(s, this);
282
- });
283
- else {
284
- const s = m(this).touchQueue;
285
- let r = s.get(t);
286
- r || (r = [], s.set(t, r)), r.push(e);
287
- }
288
- return this.parent && !i ? this.parent.touch(t, e) : Promise.resolve();
289
- }
290
- /**
291
- * Registers an asynchronous resolver.
292
- * @param key Key of the resolver.
293
- * @param factory Value factory.
294
- */
295
- registerAsync(t, e) {
296
- const i = m(this).resolvers.get(t);
297
- i && !i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${t}') previously used by a non-async resolver.`);
298
- const s = new jt(t, e, i, this);
299
- return m(this).resolvers.set(t, s), s.id;
300
- }
301
- /**
302
- * Registers a factory resolver for constructing the value to be resolved.
303
- * @param key Key of the resolver.
304
- * @param factory Value factory.
305
- */
306
- registerFactory(t, e) {
307
- const i = m(this).resolvers.get(t);
308
- i && i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
309
- const s = new zt(t, e, i, this);
310
- return m(this).resolvers.set(t, s), s.id;
311
- }
312
- /**
313
- * Registers an synchronous resolver.
314
- * @param key Key of the resolver.
315
- * @param value Value.
316
- */
317
- register(t, e) {
318
- const i = m(this).resolvers.get(t);
319
- i && i.async && process.env.NODE_ENV !== "production" && v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
320
- const s = new Dt(t, e, i, this);
321
- return m(this).resolvers.set(t, s), s.id;
322
- }
323
- /**
324
- * Gets the value for a synchronous resolver.
325
- * @param key Key of resolver to get.
326
- */
327
- get(t) {
328
- const e = m(this).resolvers.get(t);
329
- if (e)
330
- return e.async && process.env.NODE_ENV !== "production" && v(this).warn(`You are retrieving an async value (with key '${t}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`), e.resolve();
331
- if (this.parent)
332
- return this.parent.get(t);
333
- }
334
- /**
335
- * Gets the value for a asynchronous resolver.
336
- * @param key Key of resolver to get.
337
- */
338
- getAsync(t) {
339
- const e = m(this).resolvers.get(t);
340
- if (e) {
341
- if (!e.async)
342
- throw process.env.NODE_ENV !== "production" && v(this).warn(`You are retrieving a non-async value (with key '${t}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`), "Mismatching resolver type";
343
- return e.resolve();
344
- }
345
- return this.parent ? this.parent.getAsync(t) : Promise.resolve(void 0);
346
- }
347
- getMany(...t) {
348
- const e = {};
349
- return t.forEach((i) => e[i] = this.get(i)), e;
350
- }
351
- getManyAsync(...t) {
352
- const e = {};
353
- return Promise.all(t.map((i) => this.getAsync(i).then((s) => e[i] = s))).then(() => e);
354
- }
355
- createChild(t, e) {
356
- const i = new Pt(t, e, this);
357
- return m(this).children.push(i), i;
358
- }
359
- };
360
- class ut {
361
- /**
362
- *
363
- * @param type Type of event.
364
- * @param target The target of the event, which will handle the default behavour.
365
- * @param cancelable Whether the event is cancelable by calling preventDefault().
366
- * @param bubbles Whether the event will bubble up the parent hierarchy.
367
- */
368
- constructor(t, e, i = !1, s = !1) {
369
- this.type = t, this.target = e, this.cancelable = !!i, this.bubbles = !!s, this.defaultPrevented = !1;
370
- }
371
- /**
372
- * Cancels the default behaviour (if the event is cancelable).
373
- */
374
- preventDefault() {
375
- this.cancelable && (this.defaultPrevented = !0);
376
- }
377
- }
378
- const $ = R(), gt = (n, t) => [].concat(
379
- $(n).listenerLookup.get(t.toLowerCase()) || [],
380
- $(n).listenerLookup.get("*") || []
381
- ), pt = (n, t, e, i) => {
382
- let s, r;
383
- return t instanceof ut ? (s = t, r = t.type) : (s = new ut(t, n.target, !!e.cancelable, !!e.bubbles), r = t), { event: s, type: r, async: i };
384
- };
385
- class ot {
386
- /**
387
- * Creates a new Event Manager instance.
388
- * @param target The target of events dispatched from this Event Manager instance.
389
- * @param parent Parent Event Manager instance.
390
- */
391
- constructor(t, e) {
392
- this.target = t, this.parent = e, $(this).listenerLookup = /* @__PURE__ */ new Map(), $(this).children = [];
393
- }
394
- /**
395
- * Clears registered event listeners in this `EventManager` as well as in any children.
396
- */
397
- clear() {
398
- $(this).listenerLookup.clear(), $(this).children.forEach((t) => t.clear());
399
- }
400
- /**
401
- * Detaches this `EventManager` instance from its parent, allowing it to be garbage-collected.
402
- */
403
- detach() {
404
- if (this.parent) {
405
- const t = $(this.parent).children, e = t.indexOf(this);
406
- e > -1 && t.splice(e, 1);
407
- }
408
- }
409
- /**
410
- * Creates an event subscription by registering an listener for an event type.
411
- * @param type Event type to subscribe to.
412
- * @param listener Listener for the event.
413
- */
414
- subscribe(t, e, i) {
415
- const s = $(this).listenerLookup, r = t.toLowerCase();
416
- return s.has(r) || s.set(r, []), s.get(r).push(e), () => this.unsubscribe(t, e);
417
- }
418
- /**
419
- * Similar to `subscribe()` but immediately removes the subscription after the first call.
420
- * @param type Event type to subscribe to.
421
- * @param listener Listener for the event.
422
- */
423
- subscribeOnce(t, e) {
424
- const i = this.subscribe(t, (s, r) => (i(), e(s, r)));
425
- }
426
- /**
427
- * Removes a listener for the specified event type.
428
- * @param type Event type to remove subscription for.
429
- * @param listener Event listener to remove.
430
- */
431
- unsubscribe(t, e) {
432
- const i = $(this).listenerLookup.get(t.toLowerCase());
433
- if (i) {
434
- const s = i.indexOf(e);
435
- s > -1 && i.splice(s, 1);
436
- }
437
- }
438
- /**
439
- * Dispatches an asynchonous event to registered event listeners.
440
- * @param eventOrType Event type or Event object to dispatch.
441
- * @param data Optional data to be passed to event listeners.
442
- * @param options Optional event options used if first parameter is an event type.
443
- */
444
- dispatchAsync(t, e, i = {}) {
445
- const { event: s, type: r } = pt(this, t, i, !0), a = gt(this, r);
446
- let o = 0;
447
- const c = a.length;
448
- let h = Promise.resolve();
449
- for (o = 0; o < c; o++)
450
- ((d) => {
451
- h = h.then((g) => g ? Promise.resolve(!0) : Promise.resolve(d(s, e)).then(() => s.defaultPrevented));
452
- })(a[o]);
453
- return h.then((d) => !d && s.bubbles && this.parent ? this.parent.dispatchAsync(s, e) : d);
454
- }
455
- /**
456
- * Dispatches an event to registered event listeners.
457
- * @param eventOrType Event type or Event object to dispatch.
458
- * @param data Optional data to be passed to event listeners.
459
- * @param options Optional event options used if first parameter is an event type.
460
- */
461
- dispatch(t, e, i = {}) {
462
- const { event: s, type: r } = pt(this, t, i, !1), a = gt(this, r);
463
- let o = 0;
464
- const c = a.length;
465
- let h = !1;
466
- for (o = 0; o < c; o++)
467
- if (a[o](s, e), s.defaultPrevented) {
468
- h = !0;
469
- break;
470
- }
471
- return !h && s.bubbles && this.parent && (h = this.parent.dispatch(s, e)), h;
472
- }
473
- /**
474
- * Creates a child instance to the current Event manager.
475
- */
476
- createChild(t) {
477
- const e = new ot(t, this);
478
- return $(this).children.push(e), e;
479
- }
480
- }
481
- const z = (n, t, e) => {
482
- const i = n.get("$plugins").map((s) => {
483
- try {
484
- return s.invoke(t, e);
485
- } catch (r) {
486
- v(n).error("An error occured when invoking a plugin.", s, r);
487
- }
488
- });
489
- return Promise.all(i);
490
- };
491
- class Wt {
492
- constructor(t) {
493
- this.widget = t.get("$widget"), this.events = this.widget.events, this.container = this.widget.container, this.initialized = null, this.activated = null, this.initialize = this.initialize.bind(this), this.activate = this.activate.bind(this), this.deactivate = this.deactivate.bind(this), this.invoke = this.invoke.bind(this), this.createInstance();
494
- }
495
- createInstance() {
496
- if (!this.widget.container.get("$instance")) {
497
- const t = this.widget.container.get("$types"), e = this.widget.container.get("$type");
498
- !e && v(this).error("Unable to create widget. No type is specified.");
499
- const i = t[e];
500
- !i && v(this).error(`Unable to create widget. Type '${e}' is not registered.`), this.widget.events.dispatch("widget:create-instance", {}, { bubbles: !0 });
501
- try {
502
- this.widget.container.register(
503
- "$instance",
504
- new i(this.container)
505
- );
506
- } catch (s) {
507
- v(this).error("Unable to create widget type.", s);
508
- }
509
- this.widget.events.dispatch("widget:instance-created", {}, { bubbles: !0 });
510
- }
511
- }
512
- /**
513
- * The initialization is performed before the widget is activated but after it's configured
514
- * and thus all required services are available. This hook is a good place to bind events that
515
- * should trigger activation (e.g. click on "trigger links" or routing events)
516
- * @param {object} data Custom initialization data passed to the widget.
517
- */
518
- initialize(t) {
519
- return this.initialized = this.initialized || (() => {
520
- const e = this.container.get("$instance"), i = e.initialize || (() => {
521
- });
522
- return this.initialized = Promise.resolve(i.call(e, t)).then(() => z(this.container, "initialize", t)).then(() => {
523
- });
524
- })();
525
- }
526
- /**
527
- * The activation is where the widget is actually created and rendered.
528
- * Activation can be initialized from the outside or from an event originated
529
- * in the "initialize" hook.
530
- * @param {object} data Custom activation data passed to the widget.
531
- */
532
- activate(t) {
533
- return (this.initialized || this.initialize()).then(() => {
534
- this.activated = this.activated || (() => z(this.container, "activate").then(() => {
535
- const e = this.container.get("$instance");
536
- return this.activated = e.activate(t);
537
- }))();
538
- });
539
- }
540
- deactivate() {
541
- const t = this.container.get("$instance"), e = t.deactivate || (() => {
542
- });
543
- return z(this.container, "deactivate").then(() => Promise.resolve(e.call(t))).then(() => {
544
- this.initialized = null, this.activated = null;
545
- }).then(() => {
546
- });
547
- }
548
- /**
549
- * Invokes a command on the widget component.
550
- * @param command Name of command
551
- * @param args Command arguments
552
- */
553
- invoke(t, ...e) {
554
- return z(this.container, "invoke", { command: t, args: e }).then(() => {
555
- const i = this.container.get("$instance");
556
- if (i[t])
557
- return i[t].apply(i, e);
558
- const s = i.invoke;
559
- if (s)
560
- return s.call(i, t, ...e);
561
- });
562
- }
563
76
  }
564
- const M = (n, t) => {
565
- if (!t)
566
- return !0;
567
- if (typeof t == "string") {
568
- const e = t.split(",");
569
- for (let i = 0, s = e.length; i < s; i++) {
570
- const r = e[i].trim();
571
- if (r === n || r === "*")
572
- return !0;
573
- }
574
- }
575
- return t instanceof Array ? t.indexOf(n) > -1 : !1;
576
- }, Bt = (n, t) => {
577
- if (typeof t == "function")
578
- return t(n);
579
- const e = typeof t == "string" ? Vt(t) : t;
580
- return !(!M(n.implementation.tenant || "", e.tenant || "") || !M(n.implementation.name, e.implementation || "") || !M(n.name, e.widget || "") || !M(n.container.get("$type"), e.type || ""));
581
- }, Ft = (n, t) => {
582
- if (typeof t == "function")
583
- return t(n);
584
- const e = typeof t == "string" ? Ht(t) : t;
585
- return !(!M(n.tenant || "", e.tenant || "") || !M(n.name, e.implementation || ""));
586
- }, Et = (n) => (t) => Bt(t, n), Qt = (n) => (t) => Ft(t, n), E = (n) => n instanceof Array && n.length === 1 ? n[0] : n, Vt = (n) => {
587
- const t = {}, e = n.split(":");
588
- return e.length === 1 ? t.widget = E(e[0].split(",")) : e.length === 2 ? (t.implementation = E(e[0].split(",")), t.widget = E(e[1].split(","))) : (t.tenant = E(e[0].split(",")), t.implementation = E(e[1].split(",")), t.widget = E(e[2].split(","))), t;
589
- }, Ht = (n) => {
590
- const t = {}, e = n.split(":");
591
- return e.length === 1 ? t.implementation = E(e[0].split(",")) : (t.tenant = E(e[0].split(",")), t.implementation = E(e[1].split(","))), t;
592
- }, F = R(), mt = (n, t, e) => n.filter((i) => i.stage === t && Et(i.selector)(e));
593
- function Yt(n) {
594
- const t = n.container.get("$environment");
595
- let e = F(t).configurationCache;
596
- e && (e = e.filter((i) => i[0] !== n), F(t).configurationCache = e);
597
- }
598
- var Q = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(Q || {}), A = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(A || {});
599
- const At = (n, t, e) => (Object.keys(t).forEach((i) => {
600
- const s = t[i];
601
- if (typeof s == "function") {
602
- const r = s();
603
- typeof r.defaultArgs < "u" && e(r, ...r.defaultArgs), n[i] = (...a) => {
604
- const o = Object.assign(
605
- {},
606
- r,
607
- { handlerResolver: r.handlerResolver.bind({}) }
608
- );
609
- return e(o, ...a), n;
610
- };
611
- } else
612
- n[i] = At(
613
- {},
614
- s,
615
- e
616
- );
617
- }), n), Kt = (n, t) => {
618
- switch (t) {
619
- case "implementation":
620
- return n.implementation;
621
- case "widget":
622
- return n;
623
- }
624
- }, ft = (n, t, e, i) => (i.forEach((s) => {
625
- At(
626
- n,
627
- s,
628
- (r, ...a) => {
629
- const o = {
630
- selector: t,
631
- stage: r.stage,
632
- handler: (c) => {
633
- const h = Kt(c, r.scope), d = { container: h.container, events: h.events }, g = r.handlerResolver, u = g(d);
634
- let p = F(e.environment).configurationCache;
635
- return p || (p = F(e.environment).configurationCache = []), p.find((b) => b.indexOf(h) > -1 && b.indexOf(g) > -1) ? Promise.resolve() : (p.push([h, g]), Promise.resolve(u(...a)));
636
- }
637
- };
638
- e.instructions.push(o);
639
- }
640
- );
641
- }), n);
642
- function Jt(n, t) {
643
- function e(i) {
644
- return ft(
645
- {},
646
- i,
647
- n,
648
- t
649
- );
650
- }
651
- return ft(
652
- e,
653
- "*",
654
- n,
655
- t
656
- );
657
- }
658
- const Xt = (n, t, e, i) => {
659
- try {
660
- const s = new t(e, i);
661
- return {
662
- name: n,
663
- invoke: (r, a) => {
664
- let o;
665
- return s[r] && (o = s[r].call(s, a)), Promise.resolve(o);
666
- },
667
- getInstance: () => s
668
- };
669
- } catch (s) {
670
- if (s.message && s.message.indexOf("is not a constructor") >= 0)
671
- return {
672
- name: n,
673
- invoke: (r) => {
674
- let a;
675
- return r === "initialize" && (a = t(e, i)), Promise.resolve(a);
676
- },
677
- getInstance: () => t
678
- };
679
- throw s;
680
- }
77
+ const z = (s) => {
78
+ const e = new ee({});
79
+ return s(e), e.get();
681
80
  };
682
- function vt(n, t) {
683
- return typeof n > "u" ? t : n;
684
- }
685
- class Zt {
686
- constructor(t = {}) {
687
- this.part = t;
688
- }
689
- createCommand(t, e, i) {
690
- let s;
691
- typeof e == "function" ? s = {
692
- scope: Q.Widget,
693
- stage: A.Post,
694
- defaultArgs: void 0,
695
- handlerResolver: e
696
- } : s = {
697
- scope: vt(e.scope, Q.Widget),
698
- stage: vt(e.stage, A.Post),
699
- defaultArgs: e.defaultArgs,
700
- handlerResolver: i
701
- };
702
- let r = this.part;
703
- const a = t.split(".");
704
- return a.forEach((o, c) => {
705
- c === a.length - 1 ? r[o] || (r[o] = () => s) : r = this.part[o] = this.part[o] || {};
706
- }), this;
707
- }
708
- get() {
709
- return this.part;
710
- }
711
- }
712
- const Nt = (n) => {
713
- const t = new Zt({});
714
- return n(t), t.get();
715
- }, te = Nt((n) => {
716
- n.createCommand(
81
+ z((s) => {
82
+ s.createCommand(
717
83
  "types.register",
718
- { scope: Q.Implementation, stage: A.Pre },
719
- (t) => (e, i) => {
720
- t.container.get("$types")[e] = i;
84
+ { scope: G.Implementation, stage: k.Pre },
85
+ (e) => (t, n) => {
86
+ e.container.get("$types")[t] = n;
721
87
  }
722
88
  ).createCommand(
723
89
  "type",
724
- { stage: A.Pre },
725
- (t) => (e) => {
726
- t.container.register("$type", e);
90
+ { stage: k.Pre },
91
+ (e) => (t) => {
92
+ e.container.register("$type", t);
727
93
  }
728
94
  ).createCommand(
729
95
  "settings",
730
- { stage: A.Pre, defaultArgs: [null] },
731
- (t) => (e) => {
732
- t.events.dispatch(
96
+ { stage: k.Pre, defaultArgs: [null] },
97
+ (e) => (t) => {
98
+ e.events.dispatch(
733
99
  "settings:change",
734
- e,
100
+ t,
735
101
  { bubbles: !0 }
736
- ), t.container.register("$settings", e);
102
+ ), e.container.register("$settings", t);
737
103
  }
738
104
  ).createCommand(
739
105
  "plugin",
740
- { stage: A.Pre },
741
- (t) => (e, i, s) => {
742
- const { container: r } = t;
743
- let a = null, o = e, c = i;
744
- typeof e == "string" && (a = e, o = i, c = s);
745
- const h = (d) => {
746
- const { transformPluginSettings: g } = t.container.get("$environmentOptions"), u = g ? g(
747
- c || {},
748
- a,
749
- t.container,
750
- o
751
- ) : i;
106
+ { stage: k.Pre },
107
+ (e) => (t, n, i) => {
108
+ const { container: o } = e;
109
+ let c = null, r = t, a = n;
110
+ typeof t == "string" && (c = t, r = n, a = i);
111
+ const d = (h) => {
112
+ const { transformPluginSettings: f } = e.container.get("$environmentOptions"), u = f ? f(
113
+ a || {},
114
+ c,
115
+ e.container,
116
+ r
117
+ ) : n;
752
118
  try {
753
- const p = Xt(
754
- a,
755
- o,
119
+ const m = Z(
120
+ c,
756
121
  r,
122
+ o,
757
123
  u
758
124
  );
759
- r.get("$plugins").push(p), d && p.invoke("initialize", null);
760
- } catch (p) {
761
- v(t).warn("Error when initializing plugin", p);
125
+ o.get("$plugins").push(m), h && m.invoke("initialize", null);
126
+ } catch (m) {
127
+ X(e).warn("Error when initializing plugin", m);
762
128
  }
763
129
  };
764
- t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
130
+ e.container.get("$instance") ? d(!0) : e.events.subscribeOnce("widget:instance-created", () => d(!1));
765
131
  }
766
132
  ).createCommand(
767
133
  "container.register",
768
- (t) => (e, i) => {
769
- t.container.register(e, i);
134
+ (e) => (t, n) => {
135
+ e.container.register(t, n);
770
136
  }
771
137
  ).createCommand(
772
138
  "container.registerAsync",
773
- (t) => (e, i) => {
774
- t.container.registerAsync(e, i);
139
+ (e) => (t, n) => {
140
+ e.container.registerAsync(t, n);
775
141
  }
776
142
  ).createCommand(
777
143
  "container.registerFactory",
778
- (t) => (e, i) => {
779
- t.container.registerFactory(e, i);
144
+ (e) => (t, n) => {
145
+ e.container.registerFactory(t, n);
780
146
  }
781
147
  ).createCommand(
782
148
  "container.touch",
783
- (t) => (e, i) => {
784
- t.container.touch(e, i);
149
+ (e) => (t, n) => {
150
+ e.container.touch(t, n);
785
151
  }
786
152
  ).createCommand(
787
153
  "csp",
788
154
  {},
789
- (t) => (e) => {
790
- t.container.register("csp", e);
155
+ (e) => (t) => {
156
+ e.container.register("csp", t);
791
157
  }
792
158
  );
793
- }), ee = te;
794
- function ne(n, t, e = []) {
795
- const i = [ee].concat(e), s = Jt(
796
- t,
797
- i
798
- );
799
- n(s, t);
800
- }
801
- class ie {
802
- constructor() {
803
- this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
804
- }
805
- add(t, e, i, s) {
806
- this.tasks.push({ task: t, resolve: e, reject: i, done: s }), this.next();
807
- }
808
- next() {
809
- this.current = this.current.then(() => {
810
- const t = this.tasks.shift();
811
- if (t) {
812
- const e = Promise.resolve(t.task());
813
- return Promise.resolve(e).then(this.next).then(() => e.then((i) => {
814
- t.done(), t.resolve(i);
815
- })).catch((i) => (t.done(), t.reject(i), this.next()));
816
- }
817
- return Promise.resolve();
818
- });
819
- }
820
- }
821
- const U = /* @__PURE__ */ new WeakMap();
822
- function se(n) {
823
- return U.has(n) || U.set(n, new ie()), (t) => new Promise((e, i) => {
824
- const s = U.get(n);
825
- s.add(t, e, i, () => {
826
- s.tasks.length || U.delete(n);
827
- });
828
- });
829
- }
830
- const yt = (n) => typeof n < "u", L = (n, t) => {
831
- n.events.dispatch("widget:state-change", { state: t }, { bubbles: !0 }), n.state = t, n.events.dispatch("widget:state-changed", {}, { bubbles: !0 });
832
- }, y = R(), re = (n) => {
833
- const { container: t, events: e } = n;
834
- t.get("$controller") || (t.register("$controller", new Wt(t)), e.dispatch("widget:controller-created", {}, { bubbles: !0 }));
835
- };
836
- class oe {
837
- /**
838
- * Creates a new `Widget` instance.
839
- * @param name Name of widget.
840
- * @param implementation The implementation this instance belongs to.
841
- * @param configuration Configuration for the widget.
842
- */
843
- constructor(t, e, i) {
844
- this.state = "deactivated", this.name = t, this.implementation = e, this.container = e.container.createChild(this, t), this.events = e.events.createChild(this), y(this).subscriptions = [], i && e.configure((s) => {
845
- const r = s(t);
846
- yt(i.type) && r.type(i.type), yt(i.settings) && r.settings(i.settings), i.plugins && Object.keys(i.plugins).forEach((a) => {
847
- var o;
848
- const c = (o = i.plugins) == null ? void 0 : o[a];
849
- r.plugin(a, c);
850
- });
851
- }), this.load = this.load.bind(this), this.activate = this.activate.bind(this), this.invoke = this.invoke.bind(this), this.deactivate = this.deactivate.bind(this);
852
- }
853
- /**
854
- * Initializes the widget, if not already initialized, and applies any
855
- * pending configuration.
856
- */
857
- load() {
858
- return se(this)(() => {
859
- y(this).deactivatedPromise = null;
860
- const t = this.state === "deactivated";
861
- t && (L(
862
- this,
863
- "activating"
864
- /* Activating */
865
- ), this.container.register("$widget", this), this.container.register("$controller", null), this.container.register("$plugins", []), this.container.register("$type", null), this.container.register("$instance", null)), L(
866
- this,
867
- "loading"
868
- /* Loading */
869
- );
870
- const e = this.implementation.instructions, i = mt(e, A.Pre, this);
871
- return Promise.all(i.map((s) => s.handler(this))).then(() => {
872
- re(this);
873
- const s = mt(e, A.Post, this);
874
- return Promise.all(s.map((r) => r.handler(this))).then(() => {
875
- t && this.container.get("$controller").initialize();
876
- });
877
- }).then(() => (L(
878
- this,
879
- "activated"
880
- /* Activated */
881
- ), this));
882
- });
883
- }
884
- /**
885
- * Activates the widget and makes it ready for receiving commands.
886
- * @param data Activation data
887
- */
888
- activate(t) {
889
- y(this).subscriptions.push(
890
- this.implementation.events.subscribe("implementation:configured", () => {
891
- [
892
- "activated",
893
- "activating",
894
- "loading"
895
- /* Loading */
896
- ].indexOf(this.state) > -1 && this.load();
897
- })
898
- );
899
- const e = y(this).activatedPromise;
900
- return e ? (process.env.NODE_ENV !== "production" && v(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`, t), e) : y(this).activatedPromise = this.load().then(() => this.container.get("$controller").activate(t));
901
- }
902
- /**
903
- * Invokes a command on a widget. If the widget isn't activate the invocation
904
- * will be suspended until activation.
905
- * @param command Command to invoke.
906
- * @param args Command arguments.
907
- */
908
- invoke(t, ...e) {
909
- const i = y(this).activatedPromise, s = (r, ...a) => i.then(this.load).then(() => this.container.get("$controller").invoke(r, ...a));
910
- return i ? s(t, ...e) : (process.env.NODE_ENV !== "production" && v(this).warn("You are invoking a command on a deactivated widget. The invocation will be queued until the widget is activated.", this), new Promise((r) => {
911
- const a = this.events.subscribe("widget:state-changed", () => {
912
- this.state === "activated" && (a(), r(s(t, ...e)));
913
- });
914
- }));
915
- }
916
- /**
917
- * Deactivates the widget by clearing the `Container` and removing any event subscriptions in the
918
- * `EventManager`.
919
- */
920
- deactivate() {
921
- return y(this).deactivatedPromise || (this.state === "deactivated" ? Promise.resolve() : (L(
922
- this,
923
- "deactivating"
924
- /* Deactivating */
925
- ), y(this).deactivatedPromise = this.container.get("$controller").deactivate().then(() => (y(this).activatedPromise = null, y(this).subscriptions.forEach((e) => e()), y(this).subscriptions = [], this.container.clear().then(() => {
926
- this.events.clear(), Yt(this), L(
927
- this,
928
- "deactivated"
929
- /* Deactivated */
930
- );
931
- })))));
932
- }
933
- }
934
- const bt = R();
935
- class ae {
936
- /**
937
- * Creates a new Implementation instance.
938
- * @param configuration Configuration for the implementation.
939
- * @param environment The parent environment.
940
- * @param configurationApiExtensions Optional configuration API extensions.
941
- */
942
- constructor(t, e, i = []) {
943
- this.instructions = [], this.widgets = /* @__PURE__ */ new Map(), this.name = t.name, this.tenant = t.tenant, this.environment = e, this.container = e.container.createChild(this, this.name), this.events = e.events.createChild(this), this.container.register("$types", {}), bt(this).configurationApiExtensions = i;
944
- }
945
- /**
946
- * Loads all widgets in the implementation.
947
- */
948
- load() {
949
- const t = Array.from(this.widgets.values());
950
- return Promise.all(t.map((e) => e.load())).then(() => t);
951
- }
952
- /**
953
- * Configures the implementation by adding a configuration callback.
954
- * @param configFn Callback function for configuration.
955
- */
956
- configure(t) {
957
- return ne(t, this, bt(this).configurationApiExtensions), this.events.dispatch(
958
- "implementation:configured",
959
- { implementation: this },
960
- { bubbles: !0 }
961
- ), this;
962
- }
963
- /**
964
- * Creates a widget on the implementation and returns its `WidgetData`.
965
- * @param name Widget name.
966
- * @param configuration Widget configuration.
967
- */
968
- createWidget(t, e) {
969
- const i = new oe(t, this, e);
970
- return this.widgets.set(i.name, i), i;
971
- }
972
- }
973
- function ce(n, t, e) {
974
- const i = new ae(n, t, e);
975
- return n.widgets && Object.keys(n.widgets).forEach((s) => {
976
- var r;
977
- const a = (r = n.widgets) == null ? void 0 : r[s];
978
- i.createWidget(s, a);
979
- }), i;
980
- }
981
- let wt = class xt {
982
- constructor(t, e) {
983
- this.selectorFactory = e, typeof t == "function" ? this.resolver = t : this.resolver = () => t;
984
- }
985
- append(t) {
986
- const e = typeof t == "function" ? t : () => t;
987
- return new xt(
988
- () => this.all().concat(e()),
989
- this.selectorFactory
990
- );
991
- }
992
- all() {
993
- return this.resolver().concat([]);
994
- }
995
- query(t) {
996
- return this.all().filter(this.selectorFactory(t));
997
- }
998
- find(t) {
999
- const e = this.query(t);
1000
- if (e.length)
1001
- return e[0];
1002
- }
1003
- };
1004
- const at = "#____version____#", Z = R(), he = (n) => n.tenant ? `${n.name}:${n.tenant}` : n.name, Ot = class {
1005
- constructor(n, t = [], e = {}) {
1006
- this.widgets = new wt(
1007
- () => {
1008
- let i = [];
1009
- return this.implementations.all().forEach((s) => {
1010
- i = i.concat(Array.from(s.widgets.values()));
1011
- }), i;
1012
- },
1013
- Et
1014
- ), this.implementations = new wt([], Qt), this.name = n, this.container = new Ut(this, n), this.events = new ot(this), this.container.register("$version", at), this.container.register("$environment", this), this.container.register("$environmentOptions", e), Z(this).configurationApiExtensions = t;
1015
- }
1016
- /**
1017
- * Creates an implementation based on the provided configuration.
1018
- * @param config Implementation configuration.
1019
- */
1020
- createImplementation(n) {
1021
- const t = he(n);
1022
- let e = this.implementations.find(t);
1023
- if (e)
1024
- return process.env.NODE_ENV !== "production" && v(e).warn(`Implementation "${t}" already exist on current environment.`), e;
1025
- const i = Z(this).configurationApiExtensions;
1026
- return e = ce(
1027
- n,
1028
- this,
1029
- i
1030
- ), this.implementations = this.implementations.append([e]), this.events.dispatch("implementation:created", { implementation: e }), e;
1031
- }
1032
- /**
1033
- * Patches the Environment instance configuration.
1034
- * @param configuration Environment configuration.
1035
- */
1036
- patch(n = {}) {
1037
- const { name: t, configurationApiExtensions: e } = n;
1038
- typeof t < "u" && t !== null && (this.name = t), e && e.forEach(
1039
- (i) => {
1040
- Z(this).configurationApiExtensions.push(i);
1041
- }
1042
- );
1043
- }
1044
- /**
1045
- * Creates a new Environment instance based on the provided configuration.
1046
- * @param configuration Environment configuration.
1047
- */
1048
- static create(n = {}) {
1049
- return new Ot(
1050
- n.name || "",
1051
- n.configurationApiExtensions,
1052
- n.options
1053
- );
1054
- }
1055
- };
1056
- let It = Ot;
1057
- It.version = at;
1058
- const H = (n, t, ...e) => typeof t == "string" ? n(`[humany] ${t}`, ...e) : n(t, ...e), S = class {
159
+ });
160
+ const T = (s, e, ...t) => typeof e == "string" ? s(`[humany] ${e}`, ...t) : s(e, ...t), x = class {
1059
161
  constructor() {
1060
- this.keys = [], this.log = (n, ...t) => this.lookup(n, () => S.log(...t)), this.warn = (n, ...t) => this.lookup(n, () => S.warn(...t)), this.error = (n, ...t) => this.lookup(n, () => S.error(...t)), this.info = (n, ...t) => this.lookup(n, () => S.info(...t));
162
+ this.keys = [], this.log = (s, ...e) => this.lookup(s, () => x.log(...e)), this.warn = (s, ...e) => this.lookup(s, () => x.warn(...e)), this.error = (s, ...e) => this.lookup(s, () => x.error(...e)), this.info = (s, ...e) => this.lookup(s, () => x.info(...e));
1061
163
  }
1062
- lookup(n, t) {
1063
- this.keys.indexOf(n) === -1 && (this.keys.push(n), t());
164
+ lookup(s, e) {
165
+ this.keys.indexOf(s) === -1 && (this.keys.push(s), e());
1064
166
  }
1065
167
  };
1066
- let j = S;
1067
- j.log = (...n) => H(console.log, ...n);
1068
- j.warn = (...n) => H(console.warn, ...n);
1069
- j.error = (...n) => H(console.error, ...n);
1070
- j.info = (...n) => H(console.info, ...n);
1071
- const Mt = (n) => {
1072
- let t = {}, e, i;
1073
- if (typeof n != "object" || n === null)
1074
- return n;
1075
- t = Array.isArray(n) ? [] : {};
1076
- for (i in n)
1077
- e = n[i], t[i] = typeof e == "object" && e !== null ? Mt(e) : e;
1078
- return t;
168
+ let O = x;
169
+ O.log = (...s) => T(console.log, ...s);
170
+ O.warn = (...s) => T(console.warn, ...s);
171
+ O.error = (...s) => T(console.error, ...s);
172
+ O.info = (...s) => T(console.info, ...s);
173
+ const V = (s) => {
174
+ let e = {}, t, n;
175
+ if (typeof s != "object" || s === null)
176
+ return s;
177
+ e = Array.isArray(s) ? [] : {};
178
+ for (n in s)
179
+ t = s[n], e[n] = typeof t == "object" && t !== null ? V(t) : t;
180
+ return e;
1079
181
  };
1080
- class le {
1081
- constructor(t, e) {
1082
- this.lockWarningTime = t, this.lockErrorTime = e, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
182
+ class te {
183
+ constructor(e, t) {
184
+ this.lockWarningTime = e, this.lockErrorTime = t, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
1083
185
  }
1084
- add(t, e, i, s) {
1085
- this.tasks.push({ task: t, resolve: e, reject: i, done: s }), this.next();
186
+ add(e, t, n, i) {
187
+ this.tasks.push({ task: e, resolve: t, reject: n, done: i }), this.next();
1086
188
  }
1087
189
  next() {
1088
190
  this.current = this.current.then(() => {
1089
- const t = this.tasks.shift();
1090
- if (t) {
1091
- let e;
1092
- const i = setTimeout(() => {
1093
- process.env.NODE_ENV !== "production" && j.warn(
191
+ const e = this.tasks.shift();
192
+ if (e) {
193
+ let t;
194
+ const n = setTimeout(() => {
195
+ process.env.NODE_ENV !== "production" && O.warn(
1094
196
  `A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
1095
- t
1096
- ), e = setTimeout(() => {
1097
- t.reject("lock timeout exceeded");
197
+ e
198
+ ), t = setTimeout(() => {
199
+ e.reject("lock timeout exceeded");
1098
200
  }, this.lockErrorTime);
1099
- }, this.lockWarningTime), s = Promise.resolve(t.task()).then((r) => (clearTimeout(i), clearTimeout(e), r));
1100
- return Promise.resolve(s).then(this.next).then(
1101
- () => s.then((r) => {
1102
- t.done(), t.resolve(r);
201
+ }, this.lockWarningTime), i = Promise.resolve(e.task()).then((o) => (clearTimeout(n), clearTimeout(t), o));
202
+ return Promise.resolve(i).then(this.next).then(
203
+ () => i.then((o) => {
204
+ e.done(), e.resolve(o);
1103
205
  })
1104
- ).catch((r) => (t.done(), t.reject(r), this.next()));
206
+ ).catch((o) => (e.done(), e.reject(o), this.next()));
1105
207
  }
1106
208
  return Promise.resolve();
1107
209
  });
1108
210
  }
1109
211
  }
1110
- const W = /* @__PURE__ */ new WeakMap();
1111
- function de(n, t = 5e3, e = 1e3) {
1112
- return W.has(n) || W.set(n, new le(t, e)), (i) => new Promise((s, r) => {
1113
- const a = W.get(n);
1114
- a.add(i, s, r, () => {
1115
- a.tasks.length || W.delete(n);
212
+ const S = /* @__PURE__ */ new WeakMap();
213
+ function se(s, e = 5e3, t = 1e3) {
214
+ return S.has(s) || S.set(s, new te(e, t)), (n) => new Promise((i, o) => {
215
+ const c = S.get(s);
216
+ c.add(n, i, o, () => {
217
+ c.tasks.length || S.delete(s);
1116
218
  });
1117
219
  });
1118
220
  }
1119
- const ue = (n = {}) => (Object.keys(n).forEach((t) => {
1120
- (n[t] === null || typeof n[t] > "u") && delete n[t];
1121
- }), n), B = (n, t) => {
1122
- let e = !0;
1123
- return Object.keys(n).length !== Object.keys(t).length || Object.keys(n).some((i) => !Object.keys(t).some((s) => i === s)) ? !1 : (Object.keys(n).forEach((i) => {
1124
- if (e) {
1125
- const s = typeof n[i] > "u" ? "" : n[i], r = typeof t[i] > "u" ? "" : t[i];
1126
- e = s.toString() === r.toString();
1127
- }
1128
- }), e);
221
+ const ie = (s = {}) => (Object.keys(s).forEach((e) => {
222
+ (s[e] === null || typeof s[e] > "u") && delete s[e];
223
+ }), s), P = (s, e) => {
224
+ let t = !0;
225
+ return Object.keys(s).length !== Object.keys(e).length || Object.keys(s).some((n) => !Object.keys(e).some((i) => n === i)) ? !1 : (Object.keys(s).forEach((n) => {
226
+ if (t) {
227
+ const i = typeof s[n] > "u" ? "" : s[n], o = typeof e[n] > "u" ? "" : e[n];
228
+ t = i.toString() === o.toString();
229
+ }
230
+ }), t);
1129
231
  };
1130
- Nt((n) => {
1131
- n.createCommand("components", (t) => (e) => {
1132
- t.events.subscribeOnce(
232
+ z((s) => {
233
+ s.createCommand("components", (e) => (t) => {
234
+ e.events.subscribeOnce(
1133
235
  "components:platform-created",
1134
- (i, { platform: s }) => {
1135
- e.handlers && e.handlers.forEach(([r, a]) => {
1136
- s.addComponentHandler(r, a);
236
+ (n, { platform: i }) => {
237
+ t.handlers && t.handlers.forEach(([o, c]) => {
238
+ i.addComponentHandler(o, c);
1137
239
  });
1138
240
  }
1139
241
  );
1140
242
  });
1141
243
  });
1142
- const ge = "#____version____#", Rt = class extends It {
1143
- constructor(n, t = []) {
1144
- super(n, t, {
1145
- transformPluginSettings: (e, i, s) => {
1146
- const r = s.get("$settings");
1147
- return {
1148
- ...r.plugins && i ? r.plugins[i] || {} : {},
1149
- ...e
1150
- };
1151
- }
1152
- });
1153
- }
1154
- createImplementation(n) {
1155
- const t = super.createImplementation(n);
1156
- return t.bindings = n.bindings, t;
1157
- }
1158
- /**
1159
- * Performs navigation for widgets matching the specified selector by invoking a
1160
- * 'navigate' command.
1161
- * @param selector Widget selector matching the widget(s) to perform navigation on.
1162
- * @param route Route name.
1163
- * @param params Route params.
1164
- */
1165
- navigate(n, t, e) {
1166
- this.widgets.query(n).forEach((i) => i.invoke("navigate", { route: t, params: e }));
1167
- }
1168
- /**
1169
- * Creates a runtime based on provided configuration.
1170
- * @param configuration Runtime configuration.
1171
- */
1172
- static create(n = {}) {
1173
- const t = [Tt].concat(
1174
- n.configurationApiExtensions || []
1175
- );
1176
- return new Rt("humany", t);
1177
- }
1178
- /**
1179
- * Creates a widget runtime based on provided configuration and retains configuration handlers
1180
- * registered on global context. Use this factory to fully support the default embed script.
1181
- * Will return any existing widget runtime if available.
1182
- * @param configuration Runtime configuration.
1183
- * @param global Object to read configuration handlers from (default: window).
1184
- */
1185
- static createFromGlobal(n, t = {}) {
1186
- if (this.isRuntime(n))
1187
- return n.patch(t), n;
1188
- const e = [], i = n && n._c;
1189
- i && i.forEach(
1190
- (r) => e.push(r)
1191
- );
1192
- const s = this.create(t);
1193
- return s.container.register("$runtimecfg", e), s;
1194
- }
1195
- /**
1196
- * Determines whether the specified object is a valid widget runtime.
1197
- * @param obj Object to compare.
1198
- */
1199
- static isRuntime(n) {
1200
- return !!(n && typeof n == "object" && n.container && typeof n.container.get == "function" && n.container.get("$environment") === n && n.container.owner === n);
1201
- }
1202
- };
1203
- let pe = Rt;
1204
- pe.version = `${ge} (${at})`;
1205
- var V = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(V || {});
1206
- const kt = (n) => import("./index-ca15ddac.mjs").then(
1207
- ({ ServiceClient: t, ServiceProxy: e }) => n.get("settings").then((i) => {
1208
- const { name: s, events: r } = n.get("$widget"), {
1209
- data: { projection: a = "", site: o = "current", forceHttps: c = !1 }
1210
- } = i, h = new e(a, {
244
+ var q = /* @__PURE__ */ ((s) => (s.open = "open", s.closed = "closed", s.hidden = "hidden", s))(q || {});
245
+ const Q = (s) => import("./index-BpmTFodb.mjs").then(
246
+ ({ ServiceClient: e, ServiceProxy: t }) => s.get("settings").then((n) => {
247
+ const { name: i, events: o } = s.get("$widget"), {
248
+ data: { projection: c = "", site: r = "current", forceHttps: a = !1 }
249
+ } = n, d = new t(c, {
1211
250
  credentials: "same-origin"
1212
- }), d = new t(
1213
- h,
251
+ }), h = new e(
252
+ d,
1214
253
  {
1215
- funnel: s.replace("_contact-method", "").replace("_contact", ""),
1216
- site: me(o, c)
254
+ funnel: i.replace("_contact-method", "").replace("_contact", ""),
255
+ site: ne(r, a)
1217
256
  },
1218
257
  null,
1219
- n
258
+ s
1220
259
  );
1221
- return r.subscribe("widget:settings-updated", (g, { data: u }) => {
1222
- u && u.projection !== a && d.proxy.setBaseUrl(u.projection);
1223
- }), d;
260
+ return o.subscribe("widget:settings-updated", (f, { data: u }) => {
261
+ u && u.projection !== c && h.proxy.setBaseUrl(u.projection);
262
+ }), h;
1224
263
  })
1225
- ), me = (n, t) => () => {
1226
- const e = (s) => {
1227
- const r = document.createElement("a");
1228
- return r.href = s, r;
264
+ ), ne = (s, e) => () => {
265
+ const t = (i) => {
266
+ const o = document.createElement("a");
267
+ return o.href = i, o;
1229
268
  };
1230
- let i = window.location;
1231
- return n === "referrer" && document.referrer && (i = e(document.referrer)), [
1232
- t ? "https:" : "",
269
+ let n = window.location;
270
+ return s === "referrer" && document.referrer && (n = t(document.referrer)), [
271
+ e ? "https:" : "",
1233
272
  "//",
1234
- i.host,
1235
- i.pathname
273
+ n.host,
274
+ n.pathname
1236
275
  ].join("");
1237
- }, O = (n) => {
1238
- if (n) {
1239
- const { Type: t, Content: e } = n;
1240
- if (t && e)
1241
- return { type: t, content: e };
1242
- }
1243
- }, it = (n) => n.map((t) => {
1244
- const e = {
1245
- id: t.Id.toString(),
1246
- title: t.Name,
1247
- symbol: O(t.DefaultIcon),
1248
- activeSymbol: t.ActiveIcon && O(t.ActiveIcon),
1249
- description: t.Description || t.Attributes && t.Attributes.description || "",
1250
- matches: t.GuidesCount
276
+ }, N = (s) => {
277
+ if (s) {
278
+ const { Type: e, Content: t } = s;
279
+ if (e && t)
280
+ return { type: e, content: t };
281
+ }
282
+ }, U = (s) => s.map((e) => {
283
+ const t = {
284
+ id: e.Id.toString(),
285
+ title: e.Name,
286
+ symbol: N(e.DefaultIcon),
287
+ activeSymbol: e.ActiveIcon && N(e.ActiveIcon),
288
+ description: e.Description || e.Attributes && e.Attributes.description || "",
289
+ matches: e.GuidesCount
1251
290
  };
1252
- return t.Children && t.Children.length && (e.items = it(t.Children)), e;
1253
- }), P = (n, t) => n.filter(({ Type: e }) => e === t).map(({ Id: e, Title: i, Body: s }) => ({
1254
- id: e.toString(),
1255
- title: i,
1256
- body: s
1257
- })), tt = (n) => n.map(({ Id: t, Title: e, DefaultIcon: i, ListNotices: s, Notices: r }) => ({
291
+ return e.Children && e.Children.length && (t.items = U(e.Children)), t;
292
+ }), b = (s, e) => s.filter(({ Type: t }) => t === e).map(({ Id: t, Title: n, Body: i }) => ({
1258
293
  id: t.toString(),
1259
- title: e,
1260
- symbol: O(i),
294
+ title: n,
295
+ body: i
296
+ })), B = (s) => s.map(({ Id: e, Title: t, DefaultIcon: n, ListNotices: i, Notices: o }) => ({
297
+ id: e.toString(),
298
+ title: t,
299
+ symbol: N(n),
1261
300
  defaultHeaderOptions: {
1262
- visible: !!s.length
301
+ visible: !!i.length
1263
302
  },
1264
- notifications: (s || []).concat(r || []).map(({ Id: a, Title: o, Body: c, Type: h, Modified: d }) => ({
1265
- id: a.toString(),
1266
- title: o,
1267
- body: c,
1268
- modified: d,
1269
- expandable: h === "listNotice"
303
+ notifications: (i || []).concat(o || []).map(({ Id: c, Title: r, Body: a, Type: d, Modified: h }) => ({
304
+ id: c.toString(),
305
+ title: r,
306
+ body: a,
307
+ modified: h,
308
+ expandable: d === "listNotice"
1270
309
  }))
1271
- })), et = ({
1272
- Id: n,
1273
- Title: t,
1274
- DefaultIcon: e,
1275
- Exits: [i],
1276
- ExitType: s,
1277
- ConfirmationText: r,
1278
- Description: a
1279
- }, o) => {
1280
- const { Adapter: c } = i || { Adapter: {} }, { ClientName: h = "", Settings: d = {}, CustomClientName: g = "" } = c, u = {
1281
- id: n.toString(),
1282
- title: t,
1283
- description: a,
1284
- symbol: O(e),
1285
- clientName: h === "custom.adapter" ? g : h,
310
+ })), $ = ({
311
+ Id: s,
312
+ Title: e,
313
+ DefaultIcon: t,
314
+ Exits: [n],
315
+ ExitType: i,
316
+ ConfirmationText: o,
317
+ Description: c
318
+ }, r) => {
319
+ const { Adapter: a } = n || { Adapter: {} }, { ClientName: d = "", Settings: h = {}, CustomClientName: f = "" } = a, u = {
320
+ id: s.toString(),
321
+ title: e,
322
+ description: c,
323
+ symbol: N(t),
324
+ clientName: d === "custom.adapter" ? f : d,
1286
325
  expanded: !0,
1287
326
  inline: !0,
1288
327
  body: {}
1289
328
  };
1290
- if (h.indexOf("phone") > -1 || h.indexOf("freetext") > -1) {
1291
- const { displayTextBeforeClick: p, textBeforeClick: b } = d;
1292
- p === "true" && (u.expanded = !1, u.title = b), h.indexOf("phone.text") > -1 ? u.body.phoneNumber = d.phoneNumber : u.body.freetext = d.freetext;
1293
- }
1294
- return (h.indexOf("chat.popup") > -1 || h.indexOf("link") > -1 || h === "custom.adapter" && s === "custom") && (u.body = d, u.body.confirmationFallback = r), h.indexOf("ace") > -1 && (u.body = d), u;
1295
- }, q = (n = []) => n.map(
1296
- ({ Id: t, Title: e, TotalMatches: i, Symbol: s, DefaultIcon: r, ActiveIcon: a }) => ({
1297
- id: t.toString(),
1298
- title: e,
1299
- matches: i,
1300
- symbol: O(r || s),
1301
- defaultIcon: O(r),
1302
- activeIcon: O(a)
329
+ if (d.indexOf("phone") > -1 || d.indexOf("freetext") > -1) {
330
+ const { displayTextBeforeClick: m, textBeforeClick: w } = h;
331
+ m === "true" && (u.expanded = !1, u.title = w), d.indexOf("phone.text") > -1 ? u.body.phoneNumber = h.phoneNumber : u.body.freetext = h.freetext;
332
+ }
333
+ return (d.indexOf("chat.popup") > -1 || d.indexOf("link") > -1 || d === "custom.adapter" && i === "custom") && (u.body = h, u.body.confirmationFallback = o), d.indexOf("ace") > -1 && (u.body = h), u;
334
+ }, M = (s = []) => s.map(
335
+ ({ Id: e, Title: t, TotalMatches: n, Symbol: i, DefaultIcon: o, ActiveIcon: c }) => ({
336
+ id: e.toString(),
337
+ title: t,
338
+ matches: n,
339
+ symbol: N(o || i),
340
+ defaultIcon: N(o),
341
+ activeIcon: N(c)
1303
342
  })
1304
- ), nt = (n) => n.map(({ Id: t, Title: e, Tags: i, FirstPublishedDate: s, Modified: r }) => ({
1305
- id: t.toString(),
1306
- title: e,
1307
- tags: q(i),
1308
- published: s,
1309
- modified: r
1310
- })), fe = (n, t) => {
1311
- switch (n) {
343
+ ), D = (s) => s.map(({ Id: e, Title: t, Tags: n, FirstPublishedDate: i, Modified: o }) => ({
344
+ id: e.toString(),
345
+ title: t,
346
+ tags: M(n),
347
+ published: i,
348
+ modified: o
349
+ })), oe = (s, e) => {
350
+ switch (s) {
1312
351
  case C.MatchByCategory:
1313
352
  case C.Match: {
1314
- const e = {
353
+ const t = {
1315
354
  guides: [],
1316
355
  matches: 0,
1317
356
  topNotifications: [],
@@ -1321,148 +360,148 @@ const kt = (n) => import("./index-ca15ddac.mjs").then(
1321
360
  tags: [],
1322
361
  byCategory: []
1323
362
  }, {
1324
- Matches: i,
1325
- TotalMatches: s,
1326
- Notices: r,
1327
- NoticeLists: a,
1328
- Tags: o,
1329
- ByCategory: c
1330
- } = t;
1331
- return e.guides = nt(i), e.matches = s, e.byCategory = (c || []).map(
1332
- ({ Id: h, Matches: d, TotalMatches: g }) => ({
1333
- id: h,
1334
- guides: nt(d),
1335
- matches: g
363
+ Matches: n,
364
+ TotalMatches: i,
365
+ Notices: o,
366
+ NoticeLists: c,
367
+ Tags: r,
368
+ ByCategory: a
369
+ } = e;
370
+ return t.guides = D(n), t.matches = i, t.byCategory = (a || []).map(
371
+ ({ Id: d, Matches: h, TotalMatches: f }) => ({
372
+ id: d,
373
+ guides: D(h),
374
+ matches: f
1336
375
  })
1337
- ), e.tags = q(o), e.notificationLists = tt(a || []), e.topNotifications = P(r || [], "noticeRowTop"), e.middleNotifications = P(r || [], "noticeRowMiddle"), e.bottomNotifications = P(r || [], "footerNotice"), e;
376
+ ), t.tags = M(r), t.notificationLists = B(c || []), t.topNotifications = b(o || [], "noticeRowTop"), t.middleNotifications = b(o || [], "noticeRowMiddle"), t.bottomNotifications = b(o || [], "footerNotice"), t;
1338
377
  }
1339
378
  case C.Categories: {
1340
- const { Children: e, GuidesCountTotal: i } = t;
379
+ const { Children: t, GuidesCountTotal: n } = e;
1341
380
  return {
1342
- categories: it(e || []),
1343
- matches: i
381
+ categories: U(t || []),
382
+ matches: n
1344
383
  };
1345
384
  }
1346
385
  case C.Guide: {
1347
386
  const {
1348
- Id: e,
1349
- Title: i,
1350
- Body: s,
1351
- Related: r,
1352
- Options: a,
1353
- ConnectionId: o,
1354
- ContactMethods: c,
1355
- EnableFeedback: h,
1356
- HandoverExists: d,
1357
- FirstPublishedDate: g,
387
+ Id: t,
388
+ Title: n,
389
+ Body: i,
390
+ Related: o,
391
+ Options: c,
392
+ ConnectionId: r,
393
+ ContactMethods: a,
394
+ EnableFeedback: d,
395
+ HandoverExists: h,
396
+ FirstPublishedDate: f,
1358
397
  Modified: u,
1359
- ModifiedByDisplayName: p,
1360
- FirstPublishedByDisplayName: b,
1361
- Categories: w,
398
+ ModifiedByDisplayName: m,
399
+ FirstPublishedByDisplayName: w,
400
+ Categories: p,
1362
401
  Tags: l,
1363
- SeoMetaDescription: f,
1364
- SeoAllowIndex: Y,
1365
- Perspectives: _,
1366
- PerspectiveKey: ct,
1367
- Translations: ht
1368
- } = t, _t = ct || Object.values(_).find(
1369
- (N) => N === o
1370
- ) || _.Default || null, lt = {
402
+ SeoMetaDescription: g,
403
+ SeoAllowIndex: L,
404
+ Perspectives: I,
405
+ PerspectiveKey: _,
406
+ Translations: H
407
+ } = e, Y = _ || Object.values(I).find(
408
+ (v) => v === r
409
+ ) || I.Default || null, F = {
1371
410
  guide: {
1372
- id: e.toString(),
1373
- title: i,
1374
- body: s,
411
+ id: t.toString(),
412
+ title: n,
413
+ body: i,
1375
414
  modified: u,
1376
- published: g,
1377
- modifiedBy: p,
1378
- publishedBy: b,
1379
- connection: o,
1380
- categories: w,
1381
- hasHandover: d,
1382
- allowFeedback: h,
1383
- seoMetaDescription: f,
1384
- seoAllowIndex: Y,
1385
- perspectives: _,
1386
- perspective: _t,
1387
- translations: Object.keys(ht || {}).reduce((N, D) => (N[D] = ht[D].toString(), N), {})
415
+ published: f,
416
+ modifiedBy: m,
417
+ publishedBy: w,
418
+ connection: r,
419
+ categories: p,
420
+ hasHandover: h,
421
+ allowFeedback: d,
422
+ seoMetaDescription: g,
423
+ seoAllowIndex: L,
424
+ perspectives: I,
425
+ perspective: Y,
426
+ translations: Object.keys(H || {}).reduce((v, R) => (v[R] = H[R].toString(), v), {})
1388
427
  },
1389
- related: nt(r || []),
428
+ related: D(o || []),
1390
429
  dialog: [],
1391
- contactMethods: (c || []).map(
1392
- (N) => et(N)
430
+ contactMethods: (a || []).map(
431
+ (v) => $(v)
1393
432
  ),
1394
- tags: q(l)
433
+ tags: M(l)
1395
434
  };
1396
- return (a || []).forEach(
1397
- ({ CanAccess: N, Description: D, ConnectionId: Lt, Properties: k }) => {
1398
- if (!N)
435
+ return (c || []).forEach(
436
+ ({ CanAccess: v, Description: R, ConnectionId: J, Properties: y }) => {
437
+ if (!v)
1399
438
  return;
1400
- const I = {
1401
- id: e.toString(),
1402
- title: D,
1403
- connection: Lt,
1404
- connectionKey: k.ConnectionKey,
439
+ const A = {
440
+ id: t.toString(),
441
+ title: R,
442
+ connection: J,
443
+ connectionKey: y.ConnectionKey,
1405
444
  type: "default",
1406
445
  parent: {
1407
- id: e.toString(),
1408
- title: i,
1409
- tags: q(l)
446
+ id: t.toString(),
447
+ title: n,
448
+ tags: M(l)
1410
449
  }
1411
450
  };
1412
- if (k.Type === "Guide" || k.Type === "Link")
1413
- switch (k.Id && (I.id = k.Id.toString()), k.Uri && (I.href = k.Uri), k.Target && (I.target = k.Target), k.Type) {
451
+ if (y.Type === "Guide" || y.Type === "Link")
452
+ switch (y.Id && (A.id = y.Id.toString()), y.Uri && (A.href = y.Uri), y.Target && (A.target = y.Target), y.Type) {
1414
453
  case "Guide":
1415
- I.type = "guide";
454
+ A.type = "guide";
1416
455
  break;
1417
456
  case "Link":
1418
- I.type = "link";
457
+ A.type = "link";
1419
458
  break;
1420
459
  }
1421
- lt.dialog.push(I);
460
+ F.dialog.push(A);
1422
461
  }
1423
- ), lt;
462
+ ), F;
1424
463
  }
1425
464
  case C.Contacts: {
1426
465
  const {
1427
- Children: e,
1428
- Matches: i,
1429
- Notices: s,
1430
- NoticeLists: r
1431
- } = t;
466
+ Children: t,
467
+ Matches: n,
468
+ Notices: i,
469
+ NoticeLists: o
470
+ } = e;
1432
471
  return {
1433
- contactMethods: (i || []).map(
1434
- (o) => et(o)
472
+ contactMethods: (n || []).map(
473
+ (r) => $(r)
1435
474
  ),
1436
- categories: it(e || []),
1437
- topNotifications: P(s || [], "noticeRowTop"),
1438
- middleNotifications: P(s || [], "noticeRowMiddle"),
1439
- bottomNotifications: P(s || [], "footerNotice"),
1440
- notificationLists: tt(r || [])
475
+ categories: U(t || []),
476
+ topNotifications: b(i || [], "noticeRowTop"),
477
+ middleNotifications: b(i || [], "noticeRowMiddle"),
478
+ bottomNotifications: b(i || [], "footerNotice"),
479
+ notificationLists: B(o || [])
1441
480
  };
1442
481
  }
1443
482
  case C.ContactMethod: {
1444
- const { ContactMethod: e } = t;
1445
- return et(e || {});
483
+ const { ContactMethod: t } = e;
484
+ return $(t || {});
1446
485
  }
1447
486
  case C.Tags:
1448
487
  case C.TagsOnGuides:
1449
- return q(t || []);
488
+ return M(e || []);
1450
489
  case C.Notifications: {
1451
- const { Notices: e, NoticeLists: i } = t;
490
+ const { Notices: t, NoticeLists: n } = e;
1452
491
  return {
1453
- topNotifications: P(e || [], "noticeRowTop"),
1454
- middleNotifications: P(e || [], "noticeRowMiddle"),
1455
- bottomNotifications: P(e || [], "footerNotice"),
1456
- notificationLists: tt(i || [])
492
+ topNotifications: b(t || [], "noticeRowTop"),
493
+ middleNotifications: b(t || [], "noticeRowMiddle"),
494
+ bottomNotifications: b(t || [], "footerNotice"),
495
+ notificationLists: B(n || [])
1457
496
  };
1458
497
  }
1459
498
  default:
1460
499
  return {};
1461
500
  }
1462
501
  };
1463
- var ve = /* @__PURE__ */ ((n) => (n.Guide = "guide", n.Guides = "guides", n.GuidesByCategory = "guides-by-category", n.RowNotifications = "row-notices", n.NotificationLists = "notification-lists", n.GuideCategories = "guide-categories", n.ContactMethodCategories = "contact-method-categories", n.ContactMethod = "contact-method", n.ContactMethods = "contact-methods", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n))(ve || {}), C = /* @__PURE__ */ ((n) => (n.Match = "match", n.Categories = "categories", n.Guide = "guide", n.Contacts = "contacts", n.ContactMethod = "contact-method", n.MatchByCategory = "match-by-category", n.Tags = "tags", n.TagsOnGuides = "tagsonguides", n.Notifications = "notifications", n))(C || {}), ye = /* @__PURE__ */ ((n) => (n.Positive = "Positive", n.Negative = "Negative", n))(ye || {}), be = /* @__PURE__ */ ((n) => (n.POPULARITY_DESCENDING = "popularity-descending", n.ALPHABETIC_ASCENDING = "alphabetic-ascending", n.ALPHABETIC_DESCENDING = "alphabetic-descending", n.MODIFIED_ASCENDING = "modified-ascending", n.MODIFIED_DESCENDING = "modified-descending", n.PUBLISHED_ASCENDING = "published-ascending", n.PUBLISHED_DESCENDING = "published-descending", n))(be || {});
1464
- const Ct = (n) => {
1465
- switch (n) {
502
+ var re = /* @__PURE__ */ ((s) => (s.Guide = "guide", s.Guides = "guides", s.GuidesByCategory = "guides-by-category", s.RowNotifications = "row-notices", s.NotificationLists = "notification-lists", s.GuideCategories = "guide-categories", s.ContactMethodCategories = "contact-method-categories", s.ContactMethod = "contact-method", s.ContactMethods = "contact-methods", s.Tags = "tags", s.TagsOnGuides = "tagsonguides", s))(re || {}), C = /* @__PURE__ */ ((s) => (s.Match = "match", s.Categories = "categories", s.Guide = "guide", s.Contacts = "contacts", s.ContactMethod = "contact-method", s.MatchByCategory = "match-by-category", s.Tags = "tags", s.TagsOnGuides = "tagsonguides", s.Notifications = "notifications", s))(C || {}), ce = /* @__PURE__ */ ((s) => (s.Positive = "Positive", s.Negative = "Negative", s))(ce || {}), ae = /* @__PURE__ */ ((s) => (s.POPULARITY_DESCENDING = "popularity-descending", s.ALPHABETIC_ASCENDING = "alphabetic-ascending", s.ALPHABETIC_DESCENDING = "alphabetic-descending", s.MODIFIED_ASCENDING = "modified-ascending", s.MODIFIED_DESCENDING = "modified-descending", s.PUBLISHED_ASCENDING = "published-ascending", s.PUBLISHED_DESCENDING = "published-descending", s))(ae || {});
503
+ const K = (s) => {
504
+ switch (s) {
1466
505
  case "guides":
1467
506
  return "match";
1468
507
  case "guides-by-category":
@@ -1486,258 +525,258 @@ const Ct = (n) => {
1486
525
  default:
1487
526
  throw "error";
1488
527
  }
1489
- }, we = async (n) => {
1490
- const { invoke: t } = n.get("$widget");
1491
- return await t("renderState") === V.hidden;
528
+ }, de = async (s) => {
529
+ const { invoke: e } = s.get("$widget");
530
+ return await e("renderState") === q.hidden;
1492
531
  };
1493
- class G {
1494
- constructor(t, e) {
1495
- this.container = t, this.matchingClient = e, this.queries = /* @__PURE__ */ new Map(), this.getUnresolvedQueries = () => {
1496
- let i = 0;
1497
- return this.queries.forEach((s, r) => {
1498
- s.some((o) => !o.resolved) && (i = 1);
1499
- }), i;
1500
- }, this.events = t.get("$widget").events, this.events.subscribe(
532
+ class E {
533
+ constructor(e, t) {
534
+ this.container = e, this.matchingClient = t, this.queries = /* @__PURE__ */ new Map(), this.getUnresolvedQueries = () => {
535
+ let n = 0;
536
+ return this.queries.forEach((i, o) => {
537
+ i.some((r) => !r.resolved) && (n = 1);
538
+ }), n;
539
+ }, this.events = e.get("$widget").events, this.events.subscribe(
1501
540
  "widget:settings-updated",
1502
541
  () => this.queries = /* @__PURE__ */ new Map()
1503
542
  ), this.events.subscribe(
1504
543
  "widget:render-state-changed",
1505
- (i, { next: s, previous: r }) => {
1506
- r === V.hidden && s === V.open && this.fetchAllUnresolvedQueries();
544
+ (n, { next: i, previous: o }) => {
545
+ o === q.hidden && i === q.open && this.fetchAllUnresolvedQueries();
1507
546
  }
1508
547
  );
1509
548
  }
1510
- static getInstance(t, e = "dataClient") {
1511
- return de(this)(() => t.getAsync(e).then(async (i) => {
1512
- let s = await t.getAsync("matchingClient");
1513
- s || (s = await kt(t), t.registerAsync("matchingClient", () => s));
1514
- let r = i;
1515
- return r || (r = new G(t, s), t.registerAsync(e, () => r)), r;
549
+ static getInstance(e, t = "dataClient") {
550
+ return se(this)(() => e.getAsync(t).then(async (n) => {
551
+ let i = await e.getAsync("matchingClient");
552
+ i || (i = await Q(e), e.registerAsync("matchingClient", () => i));
553
+ let o = n;
554
+ return o || (o = new E(e, i), e.registerAsync(t, () => o)), o;
1516
555
  }));
1517
556
  }
1518
- fetch(t, e, i) {
1519
- return new Promise((s, r) => {
1520
- e.take, ue(e);
1521
- const a = Ct(t);
1522
- let o = this.queries.get(a) || [], c = o.find((h) => B(h.params, e)) || null;
1523
- if (c && (i != null && i.noCache)) {
1524
- const h = o.findIndex(
1525
- (d) => B(d.params, e)
557
+ fetch(e, t, n) {
558
+ return new Promise((i, o) => {
559
+ t.take, ie(t);
560
+ const c = K(e);
561
+ let r = this.queries.get(c) || [], a = r.find((d) => P(d.params, t)) || null;
562
+ if (a && (n != null && n.noCache)) {
563
+ const d = r.findIndex(
564
+ (h) => P(h.params, t)
1526
565
  );
1527
- o = [...o.slice(0, h), ...o.slice(h + 1)], c = null;
566
+ r = [...r.slice(0, d), ...r.slice(d + 1)], a = null;
1528
567
  }
1529
- if (c) {
1530
- const h = o.indexOf(c);
1531
- if (c.resolved ? (this.events.dispatch("data-client:fetched", {
1532
- params: e,
1533
- type: a,
1534
- response: c.data,
568
+ if (a) {
569
+ const d = r.indexOf(a);
570
+ if (a.resolved ? (this.events.dispatch("data-client:fetched", {
571
+ params: t,
572
+ type: c,
573
+ response: a.data,
1535
574
  unresolvedQueries: this.getUnresolvedQueries()
1536
- }), this.track(c.data, a, c.error), c.data && c.error ? r({ error: c.error }) : s(c.data)) : c.resolvers.push({ resolve: s, reject: r }), o.splice(h, 1), o.push(c), this.queries.set(a, o), !c.loading && !c.resolved)
1537
- return this.runQuery(a, e);
575
+ }), this.track(a.data, c, a.error), a.data && a.error ? o({ error: a.error }) : i(a.data)) : a.resolvers.push({ resolve: i, reject: o }), r.splice(d, 1), r.push(a), this.queries.set(c, r), !a.loading && !a.resolved)
576
+ return this.runQuery(c, t);
1538
577
  } else
1539
- return o.push({
1540
- params: e,
578
+ return r.push({
579
+ params: t,
1541
580
  resolved: !1,
1542
581
  loading: !0,
1543
582
  data: {},
1544
- resolvers: [{ resolve: s, reject: r }]
1545
- }), this.queries.set(a, o), this.runQuery(a, e);
1546
- }).then((s) => Mt(s));
583
+ resolvers: [{ resolve: i, reject: o }]
584
+ }), this.queries.set(c, r), this.runQuery(c, t);
585
+ }).then((i) => V(i));
1547
586
  }
1548
587
  // query the cached data
1549
- read(t, e) {
1550
- const { select: i } = e, s = Ct(t);
1551
- return (this.queries.get(s) || []).reduce((o, c) => {
1552
- if (typeof i == "function") {
1553
- const h = i(c.data);
1554
- h && o.push(h);
588
+ read(e, t) {
589
+ const { select: n } = t, i = K(e);
590
+ return (this.queries.get(i) || []).reduce((r, a) => {
591
+ if (typeof n == "function") {
592
+ const d = n(a.data);
593
+ d && r.push(d);
1555
594
  } else
1556
- o.push(c.data);
1557
- return o;
595
+ r.push(a.data);
596
+ return r;
1558
597
  }, []);
1559
598
  }
1560
- feedback(t, e, i) {
1561
- return this.matchingClient.giveFeedback(t, e, i);
599
+ feedback(e, t, n) {
600
+ return this.matchingClient.giveFeedback(e, t, n);
1562
601
  }
1563
- setLoadingStatus(t, e, i) {
1564
- const s = this.queries.get(t) || [], r = s.find((a) => B(a.params, e));
1565
- r && (r.loading = i), this.queries.set(t, s);
602
+ setLoadingStatus(e, t, n) {
603
+ const i = this.queries.get(e) || [], o = i.find((c) => P(c.params, t));
604
+ o && (o.loading = n), this.queries.set(e, i);
1566
605
  }
1567
- async runQuery(t, e) {
606
+ async runQuery(e, t) {
1568
607
  const {
1569
- searchPhrase: i = "",
1570
- categories: s = "0",
1571
- contactMethodCategoryId: r = "0",
1572
- contactMethodId: a = "0",
1573
- tagId: o = void 0,
1574
- take: c = 5,
1575
- connection: h = "",
1576
- guideId: d,
1577
- expandCategories: g = "descendants",
608
+ searchPhrase: n = "",
609
+ categories: i = "0",
610
+ contactMethodCategoryId: o = "0",
611
+ contactMethodId: c = "0",
612
+ tagId: r = void 0,
613
+ take: a = 5,
614
+ connection: d = "",
615
+ guideId: h,
616
+ expandCategories: f = "descendants",
1578
617
  currentCategory: u,
1579
- sorting: p = "popularity-descending",
1580
- guideIds: b = []
1581
- } = e, w = i.toString().trim();
1582
- if (await we(this.container))
618
+ sorting: m = "popularity-descending",
619
+ guideIds: w = []
620
+ } = t, p = n.toString().trim();
621
+ if (await de(this.container))
1583
622
  return Promise.resolve();
1584
- switch (t) {
623
+ switch (e) {
1585
624
  case "match": {
1586
- const l = (f) => {
1587
- const [Y, _] = f.split("-");
625
+ const l = (g) => {
626
+ const [L, I] = g.split("-");
1588
627
  return {
1589
628
  type: (/* @__PURE__ */ new Map([
1590
629
  ["popularity", "popularity"],
1591
630
  ["alphabetic", "title"],
1592
631
  ["modified", "lastModified"],
1593
632
  ["published", "firstPublished"]
1594
- ])).get(Y),
1595
- direction: _
633
+ ])).get(L),
634
+ direction: I
1596
635
  };
1597
636
  };
1598
- return b.length ? this.matchingClient.customRequest("guides", "POST", {
1599
- configuration: { ids: b, take: +c }
637
+ return w.length ? this.matchingClient.customRequest("guides", "POST", {
638
+ configuration: { ids: w, take: +a }
1600
639
  }).then(
1601
- (f) => f && this.handleResponse(f, t, e)
1602
- ) : this.matchingClient.match(w, {
1603
- categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
1604
- take: +c,
1605
- tags: o,
1606
- sorting: l(p),
1607
- ids: b
640
+ (g) => g && this.handleResponse(g, e, t)
641
+ ) : this.matchingClient.match(p, {
642
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
643
+ take: +a,
644
+ tags: r,
645
+ sorting: l(m),
646
+ ids: w
1608
647
  }).then(
1609
- (f) => f && this.handleResponse(f, t, e)
648
+ (g) => g && this.handleResponse(g, e, t)
1610
649
  );
1611
650
  }
1612
651
  case "match-by-category":
1613
- return this.matchingClient.match(w, {
652
+ return this.matchingClient.match(p, {
1614
653
  groupByCategory: !0,
1615
- categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
1616
- take: +c,
1617
- tags: o
654
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
655
+ take: +a,
656
+ tags: r
1618
657
  }).then(
1619
- (l) => l && this.handleResponse(l, t, e)
658
+ (l) => l && this.handleResponse(l, e, t)
1620
659
  );
1621
660
  case "guide":
1622
- return this.matchingClient.getGuide(d, { connectionId: h }).then((l) => {
1623
- l && this.handleResponse(l, t, e);
661
+ return this.matchingClient.getGuide(h, { connectionId: d }).then((l) => {
662
+ l && this.handleResponse(l, e, t);
1624
663
  }).catch((l) => {
1625
- const f = {
664
+ const g = {
1626
665
  message: "Something went wrong.",
1627
666
  status: l.status || 400
1628
667
  };
1629
- f.status === 404 && (f.message = "The guide could not be found."), this.handleResponse({}, t, e, f);
668
+ g.status === 404 && (g.message = "The guide could not be found."), this.handleResponse({}, e, t, g);
1630
669
  });
1631
670
  case "categories":
1632
671
  return this.matchingClient.getCategories({
1633
- phrase: w,
1634
- expand: g,
1635
- tags: o
672
+ phrase: p,
673
+ expand: f,
674
+ tags: r
1636
675
  }).then(
1637
- (l) => l && this.handleResponse(l, t, e)
676
+ (l) => l && this.handleResponse(l, e, t)
1638
677
  );
1639
678
  case "contacts":
1640
- return d ? this.matchingClient.contactMethods(+d, { phrase: w }).then(
1641
- (l) => l && this.handleResponse(l, t, e)
1642
- ) : this.matchingClient.contacts(+r, { phrase: w }).then(
1643
- (l) => l && this.handleResponse(l, t, e)
679
+ return h ? this.matchingClient.contactMethods(+h, { phrase: p }).then(
680
+ (l) => l && this.handleResponse(l, e, t)
681
+ ) : this.matchingClient.contacts(+o, { phrase: p }).then(
682
+ (l) => l && this.handleResponse(l, e, t)
1644
683
  );
1645
684
  case "contact-method":
1646
- return this.matchingClient.getContactMethod(+a, { guideId: d, currentCategory: u }).then(
1647
- (l) => l && this.handleResponse(l, t, e)
685
+ return this.matchingClient.getContactMethod(+c, { guideId: h, currentCategory: u }).then(
686
+ (l) => l && this.handleResponse(l, e, t)
1648
687
  );
1649
688
  case "tags":
1650
689
  return this.matchingClient.customRequest("tags", "GET", {
1651
690
  configuration: {
1652
691
  take: 999999,
1653
- phrase: w,
1654
- categories: s === "0" ? [] : Array.isArray(s) ? s : [+s]
692
+ phrase: p,
693
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i]
1655
694
  }
1656
695
  }).then(
1657
- (l) => l && this.handleResponse(l, t, e)
696
+ (l) => l && this.handleResponse(l, e, t)
1658
697
  );
1659
698
  case "tagsonguides":
1660
699
  return this.matchingClient.customRequest("tagsonguides", "GET", {
1661
700
  configuration: {
1662
701
  take: 999999,
1663
- phrase: w,
1664
- categories: s === "0" ? [] : Array.isArray(s) ? s : [+s],
1665
- tags: o
702
+ phrase: p,
703
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i],
704
+ tags: r
1666
705
  }
1667
706
  }).then(
1668
- (l) => l && this.handleResponse(l, t, e)
707
+ (l) => l && this.handleResponse(l, e, t)
1669
708
  );
1670
709
  case "notifications":
1671
710
  return this.matchingClient.customRequest("notices", "GET", {
1672
711
  configuration: {
1673
- phrase: w,
1674
- categories: s === "0" ? [] : Array.isArray(s) ? s : [+s]
712
+ phrase: p,
713
+ categories: i === "0" ? [] : Array.isArray(i) ? i : [+i]
1675
714
  }
1676
715
  }).then(
1677
- (l) => l && this.handleResponse(l, t, e)
716
+ (l) => l && this.handleResponse(l, e, t)
1678
717
  );
1679
718
  }
1680
719
  }
1681
- handleResponse(t = {}, e, i, s) {
1682
- const r = this.queries.get(e) || [], a = r.find((o) => B(o.params, i));
1683
- if (a) {
1684
- const o = s || fe(e, t);
1685
- this.track(o, e, s), a.resolvers.forEach((h) => {
1686
- s ? h.reject({ error: o }) : h.resolve(o);
720
+ handleResponse(e = {}, t, n, i) {
721
+ const o = this.queries.get(t) || [], c = o.find((r) => P(r.params, n));
722
+ if (c) {
723
+ const r = i || oe(t, e);
724
+ this.track(r, t, i), c.resolvers.forEach((d) => {
725
+ i ? d.reject({ error: r }) : d.resolve(r);
1687
726
  });
1688
- const c = r.indexOf(a);
1689
- c > -1 && r.splice(c, 1), r.push({
1690
- ...a,
1691
- error: s,
727
+ const a = o.indexOf(c);
728
+ a > -1 && o.splice(a, 1), o.push({
729
+ ...c,
730
+ error: i,
1692
731
  resolvers: [],
1693
- data: o,
732
+ data: r,
1694
733
  resolved: !0
1695
- }), this.setLoadingStatus(e, i, !1), this.queries.set(e, r), s || this.events.dispatch("data-client:fetched", {
1696
- type: e,
1697
- params: i,
1698
- response: o,
734
+ }), this.setLoadingStatus(t, n, !1), this.queries.set(t, o), i || this.events.dispatch("data-client:fetched", {
735
+ type: t,
736
+ params: n,
737
+ response: r,
1699
738
  unresolvedQueries: this.getUnresolvedQueries()
1700
739
  });
1701
740
  }
1702
741
  }
1703
742
  fetchAllUnresolvedQueries() {
1704
- for (const [t, e] of this.queries)
1705
- e.filter((i) => !i.resolved).forEach((i) => {
1706
- this.runQuery(t, i.params);
743
+ for (const [e, t] of this.queries)
744
+ t.filter((n) => !n.resolved).forEach((n) => {
745
+ this.runQuery(e, n.params);
1707
746
  });
1708
747
  }
1709
- track(t = {}, e, i) {
1710
- const s = this.container.get("$widget");
1711
- s && !i ? s.events.dispatch("tracking:service-client-response", {
1712
- type: e,
1713
- data: t
1714
- }) : s && s.events.dispatch("tracking:service-client-error", {
1715
- type: e,
1716
- error: i
748
+ track(e = {}, t, n) {
749
+ const i = this.container.get("$widget");
750
+ i && !n ? i.events.dispatch("tracking:service-client-response", {
751
+ type: t,
752
+ data: e
753
+ }) : i && i.events.dispatch("tracking:service-client-error", {
754
+ type: t,
755
+ error: n
1717
756
  });
1718
757
  }
1719
- static create(t) {
1720
- return t.getAsync("matchingClient").then(async (e) => {
1721
- if (e)
1722
- return new G(t, e);
1723
- const i = await kt(t);
1724
- return t.registerAsync("matchingClient", () => i), new G(t, i);
758
+ static create(e) {
759
+ return e.getAsync("matchingClient").then(async (t) => {
760
+ if (t)
761
+ return new E(e, t);
762
+ const n = await Q(e);
763
+ return e.registerAsync("matchingClient", () => n), new E(e, n);
1725
764
  });
1726
765
  }
1727
766
  getClient() {
1728
767
  return this.matchingClient;
1729
768
  }
1730
769
  }
1731
- const Ce = async (n) => {
1732
- n.registerAsync("dataClient", () => G.create(n));
770
+ const le = async (s) => {
771
+ s.registerAsync("dataClient", () => E.create(s));
1733
772
  };
1734
773
  export {
1735
- G as DataClient,
1736
- ve as DataType,
1737
- ye as FeedbackType,
1738
- Ce as KnowledgeDataClientPlugin,
774
+ E as DataClient,
775
+ re as DataType,
776
+ ce as FeedbackType,
777
+ le as KnowledgeDataClientPlugin,
1739
778
  C as ServiceClientQueryType,
1740
- be as SortingType,
1741
- Ct as determineServiceClientQueryType,
1742
- fe as formatLegacyData
779
+ ae as SortingType,
780
+ K as determineServiceClientQueryType,
781
+ oe as formatLegacyData
1743
782
  };