@luzmo/embed 5.0.4 → 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs ADDED
@@ -0,0 +1,1051 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var __decorateClass = (decorators, target, key, kind) => {
30
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
+ if (decorator = decorators[i])
33
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
+ if (kind && result)
35
+ __defProp(target, key, result);
36
+ return result;
37
+ };
38
+
39
+ // libs/embed-libs/embed/src/index.ts
40
+ var src_exports = {};
41
+ __export(src_exports, {
42
+ LuzmoDashboard: () => LuzmoDashboard
43
+ });
44
+ module.exports = __toCommonJS(src_exports);
45
+
46
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
47
+ var SharedLib2 = __toESM(require("@luzmo/shared-embed"), 1);
48
+ var import_lit2 = require("lit");
49
+ var import_decorators = require("lit/decorators.js");
50
+ var import_style_map = require("lit/directives/style-map.js");
51
+ var import_shared_embed = require("@luzmo/shared-embed");
52
+
53
+ // libs/embed-libs/embed/package.json
54
+ var version = "5.0.6";
55
+
56
+ // libs/embed-libs/embed/src/lib/luzmo-service.ts
57
+ var LuzmoService = class {
58
+ constructor() {
59
+ this._components = [];
60
+ }
61
+ };
62
+ var luzmo_service_default = new LuzmoService();
63
+
64
+ // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
65
+ var SharedLib = __toESM(require("@luzmo/shared-embed"), 1);
66
+ var _setEventHandler = () => {
67
+ if (typeof window.__luzmoMessageHandler === "function") {
68
+ return;
69
+ }
70
+ window.__luzmoMessageHandler = (event) => {
71
+ const dashboardComponent = luzmo_service_default._components.find(
72
+ (c) => event.data.name === c._iframeId
73
+ );
74
+ if (!dashboardComponent) {
75
+ return;
76
+ }
77
+ switch (event.data?.type) {
78
+ case "load": {
79
+ dashboardComponent.dispatchEvent(
80
+ new CustomEvent("load", { detail: { data: event.data } })
81
+ );
82
+ if (dashboardComponent._loadTimeoutHandle) {
83
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
84
+ dashboardComponent._loadTimeoutHandle = void 0;
85
+ }
86
+ dashboardComponent.iframeLoaded = true;
87
+ dashboardComponent.dimensions = event.data.dimensions;
88
+ dashboardComponent._calculateDimAfterDashboardLoaded();
89
+ break;
90
+ }
91
+ case "error": {
92
+ dashboardComponent.dashboardError = true;
93
+ if (dashboardComponent._loadTimeoutHandle) {
94
+ clearTimeout(dashboardComponent._loadTimeoutHandle);
95
+ dashboardComponent._loadTimeoutHandle = void 0;
96
+ }
97
+ dashboardComponent.iframeLoaded = true;
98
+ dashboardComponent._displayError();
99
+ break;
100
+ }
101
+ case "data": {
102
+ SharedLib.resolvePromise(
103
+ dashboardComponent,
104
+ event.data.requestId,
105
+ event.data.data
106
+ );
107
+ break;
108
+ }
109
+ case "filters": {
110
+ SharedLib.resolvePromise(
111
+ dashboardComponent,
112
+ event.data.requestId,
113
+ event.data.filters
114
+ );
115
+ break;
116
+ }
117
+ case "getAccessibleDashboards": {
118
+ SharedLib.resolvePromise(
119
+ dashboardComponent,
120
+ event.data.requestId,
121
+ event.data.accessibleDashboards
122
+ );
123
+ break;
124
+ }
125
+ case "dashboardAction": {
126
+ dashboardComponent.dispatchEvent(
127
+ new CustomEvent("dashboardAction", { detail: { data: event.data } })
128
+ );
129
+ break;
130
+ }
131
+ case "export": {
132
+ if (event.data.error) {
133
+ SharedLib.rejectPromise(
134
+ dashboardComponent,
135
+ event.data.requestId,
136
+ event.data
137
+ );
138
+ } else {
139
+ dashboardComponent.dispatchEvent(
140
+ new CustomEvent("exported", { detail: { data: event.data } })
141
+ );
142
+ SharedLib.resolvePromise(
143
+ dashboardComponent,
144
+ event.data.requestId,
145
+ event.data
146
+ );
147
+ }
148
+ break;
149
+ }
150
+ case "changedFilters": {
151
+ dashboardComponent.dispatchEvent(
152
+ new CustomEvent("changedFilters", { detail: { data: event.data } })
153
+ );
154
+ break;
155
+ }
156
+ case "customEvent": {
157
+ dashboardComponent.dispatchEvent(
158
+ new CustomEvent("customEvent", { detail: { data: event.data } })
159
+ );
160
+ break;
161
+ }
162
+ case "chartsRendered":
163
+ case "itemsRendered": {
164
+ event.data.type = "itemsRendered";
165
+ dashboardComponent.dispatchEvent(
166
+ new CustomEvent("itemsRendered", { detail: { data: event.data } })
167
+ );
168
+ break;
169
+ }
170
+ case "setEditMode": {
171
+ if (event.data.error) {
172
+ SharedLib.rejectPromise(
173
+ dashboardComponent,
174
+ event.data.requestId,
175
+ event.data
176
+ );
177
+ } else {
178
+ SharedLib.resolvePromise(
179
+ dashboardComponent,
180
+ event.data.requestId,
181
+ event.data
182
+ );
183
+ dashboardComponent.params.editMode = event.data.editMode;
184
+ dashboardComponent._containerStyle = SharedLib.containerStyles(dashboardComponent);
185
+ if (dashboardComponent.dimensions) {
186
+ SharedLib._setCalculatedDimensions(dashboardComponent);
187
+ }
188
+ }
189
+ break;
190
+ }
191
+ case "setFilters": {
192
+ event.data.error ? SharedLib.rejectPromise(
193
+ dashboardComponent,
194
+ event.data.requestId,
195
+ event.data
196
+ ) : SharedLib.resolvePromise(
197
+ dashboardComponent,
198
+ event.data.requestId,
199
+ event.data
200
+ );
201
+ break;
202
+ }
203
+ case "setPreview": {
204
+ event.data.error ? SharedLib.rejectPromise(
205
+ dashboardComponent,
206
+ event.data.requestId,
207
+ event.data
208
+ ) : SharedLib.resolvePromise(
209
+ dashboardComponent,
210
+ event.data.requestId,
211
+ event.data
212
+ );
213
+ break;
214
+ }
215
+ }
216
+ };
217
+ window.addEventListener("message", window.__luzmoMessageHandler, false);
218
+ };
219
+
220
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-styles.ts
221
+ var import_lit = require("lit");
222
+ var dashboardStyles = import_lit.css`
223
+ @-webkit-keyframes spin {
224
+ 0% {
225
+ -webkit-transform: rotate(0deg);
226
+ transform: rotate(0deg);
227
+ }
228
+ 100% {
229
+ -webkit-transform: rotate(360deg);
230
+ transform: rotate(360deg);
231
+ }
232
+ }
233
+
234
+ @keyframes spin {
235
+ 0% {
236
+ -webkit-transform: rotate(0deg);
237
+ transform: rotate(0deg);
238
+ }
239
+ 100% {
240
+ -webkit-transform: rotate(360deg);
241
+ transform: rotate(360deg);
242
+ }
243
+ }
244
+ :host {
245
+ position: relative;
246
+ width: 100%;
247
+ }
248
+
249
+ .luzmo-embed-dashboard {
250
+ background: transparent;
251
+ padding: 0;
252
+ border: 0;
253
+ }
254
+
255
+ .luzmo-container-loader {
256
+ width: 100%;
257
+ position: relative;
258
+ }
259
+
260
+ .luzmo-lc {
261
+ margin: 0 auto;
262
+ }
263
+
264
+ .luzmo-loading-message {
265
+ width: 100%;
266
+ height: 20px;
267
+ text-align: center;
268
+ margin-bottom: 16px;
269
+ font-family: Helvetica, Arial, sans-serif;
270
+ font-size: 14px;
271
+ }
272
+
273
+ .luzmo-loading-circle {
274
+ box-sizing: border-box;
275
+ margin: 16px auto;
276
+ position: relative;
277
+ text-indent: -9999em;
278
+ animation: spin 0.6s infinite linear;
279
+ }
280
+
281
+ .luzmo-loading-circle,
282
+ .luzmo-loading-circle:after {
283
+ border-radius: 50%;
284
+ width: 32px;
285
+ height: 32px;
286
+ }
287
+
288
+ .itemEmbedding:after {
289
+ width: 24px;
290
+ height: 24px;
291
+ }
292
+
293
+ .luzmo-error {
294
+ background: transparent;
295
+ padding: 48px 0;
296
+ margin: 0 auto;
297
+ width: 80%;
298
+ border: 0;
299
+ text-align: center;
300
+ min-height: 192px;
301
+ }
302
+
303
+ .dashboard-error {
304
+ font-size: 30px;
305
+ background: transparent;
306
+ padding: 48px 0;
307
+ margin: 0 auto;
308
+ width: 80%;
309
+ border: 0;
310
+ text-align: center;
311
+ min-height: 192px;
312
+ }
313
+
314
+ .luzmo-loader {
315
+ top: 0;
316
+ left: 0;
317
+ width: 100%;
318
+ min-height: 400px;
319
+ position: absolute;
320
+ transition-duration: 0.3s;
321
+ }
322
+ `;
323
+
324
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
325
+ var LuzmoDashboard = class extends import_lit2.LitElement {
326
+ constructor(inputParameters) {
327
+ super();
328
+ this.language = "auto";
329
+ this.screenMode = "auto";
330
+ this.switchScreenModeOnResize = true;
331
+ this.editMode = "view";
332
+ this.experimental = false;
333
+ this.iframeStyle = {};
334
+ this._containerStyle = {};
335
+ this._loaderStyle = {};
336
+ this._lcStyle = {};
337
+ this._loadingCircleStyle = {};
338
+ this._containerLoaderStyle = {};
339
+ this._loaderMsg = "";
340
+ this._itemEmbedding = false;
341
+ this.browserError = false;
342
+ this.browserErrorMsg = "";
343
+ this.dashboardError = false;
344
+ this.browserNotSupported = [];
345
+ this.VERSION = version + "-wc-luzmo";
346
+ this.isLibraryLoaded = false;
347
+ this.attributesMap = {
348
+ dashboardId: "dashboard-id",
349
+ dashboardSlug: "dashboard-slug",
350
+ itemId: "item-id",
351
+ language: "language",
352
+ qeVersion: "qe-version",
353
+ screenMode: "screen-mode",
354
+ switchScreenModeOnResize: "switch-screen-mode-on-resize",
355
+ authKey: "auth-key",
356
+ authToken: "auth-token",
357
+ editMode: "edit-mode",
358
+ mainColor: "main-color",
359
+ accentColor: "accent-color",
360
+ loaderBackground: "loader-background",
361
+ loaderFontColor: "loader-font-color",
362
+ loaderSpinnerColor: "loader-spinner-color",
363
+ loaderSpinnerBackground: "loader-spinner-background",
364
+ appServer: "app-server",
365
+ apiHost: "api-host",
366
+ itemDimensions: "item-dimensions",
367
+ timezoneId: "timezone-id"
368
+ };
369
+ this.loaderSize = 32;
370
+ this.borderWidth = 3;
371
+ this.minHeight = 400;
372
+ this._containerId = SharedLib2.uuidv4();
373
+ this._iframeId = `luzmo-dashboard-${this._containerId}`;
374
+ this.iframeLoaded = false;
375
+ this.promises = {};
376
+ this.setInputParameters(inputParameters);
377
+ this.params = this._setOptions();
378
+ this._onResize = () => {
379
+ if (this.shadowRoot?.querySelector(".dashboard-container")) {
380
+ this.containerWidth = this.container.clientWidth;
381
+ if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
382
+ for (const d of SharedLib2.EXTENTS) {
383
+ if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
384
+ this.currentScreenMode = d.mode;
385
+ }
386
+ }
387
+ }
388
+ if (this.iframeLoaded) {
389
+ this._calculateDimAfterDashboardLoaded();
390
+ }
391
+ }
392
+ };
393
+ this._resizeObserver = new ResizeObserver((entries) => {
394
+ window.requestAnimationFrame(() => {
395
+ if (!Array.isArray(entries) || entries.length === 0) {
396
+ return;
397
+ }
398
+ this._onResize();
399
+ });
400
+ });
401
+ }
402
+ loadLibrary(appServer) {
403
+ if (import_shared_embed.remotesMap[appServer]) {
404
+ return Promise.resolve(import_shared_embed.remotesMap[appServer].module);
405
+ }
406
+ import_shared_embed.remotesMap[appServer] = { url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`, format: "esm", from: "vite", module: void 0 };
407
+ return (0, import_shared_embed.__federationMethodGetRemote)(appServer, "./DashboardApp").then((module2) => {
408
+ const wrappedModule = (0, import_shared_embed.__federationMethodWrapDefault)(module2, true);
409
+ import_shared_embed.remotesMap[appServer].module = wrappedModule;
410
+ return wrappedModule;
411
+ });
412
+ }
413
+ setInputParameters(inputParameters) {
414
+ if (!inputParameters) {
415
+ return;
416
+ }
417
+ const params = [
418
+ "dashboardId",
419
+ "dashboardSlug",
420
+ "itemId",
421
+ "language",
422
+ "qeVersion",
423
+ "screenMode",
424
+ "switchScreenModeOnResize",
425
+ "accentColor",
426
+ "mainColor",
427
+ "authToken",
428
+ "authKey",
429
+ "editMode",
430
+ "loaderBackground",
431
+ "loaderFontColor",
432
+ "loaderSpinnerColor",
433
+ "loaderSpinnerBackground",
434
+ "timezoneId",
435
+ "itemDimensions",
436
+ "apiHost"
437
+ ];
438
+ for (const key of params) {
439
+ const value = inputParameters[key];
440
+ if (value) {
441
+ this[key] = value;
442
+ }
443
+ }
444
+ if (inputParameters.experimental) {
445
+ this.experimental = inputParameters.experimental;
446
+ }
447
+ if (inputParameters.appServer) {
448
+ this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
449
+ }
450
+ }
451
+ // Set resize event listener
452
+ connectedCallback() {
453
+ super.connectedCallback();
454
+ }
455
+ // Set resize event listener
456
+ disconnectedCallback() {
457
+ super.disconnectedCallback();
458
+ this._resizeObserver.disconnect();
459
+ for (const promiseKey of Object.keys(this.promises)) {
460
+ this.promises[promiseKey].reject(
461
+ new Error("Dashboard component was removed")
462
+ );
463
+ }
464
+ }
465
+ firstUpdated() {
466
+ this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
467
+ this._loaderStyles();
468
+ luzmo_service_default._components.push(this);
469
+ this.initComponent();
470
+ }
471
+ initComponent() {
472
+ this.params = this._setOptions();
473
+ if (this.getIsViewMode()) {
474
+ this.loadLibrary(this.params.appServer).then(async () => {
475
+ this.isLibraryLoaded = true;
476
+ await this.updateComplete;
477
+ const oldReference = this.renderRoot.querySelector("dashboard-component");
478
+ this.dashboardReference = oldReference.cloneNode(true);
479
+ oldReference.replaceWith(this.dashboardReference);
480
+ this.dashboardReference.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload.detail)));
481
+ this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload.detail)));
482
+ this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload.detail)));
483
+ this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload.detail)));
484
+ this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload.detail)));
485
+ this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload.detail)));
486
+ this.setAllAttributes();
487
+ });
488
+ } else {
489
+ this.containerWidth = this.container?.clientWidth;
490
+ SharedLib2._extendAndValidate(this);
491
+ SharedLib2._browserCheck(this);
492
+ this._setupLoader();
493
+ if (!this.params.error) {
494
+ this._loaderStyles();
495
+ _setEventHandler();
496
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
497
+ this.iframe?.setAttribute("src", this._iframeUrl);
498
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
499
+ }
500
+ if (this.container) {
501
+ this._resizeObserver.observe(this.container);
502
+ }
503
+ }
504
+ }
505
+ setAllAttributes() {
506
+ if (this.dashboardReference) {
507
+ for (const key in this.attributesMap) {
508
+ if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
509
+ this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
510
+ }
511
+ if (this.params.itemDimensions) {
512
+ this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
513
+ }
514
+ if (this.params.apiHost) {
515
+ this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
516
+ }
517
+ if (this.params.key) {
518
+ this.dashboardReference.setAttribute("auth-key", this.params.key);
519
+ }
520
+ if (this.params.token) {
521
+ this.dashboardReference.setAttribute("auth-token", this.params.token);
522
+ }
523
+ }
524
+ }
525
+ }
526
+ // Reload dashboard when triggerproperty changes
527
+ updated(changedProperties) {
528
+ const triggerProperties = /* @__PURE__ */ new Set([
529
+ "dashboardId",
530
+ "dashboardSlug",
531
+ "itemId",
532
+ "language",
533
+ "qeVersion",
534
+ "editMode",
535
+ "screenMode",
536
+ "switchScreenModeOnResize",
537
+ "authToken",
538
+ "authKey",
539
+ "appServer",
540
+ "timezoneId",
541
+ "itemDimensions"
542
+ ]);
543
+ if (this.getIsViewMode()) {
544
+ if (this.dashboardReference) {
545
+ for (const [propertyName] of changedProperties.entries()) {
546
+ if (propertyName === "appSever") {
547
+ this.loadLibrary(changedProperties[propertyName]).then(async () => {
548
+ this.isLibraryLoaded = true;
549
+ await this.updateComplete;
550
+ this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
551
+ this.setAllAttributes();
552
+ });
553
+ } else if (this.attributesMap[propertyName]) {
554
+ const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
555
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
556
+ this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
557
+ }
558
+ }
559
+ }
560
+ } else {
561
+ for (const [propertyName] of changedProperties.entries()) {
562
+ if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
563
+ this.iframeLoaded = false;
564
+ if (this._loadTimeoutHandle) {
565
+ clearTimeout(this._loadTimeoutHandle);
566
+ }
567
+ this._loadTimeoutHandle = setTimeout(() => {
568
+ console.error(
569
+ "Failed to load dashboard, appServer is likely down or unreachable."
570
+ );
571
+ }, 15 * 1e3);
572
+ this.params = this._setOptions();
573
+ SharedLib2._extendAndValidate(this);
574
+ this._setupLoader();
575
+ this._loaderStyles();
576
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
577
+ if (this.iframe) {
578
+ this._updateIframeUrl();
579
+ }
580
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
581
+ } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
582
+ if (this.iframeLoaded) {
583
+ this.setEditMode(this.editMode);
584
+ }
585
+ this.params = this._setOptions();
586
+ }
587
+ }
588
+ }
589
+ }
590
+ // Set params
591
+ _setOptions() {
592
+ const defaultParameters = {
593
+ dashboardId: this.dashboardId,
594
+ dashboardSlug: this.dashboardSlug
595
+ };
596
+ if (this.itemId) {
597
+ defaultParameters.itemId = this.itemId;
598
+ this._itemEmbedding = true;
599
+ } else {
600
+ this._itemEmbedding = false;
601
+ }
602
+ if (this.language) {
603
+ defaultParameters.language = this.language;
604
+ }
605
+ if (this.qeVersion) {
606
+ defaultParameters.qeVersion = this.qeVersion;
607
+ }
608
+ if (this.screenMode) {
609
+ defaultParameters.screenMode = this.screenMode;
610
+ }
611
+ defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
612
+ if (this.authToken) {
613
+ defaultParameters.token = this.authToken;
614
+ }
615
+ if (this.authKey) {
616
+ defaultParameters.key = this.authKey;
617
+ }
618
+ if (this.editMode) {
619
+ defaultParameters.editMode = this.editMode;
620
+ }
621
+ if (this.mainColor) {
622
+ defaultParameters.mainColor = this.mainColor;
623
+ }
624
+ if (this.accentColor) {
625
+ defaultParameters.accentColor = this.accentColor;
626
+ }
627
+ if (this.loaderBackground) {
628
+ defaultParameters.loaderBackground = this.loaderBackground;
629
+ }
630
+ if (this.loaderFontColor) {
631
+ defaultParameters.loaderFontColor = this.loaderFontColor;
632
+ }
633
+ if (this.loaderSpinnerColor) {
634
+ defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
635
+ }
636
+ if (this.loaderSpinnerBackground) {
637
+ defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
638
+ }
639
+ if (this.timezoneId) {
640
+ defaultParameters.timezoneId = this.timezoneId;
641
+ }
642
+ if (this.itemDimensions) {
643
+ defaultParameters.itemDimensions = this.itemDimensions;
644
+ }
645
+ if (this.appServer) {
646
+ this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
647
+ defaultParameters.appServer = this.appServer;
648
+ } else {
649
+ this.appServer = SharedLib2.addTrailingSlash(
650
+ SharedLib2.DEFAULT_PARAMETERS.appServer
651
+ );
652
+ defaultParameters.appServer = this.appServer;
653
+ }
654
+ if (this.apiHost) {
655
+ this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
656
+ defaultParameters.apiHost = this.apiHost;
657
+ } else {
658
+ this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
659
+ defaultParameters.apiHost = this.apiHost;
660
+ }
661
+ return defaultParameters;
662
+ }
663
+ _updateIframeUrl() {
664
+ SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
665
+ }
666
+ // Setup loader / browser error
667
+ _setupLoader() {
668
+ const data = SharedLib2.getLoader(this);
669
+ this._loaderMsg = data.loadingMsg;
670
+ if (data.errorMsg) {
671
+ this.browserError = true;
672
+ this.browserErrorMsg = data.errorMsg;
673
+ this._displayError();
674
+ }
675
+ }
676
+ _displayError() {
677
+ if (this.dashboardError) {
678
+ this._loaderStyles();
679
+ this.iframeStyle.opacity = 1;
680
+ }
681
+ if (this.browserError) {
682
+ this._containerStyle.display = "none";
683
+ }
684
+ }
685
+ _calculateDimAfterDashboardLoaded() {
686
+ this.dashboardError = false;
687
+ this._loaderStyles();
688
+ SharedLib2._setCalculatedDimensions(this);
689
+ }
690
+ // Set loader styles
691
+ _loaderStyles() {
692
+ this._containerStyle = SharedLib2.containerStyles(this);
693
+ this._loaderStyle = SharedLib2.loaderStyles(this);
694
+ this._loadingCircleStyle = SharedLib2.plStyles(this);
695
+ this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
696
+ this._lcStyle = SharedLib2.lcStyles(this);
697
+ }
698
+ static get styles() {
699
+ return [dashboardStyles];
700
+ }
701
+ render() {
702
+ let toBeRenderedHTML = import_lit2.html``;
703
+ const loader = import_lit2.html`
704
+ <div
705
+ class="luzmo-container-loader"
706
+ id="luzmo-container-loader-${this._containerId}"
707
+ style=${(0, import_style_map.styleMap)(
708
+ this._containerLoaderStyle
709
+ )}
710
+ >
711
+ <div
712
+ class="luzmo-loader"
713
+ id="luzmo-loader-${this._containerId}"
714
+ style=${(0, import_style_map.styleMap)(this._loaderStyle)}
715
+ >
716
+ <div
717
+ class="luzmo-lc"
718
+ style=${(0, import_style_map.styleMap)(this._lcStyle)}
719
+ >
720
+ <div
721
+ class="luzmo-loading-circle"
722
+ style=${(0, import_style_map.styleMap)(
723
+ this._loadingCircleStyle
724
+ )}
725
+ ></div>
726
+ ${this._itemEmbedding ? "" : import_lit2.html`
727
+ <div
728
+ class="luzmo-loading-message"
729
+ style=${(0, import_style_map.styleMap)({ color: this.loaderFontColor })}
730
+ >
731
+ ${this._loaderMsg}
732
+ </div>
733
+ `}
734
+ </div>
735
+ </div>
736
+ </div>
737
+ `;
738
+ if (this.getIsViewMode()) {
739
+ toBeRenderedHTML = this.isLibraryLoaded ? import_lit2.html`
740
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`<dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}" api-host="${this.params.apiHost}"></dashboard-component>` : import_lit2.html`
741
+ <div id="luzmo-error-${this._containerId}">
742
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
743
+ </div>
744
+ `}
745
+ ` : import_lit2.html`${loader}`;
746
+ } else {
747
+ toBeRenderedHTML = import_lit2.html`
748
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
749
+ ${loader}
750
+ <iframe
751
+ class="luzmo-embed-dashboard"
752
+ id="${this._iframeId}"
753
+ name="${this._iframeId}"
754
+ style=${(0, import_style_map.styleMap)(this.iframeStyle)}
755
+ src="${this._iframeUrl}"
756
+ frameborder="0"
757
+ ></iframe>
758
+ ` : import_lit2.html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
759
+ ${this.browserError ? import_lit2.html`
760
+ <div id="luzmo-error-${this._containerId}">
761
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
762
+ </div>
763
+ ` : ""}
764
+ `;
765
+ }
766
+ return import_lit2.html`
767
+ <div
768
+ class="dashboard-container"
769
+ style=${(0, import_style_map.styleMap)(Object.assign({}, this._containerStyle, {
770
+ width: this.iframeStyle.width ?? "100%",
771
+ height: this.iframeStyle.height ?? "100%"
772
+ }))}
773
+ >
774
+ ${toBeRenderedHTML}
775
+ </div>
776
+ `;
777
+ }
778
+ getDashboards() {
779
+ return new Promise(
780
+ (resolve) => resolve(luzmo_service_default._components)
781
+ );
782
+ }
783
+ // Public methods
784
+ getData(itemId) {
785
+ if (this.getIsViewMode() && this.dashboardReference) {
786
+ return this.dashboardReference.getData(itemId);
787
+ }
788
+ if (!this.getIsViewMode()) {
789
+ return SharedLib2.getData(this, this.iframe, itemId);
790
+ }
791
+ return Promise.reject();
792
+ }
793
+ getFilters() {
794
+ if (this.getIsViewMode() && this.dashboardReference) {
795
+ return this.dashboardReference.getFilters();
796
+ }
797
+ if (!this.getIsViewMode()) {
798
+ return SharedLib2.getFilters(this, this.iframe);
799
+ }
800
+ return Promise.reject();
801
+ }
802
+ setFilters(itemId, filters) {
803
+ if (this.getIsViewMode() && this.dashboardReference) {
804
+ return this.dashboardReference.setFilters(itemId, filters);
805
+ }
806
+ if (!this.getIsViewMode()) {
807
+ return SharedLib2.setFilters(this, this.iframe, itemId, filters);
808
+ }
809
+ return Promise.reject();
810
+ }
811
+ setAuthorization(key, token) {
812
+ if (this.getIsViewMode() && this.dashboardReference) {
813
+ return this.dashboardReference.setAuthorization(key, token);
814
+ }
815
+ if (!this.getIsViewMode()) {
816
+ return SharedLib2.setAuthorization(this, this.iframe, key, token);
817
+ }
818
+ return Promise.reject();
819
+ }
820
+ refreshData(itemId) {
821
+ if (this.getIsViewMode() && this.dashboardReference) {
822
+ return this.dashboardReference.refreshData(itemId);
823
+ }
824
+ if (!this.getIsViewMode()) {
825
+ return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
826
+ }
827
+ return Promise.reject();
828
+ }
829
+ reloadDashboard() {
830
+ if (this.getIsViewMode() && this.dashboardReference) {
831
+ return this.dashboardReference.reloadDashboard();
832
+ }
833
+ if (!this.getIsViewMode()) {
834
+ return SharedLib2.reloadDashboard(this, this.iframe);
835
+ }
836
+ return Promise.reject();
837
+ }
838
+ exportDashboard(format) {
839
+ if (this.getIsViewMode() && this.dashboardReference) {
840
+ return this.dashboardReference.exportDashboard(format);
841
+ }
842
+ if (!this.getIsViewMode()) {
843
+ return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
844
+ }
845
+ return Promise.reject();
846
+ }
847
+ getAccessibleDashboards() {
848
+ if (!this.getIsViewMode()) {
849
+ return SharedLib2.getAccessibleDashboards(this, this.iframe);
850
+ }
851
+ if (this.getIsViewMode() && this.dashboardReference) {
852
+ return this.dashboardReference.getAccessibleDashboards();
853
+ }
854
+ return Promise.reject();
855
+ }
856
+ addFilters(itemId, filters) {
857
+ return this.dashboardReference.addFilters(itemId, filters);
858
+ }
859
+ setEditMode(editMode) {
860
+ if (this.dashboardReference && editMode === "view") {
861
+ this.editMode = "view";
862
+ this.params.editMode = "view";
863
+ this.initComponent();
864
+ return Promise.resolve({
865
+ type: "setEditMode",
866
+ editMode
867
+ });
868
+ }
869
+ if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
870
+ this.editMode = editMode;
871
+ this.params.editMode = editMode;
872
+ this.initComponent();
873
+ return Promise.resolve({
874
+ type: "setEditMode",
875
+ editMode
876
+ });
877
+ }
878
+ if (this.getIsViewMode() && this.dashboardReference) {
879
+ return this.dashboardReference.setEditMode(editMode);
880
+ }
881
+ if (!this.getIsViewMode()) {
882
+ return SharedLib2.setEditMode(this, this.iframe, editMode);
883
+ }
884
+ return Promise.reject();
885
+ }
886
+ setPreview(preview) {
887
+ if (this.getIsViewMode() && this.dashboardReference) {
888
+ return this.dashboardReference.setPreview(preview);
889
+ }
890
+ return SharedLib2.setPreview(this, this.iframe, preview);
891
+ }
892
+ getIsViewMode() {
893
+ if (this.experimental && this.params.editMode === "view" || this.params.editMode === void 0) {
894
+ return true;
895
+ }
896
+ return false;
897
+ }
898
+ };
899
+ __decorateClass([
900
+ (0, import_decorators.query)(".dashboard-container")
901
+ ], LuzmoDashboard.prototype, "container", 2);
902
+ __decorateClass([
903
+ (0, import_decorators.query)("iframe")
904
+ ], LuzmoDashboard.prototype, "iframe", 2);
905
+ __decorateClass([
906
+ (0, import_decorators.property)()
907
+ ], LuzmoDashboard.prototype, "dashboardId", 2);
908
+ __decorateClass([
909
+ (0, import_decorators.property)()
910
+ ], LuzmoDashboard.prototype, "dashboardSlug", 2);
911
+ __decorateClass([
912
+ (0, import_decorators.property)()
913
+ ], LuzmoDashboard.prototype, "itemId", 2);
914
+ __decorateClass([
915
+ (0, import_decorators.property)()
916
+ ], LuzmoDashboard.prototype, "language", 2);
917
+ __decorateClass([
918
+ (0, import_decorators.property)()
919
+ ], LuzmoDashboard.prototype, "qeVersion", 2);
920
+ __decorateClass([
921
+ (0, import_decorators.property)()
922
+ ], LuzmoDashboard.prototype, "screenMode", 2);
923
+ __decorateClass([
924
+ (0, import_decorators.property)({
925
+ converter: {
926
+ fromAttribute: (value) => value === "true",
927
+ toAttribute: String
928
+ }
929
+ })
930
+ ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
931
+ __decorateClass([
932
+ (0, import_decorators.property)()
933
+ ], LuzmoDashboard.prototype, "editMode", 2);
934
+ __decorateClass([
935
+ (0, import_decorators.property)()
936
+ ], LuzmoDashboard.prototype, "mainColor", 2);
937
+ __decorateClass([
938
+ (0, import_decorators.property)()
939
+ ], LuzmoDashboard.prototype, "accentColor", 2);
940
+ __decorateClass([
941
+ (0, import_decorators.property)()
942
+ ], LuzmoDashboard.prototype, "authToken", 2);
943
+ __decorateClass([
944
+ (0, import_decorators.property)()
945
+ ], LuzmoDashboard.prototype, "authKey", 2);
946
+ __decorateClass([
947
+ (0, import_decorators.property)()
948
+ ], LuzmoDashboard.prototype, "loaderBackground", 2);
949
+ __decorateClass([
950
+ (0, import_decorators.property)()
951
+ ], LuzmoDashboard.prototype, "loaderFontColor", 2);
952
+ __decorateClass([
953
+ (0, import_decorators.property)()
954
+ ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
955
+ __decorateClass([
956
+ (0, import_decorators.property)()
957
+ ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
958
+ __decorateClass([
959
+ (0, import_decorators.property)()
960
+ ], LuzmoDashboard.prototype, "appServer", 2);
961
+ __decorateClass([
962
+ (0, import_decorators.property)()
963
+ ], LuzmoDashboard.prototype, "timezoneId", 2);
964
+ __decorateClass([
965
+ (0, import_decorators.property)()
966
+ ], LuzmoDashboard.prototype, "apiHost", 2);
967
+ __decorateClass([
968
+ (0, import_decorators.property)({ type: Object })
969
+ ], LuzmoDashboard.prototype, "itemDimensions", 2);
970
+ __decorateClass([
971
+ (0, import_decorators.property)()
972
+ ], LuzmoDashboard.prototype, "experimental", 2);
973
+ __decorateClass([
974
+ (0, import_decorators.property)({ attribute: false })
975
+ ], LuzmoDashboard.prototype, "_containerId", 2);
976
+ __decorateClass([
977
+ (0, import_decorators.property)({ attribute: false })
978
+ ], LuzmoDashboard.prototype, "_iframeId", 2);
979
+ __decorateClass([
980
+ (0, import_decorators.property)({ attribute: false })
981
+ ], LuzmoDashboard.prototype, "params", 2);
982
+ __decorateClass([
983
+ (0, import_decorators.property)({ attribute: false })
984
+ ], LuzmoDashboard.prototype, "_iframeUrl", 2);
985
+ __decorateClass([
986
+ (0, import_decorators.property)({ attribute: false })
987
+ ], LuzmoDashboard.prototype, "iframeLoaded", 2);
988
+ __decorateClass([
989
+ (0, import_decorators.property)({ attribute: false })
990
+ ], LuzmoDashboard.prototype, "promises", 2);
991
+ __decorateClass([
992
+ (0, import_decorators.property)({ attribute: false })
993
+ ], LuzmoDashboard.prototype, "iframeStyle", 2);
994
+ __decorateClass([
995
+ (0, import_decorators.property)({ attribute: false })
996
+ ], LuzmoDashboard.prototype, "_containerStyle", 2);
997
+ __decorateClass([
998
+ (0, import_decorators.property)({ attribute: false })
999
+ ], LuzmoDashboard.prototype, "_loaderStyle", 2);
1000
+ __decorateClass([
1001
+ (0, import_decorators.property)({ attribute: false })
1002
+ ], LuzmoDashboard.prototype, "_lcStyle", 2);
1003
+ __decorateClass([
1004
+ (0, import_decorators.property)({ attribute: false })
1005
+ ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1006
+ __decorateClass([
1007
+ (0, import_decorators.property)({ attribute: false })
1008
+ ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1009
+ __decorateClass([
1010
+ (0, import_decorators.property)({ attribute: false })
1011
+ ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1012
+ __decorateClass([
1013
+ (0, import_decorators.property)({ attribute: false })
1014
+ ], LuzmoDashboard.prototype, "containerWidth", 2);
1015
+ __decorateClass([
1016
+ (0, import_decorators.property)({ attribute: false })
1017
+ ], LuzmoDashboard.prototype, "dimensions", 2);
1018
+ __decorateClass([
1019
+ (0, import_decorators.property)({ attribute: false })
1020
+ ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1021
+ __decorateClass([
1022
+ (0, import_decorators.property)({ attribute: false })
1023
+ ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1024
+ __decorateClass([
1025
+ (0, import_decorators.property)({ attribute: false })
1026
+ ], LuzmoDashboard.prototype, "browserError", 2);
1027
+ __decorateClass([
1028
+ (0, import_decorators.property)({ attribute: false })
1029
+ ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1030
+ __decorateClass([
1031
+ (0, import_decorators.property)({ attribute: false })
1032
+ ], LuzmoDashboard.prototype, "dashboardError", 2);
1033
+ __decorateClass([
1034
+ (0, import_decorators.property)({ attribute: false })
1035
+ ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1036
+ __decorateClass([
1037
+ (0, import_decorators.property)({ attribute: false })
1038
+ ], LuzmoDashboard.prototype, "VERSION", 2);
1039
+ __decorateClass([
1040
+ (0, import_decorators.state)()
1041
+ ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1042
+ __decorateClass([
1043
+ (0, import_decorators.state)()
1044
+ ], LuzmoDashboard.prototype, "dashboardReference", 2);
1045
+ LuzmoDashboard = __decorateClass([
1046
+ (0, import_decorators.customElement)("luzmo-dashboard")
1047
+ ], LuzmoDashboard);
1048
+ // Annotate the CommonJS export names for ESM import in node:
1049
+ 0 && (module.exports = {
1050
+ LuzmoDashboard
1051
+ });