@luzmo/embed 6.2.2 → 6.2.3

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