@luzmo/embed 6.2.2 → 6.2.4-beta.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/index.cjs +1620 -0
  3. package/index.js +1589 -0
  4. package/luzmo-embed.min.js +3676 -0
  5. package/package.json +2 -2
  6. package/src/index.d.ts +8 -0
  7. package/src/lib/dashboard-component/dashboard-base.d.ts +99 -0
  8. package/src/lib/dashboard-component/dashboard-component.d.ts +8 -0
  9. package/src/lib/dashboard-component/dashboard-styles.d.ts +1 -0
  10. package/src/lib/helper/event-bus-handler.d.ts +1 -0
  11. package/src/lib/helper/json-schema-utils.d.ts +64 -0
  12. package/src/lib/luzmo-iq-components/luzmo-iq-answer.d.ts +22 -0
  13. package/src/lib/luzmo-iq-components/luzmo-iq-chat.d.ts +24 -0
  14. package/src/lib/luzmo-service.d.ts +6 -0
  15. package/src/lib/viz-item/viz-item-component.d.ts +4 -0
  16. package/src/lib/viz-item/viz-item.base.d.ts +71 -0
  17. package/.prettierignore +0 -4
  18. package/esbuild.config.cjs +0 -13
  19. package/eslint.config.cjs +0 -8
  20. package/jest.config.ts +0 -11
  21. package/project.json +0 -39
  22. package/src/index.ts +0 -42
  23. package/src/lib/dashboard-component/dashboard-base.ts +0 -828
  24. package/src/lib/dashboard-component/dashboard-component.spec.ts +0 -27
  25. package/src/lib/dashboard-component/dashboard-component.ts +0 -12
  26. package/src/lib/dashboard-component/dashboard-styles.ts +0 -117
  27. package/src/lib/helper/event-bus-handler.ts +0 -195
  28. package/src/lib/helper/json-schema-utils.ts +0 -129
  29. package/src/lib/luzmo-iq-components/luzmo-iq-answer.ts +0 -106
  30. package/src/lib/luzmo-iq-components/luzmo-iq-chat.ts +0 -106
  31. package/src/lib/luzmo-service.ts +0 -7
  32. package/src/lib/viz-item/viz-item-component.ts +0 -9
  33. package/src/lib/viz-item/viz-item.base.ts +0 -227
  34. package/src/vite-env.d.ts +0 -1
  35. package/tsconfig.json +0 -27
  36. package/tsconfig.lib.json +0 -10
  37. package/tsconfig.spec.json +0 -9
