@telia-ace/widget-core-flamingo 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +3 -0
  3. package/dist/action-resolver.d.ts +9 -0
  4. package/dist/action-resolver.d.ts.map +1 -0
  5. package/dist/bootstrap.d.ts +16 -0
  6. package/dist/bootstrap.d.ts.map +1 -0
  7. package/dist/component-platform/actions-controller.d.ts +41 -0
  8. package/dist/component-platform/actions-controller.d.ts.map +1 -0
  9. package/dist/component-platform/changeset-provider.d.ts +9 -0
  10. package/dist/component-platform/changeset-provider.d.ts.map +1 -0
  11. package/dist/component-platform/component-configuration-api.d.ts +3 -0
  12. package/dist/component-platform/component-configuration-api.d.ts.map +1 -0
  13. package/dist/component-platform/component-controller.d.ts +39 -0
  14. package/dist/component-platform/component-controller.d.ts.map +1 -0
  15. package/dist/component-platform/component-node-collection.d.ts +19 -0
  16. package/dist/component-platform/component-node-collection.d.ts.map +1 -0
  17. package/dist/component-platform/component-node.d.ts +64 -0
  18. package/dist/component-platform/component-node.d.ts.map +1 -0
  19. package/dist/component-platform/component-platform.d.ts +55 -0
  20. package/dist/component-platform/component-platform.d.ts.map +1 -0
  21. package/dist/component-platform/component-query.d.ts +17 -0
  22. package/dist/component-platform/component-query.d.ts.map +1 -0
  23. package/dist/component-platform/create-component-model.d.ts +37 -0
  24. package/dist/component-platform/create-component-model.d.ts.map +1 -0
  25. package/dist/component-platform/custom-component-handler.d.ts +22 -0
  26. package/dist/component-platform/custom-component-handler.d.ts.map +1 -0
  27. package/dist/component-platform/descriptor.d.ts +9 -0
  28. package/dist/component-platform/descriptor.d.ts.map +1 -0
  29. package/dist/component-platform/extend-component.d.ts +9 -0
  30. package/dist/component-platform/extend-component.d.ts.map +1 -0
  31. package/dist/component-platform/index.d.ts +19 -0
  32. package/dist/component-platform/index.d.ts.map +1 -0
  33. package/dist/component-platform/queries.d.ts +7 -0
  34. package/dist/component-platform/queries.d.ts.map +1 -0
  35. package/dist/component-platform/state-processor.d.ts +13 -0
  36. package/dist/component-platform/state-processor.d.ts.map +1 -0
  37. package/dist/component-resolver.d.ts +15 -0
  38. package/dist/component-resolver.d.ts.map +1 -0
  39. package/dist/environment.d.ts +49 -0
  40. package/dist/environment.d.ts.map +1 -0
  41. package/dist/event-subscriber.d.ts +8 -0
  42. package/dist/event-subscriber.d.ts.map +1 -0
  43. package/dist/implementation.d.ts +8 -0
  44. package/dist/implementation.d.ts.map +1 -0
  45. package/dist/index.d.ts +15 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +2076 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/plugin.d.ts +8 -0
  50. package/dist/plugin.d.ts.map +1 -0
  51. package/dist/types/configuration.d.ts +87 -0
  52. package/dist/types/configuration.d.ts.map +1 -0
  53. package/dist/types/index.d.ts +3 -0
  54. package/dist/types/index.d.ts.map +1 -0
  55. package/dist/types/ui.d.ts +49 -0
  56. package/dist/types/ui.d.ts.map +1 -0
  57. package/dist/version.d.ts +3 -0
  58. package/dist/version.d.ts.map +1 -0
  59. package/dist/widget-type.d.ts +8 -0
  60. package/dist/widget-type.d.ts.map +1 -0
  61. package/package.json +48 -0