package/index.js ADDED
@@ -0,0 +1,1589 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result)
9
+ __defProp(target, key, result);
10
+ return result;
11
+ };
12
+
13
+ // libs/embed-libs/embed/src/index.ts
14
+ import { selectedDataUtils } from "@luzmo/shared-embed";
15
+
16
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
17
+ import * as SharedLib2 from "@luzmo/shared-embed";
18
+ import {
19
+ html,
20
+ LitElement
21
+ } from "lit";
22
+ import {
23
+ property,
24
+ query,
25
+ state
26
+ } from "lit/decorators.js";
27
+ import {
28
+ styleMap
29
+ } from "lit/directives/style-map.js";
30
+ import {
31
+ luzmoEmbedContainerClass
32
+ } from "@luzmo/shared-embed";
33
+
34
+ // libs/embed-libs/embed/package.json
35
+ var version = "6.2.4-beta.1";
36
+
37
+ // libs/embed-libs/embed/src/lib/luzmo-service.ts
38
+ var LuzmoService = class {
39
+ constructor() {
40
+ this._components = [];
41
+ }
42
+ };
43
+ var luzmo_service_default = new LuzmoService();
44
+
45
+ // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
46
+ import * as SharedLib from "@luzmo/shared-embed";
47
+ var _setEventHandler = () => {
48
+ if (typeof window.__luzmoMessageHandler === "function") {
49
+ return;
50
+ }
51
+ window.__luzmoMessageHandler = (event) => {
52
+ const dashboardComponent = luzmo_service_default._components.find(
53
+ (c) => event.data.name === c._iframeId
54
+ );
55
+ if (!dashboardComponent) {
56
+ return;
57
+ }
58
+ switch (event.data?.type) {
59
+ case "load": {
60
+ dashboardComponent.dispatchEvent(
61
+ new CustomEvent("load", { detail: { data: event.data } })
62
+ );
63
+ if (dashboardComponent._loadTimeoutHandle) {
64
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
65
+ dashboardComponent._loadTimeoutHandle = void 0;
66
+ }
67
+ dashboardComponent.iframeLoaded = true;
68
+ dashboardComponent.dimensions = event.data.dimensions;
69
+ dashboardComponent._calculateDimAfterDashboardLoaded();
70
+ break;
71
+ }
72
+ case "error": {
73
+ dashboardComponent.dashboardError = true;
74
+ if (dashboardComponent._loadTimeoutHandle) {
75
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
76
+ dashboardComponent._loadTimeoutHandle = void 0;
77
+ }
78
+ dashboardComponent.iframeLoaded = true;
79
+ dashboardComponent._displayError();
80
+ console.error("Dashboard error:", event.data.errorMsg ?? event.data.error?.msg);
81
+ break;
82
+ }
83
+ case "data": {
84
+ SharedLib.resolvePromise(
85
+ dashboardComponent,
86
+ event.data.requestId,
87
+ event.data.data
88
+ );
89
+ break;
90
+ }
91
+ case "filters": {
92
+ SharedLib.resolvePromise(
93
+ dashboardComponent,
94
+ event.data.requestId,
95
+ event.data.filters
96
+ );
97
+ break;
98
+ }
99
+ case "getAccessibleDashboards": {
100
+ SharedLib.resolvePromise(
101
+ dashboardComponent,
102
+ event.data.requestId,
103
+ event.data.accessibleDashboards
104
+ );
105
+ break;
106
+ }
107
+ case "dashboardAction": {
108
+ dashboardComponent.dispatchEvent(
109
+ new CustomEvent("dashboardAction", { detail: { data: event.data } })
110
+ );
111
+ break;
112
+ }
113
+ case "export": {
114
+ if (event.data.error) {
115
+ SharedLib.rejectPromise(
116
+ dashboardComponent,
117
+ event.data.requestId,
118
+ event.data
119
+ );
120
+ } else {
121
+ dashboardComponent.dispatchEvent(
122
+ new CustomEvent("exported", { detail: { data: event.data } })
123
+ );
124
+ SharedLib.resolvePromise(
125
+ dashboardComponent,
126
+ event.data.requestId,
127
+ event.data
128
+ );
129
+ }
130
+ break;
131
+ }
132
+ case "changedFilters": {
133
+ dashboardComponent.dispatchEvent(
134
+ new CustomEvent("changedFilters", { detail: { data: event.data } })
135
+ );
136
+ break;
137
+ }
138
+ case "customEvent": {
139
+ dashboardComponent.dispatchEvent(
140
+ new CustomEvent("customEvent", { detail: { data: event.data } })
141
+ );
142
+ break;
143
+ }
144
+ case "chartsRendered":
145
+ case "itemsRendered": {
146
+ event.data.type = "itemsRendered";
147
+ dashboardComponent.dispatchEvent(
148
+ new CustomEvent("itemsRendered", { detail: { data: event.data } })
149
+ );
150
+ break;
151
+ }
152
+ case "setEditMode": {
153
+ if (event.data.error) {
154
+ SharedLib.rejectPromise(
155
+ dashboardComponent,
156
+ event.data.requestId,
157
+ event.data
158
+ );
159
+ } else {
160
+ SharedLib.resolvePromise(
161
+ dashboardComponent,
162
+ event.data.requestId,
163
+ event.data
164
+ );
165
+ dashboardComponent.params.editMode = event.data.editMode;
166
+ dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
167
+ if (dashboardComponent.dimensions) {
168
+ SharedLib._setCalculatedDimensions(dashboardComponent);
169
+ }
170
+ }
171
+ break;
172
+ }
173
+ case "calculatedDimensions": {
174
+ dashboardComponent.dimensions = event.data.dimensions;
175
+ SharedLib._setCalculatedDimensions(dashboardComponent);
176
+ break;
177
+ }
178
+ case "setSelectedData":
179
+ case "setFilters": {
180
+ if (event.data.error) {
181
+ SharedLib.rejectPromise(
182
+ dashboardComponent,
183
+ event.data.requestId,
184
+ event.data
185
+ );
186
+ } else {
187
+ SharedLib.resolvePromise(
188
+ dashboardComponent,
189
+ event.data.requestId,
190
+ event.data
191
+ );
192
+ }
193
+ break;
194
+ }
195
+ case "setPreview": {
196
+ if (event.data.error) {
197
+ SharedLib.rejectPromise(
198
+ dashboardComponent,
199
+ event.data.requestId,
200
+ event.data
201
+ );
202
+ } else {
203
+ SharedLib.resolvePromise(
204
+ dashboardComponent,
205
+ event.data.requestId,
206
+ event.data
207
+ );
208
+ }
209
+ break;
210
+ }
211
+ }
212
+ };
213
+ window.addEventListener("message", window.__luzmoMessageHandler, false);
214
+ };
215
+
216
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
217
+ import { css } from "lit";
218
+ var dashboardStyles = css`
219
+ :host {
220
+ display: block;
221
+ height: 100%;
222
+ }
223
+
224
+ @-webkit-keyframes spin {
225
+ 0% {
226
+ -webkit-transform: rotate(0deg);
227
+ transform: rotate(0deg);
228
+ }
229
+ 100% {
230
+ -webkit-transform: rotate(360deg);
231
+ transform: rotate(360deg);
232
+ }
233
+ }
234
+
235
+ @keyframes spin {
236
+ 0% {
237
+ -webkit-transform: rotate(0deg);
238
+ transform: rotate(0deg);
239
+ }
240
+ 100% {
241
+ -webkit-transform: rotate(360deg);
242
+ transform: rotate(360deg);
243
+ }
244
+ }
245
+ :host {
246
+ position: relative;
247
+ width: 100%;
248
+ }
249
+
250
+ .luzmo-embed-dashboard {
251
+ background: transparent;
252
+ padding: 0;
253
+ border: 0;
254
+ }
255
+
256
+ .luzmo-embed-dashboard-ede {
257
+ }
258
+
259
+ .luzmo-embed-container-ede {
260
+ width: 100%;
261
+ height: 100%;
262
+ }
263
+
264
+ .luzmo-container-loader {
265
+ width: 100%;
266
+ position: relative;
267
+ }
268
+
269
+ .luzmo-lc {
270
+ margin: 0 auto;
271
+ }
272
+
273
+ .luzmo-loading-message {
274
+ width: 100%;
275
+ height: 20px;
276
+ text-align: center;
277
+ margin-bottom: 16px;
278
+ font-family: Helvetica, Arial, sans-serif;
279
+ font-size: 14px;
280
+ }
281
+
282
+ .luzmo-loading-circle {
283
+ box-sizing: border-box;
284
+ margin: 16px auto;
285
+ position: relative;
286
+ text-indent: -9999em;
287
+ animation: spin 0.6s infinite linear;
288
+ }
289
+
290
+ .luzmo-loading-circle,
291
+ .luzmo-loading-circle:after {
292
+ border-radius: 50%;
293
+ width: 32px;
294
+ height: 32px;
295
+ }
296
+
297
+ .itemEmbedding:after {
298
+ width: 24px;
299
+ height: 24px;
300
+ }
301
+
302
+ .luzmo-error {
303
+ background: transparent;
304
+ padding: 48px 0;
305
+ margin: 0 auto;
306
+ width: 80%;
307
+ border: 0;
308
+ text-align: center;
309
+ min-height: 192px;
310
+ }
311
+
312
+ .dashboard-error {
313
+ font-size: 30px;
314
+ background: transparent;
315
+ padding: 48px 0;
316
+ margin: 0 auto;
317
+ width: 80%;
318
+ border: 0;
319
+ text-align: center;
320
+ min-height: 192px;
321
+ }
322
+
323
+ .luzmo-loader {
324
+ top: 0;
325
+ left: 0;
326
+ width: 100%;
327
+ min-height: 400px;
328
+ position: absolute;
329
+ transition-duration: 0.3s;
330
+ }
331
+ `;
332
+
333
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
334
+ var LuzmoDashboard = class extends LitElement {
335
+ constructor() {
336
+ super();
337
+ this.language = "auto";
338
+ this.screenMode = "auto";
339
+ this.switchScreenModeOnResize = true;
340
+ this.editMode = "view";
341
+ this.experimental = false;
342
+ this.iframeStyle = {};
343
+ this._containerStyle = {};
344
+ this._loaderStyle = {};
345
+ this._lcStyle = {};
346
+ this._loadingCircleStyle = {};
347
+ this._containerLoaderStyle = {};
348
+ this._loaderMsg = "";
349
+ this._itemEmbedding = false;
350
+ this.browserError = false;
351
+ this.browserErrorMsg = "";
352
+ this.dashboardError = false;
353
+ this.browserNotSupported = [];
354
+ this.libVersion = version + "-wc-luzmo";
355
+ this.isLibraryLoaded = false;
356
+ this.currentAuthKey = null;
357
+ this.currentAuthToken = null;
358
+ this.isInitCalled = false;
359
+ this.attributesMap = {
360
+ dashboardId: "dashboard-id",
361
+ dashboardSlug: "dashboard-slug",
362
+ itemId: "item-id",
363
+ language: "language",
364
+ qeVersion: "qe-version",
365
+ screenMode: "screen-mode",
366
+ switchScreenModeOnResize: "switch-screen-mode-on-resize",
367
+ authKey: "auth-key",
368
+ authToken: "auth-token",
369
+ editMode: "edit-mode",
370
+ theme: "theme",
371
+ mainColor: "main-color",
372
+ accentColor: "accent-color",
373
+ loaderBackground: "loader-background",
374
+ loaderFontColor: "loader-font-color",
375
+ loaderSpinnerColor: "loader-spinner-color",
376
+ loaderSpinnerBackground: "loader-spinner-background",
377
+ appServer: "app-server",
378
+ apiHost: "api-host",
379
+ itemDimensions: "item-dimensions",
380
+ timezoneId: "timezone-id"
381
+ };
382
+ this.loaderSize = 32;
383
+ this.borderWidth = 3;
384
+ this.minHeight = 400;
385
+ this._containerId = SharedLib2.uuidv4();
386
+ this._iframeId = `luzmo-dashboard-${this._containerId}`;
387
+ this.iframeLoaded = false;
388
+ this.promises = {};
389
+ this.params = this._setOptions();
390
+ this._onResize = () => {
391
+ if (this.shadowRoot?.querySelector(".dashboard-container")) {
392
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
393
+ if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
394
+ for (const d of SharedLib2.EXTENTS) {
395
+ if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
396
+ this.currentScreenMode = d.mode;
397
+ }
398
+ }
399
+ }
400
+ if (this.iframeLoaded) {
401
+ this._calculateDimAfterDashboardLoaded();
402
+ } else {
403
+ if (this.dimensions) {
404
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
405
+ SharedLib2._setCalculatedDimensions(this);
406
+ }
407
+ }
408
+ }
409
+ };
410
+ this._resizeObserver = new ResizeObserver((entries) => {
411
+ window.requestAnimationFrame(() => {
412
+ if (!Array.isArray(entries) || entries.length === 0) {
413
+ return;
414
+ }
415
+ this._onResize();
416
+ });
417
+ });
418
+ }
419
+ // Set resize event listener
420
+ connectedCallback() {
421
+ super.connectedCallback();
422
+ }
423
+ // Set resize event listener
424
+ disconnectedCallback() {
425
+ super.disconnectedCallback();
426
+ this._resizeObserver.disconnect();
427
+ for (const promiseKey of Object.keys(this.promises)) {
428
+ this.promises[promiseKey].reject(
429
+ new Error("Dashboard component was removed")
430
+ );
431
+ }
432
+ }
433
+ firstUpdated() {
434
+ this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
435
+ this._loaderStyles();
436
+ luzmo_service_default._components.push(this);
437
+ if (this.luzmoEmbedContainer) {
438
+ this._resizeObserver.observe(this.luzmoEmbedContainer);
439
+ }
440
+ }
441
+ initComponent() {
442
+ this.params = this._setOptions();
443
+ if (this.getIsViewMode()) {
444
+ SharedLib2.loadLibrary(this.params.appServer).then(async () => {
445
+ this.isLibraryLoaded = true;
446
+ await this.updateComplete;
447
+ const oldReference = this.renderRoot.querySelector("dashboard-component");
448
+ this.dashboardReference = oldReference.cloneNode(true);
449
+ oldReference.replaceWith(this.dashboardReference);
450
+ this.dashboardReference.addEventListener("load", (payload) => {
451
+ this.containerWidth = this.dashboardReference.offsetWidth;
452
+ this.dimensions = payload.detail.dimensions;
453
+ SharedLib2._setCalculatedDimensions(this);
454
+ window.dispatchEvent(new Event("resize"));
455
+ this.dispatchEvent(new CustomEvent("load", payload));
456
+ });
457
+ this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
458
+ this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
459
+ this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
460
+ this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
461
+ this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
462
+ this.setAllAttributes();
463
+ });
464
+ } else {
465
+ this.containerWidth = this.container?.clientWidth;
466
+ SharedLib2._extendAndValidate(this);
467
+ SharedLib2._browserCheck(this);
468
+ this._setupLoader();
469
+ if (!this.params.error) {
470
+ this._loaderStyles();
471
+ _setEventHandler();
472
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
473
+ this.iframe?.setAttribute("src", this._iframeUrl);
474
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
475
+ }
476
+ }
477
+ }
478
+ setAllAttributes() {
479
+ if (this.dashboardReference) {
480
+ for (const key in this.attributesMap) {
481
+ if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
482
+ this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
483
+ }
484
+ }
485
+ if (this.params.itemDimensions) {
486
+ this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
487
+ }
488
+ if (this.params.apiHost) {
489
+ this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
490
+ }
491
+ if (this.params.key) {
492
+ this.dashboardReference.setAttribute("auth-key", this.params.key);
493
+ }
494
+ if (this.params.token) {
495
+ this.dashboardReference.setAttribute("auth-token", this.params.token);
496
+ }
497
+ }
498
+ }
499
+ // Reload dashboard when triggerproperty changes
500
+ updated(changedProperties) {
501
+ const triggerProperties = /* @__PURE__ */ new Set([
502
+ "dashboardId",
503
+ "dashboardSlug",
504
+ "itemId",
505
+ "language",
506
+ "qeVersion",
507
+ "theme",
508
+ "editMode",
509
+ "screenMode",
510
+ "switchScreenModeOnResize",
511
+ "authToken",
512
+ "authKey",
513
+ "appServer",
514
+ "apiHost",
515
+ "timezoneId",
516
+ "itemDimensions"
517
+ ]);
518
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
519
+ let callInitComponent = false;
520
+ for (const condition of conditionsToCheck) {
521
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
522
+ }
523
+ if (callInitComponent && !this.isInitCalled) {
524
+ this.initComponent();
525
+ this.isInitCalled = true;
526
+ return;
527
+ }
528
+ if (this.getIsViewMode()) {
529
+ if (this.dashboardReference) {
530
+ for (const [propertyName] of changedProperties.entries()) {
531
+ if (propertyName === "appSever") {
532
+ SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
533
+ this.isLibraryLoaded = true;
534
+ await this.updateComplete;
535
+ this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
536
+ this.setAllAttributes();
537
+ });
538
+ } else if (this.attributesMap[propertyName]) {
539
+ const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
540
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
541
+ this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
542
+ }
543
+ }
544
+ }
545
+ } else {
546
+ for (const [propertyName] of changedProperties.entries()) {
547
+ if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
548
+ this.iframeLoaded = false;
549
+ if (this._loadTimeoutHandle) {
550
+ clearTimeout(this._loadTimeoutHandle);
551
+ }
552
+ this._loadTimeoutHandle = setTimeout(() => {
553
+ console.warn(
554
+ "Failed to load dashboard, appServer is likely down or unreachable."
555
+ );
556
+ }, 15 * 1e3);
557
+ this.params = this._setOptions();
558
+ SharedLib2._extendAndValidate(this);
559
+ this._setupLoader();
560
+ this._loaderStyles();
561
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
562
+ if (this.iframe) {
563
+ this._updateIframeUrl();
564
+ }
565
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
566
+ } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
567
+ if (this.iframeLoaded) {
568
+ this.setEditMode(this.editMode);
569
+ }
570
+ this.params = this._setOptions();
571
+ }
572
+ }
573
+ }
574
+ }
575
+ // Set params
576
+ _setOptions() {
577
+ const defaultParameters = {
578
+ dashboardId: this.dashboardId,
579
+ dashboardSlug: this.dashboardSlug
580
+ };
581
+ if (this.itemId) {
582
+ defaultParameters.itemId = this.itemId;
583
+ this._itemEmbedding = true;
584
+ } else {
585
+ this._itemEmbedding = false;
586
+ }
587
+ if (this.language) {
588
+ defaultParameters.language = this.language;
589
+ }
590
+ if (this.qeVersion) {
591
+ defaultParameters.qeVersion = this.qeVersion;
592
+ }
593
+ if (this.screenMode) {
594
+ defaultParameters.screenMode = this.screenMode;
595
+ }
596
+ defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
597
+ if (this.authToken) {
598
+ defaultParameters.token = this.authToken;
599
+ }
600
+ if (this.authKey) {
601
+ defaultParameters.key = this.authKey;
602
+ }
603
+ if (this.editMode) {
604
+ defaultParameters.editMode = this.editMode;
605
+ }
606
+ if (this.theme) {
607
+ defaultParameters.theme = this.theme;
608
+ }
609
+ if (this.mainColor) {
610
+ defaultParameters.mainColor = this.mainColor;
611
+ }
612
+ if (this.accentColor) {
613
+ defaultParameters.accentColor = this.accentColor;
614
+ }
615
+ if (this.loaderBackground) {
616
+ defaultParameters.loaderBackground = this.loaderBackground;
617
+ }
618
+ if (this.loaderFontColor) {
619
+ defaultParameters.loaderFontColor = this.loaderFontColor;
620
+ }
621
+ if (this.loaderSpinnerColor) {
622
+ defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
623
+ }
624
+ if (this.loaderSpinnerBackground) {
625
+ defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
626
+ }
627
+ if (this.timezoneId) {
628
+ defaultParameters.timezoneId = this.timezoneId;
629
+ }
630
+ if (this.itemDimensions) {
631
+ defaultParameters.itemDimensions = this.itemDimensions;
632
+ }
633
+ if (this.appServer) {
634
+ this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
635
+ defaultParameters.appServer = this.appServer;
636
+ } else {
637
+ this.appServer = SharedLib2.addTrailingSlash(
638
+ SharedLib2.DEFAULT_PARAMETERS.appServer
639
+ );
640
+ defaultParameters.appServer = this.appServer;
641
+ }
642
+ if (this.apiHost) {
643
+ this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
644
+ defaultParameters.apiHost = this.apiHost;
645
+ } else {
646
+ this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
647
+ defaultParameters.apiHost = this.apiHost;
648
+ }
649
+ this.currentAuthKey = this.authKey;
650
+ this.currentAuthToken = this.authToken;
651
+ return defaultParameters;
652
+ }
653
+ _updateIframeUrl() {
654
+ SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
655
+ }
656
+ // Setup loader / browser error
657
+ _setupLoader() {
658
+ const data = SharedLib2.getLoader(this);
659
+ this._loaderMsg = data.loadingMsg;
660
+ if (data.errorMsg) {
661
+ this.browserError = true;
662
+ this.browserErrorMsg = data.errorMsg;
663
+ this._displayError();
664
+ }
665
+ }
666
+ _displayError() {
667
+ if (this.dashboardError) {
668
+ this._loaderStyles();
669
+ this.iframeStyle.opacity = 1;
670
+ }
671
+ if (this.browserError) {
672
+ this._containerStyle.display = "none";
673
+ }
674
+ }
675
+ _calculateDimAfterDashboardLoaded() {
676
+ this.dashboardError = false;
677
+ this._loaderStyles();
678
+ SharedLib2._setCalculatedDimensions(this);
679
+ }
680
+ // Set loader styles
681
+ _loaderStyles() {
682
+ this._containerStyle = SharedLib2.containerStyles(this);
683
+ this._loaderStyle = SharedLib2.loaderStyles(this);
684
+ this._loadingCircleStyle = SharedLib2.plStyles(this);
685
+ this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
686
+ this._lcStyle = SharedLib2.lcStyles(this);
687
+ }
688
+ static get styles() {
689
+ return [dashboardStyles];
690
+ }
691
+ render() {
692
+ let toBeRenderedHTML;
693
+ const loader = html`
694
+ <div
695
+ class="luzmo-container-loader"
696
+ id="luzmo-container-loader-${this._containerId}"
697
+ style=${styleMap(
698
+ this._containerLoaderStyle
699
+ )}
700
+ >
701
+ <div
702
+ class="luzmo-loader"
703
+ id="luzmo-loader-${this._containerId}"
704
+ style=${styleMap(this._loaderStyle)}
705
+ >
706
+ <div
707
+ class="luzmo-lc"
708
+ style=${styleMap(this._lcStyle)}
709
+ >
710
+ <div
711
+ class="luzmo-loading-circle"
712
+ style=${styleMap(
713
+ this._loadingCircleStyle
714
+ )}
715
+ ></div>
716
+ ${this._itemEmbedding ? "" : html`
717
+ <div
718
+ class="luzmo-loading-message"
719
+ style=${styleMap({ color: this.loaderFontColor })}
720
+ >
721
+ ${this._loaderMsg}
722
+ </div>
723
+ `}
724
+ </div>
725
+ </div>
726
+ </div>
727
+ `;
728
+ if (this.getIsViewMode()) {
729
+ toBeRenderedHTML = this.isLibraryLoaded ? html`
730
+ ${this.dashboardId || this.dashboardSlug ? html`
731
+ <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
732
+ api-host="${this.params.apiHost}"></dashboard-component>
733
+ ` : html`
734
+ <div id="luzmo-error-${this._containerId}">
735
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
736
+ </div>
737
+ `}
738
+ ` : html`${loader}`;
739
+ } else {
740
+ toBeRenderedHTML = html`
741
+ ${this.dashboardId || this.dashboardSlug ? html`
742
+ ${loader}
743
+ <iframe
744
+ class="luzmo-embed-dashboard ${this.getIsViewMode() ? "" : `luzmo-embed-dashboard-ede`}"
745
+ id="${this._iframeId}"
746
+ name="${this._iframeId}"
747
+ style=${styleMap(this.iframeStyle)}
748
+ src="${this._iframeUrl}"
749
+ frameborder="0"
750
+ ></iframe>
751
+ ` : html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
752
+ ${this.browserError ? html`
753
+ <div id="luzmo-error-${this._containerId}">
754
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
755
+ </div>
756
+ ` : ""}
757
+ `;
758
+ }
759
+ return html`
760
+ <div class="${luzmoEmbedContainerClass} ${this.getIsViewMode() ? "" : `${luzmoEmbedContainerClass}-ede`}">
761
+ <div
762
+ class="dashboard-container"
763
+ style=${styleMap(Object.assign({}, this._containerStyle, {
764
+ width: this.iframeStyle.width ?? "100%",
765
+ height: this.iframeStyle.height ?? "100%"
766
+ }))}
767
+ >
768
+ ${toBeRenderedHTML}
769
+ </div>
770
+ </div>
771
+
772
+ `;
773
+ }
774
+ getDashboards() {
775
+ return new Promise(
776
+ (resolve) => resolve(luzmo_service_default._components)
777
+ );
778
+ }
779
+ // Public methods
780
+ getData(itemId) {
781
+ if (this.getIsViewMode() && this.dashboardReference) {
782
+ return this.dashboardReference.getData(itemId);
783
+ }
784
+ if (!this.getIsViewMode()) {
785
+ return SharedLib2.getData(this, this.iframe, itemId);
786
+ }
787
+ return Promise.reject();
788
+ }
789
+ getFilters() {
790
+ if (this.getIsViewMode() && this.dashboardReference) {
791
+ return this.dashboardReference.getFilters();
792
+ }
793
+ if (!this.getIsViewMode()) {
794
+ return SharedLib2.getFilters(this, this.iframe);
795
+ }
796
+ return Promise.reject();
797
+ }
798
+ setSelectedData(itemId, filters) {
799
+ if (this.getIsViewMode() && this.dashboardReference) {
800
+ return this.dashboardReference.setSelectedData(itemId, filters);
801
+ }
802
+ if (!this.getIsViewMode()) {
803
+ return SharedLib2.setSelectedData(this, this.iframe, itemId, filters);
804
+ }
805
+ return Promise.reject();
806
+ }
807
+ setAuthorization(key, token) {
808
+ this.currentAuthKey = key;
809
+ this.currentAuthToken = token;
810
+ if (this.getIsViewMode() && this.dashboardReference) {
811
+ return this.dashboardReference.setAuthorization(key, token);
812
+ }
813
+ if (!this.getIsViewMode()) {
814
+ return SharedLib2.setAuthorization(this, this.iframe, key, token);
815
+ }
816
+ return Promise.reject();
817
+ }
818
+ refreshData(itemId) {
819
+ if (this.getIsViewMode() && this.dashboardReference) {
820
+ return this.dashboardReference.refreshData(itemId);
821
+ }
822
+ if (!this.getIsViewMode()) {
823
+ return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
824
+ }
825
+ return Promise.reject();
826
+ }
827
+ reloadDashboard() {
828
+ if (this.getIsViewMode() && this.dashboardReference) {
829
+ return this.dashboardReference.reloadDashboard();
830
+ }
831
+ if (!this.getIsViewMode()) {
832
+ return SharedLib2.reloadDashboard(this, this.iframe);
833
+ }
834
+ return Promise.reject();
835
+ }
836
+ exportDashboard(format) {
837
+ if (this.getIsViewMode() && this.dashboardReference) {
838
+ return this.dashboardReference.exportDashboard(format);
839
+ }
840
+ if (!this.getIsViewMode()) {
841
+ return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
842
+ }
843
+ return Promise.reject();
844
+ }
845
+ getAccessibleDashboards() {
846
+ return SharedLib2.getAccessibleDashboards(this);
847
+ }
848
+ addFilters(itemId, filters) {
849
+ return this.dashboardReference.addFilters(itemId, filters);
850
+ }
851
+ setEditMode(editMode) {
852
+ if (this.dashboardReference && editMode === "view") {
853
+ this.editMode = "view";
854
+ this.params.editMode = "view";
855
+ this.initComponent();
856
+ return Promise.resolve({
857
+ type: "setEditMode",
858
+ editMode
859
+ });
860
+ }
861
+ if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
862
+ this.editMode = editMode;
863
+ this.params.editMode = editMode;
864
+ this.initComponent();
865
+ return Promise.resolve({
866
+ type: "setEditMode",
867
+ editMode
868
+ });
869
+ }
870
+ if (this.getIsViewMode() && this.dashboardReference) {
871
+ return this.dashboardReference.setEditMode(editMode);
872
+ }
873
+ if (!this.getIsViewMode()) {
874
+ return SharedLib2.setEditMode(this, this.iframe, editMode);
875
+ }
876
+ return Promise.reject();
877
+ }
878
+ setPreview(preview) {
879
+ if (this.getIsViewMode() && this.dashboardReference) {
880
+ return this.dashboardReference.setPreview(preview);
881
+ }
882
+ return SharedLib2.setPreview(this, this.iframe, preview);
883
+ }
884
+ getIsViewMode() {
885
+ return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
886
+ }
887
+ };
888
+ __decorateClass([
889
+ query(".dashboard-container")
890
+ ], LuzmoDashboard.prototype, "container", 2);
891
+ __decorateClass([
892
+ query(`.${luzmoEmbedContainerClass}`)
893
+ ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
894
+ __decorateClass([
895
+ query("iframe")
896
+ ], LuzmoDashboard.prototype, "iframe", 2);
897
+ __decorateClass([
898
+ property()
899
+ ], LuzmoDashboard.prototype, "dashboardId", 2);
900
+ __decorateClass([
901
+ property()
902
+ ], LuzmoDashboard.prototype, "dashboardSlug", 2);
903
+ __decorateClass([
904
+ property()
905
+ ], LuzmoDashboard.prototype, "itemId", 2);
906
+ __decorateClass([
907
+ property()
908
+ ], LuzmoDashboard.prototype, "language", 2);
909
+ __decorateClass([
910
+ property()
911
+ ], LuzmoDashboard.prototype, "qeVersion", 2);
912
+ __decorateClass([
913
+ property()
914
+ ], LuzmoDashboard.prototype, "screenMode", 2);
915
+ __decorateClass([
916
+ property({
917
+ converter: {
918
+ fromAttribute: (value) => value === "true",
919
+ toAttribute: String
920
+ }
921
+ })
922
+ ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
923
+ __decorateClass([
924
+ property()
925
+ ], LuzmoDashboard.prototype, "editMode", 2);
926
+ __decorateClass([
927
+ property()
928
+ ], LuzmoDashboard.prototype, "theme", 2);
929
+ __decorateClass([
930
+ property()
931
+ ], LuzmoDashboard.prototype, "mainColor", 2);
932
+ __decorateClass([
933
+ property()
934
+ ], LuzmoDashboard.prototype, "accentColor", 2);
935
+ __decorateClass([
936
+ property()
937
+ ], LuzmoDashboard.prototype, "authToken", 2);
938
+ __decorateClass([
939
+ property()
940
+ ], LuzmoDashboard.prototype, "authKey", 2);
941
+ __decorateClass([
942
+ property()
943
+ ], LuzmoDashboard.prototype, "loaderBackground", 2);
944
+ __decorateClass([
945
+ property()
946
+ ], LuzmoDashboard.prototype, "loaderFontColor", 2);
947
+ __decorateClass([
948
+ property()
949
+ ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
950
+ __decorateClass([
951
+ property()
952
+ ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
953
+ __decorateClass([
954
+ property()
955
+ ], LuzmoDashboard.prototype, "appServer", 2);
956
+ __decorateClass([
957
+ property()
958
+ ], LuzmoDashboard.prototype, "timezoneId", 2);
959
+ __decorateClass([
960
+ property()
961
+ ], LuzmoDashboard.prototype, "apiHost", 2);
962
+ __decorateClass([
963
+ property({ type: Object })
964
+ ], LuzmoDashboard.prototype, "itemDimensions", 2);
965
+ __decorateClass([
966
+ property({
967
+ converter: {
968
+ fromAttribute: (value) => value === "true",
969
+ toAttribute: String
970
+ }
971
+ })
972
+ ], LuzmoDashboard.prototype, "experimental", 2);
973
+ __decorateClass([
974
+ property({ attribute: false })
975
+ ], LuzmoDashboard.prototype, "_containerId", 2);
976
+ __decorateClass([
977
+ property({ attribute: false })
978
+ ], LuzmoDashboard.prototype, "_iframeId", 2);
979
+ __decorateClass([
980
+ property({ attribute: false })
981
+ ], LuzmoDashboard.prototype, "params", 2);
982
+ __decorateClass([
983
+ property({ attribute: false })
984
+ ], LuzmoDashboard.prototype, "_iframeUrl", 2);
985
+ __decorateClass([
986
+ property({ attribute: false })
987
+ ], LuzmoDashboard.prototype, "iframeLoaded", 2);
988
+ __decorateClass([
989
+ property({ attribute: false })
990
+ ], LuzmoDashboard.prototype, "promises", 2);
991
+ __decorateClass([
992
+ property({ attribute: false })
993
+ ], LuzmoDashboard.prototype, "iframeStyle", 2);
994
+ __decorateClass([
995
+ property({ attribute: false })
996
+ ], LuzmoDashboard.prototype, "_containerStyle", 2);
997
+ __decorateClass([
998
+ property({ attribute: false })
999
+ ], LuzmoDashboard.prototype, "_loaderStyle", 2);
1000
+ __decorateClass([
1001
+ property({ attribute: false })
1002
+ ], LuzmoDashboard.prototype, "_lcStyle", 2);
1003
+ __decorateClass([
1004
+ property({ attribute: false })
1005
+ ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1006
+ __decorateClass([
1007
+ property({ attribute: false })
1008
+ ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1009
+ __decorateClass([
1010
+ property({ attribute: false })
1011
+ ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1012
+ __decorateClass([
1013
+ property({ attribute: false })
1014
+ ], LuzmoDashboard.prototype, "containerWidth", 2);
1015
+ __decorateClass([
1016
+ property({ attribute: false })
1017
+ ], LuzmoDashboard.prototype, "dimensions", 2);
1018
+ __decorateClass([
1019
+ property({ attribute: false })
1020
+ ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1021
+ __decorateClass([
1022
+ property({ attribute: false })
1023
+ ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1024
+ __decorateClass([
1025
+ property({ attribute: false })
1026
+ ], LuzmoDashboard.prototype, "browserError", 2);
1027
+ __decorateClass([
1028
+ property({ attribute: false })
1029
+ ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1030
+ __decorateClass([
1031
+ property({ attribute: false })
1032
+ ], LuzmoDashboard.prototype, "dashboardError", 2);
1033
+ __decorateClass([
1034
+ property({ attribute: false })
1035
+ ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1036
+ __decorateClass([
1037
+ property()
1038
+ ], LuzmoDashboard.prototype, "libVersion", 2);
1039
+ __decorateClass([
1040
+ state()
1041
+ ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1042
+ __decorateClass([
1043
+ state()
1044
+ ], LuzmoDashboard.prototype, "dashboardReference", 2);
1045
+ __decorateClass([
1046
+ state()
1047
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1048
+ __decorateClass([
1049
+ state()
1050
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1051
+ __decorateClass([
1052
+ state()
1053
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
1054
+
1055
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
1056
+ var LuzmoEmbedDashboard = class extends LuzmoDashboard {
1057
+ };
1058
+ if (!customElements.get("luzmo-embed-dashboard")) {
1059
+ customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1060
+ }
1061
+
1062
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1063
+ import { property as property2 } from "lit/decorators.js";
1064
+ import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
1065
+ import * as SharedLib3 from "@luzmo/shared-embed";
1066
+ var dashboardContentsVersion = "0.1.92";
1067
+ var LuzmoBaseVizItem = class extends LitElement2 {
1068
+ constructor() {
1069
+ super(...arguments);
1070
+ this.appServer = "https://app.luzmo.com";
1071
+ this.apiHost = "https://api.luzmo.com";
1072
+ this.slots = [];
1073
+ this.version = version + "-wc-luzmo";
1074
+ this.dashboardContentsVersion = dashboardContentsVersion;
1075
+ this.libVersion = version + "-wc-luzmo";
1076
+ this.postInitCallQueue = [];
1077
+ }
1078
+ static {
1079
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1080
+ this.styles = css2`
1081
+ :host {
1082
+ display: block;
1083
+ width: 100%;
1084
+ height: 100%;
1085
+ }
1086
+
1087
+ luzmo-embed-viz-item {
1088
+ width: 100%;
1089
+ height: 1000%;
1090
+ display: block;
1091
+ }
1092
+ `;
1093
+ }
1094
+ createRenderRoot() {
1095
+ if (!this.style.display) {
1096
+ this.style.display = "block";
1097
+ }
1098
+ if (!this.style.height) {
1099
+ this.style.height = "100%";
1100
+ }
1101
+ if (!this.style.width) {
1102
+ this.style.width = "100%";
1103
+ }
1104
+ return this;
1105
+ }
1106
+ canInitializeVizItem() {
1107
+ return !!(this.type || this.dashboardId && this.itemId);
1108
+ }
1109
+ getFilters() {
1110
+ return this.chartElement.getFilters();
1111
+ }
1112
+ export() {
1113
+ return this.chartElement.export();
1114
+ }
1115
+ getData() {
1116
+ return this.chartElement.getData();
1117
+ }
1118
+ refreshData() {
1119
+ return this.chartElement.refreshData();
1120
+ }
1121
+ setSelectedData(selectedDataInput) {
1122
+ return this.chartElement.setSelectedData(void 0, selectedDataInput);
1123
+ }
1124
+ setAuthorization(key, token) {
1125
+ return this.chartElement.setAuthorization(key, token);
1126
+ }
1127
+ attributeChangedCallback(name, _old, value) {
1128
+ super.attributeChangedCallback(name, _old, value);
1129
+ if (name === "selecteddata") {
1130
+ if (this.chartElement) {
1131
+ this.setSelectedData(JSON.parse(value ?? "{}"));
1132
+ } else {
1133
+ this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(value ?? "{}")]]);
1134
+ }
1135
+ }
1136
+ }
1137
+ async firstUpdated(_changedProperties) {
1138
+ super.firstUpdated(_changedProperties);
1139
+ if (this.canInitializeVizItem()) {
1140
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1141
+ this.createAndAppendElement();
1142
+ }
1143
+ }
1144
+ createAndAppendElement() {
1145
+ if (!this.chartElement) {
1146
+ this.chartElement = document.createElement("chart-component");
1147
+ this.chartElement.setAttribute("embedding-mode", "chart");
1148
+ this.chartElement.style.height = "100%";
1149
+ this.chartElement.style.width = "100%";
1150
+ this.chartElement.style.display = "block";
1151
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1152
+ this.chartElement.addEventListener("rendered", (payload) => {
1153
+ if (this.postInitCallQueue?.length > 0) {
1154
+ for (const functionToCall of this.postInitCallQueue) {
1155
+ functionToCall[0].bind(this)(...functionToCall[1]);
1156
+ }
1157
+ } else {
1158
+ if (this.selectedData) {
1159
+ this.setSelectedData(this.selectedData);
1160
+ }
1161
+ }
1162
+ this.dispatchEvent(new CustomEvent("rendered", payload));
1163
+ });
1164
+ this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1165
+ this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1166
+ this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1167
+ this.updateVizItemProperties();
1168
+ this.renderRoot.append(this.chartElement);
1169
+ }
1170
+ }
1171
+ updateVizItemProperties() {
1172
+ if (this.chartElement) {
1173
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1174
+ const value = this[key];
1175
+ if (value) {
1176
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1177
+ this.chartElement.setAttribute(
1178
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1179
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1180
+ );
1181
+ }
1182
+ }
1183
+ }
1184
+ }
1185
+ async updated(changedProperties) {
1186
+ if (this.chartElement) {
1187
+ for (const [propertyName] of changedProperties.entries()) {
1188
+ const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1189
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1190
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1191
+ }
1192
+ } else {
1193
+ if (this.canInitializeVizItem()) {
1194
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1195
+ this.createAndAppendElement();
1196
+ }
1197
+ }
1198
+ }
1199
+ render() {
1200
+ return html2` `;
1201
+ }
1202
+ };
1203
+ __decorateClass([
1204
+ property2()
1205
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
1206
+ __decorateClass([
1207
+ property2()
1208
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1209
+ __decorateClass([
1210
+ property2({ type: Array })
1211
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
1212
+ __decorateClass([
1213
+ property2({ type: Object })
1214
+ ], LuzmoBaseVizItem.prototype, "options", 2);
1215
+ __decorateClass([
1216
+ property2()
1217
+ ], LuzmoBaseVizItem.prototype, "type", 2);
1218
+ __decorateClass([
1219
+ property2()
1220
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
1221
+ __decorateClass([
1222
+ property2()
1223
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
1224
+ __decorateClass([
1225
+ property2()
1226
+ ], LuzmoBaseVizItem.prototype, "version", 2);
1227
+ __decorateClass([
1228
+ property2()
1229
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
1230
+ __decorateClass([
1231
+ property2({
1232
+ converter: (value) => {
1233
+ try {
1234
+ return JSON.parse(value);
1235
+ } catch {
1236
+ return value;
1237
+ }
1238
+ }
1239
+ })
1240
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1241
+ __decorateClass([
1242
+ property2({ type: Array })
1243
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
1244
+ __decorateClass([
1245
+ property2()
1246
+ ], LuzmoBaseVizItem.prototype, "dashboardId", 2);
1247
+ __decorateClass([
1248
+ property2()
1249
+ ], LuzmoBaseVizItem.prototype, "itemId", 2);
1250
+ __decorateClass([
1251
+ property2({ type: Object })
1252
+ ], LuzmoBaseVizItem.prototype, "selectedData", 2);
1253
+ __decorateClass([
1254
+ property2()
1255
+ ], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2);
1256
+ __decorateClass([
1257
+ property2()
1258
+ ], LuzmoBaseVizItem.prototype, "libVersion", 2);
1259
+
1260
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
1261
+ var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
1262
+ };
1263
+ if (!customElements.get("luzmo-embed-viz-item")) {
1264
+ customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
1265
+ }
1266
+
1267
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-chat.ts
1268
+ import { property as property3 } from "lit/decorators.js";
1269
+ import { LitElement as LitElement3, html as html3, css as css3 } from "lit";
1270
+ import * as SharedLib4 from "@luzmo/shared-embed";
1271
+ var inputMap = {
1272
+ aiEndpoint: "ai-endpoint",
1273
+ appServer: "app-server",
1274
+ apiHost: "api-host",
1275
+ options: "options",
1276
+ initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
1277
+ authKey: "auth-key",
1278
+ authToken: "auth-token",
1279
+ version: "version",
1280
+ libVersion: "lib-version",
1281
+ aydHost: "ayd-host"
1282
+ };
1283
+ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1284
+ constructor() {
1285
+ super(...arguments);
1286
+ this.appServer = "https://app.luzmo.com";
1287
+ this.apiHost = "https://api.luzmo.com";
1288
+ this.version = version + "-wc-luzmo";
1289
+ this.libVersion = version + "-wc-luzmo";
1290
+ this.remoteEntryServer = "http://localhost:4202/";
1291
+ this.aydHost = "https://ayd.luzmo.com/";
1292
+ }
1293
+ static {
1294
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1295
+ this.styles = css3`
1296
+ :host {
1297
+ display: block;
1298
+ width: 100%;
1299
+ height: 100%;
1300
+ }
1301
+ `;
1302
+ }
1303
+ createRenderRoot() {
1304
+ return this;
1305
+ }
1306
+ async firstUpdated(_changedProperties) {
1307
+ super.firstUpdated(_changedProperties);
1308
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1309
+ this.createAndAppendElement();
1310
+ }
1311
+ createAndAppendElement() {
1312
+ if (!this.chartElement) {
1313
+ this.chartElement = document.createElement("luzmo-iq-chat-component");
1314
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1315
+ this.updateVizItemProperties();
1316
+ this.renderRoot.append(this.chartElement);
1317
+ }
1318
+ }
1319
+ updateVizItemProperties() {
1320
+ if (this.chartElement) {
1321
+ for (const key in inputMap) {
1322
+ const value = this[key];
1323
+ if (value) {
1324
+ const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? SharedLib4.removeTrailingSlash(value) : value;
1325
+ this.chartElement.setAttribute(
1326
+ inputMap[key],
1327
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1328
+ );
1329
+ }
1330
+ }
1331
+ }
1332
+ }
1333
+ async updated(changedProperties) {
1334
+ if (this.chartElement) {
1335
+ for (const [propertyName] of changedProperties.entries()) {
1336
+ const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1337
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1338
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1339
+ }
1340
+ } else {
1341
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1342
+ this.createAndAppendElement();
1343
+ }
1344
+ }
1345
+ render() {
1346
+ return html3``;
1347
+ }
1348
+ connectedCallback() {
1349
+ super.connectedCallback();
1350
+ const embedChat = document.querySelector("luzmo-iq-embed-chat");
1351
+ if (!embedChat) {
1352
+ return;
1353
+ }
1354
+ const observer = new MutationObserver(() => {
1355
+ const customChatWidgetContentSlot = embedChat.querySelector('*[slot="custom-chat-widget-content"]');
1356
+ if (!customChatWidgetContentSlot) {
1357
+ return;
1358
+ }
1359
+ const chatElement = embedChat.querySelector("luzmo-iq-chat-component");
1360
+ if (chatElement) {
1361
+ chatElement.append(customChatWidgetContentSlot);
1362
+ observer.disconnect();
1363
+ }
1364
+ });
1365
+ observer.observe(embedChat, { childList: true, subtree: true });
1366
+ }
1367
+ };
1368
+ __decorateClass([
1369
+ property3()
1370
+ ], LuzmoIQEmbedChatComponent.prototype, "appServer", 2);
1371
+ __decorateClass([
1372
+ property3()
1373
+ ], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2);
1374
+ __decorateClass([
1375
+ property3({ type: Object })
1376
+ ], LuzmoIQEmbedChatComponent.prototype, "options", 2);
1377
+ __decorateClass([
1378
+ property3({ type: String })
1379
+ ], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2);
1380
+ __decorateClass([
1381
+ property3()
1382
+ ], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2);
1383
+ __decorateClass([
1384
+ property3()
1385
+ ], LuzmoIQEmbedChatComponent.prototype, "authKey", 2);
1386
+ __decorateClass([
1387
+ property3()
1388
+ ], LuzmoIQEmbedChatComponent.prototype, "authToken", 2);
1389
+ __decorateClass([
1390
+ property3()
1391
+ ], LuzmoIQEmbedChatComponent.prototype, "version", 2);
1392
+ __decorateClass([
1393
+ property3()
1394
+ ], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2);
1395
+ __decorateClass([
1396
+ property3()
1397
+ ], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2);
1398
+ __decorateClass([
1399
+ property3()
1400
+ ], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2);
1401
+ if (!customElements.get("luzmo-iq-embed-chat")) {
1402
+ customElements.define("luzmo-iq-embed-chat", LuzmoIQEmbedChatComponent);
1403
+ }
1404
+
1405
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-answer.ts
1406
+ import { property as property4 } from "lit/decorators.js";
1407
+ import { LitElement as LitElement4, html as html4, css as css4 } from "lit";
1408
+ import * as SharedLib5 from "@luzmo/shared-embed";
1409
+ var inputMap2 = {
1410
+ aiEndPoint: "ai-end-point",
1411
+ appServer: "app-server",
1412
+ apiHost: "api-host",
1413
+ options: "options",
1414
+ authKey: "auth-key",
1415
+ authToken: "auth-token",
1416
+ version: "version",
1417
+ libVersion: "lib-version",
1418
+ messages: "messages"
1419
+ };
1420
+ var LuzmoIQEmbedAnswerComponent = class extends LitElement4 {
1421
+ constructor() {
1422
+ super(...arguments);
1423
+ this.appServer = "https://app.luzmo.com";
1424
+ this.apiHost = "https://api.luzmo.com";
1425
+ this.version = version + "-wc-luzmo";
1426
+ this.libVersion = version + "-wc-luzmo";
1427
+ this.remoteEntryServer = "http://localhost:4202";
1428
+ }
1429
+ static {
1430
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1431
+ this.styles = css4`
1432
+ :host {
1433
+ display: block;
1434
+ width: 100%;
1435
+ height: 100%;
1436
+ }
1437
+ `;
1438
+ }
1439
+ createRenderRoot() {
1440
+ return this;
1441
+ }
1442
+ async firstUpdated(_changedProperties) {
1443
+ super.firstUpdated(_changedProperties);
1444
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1445
+ this.createAndAppendElement();
1446
+ }
1447
+ createAndAppendElement() {
1448
+ if (!this.chartElement) {
1449
+ this.chartElement = document.createElement("luzmo-iq-answer-component");
1450
+ this.chartElement.addEventListener("addQuestion", (payload) => this.dispatchEvent(new CustomEvent("addQuestion", payload)));
1451
+ this.chartElement.addEventListener("addAnswer", (payload) => this.dispatchEvent(new CustomEvent("addAnswer", payload)));
1452
+ this.updateVizItemProperties();
1453
+ this.renderRoot.append(this.chartElement);
1454
+ }
1455
+ }
1456
+ updateVizItemProperties() {
1457
+ if (this.chartElement) {
1458
+ for (const key in inputMap2) {
1459
+ const value = this[key];
1460
+ if (value) {
1461
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib5.removeTrailingSlash(value) : value;
1462
+ this.chartElement.setAttribute(
1463
+ inputMap2[key],
1464
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1465
+ );
1466
+ }
1467
+ }
1468
+ }
1469
+ }
1470
+ async updated(changedProperties) {
1471
+ if (this.chartElement) {
1472
+ for (const [propertyName] of changedProperties.entries()) {
1473
+ const mappedAttributeName = inputMap2[propertyName] ?? propertyName;
1474
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1475
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1476
+ }
1477
+ } else {
1478
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1479
+ this.createAndAppendElement();
1480
+ }
1481
+ }
1482
+ render() {
1483
+ return html4` `;
1484
+ }
1485
+ };
1486
+ __decorateClass([
1487
+ property4()
1488
+ ], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2);
1489
+ __decorateClass([
1490
+ property4()
1491
+ ], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2);
1492
+ __decorateClass([
1493
+ property4({ type: Object })
1494
+ ], LuzmoIQEmbedAnswerComponent.prototype, "options", 2);
1495
+ __decorateClass([
1496
+ property4()
1497
+ ], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2);
1498
+ __decorateClass([
1499
+ property4()
1500
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2);
1501
+ __decorateClass([
1502
+ property4()
1503
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2);
1504
+ __decorateClass([
1505
+ property4()
1506
+ ], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2);
1507
+ __decorateClass([
1508
+ property4()
1509
+ ], LuzmoIQEmbedAnswerComponent.prototype, "version", 2);
1510
+ __decorateClass([
1511
+ property4()
1512
+ ], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2);
1513
+ __decorateClass([
1514
+ property4()
1515
+ ], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2);
1516
+ if (!customElements.get("luzmo-iq-embed-answer")) {
1517
+ customElements.define("luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent);
1518
+ }
1519
+
1520
+ // libs/embed-libs/embed/src/lib/helper/json-schema-utils.ts
1521
+ var cachedSchemas = {};
1522
+ function addJSONSchemas(schemas) {
1523
+ if (schemas.some((schema) => !schema.$id)) {
1524
+ throw new Error("To add schemas they all must have an $id property.");
1525
+ }
1526
+ schemas.forEach((schema) => {
1527
+ cachedSchemas[schema.$id] = schema;
1528
+ });
1529
+ }
1530
+ function getCachedJSONSchema(schemaUrl) {
1531
+ return cachedSchemas[schemaUrl];
1532
+ }
1533
+ function getCachedJSONSchemas() {
1534
+ return cachedSchemas;
1535
+ }
1536
+ function getJSONSchemaUrl(schemaName) {
1537
+ return `https://developer.luzmo.com/assets/json-schemas/${dashboardContentsVersion}/${schemaName}.schema.json`;
1538
+ }
1539
+ async function fetchJSONSchema(schemaName) {
1540
+ const schemaUrl = getJSONSchemaUrl(schemaName);
1541
+ if (getCachedJSONSchema(schemaUrl)) {
1542
+ return getCachedJSONSchema(schemaUrl);
1543
+ }
1544
+ try {
1545
+ const response = await fetch(schemaUrl, { credentials: "omit" });
1546
+ if (!response.ok) {
1547
+ throw new Error(`Failed to fetch schema ${schemaUrl}, response status: ${response.status}`);
1548
+ }
1549
+ const schema = await response.json();
1550
+ addJSONSchemas([schema]);
1551
+ return schema;
1552
+ } catch (error) {
1553
+ console.error(error);
1554
+ }
1555
+ }
1556
+ var luzmoRefParserResolver = {
1557
+ order: 101,
1558
+ // 101 would make it run after the file resolver, but before the HTTP resolver
1559
+ canRead: (file) => {
1560
+ const isLuzmoUrl = file.url.startsWith("https://developer.luzmo.com");
1561
+ if (isLuzmoUrl) {
1562
+ return !!getCachedJSONSchema(file.url);
1563
+ }
1564
+ return false;
1565
+ },
1566
+ read: (file, callback) => {
1567
+ callback(null, getCachedJSONSchema(file.url));
1568
+ }
1569
+ };
1570
+ var luzmoRefParserOptions = {
1571
+ mutateInputSchema: false,
1572
+ resolve: {
1573
+ luzmo: luzmoRefParserResolver,
1574
+ external: true
1575
+ }
1576
+ };
1577
+ export {
1578
+ LuzmoEmbedDashboard,
1579
+ LuzmoEmbedVizItem,
1580
+ LuzmoIQEmbedAnswerComponent,
1581
+ LuzmoIQEmbedChatComponent,
1582
+ addJSONSchemas,
1583
+ fetchJSONSchema,
1584
+ getCachedJSONSchema,
1585
+ getCachedJSONSchemas,
1586
+ getJSONSchemaUrl,
1587
+ luzmoRefParserOptions,
1588
+ selectedDataUtils
1589
+ };