package/dist/index.js ADDED
@@ -0,0 +1,2076 @@
1
+ var Vt = Object.defineProperty, jt = Object.defineProperties;
2
+ var qt = Object.getOwnPropertyDescriptors;
3
+ var ct = Object.getOwnPropertySymbols;
4
+ var Ft = Object.prototype.hasOwnProperty, Ht = Object.prototype.propertyIsEnumerable;
5
+ var at = (n, t, e) => t in n ? Vt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, I = (n, t) => {
6
+ for (var e in t || (t = {}))
7
+ Ft.call(t, e) && at(n, e, t[e]);
8
+ if (ct)
9
+ for (var e of ct(t))
10
+ Ht.call(t, e) && at(n, e, t[e]);
11
+ return n;
12
+ }, ht = (n, t) => jt(n, qt(t));
13
+ class He {
14
+ constructor(t) {
15
+ const { events: e } = t.get("$widget");
16
+ this.events = e.createChild(this);
17
+ }
18
+ action(t, e, s) {
19
+ this.events.dispatch(
20
+ "data:action",
21
+ { action: e, value: s, target: t },
22
+ { bubbles: !0 }
23
+ );
24
+ }
25
+ subscribe(t, e) {
26
+ return this.events.subscribe(
27
+ "data:action",
28
+ (s, { action: i, value: r, target: o }) => t === o && e(t, i, r)
29
+ );
30
+ }
31
+ }
32
+ const j = (n, t, e, ...s) => {
33
+ const i = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
34
+ switch (t) {
35
+ case "info":
36
+ console.info(i, ...s);
37
+ break;
38
+ case "warning":
39
+ console.warn(i, ...s);
40
+ break;
41
+ case "error":
42
+ console.error(i, ...s);
43
+ break;
44
+ }
45
+ }, $t = (n) => {
46
+ const t = n.container || n;
47
+ return {
48
+ info: (e, ...s) => j(t, "info", e, ...s),
49
+ warn: (e, ...s) => j(t, "warning", e, ...s),
50
+ error: (e, ...s) => j(t, "error", e, ...s)
51
+ };
52
+ }, lt = (n, t) => {
53
+ if (!t)
54
+ return !0;
55
+ if (typeof t == "string") {
56
+ const e = t.split(",");
57
+ for (let s = 0, i = e.length; s < i; s++) {
58
+ const r = e[s].trim();
59
+ if (r === n || r === "*")
60
+ return !0;
61
+ }
62
+ }
63
+ return t instanceof Array ? t.indexOf(n) > -1 : !1;
64
+ }, Wt = (n, t) => {
65
+ if (typeof t == "function")
66
+ return t(n);
67
+ const e = typeof t == "string" ? Qt(t) : t;
68
+ return !(!lt(n.tenant || "", e.tenant || "") || !lt(n.name, e.implementation || ""));
69
+ }, Bt = (n) => (t) => Wt(t, n), q = (n) => n instanceof Array && n.length === 1 ? n[0] : n, Qt = (n) => {
70
+ const t = {}, e = n.split(":");
71
+ return e.length === 1 ? t.implementation = q(e[0].split(",")) : (t.tenant = q(e[0].split(",")), t.implementation = q(e[1].split(","))), t;
72
+ };
73
+ var D = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(D || {}), E = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))(E || {});
74
+ const Yt = (n, t, e, s) => {
75
+ try {
76
+ const i = new t(e, s);
77
+ return {
78
+ name: n,
79
+ invoke: (r, o) => {
80
+ let c;
81
+ return i[r] && (c = i[r].call(i, o)), Promise.resolve(c);
82
+ },
83
+ getInstance: () => i
84
+ };
85
+ } catch (i) {
86
+ if (i.message && i.message.indexOf("is not a constructor") >= 0)
87
+ return {
88
+ name: n,
89
+ invoke: (r) => {
90
+ let o;
91
+ return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
92
+ },
93
+ getInstance: () => t
94
+ };
95
+ throw i;
96
+ }
97
+ };
98
+ function ut(n, t) {
99
+ return typeof n == "undefined" ? t : n;
100
+ }
101
+ let Ut = class {
102
+ constructor(t = {}) {
103
+ this.part = t;
104
+ }
105
+ createCommand(t, e, s) {
106
+ let i;
107
+ typeof e == "function" ? i = {
108
+ scope: D.Widget,
109
+ stage: E.Post,
110
+ defaultArgs: void 0,
111
+ handlerResolver: e
112
+ } : i = {
113
+ scope: ut(e.scope, D.Widget),
114
+ stage: ut(e.stage, E.Post),
115
+ defaultArgs: e.defaultArgs,
116
+ handlerResolver: s
117
+ };
118
+ let r = this.part;
119
+ const o = t.split(".");
120
+ return o.forEach((c, u) => {
121
+ u === o.length - 1 ? r[c] || (r[c] = () => i) : r = this.part[c] = this.part[c] || {};
122
+ }), this;
123
+ }
124
+ get() {
125
+ return this.part;
126
+ }
127
+ };
128
+ const Ct = (n) => {
129
+ const t = new Ut({});
130
+ return n(t), t.get();
131
+ };
132
+ Ct((n) => {
133
+ n.createCommand(
134
+ "types.register",
135
+ { scope: D.Implementation, stage: E.Pre },
136
+ (t) => (e, s) => {
137
+ t.container.get("$types")[e] = s;
138
+ }
139
+ ).createCommand(
140
+ "type",
141
+ { stage: E.Pre },
142
+ (t) => (e) => {
143
+ t.container.register("$type", e);
144
+ }
145
+ ).createCommand(
146
+ "settings",
147
+ { stage: E.Pre, defaultArgs: [null] },
148
+ (t) => (e) => {
149
+ t.events.dispatch(
150
+ "settings:change",
151
+ e,
152
+ { bubbles: !0 }
153
+ ), t.container.register("$settings", e);
154
+ }
155
+ ).createCommand(
156
+ "plugin",
157
+ { stage: E.Pre },
158
+ (t) => (e, s, i) => {
159
+ const { container: r } = t;
160
+ let o = null, c = e, u = s;
161
+ typeof e == "string" && (o = e, c = s, u = i);
162
+ const h = (a) => {
163
+ const { transformPluginSettings: l } = t.container.get("$environmentOptions"), p = l ? l(
164
+ u || {},
165
+ o,
166
+ t.container,
167
+ c
168
+ ) : s;
169
+ try {
170
+ const d = Yt(
171
+ o,
172
+ c,
173
+ r,
174
+ p
175
+ );
176
+ r.get("$plugins").push(d), a && d.invoke("initialize", null);
177
+ } catch (d) {
178
+ $t(t).warn("Error when initializing plugin", d);
179
+ }
180
+ };
181
+ t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
182
+ }
183
+ ).createCommand(
184
+ "container.register",
185
+ (t) => (e, s) => {
186
+ t.container.register(e, s);
187
+ }
188
+ ).createCommand(
189
+ "container.registerAsync",
190
+ (t) => (e, s) => {
191
+ t.container.registerAsync(e, s);
192
+ }
193
+ ).createCommand(
194
+ "container.registerFactory",
195
+ (t) => (e, s) => {
196
+ t.container.registerFactory(e, s);
197
+ }
198
+ ).createCommand(
199
+ "container.touch",
200
+ (t) => (e, s) => {
201
+ t.container.touch(e, s);
202
+ }
203
+ ).createCommand(
204
+ "csp",
205
+ {},
206
+ (t) => (e) => {
207
+ t.container.register("csp", e);
208
+ }
209
+ );
210
+ });
211
+ function Gt(n, t, e) {
212
+ return Array.from(n.querySelectorAll(
213
+ `div[id^="${t}_"], div[id^="${t}:"]`
214
+ )).map((s) => {
215
+ if (s.id.substr(0, 7) === `${t}_`)
216
+ return { widgetName: s.id.substr(7), element: s };
217
+ const { 3: i } = s.id.split(":");
218
+ return { widgetName: i, element: s };
219
+ });
220
+ }
221
+ const Kt = (n) => {
222
+ const t = n.map((e) => e.replace(/\./g, "\\.")).join("|");
223
+ return new RegExp("^((http[s]?:)?//)?(" + t + ")/([^\\s]+)");
224
+ }, Jt = (n) => n.href;
225
+ function Xt(n, t) {
226
+ const e = Kt(t), s = (i) => {
227
+ const r = e.exec(Jt(i));
228
+ return r ? {
229
+ element: i,
230
+ widget: r[4]
231
+ } : null;
232
+ };
233
+ return Array.from(n.querySelectorAll("a")).map((i) => s(i)).filter((i) => !!i).map((i) => ({
234
+ element: i.element,
235
+ widgetName: i.widget
236
+ }));
237
+ }
238
+ function kt(n) {
239
+ return n.filter((t, e, s) => s.indexOf(t) === e);
240
+ }
241
+ let Zt = class {
242
+ constructor(t) {
243
+ this.container = t.container, this.events = t.events;
244
+ }
245
+ watch(t) {
246
+ const e = this.container.get("triggerElements") || [], s = kt(e.concat(t));
247
+ this.container.register("triggerElements", s), this.events.dispatch(
248
+ "bootstrap:trigger-elements-updated",
249
+ { triggerElements: s },
250
+ { bubbles: !0 }
251
+ );
252
+ }
253
+ };
254
+ function Et(n, ...t) {
255
+ return n.implementation.events.subscribe("widget:create-instance", (e, s) => {
256
+ if (e.target === n) {
257
+ let i = n.container.get("bootstrapping.monitor");
258
+ i || (i = new Zt(n), n.container.register("bootstrapping.monitor", i)), i.watch(t);
259
+ }
260
+ }), n.load();
261
+ }
262
+ function Pt(n, t = document) {
263
+ var e;
264
+ const s = n.bindings, i = [].concat(
265
+ Xt(t, s),
266
+ Gt(t, ((e = n.environment) == null ? void 0 : e.name) || "")
267
+ ), r = kt(i.map(({ widgetName: o }) => o)).reduce((o, c) => {
268
+ const u = n.widgets.get(c);
269
+ if (!u)
270
+ return process.env.NODE_ENV !== "production" && $t(n).warn(`A trigger element for "${c}" was found but no widget with that name is available on the implementation ("${n.name}"). Make sure this is not a mistake.`), o;
271
+ const h = i.filter((a) => a.widgetName === c).map((a) => a.element);
272
+ return o.push(Et(u, ...h)), o;
273
+ }, []);
274
+ return Promise.all(r);
275
+ }
276
+ function te() {
277
+ return new Promise((n) => {
278
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => n()) : n();
279
+ });
280
+ }
281
+ const ee = (n, t) => {
282
+ const e = n;
283
+ e.scan = (i) => Pt(e, i), e.bindings = t, e.attach = (i, ...r) => Et(i, ...r);
284
+ const { environment: s } = e;
285
+ return typeof s.configure == "undefined" && (s.configure = (i, r) => {
286
+ let o, c;
287
+ r ? (o = i, c = r) : (o = "*", c = i), s.implementations.query(o).forEach((u) => u.configure(c)), s.events.subscribe("implementation:created", (u, h) => {
288
+ const { implementation: a } = h;
289
+ Bt(o)(a) && a.configure(c);
290
+ });
291
+ }), e;
292
+ };
293
+ function se(n, t, e = () => [], s) {
294
+ const i = { ready: !1 };
295
+ n.container.register("bootstrapping", i);
296
+ const r = ee(n, t);
297
+ return te().then(() => {
298
+ n.configure((...o) => {
299
+ e().forEach((c) => c(...o));
300
+ });
301
+ }).then(() => Pt(r, s())).then(() => (i.ready = !0, n.events.dispatch("bootstrap:ready", {}), r));
302
+ }
303
+ const ne = Ct((n) => {
304
+ n.createCommand(
305
+ "ready",
306
+ { scope: D.Implementation, stage: E.Pre },
307
+ (t) => (e) => {
308
+ const { container: s } = t, i = s.owner;
309
+ s.get("bootstrapping").ready ? e(i) : i.events.subscribeOnce("bootstrap:ready", () => {
310
+ e(i);
311
+ });
312
+ }
313
+ );
314
+ }), F = /* @__PURE__ */ new WeakMap();
315
+ function A() {
316
+ return (n) => (F.has(n) || F.set(n, {}), F.get(n));
317
+ }
318
+ const H = (n, t, e, ...s) => {
319
+ const i = `[${n.get("$environment").name || "webprovisions"}] ${e}`;
320
+ switch (t) {
321
+ case "info":
322
+ console.info(i, ...s);
323
+ break;
324
+ case "warning":
325
+ console.warn(i, ...s);
326
+ break;
327
+ case "error":
328
+ console.error(i, ...s);
329
+ break;
330
+ }
331
+ }, g = (n) => {
332
+ const t = n.container || n;
333
+ return {
334
+ info: (e, ...s) => H(t, "info", e, ...s),
335
+ warn: (e, ...s) => H(t, "warning", e, ...s),
336
+ error: (e, ...s) => H(t, "error", e, ...s)
337
+ };
338
+ }, m = A(), U = (() => {
339
+ let n = 0;
340
+ return () => ++n;
341
+ })(), G = (n, t, e) => {
342
+ const s = m(n).touchQueue.get(t);
343
+ s && s.forEach((i) => {
344
+ i(e, n);
345
+ });
346
+ };
347
+ class ie {
348
+ constructor(t, e, s, i) {
349
+ this.key = t, this.factory = e, this.parent = s, this.container = i, this.id = U(), this.resolved = !1, this.constructed = !1, this.async = !0;
350
+ }
351
+ resolve() {
352
+ if (!this.constructed) {
353
+ const t = this.factory(this.parent, this.container);
354
+ return this.constructed = !0, this.value = Promise.resolve(t).then((e) => (this.resolved = !0, G(this.container, this.key, e), e));
355
+ }
356
+ return this.value;
357
+ }
358
+ }
359
+ class re {
360
+ constructor(t, e, s, i) {
361
+ this.key = t, this.value = e, this.parent = s, this.container = i, this.id = U(), this.async = !1, this.resolved = !1, this.constructed = !0, this.resolve = () => (this.resolved = !0, G(this.container, this.key, this.value), this.value);
362
+ }
363
+ }
364
+ class oe {
365
+ constructor(t, e, s, i) {
366
+ this.key = t, this.value = e, this.parent = s, this.container = i, this.id = U(), this.async = !1, this.resolved = !1, this.constructed = !1, this.resolve = () => {
367
+ this.resolved = !0, this.constructed = !0;
368
+ const r = this.value(this.parent, this.container);
369
+ return G(this.container, this.key, this.value), r;
370
+ };
371
+ }
372
+ }
373
+ class K {
374
+ /**
375
+ * Creates a new instance of `Container`.
376
+ * @param owner The object owning this inctance.
377
+ * @param name Optional name for the container.
378
+ * @param parent Parent container this should be a child of.
379
+ */
380
+ constructor(t, e, s) {
381
+ this.owner = t, this.name = e, this.parent = s, m(this).resolvers = /* @__PURE__ */ new Map(), m(this).touchQueue = /* @__PURE__ */ new Map(), m(this).children = [];
382
+ }
383
+ /**
384
+ * Deletes an existing resolver by its unique id.
385
+ * @param id Resolver id.
386
+ */
387
+ delete(t) {
388
+ const e = m(this).resolvers, s = Array.from(e.values()).find((i) => i.id === t);
389
+ return s ? (m(this).touchQueue.delete(s.key), Promise.resolve(e.delete(s.key))) : this.parent ? this.parent.delete(t) : Promise.resolve(!1);
390
+ }
391
+ /**
392
+ * Clears the `Container` and any child containers by deleteing all registered resolvers.
393
+ */
394
+ clear() {
395
+ const t = m(this).resolvers, e = Array.from(t.values());
396
+ return Promise.all(e.map((s) => {
397
+ if (s.constructed)
398
+ return Promise.resolve(s.resolve()).then((i) => {
399
+ if (i !== null && typeof i == "object" && typeof i.dispose == "function")
400
+ return i.dispose.call(i, this, s);
401
+ });
402
+ })).then(() => {
403
+ e.forEach((s) => this.delete(s.id)), m(this).children.forEach((s) => s.clear());
404
+ });
405
+ }
406
+ /**
407
+ * Detaches this `Container` instance from its parent, allowing it to be garbage-collected.
408
+ */
409
+ detach() {
410
+ if (this.parent) {
411
+ const t = m(this.parent).children, e = t.indexOf(this);
412
+ e > -1 && (t.splice(e, 1), delete this.parent);
413
+ }
414
+ }
415
+ /**
416
+ * Provides a way of touching a value in the `Container` without forcing it to be resolved.
417
+ * @param key Key of the resolved value to touch.
418
+ * @param handler Handler function for touching the resolved value.
419
+ */
420
+ touch(t, e) {
421
+ const s = m(this).resolvers.get(t);
422
+ if (s && s.constructed)
423
+ Promise.resolve(s.resolve()).then((i) => {
424
+ e(i, this);
425
+ });
426
+ else {
427
+ const i = m(this).touchQueue;
428
+ let r = i.get(t);
429
+ r || (r = [], i.set(t, r)), r.push(e);
430
+ }
431
+ return this.parent && !s ? this.parent.touch(t, e) : Promise.resolve();
432
+ }
433
+ /**
434
+ * Registers an asynchronous resolver.
435
+ * @param key Key of the resolver.
436
+ * @param factory Value factory.
437
+ */
438
+ registerAsync(t, e) {
439
+ const s = m(this).resolvers.get(t);
440
+ s && !s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${t}') previously used by a non-async resolver.`);
441
+ const i = new ie(t, e, s, this);
442
+ return m(this).resolvers.set(t, i), i.id;
443
+ }
444
+ /**
445
+ * Registers a factory resolver for constructing the value to be resolved.
446
+ * @param key Key of the resolver.
447
+ * @param factory Value factory.
448
+ */
449
+ registerFactory(t, e) {
450
+ const s = m(this).resolvers.get(t);
451
+ s && s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
452
+ const i = new oe(t, e, s, this);
453
+ return m(this).resolvers.set(t, i), i.id;
454
+ }
455
+ /**
456
+ * Registers an synchronous resolver.
457
+ * @param key Key of the resolver.
458
+ * @param value Value.
459
+ */
460
+ register(t, e) {
461
+ const s = m(this).resolvers.get(t);
462
+ s && s.async && process.env.NODE_ENV !== "production" && g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);
463
+ const i = new re(t, e, s, this);
464
+ return m(this).resolvers.set(t, i), i.id;
465
+ }
466
+ /**
467
+ * Gets the value for a synchronous resolver.
468
+ * @param key Key of resolver to get.
469
+ */
470
+ get(t) {
471
+ const e = m(this).resolvers.get(t);
472
+ if (e)
473
+ return e.async && process.env.NODE_ENV !== "production" && g(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();
474
+ if (this.parent)
475
+ return this.parent.get(t);
476
+ }
477
+ /**
478
+ * Gets the value for a asynchronous resolver.
479
+ * @param key Key of resolver to get.
480
+ */
481
+ getAsync(t) {
482
+ const e = m(this).resolvers.get(t);
483
+ if (e) {
484
+ if (!e.async)
485
+ throw process.env.NODE_ENV !== "production" && g(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";
486
+ return e.resolve();
487
+ }
488
+ return this.parent ? this.parent.getAsync(t) : Promise.resolve(void 0);
489
+ }
490
+ getMany(...t) {
491
+ const e = {};
492
+ return t.forEach((s) => e[s] = this.get(s)), e;
493
+ }
494
+ getManyAsync(...t) {
495
+ const e = {};
496
+ return Promise.all(t.map((s) => this.getAsync(s).then((i) => e[s] = i))).then(() => e);
497
+ }
498
+ createChild(t, e) {
499
+ const s = new K(t, e, this);
500
+ return m(this).children.push(s), s;
501
+ }
502
+ }
503
+ class pt {
504
+ /**
505
+ *
506
+ * @param type Type of event.
507
+ * @param target The target of the event, which will handle the default behavour.
508
+ * @param cancelable Whether the event is cancelable by calling preventDefault().
509
+ * @param bubbles Whether the event will bubble up the parent hierarchy.
510
+ */
511
+ constructor(t, e, s = !1, i = !1) {
512
+ this.type = t, this.target = e, this.cancelable = !!s, this.bubbles = !!i, this.defaultPrevented = !1;
513
+ }
514
+ /**
515
+ * Cancels the default behaviour (if the event is cancelable).
516
+ */
517
+ preventDefault() {
518
+ this.cancelable && (this.defaultPrevented = !0);
519
+ }
520
+ }
521
+ const b = A(), dt = (n, t) => [].concat(
522
+ b(n).listenerLookup.get(t.toLowerCase()) || [],
523
+ b(n).listenerLookup.get("*") || []
524
+ ), mt = (n, t, e, s) => {
525
+ let i, r;
526
+ return t instanceof pt ? (i = t, r = t.type) : (i = new pt(t, n.target, !!e.cancelable, !!e.bubbles), r = t), { event: i, type: r, async: s };
527
+ };
528
+ class J {
529
+ /**
530
+ * Creates a new Event Manager instance.
531
+ * @param target The target of events dispatched from this Event Manager instance.
532
+ * @param parent Parent Event Manager instance.
533
+ */
534
+ constructor(t, e) {
535
+ this.target = t, this.parent = e, b(this).listenerLookup = /* @__PURE__ */ new Map(), b(this).children = [];
536
+ }
537
+ /**
538
+ * Clears registered event listeners in this `EventManager` as well as in any children.
539
+ */
540
+ clear() {
541
+ b(this).listenerLookup.clear(), b(this).children.forEach((t) => t.clear());
542
+ }
543
+ /**
544
+ * Detaches this `EventManager` instance from its parent, allowing it to be garbage-collected.
545
+ */
546
+ detach() {
547
+ if (this.parent) {
548
+ const t = b(this.parent).children, e = t.indexOf(this);
549
+ e > -1 && t.splice(e, 1);
550
+ }
551
+ }
552
+ /**
553
+ * Creates an event subscription by registering an listener for an event type.
554
+ * @param type Event type to subscribe to.
555
+ * @param listener Listener for the event.
556
+ */
557
+ subscribe(t, e, s) {
558
+ const i = b(this).listenerLookup, r = t.toLowerCase();
559
+ return i.has(r) || i.set(r, []), i.get(r).push(e), () => this.unsubscribe(t, e);
560
+ }
561
+ /**
562
+ * Similar to `subscribe()` but immediately removes the subscription after the first call.
563
+ * @param type Event type to subscribe to.
564
+ * @param listener Listener for the event.
565
+ */
566
+ subscribeOnce(t, e) {
567
+ const s = this.subscribe(t, (i, r) => (s(), e(i, r)));
568
+ }
569
+ /**
570
+ * Removes a listener for the specified event type.
571
+ * @param type Event type to remove subscription for.
572
+ * @param listener Event listener to remove.
573
+ */
574
+ unsubscribe(t, e) {
575
+ const s = b(this).listenerLookup.get(t.toLowerCase());
576
+ if (s) {
577
+ const i = s.indexOf(e);
578
+ i > -1 && s.splice(i, 1);
579
+ }
580
+ }
581
+ /**
582
+ * Dispatches an asynchonous event to registered event listeners.
583
+ * @param eventOrType Event type or Event object to dispatch.
584
+ * @param data Optional data to be passed to event listeners.
585
+ * @param options Optional event options used if first parameter is an event type.
586
+ */
587
+ dispatchAsync(t, e, s = {}) {
588
+ const { event: i, type: r } = mt(this, t, s, !0), o = dt(this, r);
589
+ let c = 0;
590
+ const u = o.length;
591
+ let h = Promise.resolve();
592
+ for (c = 0; c < u; c++)
593
+ ((a) => {
594
+ h = h.then((l) => l ? Promise.resolve(!0) : Promise.resolve(a(i, e)).then(() => i.defaultPrevented));
595
+ })(o[c]);
596
+ return h.then((a) => !a && i.bubbles && this.parent ? this.parent.dispatchAsync(i, e) : a);
597
+ }
598
+ /**
599
+ * Dispatches an event to registered event listeners.
600
+ * @param eventOrType Event type or Event object to dispatch.
601
+ * @param data Optional data to be passed to event listeners.
602
+ * @param options Optional event options used if first parameter is an event type.
603
+ */
604
+ dispatch(t, e, s = {}) {
605
+ const { event: i, type: r } = mt(this, t, s, !1), o = dt(this, r);
606
+ let c = 0;
607
+ const u = o.length;
608
+ let h = !1;
609
+ for (c = 0; c < u; c++)
610
+ if (o[c](i, e), i.defaultPrevented) {
611
+ h = !0;
612
+ break;
613
+ }
614
+ return !h && i.bubbles && this.parent && (h = this.parent.dispatch(i, e)), h;
615
+ }
616
+ /**
617
+ * Creates a child instance to the current Event manager.
618
+ */
619
+ createChild(t) {
620
+ const e = new J(t, this);
621
+ return b(this).children.push(e), e;
622
+ }
623
+ }
624
+ const L = (n, t, e) => {
625
+ const s = n.get("$plugins").map((i) => {
626
+ try {
627
+ return i.invoke(t, e);
628
+ } catch (r) {
629
+ g(n).error("An error occured when invoking a plugin.", i, r);
630
+ }
631
+ });
632
+ return Promise.all(s);
633
+ };
634
+ class ce {
635
+ constructor(t) {
636
+ 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();
637
+ }
638
+ createInstance() {
639
+ if (!this.widget.container.get("$instance")) {
640
+ const t = this.widget.container.get("$types"), e = this.widget.container.get("$type");
641
+ !e && g(this).error("Unable to create widget. No type is specified.");
642
+ const s = t[e];
643
+ !s && g(this).error(`Unable to create widget. Type '${e}' is not registered.`), this.widget.events.dispatch("widget:create-instance", {}, { bubbles: !0 });
644
+ try {
645
+ this.widget.container.register(
646
+ "$instance",
647
+ new s(this.container)
648
+ );
649
+ } catch (i) {
650
+ g(this).error("Unable to create widget type.", i);
651
+ }
652
+ this.widget.events.dispatch("widget:instance-created", {}, { bubbles: !0 });
653
+ }
654
+ }
655
+ /**
656
+ * The initialization is performed before the widget is activated but after it's configured
657
+ * and thus all required services are available. This hook is a good place to bind events that
658
+ * should trigger activation (e.g. click on "trigger links" or routing events)
659
+ * @param {object} data Custom initialization data passed to the widget.
660
+ */
661
+ initialize(t) {
662
+ return this.initialized = this.initialized || (() => {
663
+ const e = this.container.get("$instance"), s = e.initialize || (() => {
664
+ });
665
+ return this.initialized = Promise.resolve(s.call(e, t)).then(() => L(this.container, "initialize", t)).then(() => {
666
+ });
667
+ })();
668
+ }
669
+ /**
670
+ * The activation is where the widget is actually created and rendered.
671
+ * Activation can be initialized from the outside or from an event originated
672
+ * in the "initialize" hook.
673
+ * @param {object} data Custom activation data passed to the widget.
674
+ */
675
+ activate(t) {
676
+ return (this.initialized || this.initialize()).then(() => {
677
+ this.activated = this.activated || (() => L(this.container, "activate").then(() => {
678
+ const e = this.container.get("$instance");
679
+ return this.activated = e.activate(t);
680
+ }))();
681
+ });
682
+ }
683
+ deactivate() {
684
+ const t = this.container.get("$instance"), e = t.deactivate || (() => {
685
+ });
686
+ return L(this.container, "deactivate").then(() => Promise.resolve(e.call(t))).then(() => {
687
+ this.initialized = null, this.activated = null;
688
+ }).then(() => {
689
+ });
690
+ }
691
+ /**
692
+ * Invokes a command on the widget component.
693
+ * @param command Name of command
694
+ * @param args Command arguments
695
+ */
696
+ invoke(t, ...e) {
697
+ return L(this.container, "invoke", { command: t, args: e }).then(() => {
698
+ const s = this.container.get("$instance");
699
+ if (s[t])
700
+ return s[t].apply(s, e);
701
+ const i = s.invoke;
702
+ if (i)
703
+ return i.call(s, t, ...e);
704
+ });
705
+ }
706
+ }
707
+ const O = (n, t) => {
708
+ if (!t)
709
+ return !0;
710
+ if (typeof t == "string") {
711
+ const e = t.split(",");
712
+ for (let s = 0, i = e.length; s < i; s++) {
713
+ const r = e[s].trim();
714
+ if (r === n || r === "*")
715
+ return !0;
716
+ }
717
+ }
718
+ return t instanceof Array ? t.indexOf(n) > -1 : !1;
719
+ }, ae = (n, t) => {
720
+ if (typeof t == "function")
721
+ return t(n);
722
+ const e = typeof t == "string" ? le(t) : t;
723
+ return !(!O(n.implementation.tenant || "", e.tenant || "") || !O(n.implementation.name, e.implementation || "") || !O(n.name, e.widget || "") || !O(n.container.get("$type"), e.type || ""));
724
+ }, he = (n, t) => {
725
+ if (typeof t == "function")
726
+ return t(n);
727
+ const e = typeof t == "string" ? ue(t) : t;
728
+ return !(!O(n.tenant || "", e.tenant || "") || !O(n.name, e.implementation || ""));
729
+ }, Ot = (n) => (t) => ae(t, n), At = (n) => (t) => he(t, n), x = (n) => n instanceof Array && n.length === 1 ? n[0] : n, le = (n) => {
730
+ const t = {}, e = n.split(":");
731
+ return e.length === 1 ? t.widget = x(e[0].split(",")) : e.length === 2 ? (t.implementation = x(e[0].split(",")), t.widget = x(e[1].split(","))) : (t.tenant = x(e[0].split(",")), t.implementation = x(e[1].split(",")), t.widget = x(e[2].split(","))), t;
732
+ }, ue = (n) => {
733
+ const t = {}, e = n.split(":");
734
+ return e.length === 1 ? t.implementation = x(e[0].split(",")) : (t.tenant = x(e[0].split(",")), t.implementation = x(e[1].split(","))), t;
735
+ }, z = A(), gt = (n, t, e) => n.filter((s) => s.stage === t && Ot(s.selector)(e));
736
+ function pe(n) {
737
+ const t = n.container.get("$environment");
738
+ let e = z(t).configurationCache;
739
+ e && (e = e.filter((s) => s[0] !== n), z(t).configurationCache = e);
740
+ }
741
+ var S = /* @__PURE__ */ ((n) => (n.Implementation = "implementation", n.Widget = "widget", n))(S || {}), $ = /* @__PURE__ */ ((n) => (n.Pre = "pre", n.Post = "post", n))($ || {});
742
+ const Nt = (n, t, e) => (Object.keys(t).forEach((s) => {
743
+ const i = t[s];
744
+ if (typeof i == "function") {
745
+ const r = i();
746
+ typeof r.defaultArgs != "undefined" && e(r, ...r.defaultArgs), n[s] = (...o) => {
747
+ const c = Object.assign(
748
+ {},
749
+ r,
750
+ { handlerResolver: r.handlerResolver.bind({}) }
751
+ );
752
+ return e(c, ...o), n;
753
+ };
754
+ } else
755
+ n[s] = Nt(
756
+ {},
757
+ i,
758
+ e
759
+ );
760
+ }), n), de = (n, t) => {
761
+ switch (t) {
762
+ case "implementation":
763
+ return n.implementation;
764
+ case "widget":
765
+ return n;
766
+ }
767
+ }, ft = (n, t, e, s) => (s.forEach((i) => {
768
+ Nt(
769
+ n,
770
+ i,
771
+ (r, ...o) => {
772
+ const c = {
773
+ selector: t,
774
+ stage: r.stage,
775
+ handler: (u) => {
776
+ const h = de(u, r.scope), a = { container: h.container, events: h.events }, l = r.handlerResolver, p = l(a);
777
+ let d = z(e.environment).configurationCache;
778
+ return d || (d = z(e.environment).configurationCache = []), d.find((C) => C.indexOf(h) > -1 && C.indexOf(l) > -1) ? Promise.resolve() : (d.push([h, l]), Promise.resolve(p(...o)));
779
+ }
780
+ };
781
+ e.instructions.push(c);
782
+ }
783
+ );
784
+ }), n);
785
+ function me(n, t) {
786
+ function e(s) {
787
+ return ft(
788
+ {},
789
+ s,
790
+ n,
791
+ t
792
+ );
793
+ }
794
+ return ft(
795
+ e,
796
+ "*",
797
+ n,
798
+ t
799
+ );
800
+ }
801
+ class ge {
802
+ constructor(t, e) {
803
+ this.container = t, this.settings = e, this.widget = t.get("$widget"), this.events = this.widget.events;
804
+ }
805
+ }
806
+ const fe = (n, t, e, s) => {
807
+ try {
808
+ const i = new t(e, s);
809
+ return {
810
+ name: n,
811
+ invoke: (r, o) => {
812
+ let c;
813
+ return i[r] && (c = i[r].call(i, o)), Promise.resolve(c);
814
+ },
815
+ getInstance: () => i
816
+ };
817
+ } catch (i) {
818
+ if (i.message && i.message.indexOf("is not a constructor") >= 0)
819
+ return {
820
+ name: n,
821
+ invoke: (r) => {
822
+ let o;
823
+ return r === "initialize" && (o = t(e, s)), Promise.resolve(o);
824
+ },
825
+ getInstance: () => t
826
+ };
827
+ throw i;
828
+ }
829
+ };
830
+ function vt(n, t) {
831
+ return typeof n == "undefined" ? t : n;
832
+ }
833
+ class ve {
834
+ constructor(t = {}) {
835
+ this.part = t;
836
+ }
837
+ createCommand(t, e, s) {
838
+ let i;
839
+ typeof e == "function" ? i = {
840
+ scope: S.Widget,
841
+ stage: $.Post,
842
+ defaultArgs: void 0,
843
+ handlerResolver: e
844
+ } : i = {
845
+ scope: vt(e.scope, S.Widget),
846
+ stage: vt(e.stage, $.Post),
847
+ defaultArgs: e.defaultArgs,
848
+ handlerResolver: s
849
+ };
850
+ let r = this.part;
851
+ const o = t.split(".");
852
+ return o.forEach((c, u) => {
853
+ u === o.length - 1 ? r[c] || (r[c] = () => i) : r = this.part[c] = this.part[c] || {};
854
+ }), this;
855
+ }
856
+ get() {
857
+ return this.part;
858
+ }
859
+ }
860
+ const _t = (n) => {
861
+ const t = new ve({});
862
+ return n(t), t.get();
863
+ }, be = _t((n) => {
864
+ n.createCommand(
865
+ "types.register",
866
+ { scope: S.Implementation, stage: $.Pre },
867
+ (t) => (e, s) => {
868
+ t.container.get("$types")[e] = s;
869
+ }
870
+ ).createCommand(
871
+ "type",
872
+ { stage: $.Pre },
873
+ (t) => (e) => {
874
+ t.container.register("$type", e);
875
+ }
876
+ ).createCommand(
877
+ "settings",
878
+ { stage: $.Pre, defaultArgs: [null] },
879
+ (t) => (e) => {
880
+ t.events.dispatch(
881
+ "settings:change",
882
+ e,
883
+ { bubbles: !0 }
884
+ ), t.container.register("$settings", e);
885
+ }
886
+ ).createCommand(
887
+ "plugin",
888
+ { stage: $.Pre },
889
+ (t) => (e, s, i) => {
890
+ const { container: r } = t;
891
+ let o = null, c = e, u = s;
892
+ typeof e == "string" && (o = e, c = s, u = i);
893
+ const h = (a) => {
894
+ const { transformPluginSettings: l } = t.container.get("$environmentOptions"), p = l ? l(
895
+ u || {},
896
+ o,
897
+ t.container,
898
+ c
899
+ ) : s;
900
+ try {
901
+ const d = fe(
902
+ o,
903
+ c,
904
+ r,
905
+ p
906
+ );
907
+ r.get("$plugins").push(d), a && d.invoke("initialize", null);
908
+ } catch (d) {
909
+ g(t).warn("Error when initializing plugin", d);
910
+ }
911
+ };
912
+ t.container.get("$instance") ? h(!0) : t.events.subscribeOnce("widget:instance-created", () => h(!1));
913
+ }
914
+ ).createCommand(
915
+ "container.register",
916
+ (t) => (e, s) => {
917
+ t.container.register(e, s);
918
+ }
919
+ ).createCommand(
920
+ "container.registerAsync",
921
+ (t) => (e, s) => {
922
+ t.container.registerAsync(e, s);
923
+ }
924
+ ).createCommand(
925
+ "container.registerFactory",
926
+ (t) => (e, s) => {
927
+ t.container.registerFactory(e, s);
928
+ }
929
+ ).createCommand(
930
+ "container.touch",
931
+ (t) => (e, s) => {
932
+ t.container.touch(e, s);
933
+ }
934
+ ).createCommand(
935
+ "csp",
936
+ {},
937
+ (t) => (e) => {
938
+ t.container.register("csp", e);
939
+ }
940
+ );
941
+ }), ye = be;
942
+ function we(n, t, e = []) {
943
+ const s = [ye].concat(e), i = me(
944
+ t,
945
+ s
946
+ );
947
+ n(i, t);
948
+ }
949
+ class xe {
950
+ constructor() {
951
+ this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
952
+ }
953
+ add(t, e, s, i) {
954
+ this.tasks.push({ task: t, resolve: e, reject: s, done: i }), this.next();
955
+ }
956
+ next() {
957
+ this.current = this.current.then(() => {
958
+ const t = this.tasks.shift();
959
+ if (t) {
960
+ const e = Promise.resolve(t.task());
961
+ return Promise.resolve(e).then(this.next).then(() => e.then((s) => {
962
+ t.done(), t.resolve(s);
963
+ })).catch((s) => (t.done(), t.reject(s), this.next()));
964
+ }
965
+ return Promise.resolve();
966
+ });
967
+ }
968
+ }
969
+ const M = /* @__PURE__ */ new WeakMap();
970
+ function $e(n) {
971
+ return M.has(n) || M.set(n, new xe()), (t) => new Promise((e, s) => {
972
+ const i = M.get(n);
973
+ i.add(t, e, s, () => {
974
+ i.tasks.length || M.delete(n);
975
+ });
976
+ });
977
+ }
978
+ const bt = (n) => typeof n != "undefined", _ = (n, t) => {
979
+ n.events.dispatch("widget:state-change", { state: t }, { bubbles: !0 }), n.state = t, n.events.dispatch("widget:state-changed", {}, { bubbles: !0 });
980
+ }, v = A(), Ce = (n) => {
981
+ const { container: t, events: e } = n;
982
+ t.get("$controller") || (t.register("$controller", new ce(t)), e.dispatch("widget:controller-created", {}, { bubbles: !0 }));
983
+ };
984
+ class ke {
985
+ /**
986
+ * Creates a new `Widget` instance.
987
+ * @param name Name of widget.
988
+ * @param implementation The implementation this instance belongs to.
989
+ * @param configuration Configuration for the widget.
990
+ */
991
+ constructor(t, e, s) {
992
+ this.state = "deactivated", this.name = t, this.implementation = e, this.container = e.container.createChild(this, t), this.events = e.events.createChild(this), v(this).subscriptions = [], s && e.configure((i) => {
993
+ const r = i(t);
994
+ bt(s.type) && r.type(s.type), bt(s.settings) && r.settings(s.settings), s.plugins && Object.keys(s.plugins).forEach((o) => {
995
+ var c;
996
+ const u = (c = s.plugins) == null ? void 0 : c[o];
997
+ r.plugin(o, u);
998
+ });
999
+ }), this.load = this.load.bind(this), this.activate = this.activate.bind(this), this.invoke = this.invoke.bind(this), this.deactivate = this.deactivate.bind(this);
1000
+ }
1001
+ /**
1002
+ * Initializes the widget, if not already initialized, and applies any
1003
+ * pending configuration.
1004
+ */
1005
+ load() {
1006
+ return $e(this)(() => {
1007
+ v(this).deactivatedPromise = null;
1008
+ const t = this.state === "deactivated";
1009
+ t && (_(
1010
+ this,
1011
+ "activating"
1012
+ /* Activating */
1013
+ ), this.container.register("$widget", this), this.container.register("$controller", null), this.container.register("$plugins", []), this.container.register("$type", null), this.container.register("$instance", null)), _(
1014
+ this,
1015
+ "loading"
1016
+ /* Loading */
1017
+ );
1018
+ const e = this.implementation.instructions, s = gt(e, $.Pre, this);
1019
+ return Promise.all(s.map((i) => i.handler(this))).then(() => {
1020
+ Ce(this);
1021
+ const i = gt(e, $.Post, this);
1022
+ return Promise.all(i.map((r) => r.handler(this))).then(() => {
1023
+ t && this.container.get("$controller").initialize();
1024
+ });
1025
+ }).then(() => (_(
1026
+ this,
1027
+ "activated"
1028
+ /* Activated */
1029
+ ), this));
1030
+ });
1031
+ }
1032
+ /**
1033
+ * Activates the widget and makes it ready for receiving commands.
1034
+ * @param data Activation data
1035
+ */
1036
+ activate(t) {
1037
+ v(this).subscriptions.push(
1038
+ this.implementation.events.subscribe("implementation:configured", () => {
1039
+ [
1040
+ "activated",
1041
+ "activating",
1042
+ "loading"
1043
+ /* Loading */
1044
+ ].indexOf(this.state) > -1 && this.load();
1045
+ })
1046
+ );
1047
+ const e = v(this).activatedPromise;
1048
+ return e ? (process.env.NODE_ENV !== "production" && g(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`, t), e) : v(this).activatedPromise = this.load().then(() => this.container.get("$controller").activate(t));
1049
+ }
1050
+ /**
1051
+ * Invokes a command on a widget. If the widget isn't activate the invocation
1052
+ * will be suspended until activation.
1053
+ * @param command Command to invoke.
1054
+ * @param args Command arguments.
1055
+ */
1056
+ invoke(t, ...e) {
1057
+ const s = v(this).activatedPromise, i = (r, ...o) => s.then(this.load).then(() => this.container.get("$controller").invoke(r, ...o));
1058
+ return s ? i(t, ...e) : (process.env.NODE_ENV !== "production" && g(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) => {
1059
+ const o = this.events.subscribe("widget:state-changed", () => {
1060
+ this.state === "activated" && (o(), r(i(t, ...e)));
1061
+ });
1062
+ }));
1063
+ }
1064
+ /**
1065
+ * Deactivates the widget by clearing the `Container` and removing any event subscriptions in the
1066
+ * `EventManager`.
1067
+ */
1068
+ deactivate() {
1069
+ return v(this).deactivatedPromise || (this.state === "deactivated" ? Promise.resolve() : (_(
1070
+ this,
1071
+ "deactivating"
1072
+ /* Deactivating */
1073
+ ), v(this).deactivatedPromise = this.container.get("$controller").deactivate().then(() => (v(this).activatedPromise = null, v(this).subscriptions.forEach((e) => e()), v(this).subscriptions = [], this.container.clear().then(() => {
1074
+ this.events.clear(), pe(this), _(
1075
+ this,
1076
+ "deactivated"
1077
+ /* Deactivated */
1078
+ );
1079
+ })))));
1080
+ }
1081
+ }
1082
+ class Ee {
1083
+ /**
1084
+ * Creates a new `Widget` instance.
1085
+ * @param container The `Container` instance to base the widget upon.
1086
+ */
1087
+ constructor(t) {
1088
+ this.container = t, this.widget = t.get("$widget"), this.settings = t.get("$settings"), this.events = this.widget.events, this.widget.events.subscribe("settings:change", (e, s) => {
1089
+ this.settings = s;
1090
+ });
1091
+ }
1092
+ }
1093
+ const yt = A();
1094
+ class Rt {
1095
+ /**
1096
+ * Creates a new Implementation instance.
1097
+ * @param configuration Configuration for the implementation.
1098
+ * @param environment The parent environment.
1099
+ * @param configurationApiExtensions Optional configuration API extensions.
1100
+ */
1101
+ constructor(t, e, s = []) {
1102
+ 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", {}), yt(this).configurationApiExtensions = s;
1103
+ }
1104
+ /**
1105
+ * Loads all widgets in the implementation.
1106
+ */
1107
+ load() {
1108
+ const t = Array.from(this.widgets.values());
1109
+ return Promise.all(t.map((e) => e.load())).then(() => t);
1110
+ }
1111
+ /**
1112
+ * Configures the implementation by adding a configuration callback.
1113
+ * @param configFn Callback function for configuration.
1114
+ */
1115
+ configure(t) {
1116
+ return we(t, this, yt(this).configurationApiExtensions), this.events.dispatch(
1117
+ "implementation:configured",
1118
+ { implementation: this },
1119
+ { bubbles: !0 }
1120
+ ), this;
1121
+ }
1122
+ /**
1123
+ * Creates a widget on the implementation and returns its `WidgetData`.
1124
+ * @param name Widget name.
1125
+ * @param configuration Widget configuration.
1126
+ */
1127
+ createWidget(t, e) {
1128
+ const s = new ke(t, this, e);
1129
+ return this.widgets.set(s.name, s), s;
1130
+ }
1131
+ }
1132
+ function Pe(n, t, e) {
1133
+ const s = new Rt(n, t, e);
1134
+ return n.widgets && Object.keys(n.widgets).forEach((i) => {
1135
+ var r;
1136
+ const o = (r = n.widgets) == null ? void 0 : r[i];
1137
+ s.createWidget(i, o);
1138
+ }), s;
1139
+ }
1140
+ let wt = class Dt {
1141
+ constructor(t, e) {
1142
+ this.selectorFactory = e, typeof t == "function" ? this.resolver = t : this.resolver = () => t;
1143
+ }
1144
+ append(t) {
1145
+ const e = typeof t == "function" ? t : () => t;
1146
+ return new Dt(
1147
+ () => this.all().concat(e()),
1148
+ this.selectorFactory
1149
+ );
1150
+ }
1151
+ all() {
1152
+ return this.resolver().concat([]);
1153
+ }
1154
+ query(t) {
1155
+ return this.all().filter(this.selectorFactory(t));
1156
+ }
1157
+ find(t) {
1158
+ const e = this.query(t);
1159
+ if (e.length)
1160
+ return e[0];
1161
+ }
1162
+ };
1163
+ const X = "#____version____#", W = A(), Oe = (n) => n.tenant ? `${n.name}:${n.tenant}` : n.name, It = class {
1164
+ constructor(n, t = [], e = {}) {
1165
+ this.widgets = new wt(
1166
+ () => {
1167
+ let s = [];
1168
+ return this.implementations.all().forEach((i) => {
1169
+ s = s.concat(Array.from(i.widgets.values()));
1170
+ }), s;
1171
+ },
1172
+ Ot
1173
+ ), this.implementations = new wt([], At), this.name = n, this.container = new K(this, n), this.events = new J(this), this.container.register("$version", X), this.container.register("$environment", this), this.container.register("$environmentOptions", e), W(this).configurationApiExtensions = t;
1174
+ }
1175
+ /**
1176
+ * Creates an implementation based on the provided configuration.
1177
+ * @param config Implementation configuration.
1178
+ */
1179
+ createImplementation(n) {
1180
+ const t = Oe(n);
1181
+ let e = this.implementations.find(t);
1182
+ if (e)
1183
+ return process.env.NODE_ENV !== "production" && g(e).warn(`Implementation "${t}" already exist on current environment.`), e;
1184
+ const s = W(this).configurationApiExtensions;
1185
+ return e = Pe(
1186
+ n,
1187
+ this,
1188
+ s
1189
+ ), this.implementations = this.implementations.append([e]), this.events.dispatch("implementation:created", { implementation: e }), e;
1190
+ }
1191
+ /**
1192
+ * Patches the Environment instance configuration.
1193
+ * @param configuration Environment configuration.
1194
+ */
1195
+ patch(n = {}) {
1196
+ const { name: t, configurationApiExtensions: e } = n;
1197
+ typeof t != "undefined" && t !== null && (this.name = t), e && e.forEach(
1198
+ (s) => {
1199
+ W(this).configurationApiExtensions.push(s);
1200
+ }
1201
+ );
1202
+ }
1203
+ /**
1204
+ * Creates a new Environment instance based on the provided configuration.
1205
+ * @param configuration Environment configuration.
1206
+ */
1207
+ static create(n = {}) {
1208
+ return new It(
1209
+ n.name || "",
1210
+ n.configurationApiExtensions,
1211
+ n.options
1212
+ );
1213
+ }
1214
+ };
1215
+ let Lt = It;
1216
+ Lt.version = X;
1217
+ const Qe = (n, t, e = {}) => se(
1218
+ n,
1219
+ n.bindings,
1220
+ () => {
1221
+ const s = n.container.get("$runtimecfg").map((i) => {
1222
+ const r = i[0];
1223
+ if (typeof r == "function")
1224
+ return r;
1225
+ if (At(r)(n))
1226
+ return i[1];
1227
+ }).filter((i) => !!i);
1228
+ return (t ? [t] : []).concat(s);
1229
+ },
1230
+ e.rootElementResolver || (() => document.body)
1231
+ ), Ae = (n) => {
1232
+ const t = [];
1233
+ return [
1234
+ (s, i) => {
1235
+ t.push(n.subscribe(s, i));
1236
+ },
1237
+ () => {
1238
+ t.forEach((s) => {
1239
+ s();
1240
+ });
1241
+ }
1242
+ ];
1243
+ };
1244
+ class Z {
1245
+ constructor(t, e = []) {
1246
+ this.platform = t, this.rules = e;
1247
+ }
1248
+ match(t) {
1249
+ return this.rules.every((e) => !(e.id && e.id !== t.id || e.type && e.type !== t.type));
1250
+ }
1251
+ ofType(t) {
1252
+ return this.rules.push({ type: t }), this;
1253
+ }
1254
+ withId(t) {
1255
+ return this.rules.push({ id: t }), this;
1256
+ }
1257
+ select() {
1258
+ return new Ne(this.platform, this);
1259
+ }
1260
+ }
1261
+ class Mt {
1262
+ constructor(t, e, s) {
1263
+ this.platform = t, this.node = e, this.actions = new tt(
1264
+ t,
1265
+ new Z(t).withId(e.id),
1266
+ s
1267
+ );
1268
+ const [i, r] = Ae(
1269
+ this.platform.events
1270
+ );
1271
+ this.subscribe = i, this.unsubscribe = r;
1272
+ }
1273
+ properties(t) {
1274
+ return t && this.node.touchProperties((e) => t(e)), this.node.attributes.properties;
1275
+ }
1276
+ context(t) {
1277
+ return t && this.subscribe("components:context-changed", (e, { node: s }) => {
1278
+ s === this.node && t(this.node.attributes.context);
1279
+ }), this.node.attributes.context;
1280
+ }
1281
+ layout(t) {
1282
+ return t && this.subscribe("components:layout-changed", (e, { node: s }) => {
1283
+ s === this.node && t(this.node.attributes.layout);
1284
+ }), this.node.attributes.layout;
1285
+ }
1286
+ writeProperties(t, e) {
1287
+ this.node.writeProperties(t, e);
1288
+ }
1289
+ writeContext(t, e) {
1290
+ this.node.writeProperties(t, e);
1291
+ }
1292
+ writeLayout(t, e) {
1293
+ this.node.writeLayout(t, e);
1294
+ }
1295
+ dispose() {
1296
+ this.unsubscribe(), this.actions.dispose();
1297
+ }
1298
+ }
1299
+ class Ne {
1300
+ constructor(t, e, s = !0) {
1301
+ this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new tt(this.platform, this.target);
1302
+ }
1303
+ writeProperties(t, e) {
1304
+ this.removes.push(
1305
+ this.platform.write({
1306
+ options: e,
1307
+ attributes: { properties: t },
1308
+ target: this.target,
1309
+ removable: this.clearOnDispose
1310
+ })
1311
+ );
1312
+ }
1313
+ writeContext(t, e) {
1314
+ this.removes.push(
1315
+ this.platform.write({
1316
+ options: e,
1317
+ attributes: { context: t },
1318
+ target: this.target,
1319
+ removable: this.clearOnDispose
1320
+ })
1321
+ );
1322
+ }
1323
+ writeLayout(t, e) {
1324
+ this.removes.push(
1325
+ this.platform.write({
1326
+ options: e,
1327
+ attributes: { layout: t },
1328
+ target: this.target,
1329
+ removable: this.clearOnDispose
1330
+ })
1331
+ );
1332
+ }
1333
+ dispose() {
1334
+ this.removes.forEach((t) => {
1335
+ t();
1336
+ }), this.actions.dispose();
1337
+ }
1338
+ }
1339
+ const _e = (n, t, e) => {
1340
+ const s = n.concat(), i = (r, o, c) => {
1341
+ let u = !0;
1342
+ if (s.length) {
1343
+ const h = s.shift(), a = (l, p) => (u = !1, i(l, Object.assign({}, o, p), c));
1344
+ return Promise.resolve(h(r, a, c)).then((l) => ht(I({}, l), {
1345
+ cancelled: u
1346
+ }));
1347
+ }
1348
+ return Promise.resolve({ data: r, cancelled: !1, options: o });
1349
+ };
1350
+ return i(t, {}, e);
1351
+ };
1352
+ class tt {
1353
+ constructor(t, e, s) {
1354
+ this.platform = t, this.target = e, this.ns = s, this.subscriptions = [], this.create = this.create.bind(this);
1355
+ }
1356
+ create(t, e = () => {
1357
+ }) {
1358
+ const s = {
1359
+ key: t,
1360
+ fn: e,
1361
+ target: this.target,
1362
+ ns: this.ns
1363
+ };
1364
+ this.platform.actionsState.handlers.push(s);
1365
+ const i = () => {
1366
+ const r = this.platform.actionsState.handlers.indexOf(s);
1367
+ r > -1 && this.platform.actionsState.handlers.splice(r, 1);
1368
+ };
1369
+ return this.subscriptions.push(i), i;
1370
+ }
1371
+ dispatch(t, e) {
1372
+ const s = this.platform.nodes.all.concat(
1373
+ this.platform.nodes.detached
1374
+ ), i = {}, r = this.platform.actionsState.handlers.filter(
1375
+ (o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
1376
+ );
1377
+ return Promise.all(
1378
+ r.map((o) => {
1379
+ const c = s.filter(
1380
+ (h) => o.target.match(h) && this.target.match(h)
1381
+ ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && c.some((a) => h.target.match(a))).map((h) => h.fn);
1382
+ return Promise.all(
1383
+ c.map((h) => {
1384
+ const a = new Mt(
1385
+ this.platform,
1386
+ h,
1387
+ this.ns
1388
+ );
1389
+ return _e(u, e, a).then((l) => {
1390
+ const { data: p = {}, options: d, cancelled: C } = l;
1391
+ return Promise.resolve(
1392
+ C ? {} : o.fn(p, d, a)
1393
+ ).then((N) => {
1394
+ i[h.id] = N;
1395
+ });
1396
+ });
1397
+ })
1398
+ );
1399
+ })
1400
+ ).then(() => i);
1401
+ }
1402
+ watch(t, e) {
1403
+ let s = t, i = this.ns;
1404
+ const r = t.split(".");
1405
+ r.length > 1 && (i = r[0], s = r.splice(1).join("."));
1406
+ const o = {
1407
+ fn: e,
1408
+ target: this.target,
1409
+ key: s,
1410
+ ns: i
1411
+ };
1412
+ this.platform.actionsState.watchers.push(o);
1413
+ const c = () => {
1414
+ const u = this.platform.actionsState.watchers.indexOf(o);
1415
+ u > -1 && this.platform.actionsState.watchers.splice(u, 1);
1416
+ };
1417
+ return this.subscriptions.push(c), c;
1418
+ }
1419
+ dispose() {
1420
+ this.subscriptions.forEach((t) => t());
1421
+ }
1422
+ }
1423
+ const Ye = _t((n) => {
1424
+ n.createCommand("components", (t) => (e) => {
1425
+ t.events.subscribeOnce(
1426
+ "components:platform-created",
1427
+ (s, { platform: i }) => {
1428
+ e.handlers && e.handlers.forEach(([r, o]) => {
1429
+ i.addComponentHandler(r, o);
1430
+ });
1431
+ }
1432
+ );
1433
+ });
1434
+ }), T = (n, t, ...e) => typeof t == "string" ? n(`[humany] ${t}`, ...e) : n(t, ...e), R = class {
1435
+ constructor() {
1436
+ this.keys = [], this.log = (n, ...t) => this.lookup(n, () => R.log(...t)), this.warn = (n, ...t) => this.lookup(n, () => R.warn(...t)), this.error = (n, ...t) => this.lookup(n, () => R.error(...t)), this.info = (n, ...t) => this.lookup(n, () => R.info(...t));
1437
+ }
1438
+ lookup(n, t) {
1439
+ this.keys.indexOf(n) === -1 && (this.keys.push(n), t());
1440
+ }
1441
+ };
1442
+ let P = R;
1443
+ P.log = (...n) => T(console.log, ...n);
1444
+ P.warn = (...n) => T(console.warn, ...n);
1445
+ P.error = (...n) => T(console.error, ...n);
1446
+ P.info = (...n) => T(console.info, ...n);
1447
+ const k = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
1448
+ function et() {
1449
+ return k() + k() + "-" + k() + "-" + k() + "-" + k() + "-" + k() + k() + k();
1450
+ }
1451
+ class xt {
1452
+ constructor(t, e) {
1453
+ this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = et(), this.type = e, this.attributes = {
1454
+ context: {},
1455
+ properties: {},
1456
+ layout: {},
1457
+ tags: []
1458
+ }, this.writeLayout({ size: "full", indent: 0 });
1459
+ }
1460
+ mount(t, e) {
1461
+ let s = t.get("mounted-nodes");
1462
+ return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && P.error(
1463
+ "Trying to mount an already mounted component node.",
1464
+ this
1465
+ ), () => {
1466
+ }) : (this.events.dispatch("components:node-mounted", { node: this }), this.mountCount === 0 && (this.mountCount = this.mountCount + 1, this.events.dispatch("components:node-enter", { node: this })), () => {
1467
+ s.delete(this), this.events.dispatch("components:node-unmounted", { node: this }), this.mountCount = this.mountCount - 1, this.mountCount === 0 && this.events.dispatch("components:node-exit", { node: this });
1468
+ });
1469
+ }
1470
+ appendChild(t, e = "default") {
1471
+ if (t.parent) {
1472
+ if (t.parent === this)
1473
+ return;
1474
+ t.parent.removeChild(t);
1475
+ }
1476
+ t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].push(t), this.events.dispatch("components:node-appended", { node: t });
1477
+ }
1478
+ prependChild(t, e = "default") {
1479
+ if (t.parent) {
1480
+ if (t.parent === this)
1481
+ return;
1482
+ t.parent.removeChild(t);
1483
+ }
1484
+ t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].unshift(t), this.events.dispatch("components:node-appended", { node: t });
1485
+ }
1486
+ touchProperties(t, e = {}, s) {
1487
+ const r = [{ properties: t }, e];
1488
+ return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
1489
+ if (s) {
1490
+ const o = this.changesets.indexOf(r);
1491
+ o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
1492
+ }
1493
+ };
1494
+ }
1495
+ writeProperties(t, e = {}, s) {
1496
+ const r = [{ properties: t }, e];
1497
+ return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
1498
+ if (s) {
1499
+ const o = this.changesets.indexOf(r);
1500
+ o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
1501
+ }
1502
+ };
1503
+ }
1504
+ writeLayout(t, e = {}, s) {
1505
+ const r = [{ layout: t }, e];
1506
+ return this.changesets.push(r), this.events.dispatch("components:set-layout", { node: this }), () => {
1507
+ if (!s)
1508
+ return;
1509
+ const o = this.changesets.indexOf(r);
1510
+ o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-layout", { node: this }));
1511
+ };
1512
+ }
1513
+ writeContext(t, e = {}, s) {
1514
+ const r = [{ context: t }, e];
1515
+ return this.changesets.push(r), this.events.dispatch("components:set-context", { node: this }), () => {
1516
+ if (!s)
1517
+ return;
1518
+ const o = this.changesets.indexOf(r);
1519
+ o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-context", { node: this }));
1520
+ };
1521
+ }
1522
+ getChildren(t = "default") {
1523
+ const e = this.children[t] || [];
1524
+ return e.reduce((s, i, r) => {
1525
+ const { order: o = r } = i.attributes.layout;
1526
+ return s[o] ? s.splice(o, 0, i) : s[o] = i, s;
1527
+ }, Array(e.length));
1528
+ }
1529
+ remove() {
1530
+ this.parent && this.parent.removeChild(this);
1531
+ }
1532
+ removeChild(t) {
1533
+ Object.keys(this.children).forEach((e) => {
1534
+ const s = this.children[e], i = s.indexOf(t);
1535
+ i > -1 && (s.splice(i, 1), this.events.dispatch("components:node-removed", {
1536
+ node: t,
1537
+ parentNode: this
1538
+ }));
1539
+ }), delete t.parent;
1540
+ }
1541
+ }
1542
+ const zt = (n, t, e) => {
1543
+ for (let s = 0, i = n.length; s < i && e(n[s]) !== !0; s++) {
1544
+ const r = t[n[s].id] || "default", o = n[s].getChildren(r);
1545
+ zt(o, t, e);
1546
+ }
1547
+ }, st = (n, t, e) => {
1548
+ if (e(n) !== !0) {
1549
+ const s = t[n.id] || "default", i = n.children[s];
1550
+ zt(i, t, e);
1551
+ }
1552
+ }, B = (n, t) => {
1553
+ const e = [];
1554
+ return st(n, t, (s) => {
1555
+ e.push(s);
1556
+ }), e;
1557
+ }, Re = (n, t, e) => {
1558
+ let s;
1559
+ return st(n, t, (i) => {
1560
+ if (e(i))
1561
+ return s = i, !0;
1562
+ }), s;
1563
+ };
1564
+ class De {
1565
+ constructor(t, e, s) {
1566
+ this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe(
1567
+ "components:node-appended",
1568
+ (i, r) => {
1569
+ this.all.push(r.node), this.visible = B(t, e);
1570
+ }
1571
+ ), s.subscribe(
1572
+ "components:node-removed",
1573
+ (i, r) => {
1574
+ let o = this.all.indexOf(r.node);
1575
+ o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(r.node), o > -1 && this.visible.splice(o, 1), this.visible = B(t, e);
1576
+ }
1577
+ ), s.subscribe(
1578
+ "components:node-switched",
1579
+ (i, r) => {
1580
+ this.visible = B(t, e);
1581
+ }
1582
+ );
1583
+ }
1584
+ query(t = {}) {
1585
+ const e = [];
1586
+ return st(this.root, this.switches, (s) => {
1587
+ Object.keys(t).every((r) => t[r] === s[r]) && e.push(s);
1588
+ }), e;
1589
+ }
1590
+ get(t) {
1591
+ return Re(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
1592
+ }
1593
+ }
1594
+ class Ie {
1595
+ constructor() {
1596
+ this.handlers = /* @__PURE__ */ new Map();
1597
+ }
1598
+ add(t, e) {
1599
+ this.handlers.set(t, e);
1600
+ }
1601
+ get(t) {
1602
+ return this.handlers.get(t);
1603
+ }
1604
+ }
1605
+ const Le = (n) => {
1606
+ let t = n, e = 0;
1607
+ for (; t.parent; )
1608
+ e = e + 1, t = t.parent;
1609
+ return e;
1610
+ }, Me = (n) => n.map(([e, s]) => [Le(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), Q = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), w = (n, ...t) => {
1611
+ if (!t.length)
1612
+ return n;
1613
+ const e = t.shift();
1614
+ if (Q(n) && Q(e))
1615
+ for (const s in e)
1616
+ Q(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), w(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
1617
+ return w(n, ...t);
1618
+ }, ze = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), Se = (n, t) => {
1619
+ let e = [], s = [], i;
1620
+ const r = () => {
1621
+ process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
1622
+ const c = /* @__PURE__ */ new Map(), u = Me(e.map((a, l) => [a, s[l]])), h = (a, l) => {
1623
+ var ot;
1624
+ const p = c.get(a) || {}, d = l.context && !p.context, C = l.properties && !p.properties, N = l.layout && !p.layout;
1625
+ c.set(a, {
1626
+ context: p.context || d,
1627
+ properties: p.properties || C,
1628
+ layout: p.layout || N
1629
+ }), C && (a.attributes.properties = {}), N && (a.attributes.layout = {}), d && (a.attributes.context = w({}, (ot = a.parent) == null ? void 0 : ot.attributes.context));
1630
+ const nt = [], it = [], rt = [];
1631
+ if (a.changesets.forEach((y) => {
1632
+ const [f, V] = y;
1633
+ ze(V.breakpoints, n.breakpoints) && (C && (typeof f.properties == "function" ? nt.push(
1634
+ f.properties
1635
+ ) : w(a.attributes.properties, f.properties)), N && (typeof f.layout == "function" ? it.push(f.layout) : w(a.attributes.layout, f.layout)), d && (typeof f.context == "function" ? rt.push(f.context) : w(a.attributes.context, f.context)));
1636
+ }), nt.forEach((y) => {
1637
+ w(a.attributes.properties, y(a.attributes.properties));
1638
+ }), it.forEach((y) => {
1639
+ w(a.attributes.layout, y(a.attributes.layout));
1640
+ }), rt.forEach((y) => {
1641
+ w(a.attributes.context, y(a.attributes.context));
1642
+ }), d || l.recursive) {
1643
+ const y = n.getBranch(a), f = l.recursive ? l : {
1644
+ context: !!d
1645
+ };
1646
+ a.getChildren(y).forEach((V) => {
1647
+ h(V, f);
1648
+ });
1649
+ }
1650
+ };
1651
+ process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), u.forEach(([a, l]) => {
1652
+ h(a, l);
1653
+ }), e = [], s = [], t(c);
1654
+ }, o = () => {
1655
+ clearTimeout(i), i = setTimeout(r, 0);
1656
+ };
1657
+ return (c, u) => {
1658
+ const h = e.indexOf(c);
1659
+ if (h > -1) {
1660
+ const a = s[h];
1661
+ return u.context && (a.context = !0), u.properties && (a.properties = !0), u.layout && (a.layout = !0), u.recursive && (a.recursive = !0), o();
1662
+ }
1663
+ return e.push(c), s.push(u), o();
1664
+ };
1665
+ };
1666
+ class Te {
1667
+ constructor(t, e = {}) {
1668
+ this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new Ie(), this.events = t.events.createChild(this);
1669
+ const s = new xt(this.events, "root");
1670
+ s.name = `root-${t.name}`, this.nodes = new De(s, this.switches, this.events);
1671
+ const i = this.processNode = Se(
1672
+ this,
1673
+ (r) => {
1674
+ const o = Array.from(r.keys());
1675
+ process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
1676
+ ${o.map(
1677
+ (c) => `${c.name || "<no name>"} (${c.id})
1678
+ `
1679
+ )}`), o.forEach((c) => {
1680
+ const u = r.get(c);
1681
+ c.parent && c.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: c }), u != null && u.context && this.events.dispatch("components:context-changed", { node: c }), u != null && u.properties && this.events.dispatch("components:properties-changed", { node: c }), u != null && u.layout && this.events.dispatch("components:layout-changed", { node: c });
1682
+ }), this.events.dispatch(
1683
+ "components:component-model-initialized",
1684
+ {},
1685
+ { bubbles: !0 }
1686
+ );
1687
+ }
1688
+ );
1689
+ Promise.all(
1690
+ Object.keys(e).map((r) => e[r].load(this))
1691
+ ), this.subscriptions.push(
1692
+ this.events.subscribe(
1693
+ "components:node-appended",
1694
+ (r, o) => {
1695
+ const { node: c } = o;
1696
+ this.changesets.forEach((u) => {
1697
+ const { changeset: h, target: a, removes: l } = u, [p, d] = h;
1698
+ a.match(o.node) && (p.properties && l.push(c.writeProperties(p.properties, d)), p.context && l.push(c.writeContext(p.context, d)), p.layout && l.push(c.writeLayout(p.layout, d)));
1699
+ });
1700
+ }
1701
+ )
1702
+ ), this.subscriptions.push(
1703
+ this.events.subscribe(
1704
+ "components:node-appended",
1705
+ (r, o) => {
1706
+ i(o.node, { properties: !0, context: !0 });
1707
+ }
1708
+ )
1709
+ ), this.subscriptions.push(
1710
+ this.events.subscribe(
1711
+ "components:set-properties",
1712
+ (r, o) => {
1713
+ i(o.node, { properties: !0 });
1714
+ }
1715
+ )
1716
+ ), this.subscriptions.push(
1717
+ this.events.subscribe(
1718
+ "components:set-context",
1719
+ (r, o) => {
1720
+ i(o.node, { properties: !0, context: !0 });
1721
+ }
1722
+ )
1723
+ ), this.subscriptions.push(
1724
+ this.events.subscribe(
1725
+ "components:set-indent",
1726
+ (r, o) => {
1727
+ i(o.node, { layout: !0 });
1728
+ }
1729
+ )
1730
+ ), this.subscriptions.push(
1731
+ this.events.subscribe(
1732
+ "components:set-layout",
1733
+ (r, o) => {
1734
+ i(o.node, { layout: !0 });
1735
+ }
1736
+ )
1737
+ ), this.subscriptions.push(
1738
+ this.events.subscribe(
1739
+ "components:node-switched",
1740
+ (r, { node: o, branch: c }) => {
1741
+ i(o, {
1742
+ layout: !0,
1743
+ recursive: !0,
1744
+ properties: !0,
1745
+ context: !0
1746
+ });
1747
+ }
1748
+ )
1749
+ ), this.subscriptions.push(
1750
+ this.events.subscribe(
1751
+ "components:node-removed",
1752
+ (r, { parentNode: o }) => {
1753
+ i(o, { properties: !0 });
1754
+ }
1755
+ )
1756
+ ), this.events.parent && this.events.parent.dispatch("components:platform-created", {
1757
+ platform: this
1758
+ });
1759
+ }
1760
+ static getInstance(t) {
1761
+ return t.getAsync("components");
1762
+ }
1763
+ addBreakpoint(t) {
1764
+ this.breakpoints.indexOf(t) === -1 && (this.breakpoints.push(t), this.processNode(this.nodes.root, {
1765
+ context: !0,
1766
+ properties: !0,
1767
+ layout: !0,
1768
+ recursive: !0
1769
+ }));
1770
+ }
1771
+ removeBreakpoint(t) {
1772
+ const e = this.breakpoints.indexOf(t);
1773
+ e > -1 && (this.breakpoints.splice(e, 1), this.processNode(this.nodes.root, {
1774
+ context: !0,
1775
+ properties: !0,
1776
+ layout: !0,
1777
+ recursive: !0
1778
+ }));
1779
+ }
1780
+ setSwitch(t, e) {
1781
+ this.switches[t.id] = e, this.events.dispatch("components:node-switched", { node: t, branch: e });
1782
+ }
1783
+ getBranch(t) {
1784
+ return this.switches[t.id];
1785
+ }
1786
+ /**
1787
+ * Creates a `ComponentNode` of the specified type.
1788
+ * @param type Type of node.
1789
+ */
1790
+ createNode(t, e = {}) {
1791
+ const s = new xt(this.events, t);
1792
+ return e.detached && this.nodes.detached.push(s), s;
1793
+ }
1794
+ components() {
1795
+ return new Z(this);
1796
+ }
1797
+ actions(t, e) {
1798
+ return new tt(this, t, e);
1799
+ }
1800
+ write(t) {
1801
+ const {
1802
+ provider: e,
1803
+ target: s,
1804
+ attributes: i,
1805
+ options: r = {},
1806
+ removable: o
1807
+ } = t, c = t.key || et(), h = { changeset: [i, r], target: s, removes: [] };
1808
+ if (e) {
1809
+ const a = this.providers[e];
1810
+ a.write(c, s, i, r), h.removes.push(() => {
1811
+ a.remove(c);
1812
+ });
1813
+ }
1814
+ return this.changesets.push(h), this.nodes.all.forEach((a) => {
1815
+ if (s.match(a)) {
1816
+ let l = () => {
1817
+ };
1818
+ i.properties && (l = a.writeProperties(
1819
+ i.properties,
1820
+ r,
1821
+ o
1822
+ )), i.context && (l = a.writeContext(i.context, r, o)), i.layout && (l = a.writeContext(i.layout, r, o)), h.removes.push(l);
1823
+ }
1824
+ }), () => {
1825
+ if (o) {
1826
+ h.removes.forEach((l) => l());
1827
+ const a = this.changesets.indexOf(h);
1828
+ a > -1 && this.changesets.splice(a, 1);
1829
+ }
1830
+ };
1831
+ }
1832
+ addComponentHandler(t, e) {
1833
+ this.customComponentHandler.add(t, e);
1834
+ }
1835
+ getComponentHandler(t) {
1836
+ return this.customComponentHandler.get(t);
1837
+ }
1838
+ dispose() {
1839
+ this.subscriptions.forEach((t) => t());
1840
+ }
1841
+ }
1842
+ const Ve = (n) => {
1843
+ if (Array.isArray(n)) {
1844
+ const [t, ...e] = n;
1845
+ return {
1846
+ definitionId: t,
1847
+ overrides: e
1848
+ };
1849
+ }
1850
+ return {
1851
+ definitionId: n,
1852
+ overrides: []
1853
+ };
1854
+ }, Y = (n, t, e, s, i, r) => {
1855
+ e.forEach((o) => {
1856
+ const c = Ve(o), u = s[c.definitionId];
1857
+ if (c.definitionId === "view") {
1858
+ const h = n.createNode("view");
1859
+ h.name = "view", Object.keys(i).forEach((a) => {
1860
+ const l = i[a];
1861
+ Y(n, h, [l.entry], s, i, a);
1862
+ }), t.appendChild(h), c.overrides.forEach((a) => {
1863
+ a.properties && h.writeProperties(a.properties, {
1864
+ breakpoints: a.breakpoints
1865
+ }), a.context && h.writeContext(a.context, { breakpoints: a.breakpoints }), a.layout && h.writeLayout(a.layout, { breakpoints: a.breakpoints });
1866
+ });
1867
+ } else if (n.getComponentHandler(u.type)) {
1868
+ const h = n.getComponentHandler(u.type);
1869
+ h && h(c, {
1870
+ platform: n,
1871
+ node: t,
1872
+ references: e,
1873
+ definitions: s,
1874
+ views: i,
1875
+ branch: r
1876
+ });
1877
+ } else {
1878
+ const h = s[c.definitionId];
1879
+ if (process.env.NODE_ENV !== "production" && !h) {
1880
+ P.error(
1881
+ `No definition found for component type '${c.definitionId}'.`
1882
+ );
1883
+ return;
1884
+ }
1885
+ const a = n.createNode(h.type);
1886
+ a.name = c.definitionId, a.tags = h.tags || [], h.properties && a.writeProperties(h.properties), h.context && a.writeContext(h.context), h.layout && a.writeLayout(h.layout), t.appendChild(a, r), c.overrides.forEach((l) => {
1887
+ const p = { breakpoints: l.breakpoints };
1888
+ l.properties && a.writeProperties(l.properties, p), l.context && a.writeContext(l.context, p), l.layout && a.writeLayout(l.layout, p);
1889
+ }), h.children && Y(n, a, h.children, s, i);
1890
+ }
1891
+ });
1892
+ }, Ue = (n, t) => {
1893
+ const { entry: e, components: s, breakpoints: i, views: r } = t, o = [];
1894
+ return Object.keys(i).forEach((c) => {
1895
+ const u = i[c], h = window.matchMedia(u);
1896
+ h.matches && n.breakpoints.push(c);
1897
+ const a = (l) => {
1898
+ l.matches ? n.addBreakpoint(c) : n.removeBreakpoint(c);
1899
+ };
1900
+ h.addListener(a), o.push(() => h.removeListener(a));
1901
+ }), Y(n, n.nodes.root, [e], s, r), () => o.forEach((c) => {
1902
+ c();
1903
+ });
1904
+ }, Ge = (n, t) => ({
1905
+ id: n.id,
1906
+ type: n.type,
1907
+ name: n.name,
1908
+ branch: t || "default"
1909
+ }), Ke = (n, t, e, s = et(), i = {}) => n.getAsync("components").then((r) => {
1910
+ let o;
1911
+ if (typeof t == "string") {
1912
+ const h = new Z(r);
1913
+ h.ofType(t), o = h;
1914
+ } else
1915
+ o = t;
1916
+ const c = {}, u = (h) => {
1917
+ const a = c[h.id];
1918
+ return a ? Promise.resolve(a.controller) : Te.getInstance(n).then((l) => new Mt(l, h, s));
1919
+ };
1920
+ r.events.subscribe(
1921
+ "components:node-enter",
1922
+ (h, { node: a }) => {
1923
+ o.match(a) && u(a).then((l) => {
1924
+ Promise.resolve(e(l)).then((p) => {
1925
+ c[a.id] = {
1926
+ dispose: p,
1927
+ controller: l
1928
+ };
1929
+ });
1930
+ });
1931
+ }
1932
+ ), r.events.subscribe(
1933
+ "components:node-exit",
1934
+ (h, { node: a }) => {
1935
+ const l = c[a.id];
1936
+ l && (l.dispose && l.dispose(), i.reuseController || (l.controller.dispose(), delete c[a.id]));
1937
+ }
1938
+ );
1939
+ });
1940
+ class Je {
1941
+ constructor(t) {
1942
+ this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new P();
1943
+ const { events: e } = t.get("$widget");
1944
+ this.events = e;
1945
+ }
1946
+ getComponent(t) {
1947
+ const e = this.aliases.get(t), s = this.components.get(e || t) || null;
1948
+ return process.env.NODE_ENV !== "production" && (s || this.logger.warn(
1949
+ e || t,
1950
+ `Unable to resolve component: "${e || t}". You most likely forgot to register the required plugin for: ${e || t}.`
1951
+ )), s;
1952
+ }
1953
+ registerComponent(t, e) {
1954
+ return this.components.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
1955
+ this.components.delete(t);
1956
+ };
1957
+ }
1958
+ registerResolver(t, e) {
1959
+ return this.events.subscribe(
1960
+ "component-resolver:resolve",
1961
+ (s, i) => {
1962
+ if (i === t) {
1963
+ const r = this.getComponent(t);
1964
+ e(r);
1965
+ }
1966
+ }
1967
+ );
1968
+ }
1969
+ registerAlias(t, e) {
1970
+ return this.aliases.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
1971
+ this.aliases.delete(t);
1972
+ };
1973
+ }
1974
+ }
1975
+ const je = "#____version____#", St = class Tt extends Lt {
1976
+ constructor(t, e = []) {
1977
+ super(t, e, {
1978
+ transformPluginSettings: (s, i, r) => {
1979
+ const o = r.get("$settings"), c = o.plugins && i ? o.plugins[i] || {} : {};
1980
+ return I(I({}, c), s);
1981
+ }
1982
+ });
1983
+ }
1984
+ createImplementation(t) {
1985
+ const e = super.createImplementation(t);
1986
+ return e.bindings = t.bindings, e;
1987
+ }
1988
+ /**
1989
+ * Performs navigation for widgets matching the specified selector by invoking a
1990
+ * 'navigate' command.
1991
+ * @param selector Widget selector matching the widget(s) to perform navigation on.
1992
+ * @param route Route name.
1993
+ * @param params Route params.
1994
+ */
1995
+ navigate(t, e, s) {
1996
+ this.widgets.query(t).forEach((i) => i.invoke("navigate", { route: e, params: s }));
1997
+ }
1998
+ /**
1999
+ * Creates a runtime based on provided configuration.
2000
+ * @param configuration Runtime configuration.
2001
+ */
2002
+ static create(t = {}) {
2003
+ const e = [ne].concat(
2004
+ t.configurationApiExtensions || []
2005
+ );
2006
+ return new Tt("humany", e);
2007
+ }
2008
+ /**
2009
+ * Creates a widget runtime based on provided configuration and retains configuration handlers
2010
+ * registered on global context. Use this factory to fully support the default embed script.
2011
+ * Will return any existing widget runtime if available.
2012
+ * @param configuration Runtime configuration.
2013
+ * @param global Object to read configuration handlers from (default: window).
2014
+ */
2015
+ static createFromGlobal(t, e = {}) {
2016
+ if (this.isRuntime(t))
2017
+ return t.patch(e), t;
2018
+ const s = [], i = t && t._c;
2019
+ i && i.forEach(
2020
+ (o) => s.push(o)
2021
+ );
2022
+ const r = this.create(e);
2023
+ return r.container.register("$runtimecfg", s), r;
2024
+ }
2025
+ /**
2026
+ * Determines whether the specified object is a valid widget runtime.
2027
+ * @param obj Object to compare.
2028
+ */
2029
+ static isRuntime(t) {
2030
+ return !!(t && typeof t == "object" && t.container && typeof t.container.get == "function" && t.container.get("$environment") === t && t.container.owner === t);
2031
+ }
2032
+ };
2033
+ St.version = `${je} (${X})`;
2034
+ let Xe = St;
2035
+ class Ze extends Rt {
2036
+ constructor() {
2037
+ super(...arguments), this.bindings = [];
2038
+ }
2039
+ }
2040
+ class ts extends ge {
2041
+ constructor(t, e) {
2042
+ super(t, e);
2043
+ }
2044
+ }
2045
+ var qe = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(qe || {});
2046
+ class es extends Ee {
2047
+ constructor(t) {
2048
+ super(t);
2049
+ }
2050
+ }
2051
+ export {
2052
+ He as ActionResolver,
2053
+ tt as ActionsController,
2054
+ xt as ComponentNode,
2055
+ Mt as ComponentNodeController,
2056
+ Te as ComponentPlatform,
2057
+ Z as ComponentQuery,
2058
+ Je as ComponentResolver,
2059
+ Xe as Environment,
2060
+ Ze as Implementation,
2061
+ ts as Plugin,
2062
+ qe as WidgetRenderState,
2063
+ es as WidgetType,
2064
+ Ge as asDescriptor,
2065
+ Qe as bootstrap,
2066
+ Ye as componentConfigurationApi,
2067
+ Y as createChildren,
2068
+ Ue as createComponentModel,
2069
+ Ae as createEventSubscriber,
2070
+ Ke as extendComponent,
2071
+ Re as findComponent,
2072
+ B as findVisibleComponents,
2073
+ st as traverseComponents,
2074
+ je as version
2075
+ };
2076
+ //# sourceMappingURL=index.js.map