@luzmo/embed 6.2.2 → 6.2.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/index.cjs +1620 -0
  3. package/index.js +1589 -0
  4. package/luzmo-embed.min.js +3676 -0
  5. package/package.json +2 -2
  6. package/src/index.d.ts +8 -0
  7. package/src/lib/dashboard-component/dashboard-base.d.ts +99 -0
  8. package/src/lib/dashboard-component/dashboard-component.d.ts +8 -0
  9. package/src/lib/dashboard-component/dashboard-styles.d.ts +1 -0
  10. package/src/lib/helper/event-bus-handler.d.ts +1 -0
  11. package/src/lib/helper/json-schema-utils.d.ts +64 -0
  12. package/src/lib/luzmo-iq-components/luzmo-iq-answer.d.ts +22 -0
  13. package/src/lib/luzmo-iq-components/luzmo-iq-chat.d.ts +24 -0
  14. package/src/lib/luzmo-service.d.ts +6 -0
  15. package/src/lib/viz-item/viz-item-component.d.ts +4 -0
  16. package/src/lib/viz-item/viz-item.base.d.ts +71 -0
  17. package/.prettierignore +0 -4
  18. package/esbuild.config.cjs +0 -13
  19. package/eslint.config.cjs +0 -8
  20. package/jest.config.ts +0 -11
  21. package/project.json +0 -39
  22. package/src/index.ts +0 -42
  23. package/src/lib/dashboard-component/dashboard-base.ts +0 -828
  24. package/src/lib/dashboard-component/dashboard-component.spec.ts +0 -27
  25. package/src/lib/dashboard-component/dashboard-component.ts +0 -12
  26. package/src/lib/dashboard-component/dashboard-styles.ts +0 -117
  27. package/src/lib/helper/event-bus-handler.ts +0 -195
  28. package/src/lib/helper/json-schema-utils.ts +0 -129
  29. package/src/lib/luzmo-iq-components/luzmo-iq-answer.ts +0 -106
  30. package/src/lib/luzmo-iq-components/luzmo-iq-chat.ts +0 -106
  31. package/src/lib/luzmo-service.ts +0 -7
  32. package/src/lib/viz-item/viz-item-component.ts +0 -9
  33. package/src/lib/viz-item/viz-item.base.ts +0 -227
  34. package/src/vite-env.d.ts +0 -1
  35. package/tsconfig.json +0 -27
  36. package/tsconfig.lib.json +0 -10
  37. package/tsconfig.spec.json +0 -9
package/index.cjs ADDED
@@ -0,0 +1,1620 @@
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.4-beta.1";
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
+ theme: "theme",
401
+ mainColor: "main-color",
402
+ accentColor: "accent-color",
403
+ loaderBackground: "loader-background",
404
+ loaderFontColor: "loader-font-color",
405
+ loaderSpinnerColor: "loader-spinner-color",
406
+ loaderSpinnerBackground: "loader-spinner-background",
407
+ appServer: "app-server",
408
+ apiHost: "api-host",
409
+ itemDimensions: "item-dimensions",
410
+ timezoneId: "timezone-id"
411
+ };
412
+ this.loaderSize = 32;
413
+ this.borderWidth = 3;
414
+ this.minHeight = 400;
415
+ this._containerId = SharedLib2.uuidv4();
416
+ this._iframeId = `luzmo-dashboard-${this._containerId}`;
417
+ this.iframeLoaded = false;
418
+ this.promises = {};
419
+ this.params = this._setOptions();
420
+ this._onResize = () => {
421
+ if (this.shadowRoot?.querySelector(".dashboard-container")) {
422
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
423
+ if (this.params.switchScreenModeOnResize && this.params.screenMode === "auto") {
424
+ for (const d of SharedLib2.EXTENTS) {
425
+ if (d.width[0] <= window.innerWidth && window.innerWidth <= d.width[1]) {
426
+ this.currentScreenMode = d.mode;
427
+ }
428
+ }
429
+ }
430
+ if (this.iframeLoaded) {
431
+ this._calculateDimAfterDashboardLoaded();
432
+ } else {
433
+ if (this.dimensions) {
434
+ this.containerWidth = this.luzmoEmbedContainer.offsetWidth;
435
+ SharedLib2._setCalculatedDimensions(this);
436
+ }
437
+ }
438
+ }
439
+ };
440
+ this._resizeObserver = new ResizeObserver((entries) => {
441
+ window.requestAnimationFrame(() => {
442
+ if (!Array.isArray(entries) || entries.length === 0) {
443
+ return;
444
+ }
445
+ this._onResize();
446
+ });
447
+ });
448
+ }
449
+ // Set resize event listener
450
+ connectedCallback() {
451
+ super.connectedCallback();
452
+ }
453
+ // Set resize event listener
454
+ disconnectedCallback() {
455
+ super.disconnectedCallback();
456
+ this._resizeObserver.disconnect();
457
+ for (const promiseKey of Object.keys(this.promises)) {
458
+ this.promises[promiseKey].reject(
459
+ new Error("Dashboard component was removed")
460
+ );
461
+ }
462
+ }
463
+ firstUpdated() {
464
+ this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
465
+ this._loaderStyles();
466
+ luzmo_service_default._components.push(this);
467
+ if (this.luzmoEmbedContainer) {
468
+ this._resizeObserver.observe(this.luzmoEmbedContainer);
469
+ }
470
+ }
471
+ initComponent() {
472
+ this.params = this._setOptions();
473
+ if (this.getIsViewMode()) {
474
+ SharedLib2.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) => {
481
+ this.containerWidth = this.dashboardReference.offsetWidth;
482
+ this.dimensions = payload.detail.dimensions;
483
+ SharedLib2._setCalculatedDimensions(this);
484
+ window.dispatchEvent(new Event("resize"));
485
+ this.dispatchEvent(new CustomEvent("load", payload));
486
+ });
487
+ this.dashboardReference.addEventListener("itemsRendered", (payload) => this.dispatchEvent(new CustomEvent("itemsRendered", payload)));
488
+ this.dashboardReference.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
489
+ this.dashboardReference.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
490
+ this.dashboardReference.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
491
+ this.dashboardReference.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
492
+ this.setAllAttributes();
493
+ });
494
+ } else {
495
+ this.containerWidth = this.container?.clientWidth;
496
+ SharedLib2._extendAndValidate(this);
497
+ SharedLib2._browserCheck(this);
498
+ this._setupLoader();
499
+ if (!this.params.error) {
500
+ this._loaderStyles();
501
+ _setEventHandler();
502
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
503
+ this.iframe?.setAttribute("src", this._iframeUrl);
504
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
505
+ }
506
+ }
507
+ }
508
+ setAllAttributes() {
509
+ if (this.dashboardReference) {
510
+ for (const key in this.attributesMap) {
511
+ if (!["authKey", "authToken", "apiHost", "itemDimensions"].includes(key) && this.params[key]) {
512
+ this.dashboardReference.setAttribute(this.attributesMap[key], this.params[key]);
513
+ }
514
+ }
515
+ if (this.params.itemDimensions) {
516
+ this.dashboardReference.setAttribute("item-dimensions", JSON.stringify(this.params.itemDimensions));
517
+ }
518
+ if (this.params.apiHost) {
519
+ this.dashboardReference.setAttribute("api-host", SharedLib2.removeTrailingSlash(this.params.apiHost));
520
+ }
521
+ if (this.params.key) {
522
+ this.dashboardReference.setAttribute("auth-key", this.params.key);
523
+ }
524
+ if (this.params.token) {
525
+ this.dashboardReference.setAttribute("auth-token", this.params.token);
526
+ }
527
+ }
528
+ }
529
+ // Reload dashboard when triggerproperty changes
530
+ updated(changedProperties) {
531
+ const triggerProperties = /* @__PURE__ */ new Set([
532
+ "dashboardId",
533
+ "dashboardSlug",
534
+ "itemId",
535
+ "language",
536
+ "qeVersion",
537
+ "theme",
538
+ "editMode",
539
+ "screenMode",
540
+ "switchScreenModeOnResize",
541
+ "authToken",
542
+ "authKey",
543
+ "appServer",
544
+ "apiHost",
545
+ "timezoneId",
546
+ "itemDimensions"
547
+ ]);
548
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
549
+ let callInitComponent = false;
550
+ for (const condition of conditionsToCheck) {
551
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition] !== void 0;
552
+ }
553
+ if (callInitComponent && !this.isInitCalled) {
554
+ this.initComponent();
555
+ this.isInitCalled = true;
556
+ return;
557
+ }
558
+ if (this.getIsViewMode()) {
559
+ if (this.dashboardReference) {
560
+ for (const [propertyName] of changedProperties.entries()) {
561
+ if (propertyName === "appSever") {
562
+ SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
563
+ this.isLibraryLoaded = true;
564
+ await this.updateComplete;
565
+ this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
566
+ this.setAllAttributes();
567
+ });
568
+ } else if (this.attributesMap[propertyName]) {
569
+ const mappedAttributeName = this.attributesMap[propertyName] ?? propertyName;
570
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() || this[propertyName];
571
+ this.dashboardReference.setAttribute(mappedAttributeName, attributeValue);
572
+ }
573
+ }
574
+ }
575
+ } else {
576
+ for (const [propertyName] of changedProperties.entries()) {
577
+ if (triggerProperties.has(propertyName) && propertyName !== "editMode") {
578
+ this.iframeLoaded = false;
579
+ if (this._loadTimeoutHandle) {
580
+ clearTimeout(this._loadTimeoutHandle);
581
+ }
582
+ this._loadTimeoutHandle = setTimeout(() => {
583
+ console.warn(
584
+ "Failed to load dashboard, appServer is likely down or unreachable."
585
+ );
586
+ }, 15 * 1e3);
587
+ this.params = this._setOptions();
588
+ SharedLib2._extendAndValidate(this);
589
+ this._setupLoader();
590
+ this._loaderStyles();
591
+ this._iframeUrl = SharedLib2.createIframeUrl(this);
592
+ if (this.iframe) {
593
+ this._updateIframeUrl();
594
+ }
595
+ this.iframeStyle = SharedLib2.calculateIframeStyles(this);
596
+ } else if (triggerProperties.has(propertyName) && propertyName === "editMode") {
597
+ if (this.iframeLoaded) {
598
+ this.setEditMode(this.editMode);
599
+ }
600
+ this.params = this._setOptions();
601
+ }
602
+ }
603
+ }
604
+ }
605
+ // Set params
606
+ _setOptions() {
607
+ const defaultParameters = {
608
+ dashboardId: this.dashboardId,
609
+ dashboardSlug: this.dashboardSlug
610
+ };
611
+ if (this.itemId) {
612
+ defaultParameters.itemId = this.itemId;
613
+ this._itemEmbedding = true;
614
+ } else {
615
+ this._itemEmbedding = false;
616
+ }
617
+ if (this.language) {
618
+ defaultParameters.language = this.language;
619
+ }
620
+ if (this.qeVersion) {
621
+ defaultParameters.qeVersion = this.qeVersion;
622
+ }
623
+ if (this.screenMode) {
624
+ defaultParameters.screenMode = this.screenMode;
625
+ }
626
+ defaultParameters.switchScreenModeOnResize = this.switchScreenModeOnResize;
627
+ if (this.authToken) {
628
+ defaultParameters.token = this.authToken;
629
+ }
630
+ if (this.authKey) {
631
+ defaultParameters.key = this.authKey;
632
+ }
633
+ if (this.editMode) {
634
+ defaultParameters.editMode = this.editMode;
635
+ }
636
+ if (this.theme) {
637
+ defaultParameters.theme = this.theme;
638
+ }
639
+ if (this.mainColor) {
640
+ defaultParameters.mainColor = this.mainColor;
641
+ }
642
+ if (this.accentColor) {
643
+ defaultParameters.accentColor = this.accentColor;
644
+ }
645
+ if (this.loaderBackground) {
646
+ defaultParameters.loaderBackground = this.loaderBackground;
647
+ }
648
+ if (this.loaderFontColor) {
649
+ defaultParameters.loaderFontColor = this.loaderFontColor;
650
+ }
651
+ if (this.loaderSpinnerColor) {
652
+ defaultParameters.loaderSpinnerColor = this.loaderSpinnerColor;
653
+ }
654
+ if (this.loaderSpinnerBackground) {
655
+ defaultParameters.loaderSpinnerBackground = this.loaderSpinnerBackground;
656
+ }
657
+ if (this.timezoneId) {
658
+ defaultParameters.timezoneId = this.timezoneId;
659
+ }
660
+ if (this.itemDimensions) {
661
+ defaultParameters.itemDimensions = this.itemDimensions;
662
+ }
663
+ if (this.appServer) {
664
+ this.appServer = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.appServer) : SharedLib2.addTrailingSlash(this.appServer);
665
+ defaultParameters.appServer = this.appServer;
666
+ } else {
667
+ this.appServer = SharedLib2.addTrailingSlash(
668
+ SharedLib2.DEFAULT_PARAMETERS.appServer
669
+ );
670
+ defaultParameters.appServer = this.appServer;
671
+ }
672
+ if (this.apiHost) {
673
+ this.apiHost = this.getIsViewMode() ? SharedLib2.removeTrailingSlash(this.apiHost) : SharedLib2.addTrailingSlash(this.apiHost);
674
+ defaultParameters.apiHost = this.apiHost;
675
+ } else {
676
+ this.apiHost = this.appServer.includes("luzmo.com") ? this.appServer.replace("app", "api") : this.appServer;
677
+ defaultParameters.apiHost = this.apiHost;
678
+ }
679
+ this.currentAuthKey = this.authKey;
680
+ this.currentAuthToken = this.authToken;
681
+ return defaultParameters;
682
+ }
683
+ _updateIframeUrl() {
684
+ SharedLib2.updateIframeUrl(this.iframe, this._iframeUrl);
685
+ }
686
+ // Setup loader / browser error
687
+ _setupLoader() {
688
+ const data = SharedLib2.getLoader(this);
689
+ this._loaderMsg = data.loadingMsg;
690
+ if (data.errorMsg) {
691
+ this.browserError = true;
692
+ this.browserErrorMsg = data.errorMsg;
693
+ this._displayError();
694
+ }
695
+ }
696
+ _displayError() {
697
+ if (this.dashboardError) {
698
+ this._loaderStyles();
699
+ this.iframeStyle.opacity = 1;
700
+ }
701
+ if (this.browserError) {
702
+ this._containerStyle.display = "none";
703
+ }
704
+ }
705
+ _calculateDimAfterDashboardLoaded() {
706
+ this.dashboardError = false;
707
+ this._loaderStyles();
708
+ SharedLib2._setCalculatedDimensions(this);
709
+ }
710
+ // Set loader styles
711
+ _loaderStyles() {
712
+ this._containerStyle = SharedLib2.containerStyles(this);
713
+ this._loaderStyle = SharedLib2.loaderStyles(this);
714
+ this._loadingCircleStyle = SharedLib2.plStyles(this);
715
+ this._containerLoaderStyle = SharedLib2.containerLoaderStyles(this);
716
+ this._lcStyle = SharedLib2.lcStyles(this);
717
+ }
718
+ static get styles() {
719
+ return [dashboardStyles];
720
+ }
721
+ render() {
722
+ let toBeRenderedHTML;
723
+ const loader = import_lit2.html`
724
+ <div
725
+ class="luzmo-container-loader"
726
+ id="luzmo-container-loader-${this._containerId}"
727
+ style=${(0, import_style_map.styleMap)(
728
+ this._containerLoaderStyle
729
+ )}
730
+ >
731
+ <div
732
+ class="luzmo-loader"
733
+ id="luzmo-loader-${this._containerId}"
734
+ style=${(0, import_style_map.styleMap)(this._loaderStyle)}
735
+ >
736
+ <div
737
+ class="luzmo-lc"
738
+ style=${(0, import_style_map.styleMap)(this._lcStyle)}
739
+ >
740
+ <div
741
+ class="luzmo-loading-circle"
742
+ style=${(0, import_style_map.styleMap)(
743
+ this._loadingCircleStyle
744
+ )}
745
+ ></div>
746
+ ${this._itemEmbedding ? "" : import_lit2.html`
747
+ <div
748
+ class="luzmo-loading-message"
749
+ style=${(0, import_style_map.styleMap)({ color: this.loaderFontColor })}
750
+ >
751
+ ${this._loaderMsg}
752
+ </div>
753
+ `}
754
+ </div>
755
+ </div>
756
+ </div>
757
+ `;
758
+ if (this.getIsViewMode()) {
759
+ toBeRenderedHTML = this.isLibraryLoaded ? import_lit2.html`
760
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
761
+ <dashboard-component dashboard-id="${this.params.dashboardId}" app-server="${this.params.appServer}"
762
+ api-host="${this.params.apiHost}"></dashboard-component>
763
+ ` : import_lit2.html`
764
+ <div id="luzmo-error-${this._containerId}">
765
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
766
+ </div>
767
+ `}
768
+ ` : import_lit2.html`${loader}`;
769
+ } else {
770
+ toBeRenderedHTML = import_lit2.html`
771
+ ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
772
+ ${loader}
773
+ <iframe
774
+ class="luzmo-embed-dashboard ${this.getIsViewMode() ? "" : `luzmo-embed-dashboard-ede`}"
775
+ id="${this._iframeId}"
776
+ name="${this._iframeId}"
777
+ style=${(0, import_style_map.styleMap)(this.iframeStyle)}
778
+ src="${this._iframeUrl}"
779
+ frameborder="0"
780
+ ></iframe>
781
+ ` : import_lit2.html`<!-- the dashboard will inititialize when you provide a dashboardSlug or a dashboardId -->`}
782
+ ${this.browserError ? import_lit2.html`
783
+ <div id="luzmo-error-${this._containerId}">
784
+ <h3 class="luzmo-error">${this.browserErrorMsg}</h3>
785
+ </div>
786
+ ` : ""}
787
+ `;
788
+ }
789
+ return import_lit2.html`
790
+ <div class="${import_shared_embed.luzmoEmbedContainerClass} ${this.getIsViewMode() ? "" : `${import_shared_embed.luzmoEmbedContainerClass}-ede`}">
791
+ <div
792
+ class="dashboard-container"
793
+ style=${(0, import_style_map.styleMap)(Object.assign({}, this._containerStyle, {
794
+ width: this.iframeStyle.width ?? "100%",
795
+ height: this.iframeStyle.height ?? "100%"
796
+ }))}
797
+ >
798
+ ${toBeRenderedHTML}
799
+ </div>
800
+ </div>
801
+
802
+ `;
803
+ }
804
+ getDashboards() {
805
+ return new Promise(
806
+ (resolve) => resolve(luzmo_service_default._components)
807
+ );
808
+ }
809
+ // Public methods
810
+ getData(itemId) {
811
+ if (this.getIsViewMode() && this.dashboardReference) {
812
+ return this.dashboardReference.getData(itemId);
813
+ }
814
+ if (!this.getIsViewMode()) {
815
+ return SharedLib2.getData(this, this.iframe, itemId);
816
+ }
817
+ return Promise.reject();
818
+ }
819
+ getFilters() {
820
+ if (this.getIsViewMode() && this.dashboardReference) {
821
+ return this.dashboardReference.getFilters();
822
+ }
823
+ if (!this.getIsViewMode()) {
824
+ return SharedLib2.getFilters(this, this.iframe);
825
+ }
826
+ return Promise.reject();
827
+ }
828
+ setSelectedData(itemId, filters) {
829
+ if (this.getIsViewMode() && this.dashboardReference) {
830
+ return this.dashboardReference.setSelectedData(itemId, filters);
831
+ }
832
+ if (!this.getIsViewMode()) {
833
+ return SharedLib2.setSelectedData(this, this.iframe, itemId, filters);
834
+ }
835
+ return Promise.reject();
836
+ }
837
+ setAuthorization(key, token) {
838
+ this.currentAuthKey = key;
839
+ this.currentAuthToken = token;
840
+ if (this.getIsViewMode() && this.dashboardReference) {
841
+ return this.dashboardReference.setAuthorization(key, token);
842
+ }
843
+ if (!this.getIsViewMode()) {
844
+ return SharedLib2.setAuthorization(this, this.iframe, key, token);
845
+ }
846
+ return Promise.reject();
847
+ }
848
+ refreshData(itemId) {
849
+ if (this.getIsViewMode() && this.dashboardReference) {
850
+ return this.dashboardReference.refreshData(itemId);
851
+ }
852
+ if (!this.getIsViewMode()) {
853
+ return itemId ? SharedLib2.refreshData(this, this.iframe, itemId) : SharedLib2.refreshData(this, this.iframe);
854
+ }
855
+ return Promise.reject();
856
+ }
857
+ reloadDashboard() {
858
+ if (this.getIsViewMode() && this.dashboardReference) {
859
+ return this.dashboardReference.reloadDashboard();
860
+ }
861
+ if (!this.getIsViewMode()) {
862
+ return SharedLib2.reloadDashboard(this, this.iframe);
863
+ }
864
+ return Promise.reject();
865
+ }
866
+ exportDashboard(format) {
867
+ if (this.getIsViewMode() && this.dashboardReference) {
868
+ return this.dashboardReference.exportDashboard(format);
869
+ }
870
+ if (!this.getIsViewMode()) {
871
+ return format ? SharedLib2.exportDashboard(this, this.iframe, format) : SharedLib2.exportDashboard(this, this.iframe);
872
+ }
873
+ return Promise.reject();
874
+ }
875
+ getAccessibleDashboards() {
876
+ return SharedLib2.getAccessibleDashboards(this);
877
+ }
878
+ addFilters(itemId, filters) {
879
+ return this.dashboardReference.addFilters(itemId, filters);
880
+ }
881
+ setEditMode(editMode) {
882
+ if (this.dashboardReference && editMode === "view") {
883
+ this.editMode = "view";
884
+ this.params.editMode = "view";
885
+ this.initComponent();
886
+ return Promise.resolve({
887
+ type: "setEditMode",
888
+ editMode
889
+ });
890
+ }
891
+ if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
892
+ this.editMode = editMode;
893
+ this.params.editMode = editMode;
894
+ this.initComponent();
895
+ return Promise.resolve({
896
+ type: "setEditMode",
897
+ editMode
898
+ });
899
+ }
900
+ if (this.getIsViewMode() && this.dashboardReference) {
901
+ return this.dashboardReference.setEditMode(editMode);
902
+ }
903
+ if (!this.getIsViewMode()) {
904
+ return SharedLib2.setEditMode(this, this.iframe, editMode);
905
+ }
906
+ return Promise.reject();
907
+ }
908
+ setPreview(preview) {
909
+ if (this.getIsViewMode() && this.dashboardReference) {
910
+ return this.dashboardReference.setPreview(preview);
911
+ }
912
+ return SharedLib2.setPreview(this, this.iframe, preview);
913
+ }
914
+ getIsViewMode() {
915
+ return this.experimental && this.params.editMode === "view" || this.params.editMode === void 0;
916
+ }
917
+ };
918
+ __decorateClass([
919
+ (0, import_decorators.query)(".dashboard-container")
920
+ ], LuzmoDashboard.prototype, "container", 2);
921
+ __decorateClass([
922
+ (0, import_decorators.query)(`.${import_shared_embed.luzmoEmbedContainerClass}`)
923
+ ], LuzmoDashboard.prototype, "luzmoEmbedContainer", 2);
924
+ __decorateClass([
925
+ (0, import_decorators.query)("iframe")
926
+ ], LuzmoDashboard.prototype, "iframe", 2);
927
+ __decorateClass([
928
+ (0, import_decorators.property)()
929
+ ], LuzmoDashboard.prototype, "dashboardId", 2);
930
+ __decorateClass([
931
+ (0, import_decorators.property)()
932
+ ], LuzmoDashboard.prototype, "dashboardSlug", 2);
933
+ __decorateClass([
934
+ (0, import_decorators.property)()
935
+ ], LuzmoDashboard.prototype, "itemId", 2);
936
+ __decorateClass([
937
+ (0, import_decorators.property)()
938
+ ], LuzmoDashboard.prototype, "language", 2);
939
+ __decorateClass([
940
+ (0, import_decorators.property)()
941
+ ], LuzmoDashboard.prototype, "qeVersion", 2);
942
+ __decorateClass([
943
+ (0, import_decorators.property)()
944
+ ], LuzmoDashboard.prototype, "screenMode", 2);
945
+ __decorateClass([
946
+ (0, import_decorators.property)({
947
+ converter: {
948
+ fromAttribute: (value) => value === "true",
949
+ toAttribute: String
950
+ }
951
+ })
952
+ ], LuzmoDashboard.prototype, "switchScreenModeOnResize", 2);
953
+ __decorateClass([
954
+ (0, import_decorators.property)()
955
+ ], LuzmoDashboard.prototype, "editMode", 2);
956
+ __decorateClass([
957
+ (0, import_decorators.property)()
958
+ ], LuzmoDashboard.prototype, "theme", 2);
959
+ __decorateClass([
960
+ (0, import_decorators.property)()
961
+ ], LuzmoDashboard.prototype, "mainColor", 2);
962
+ __decorateClass([
963
+ (0, import_decorators.property)()
964
+ ], LuzmoDashboard.prototype, "accentColor", 2);
965
+ __decorateClass([
966
+ (0, import_decorators.property)()
967
+ ], LuzmoDashboard.prototype, "authToken", 2);
968
+ __decorateClass([
969
+ (0, import_decorators.property)()
970
+ ], LuzmoDashboard.prototype, "authKey", 2);
971
+ __decorateClass([
972
+ (0, import_decorators.property)()
973
+ ], LuzmoDashboard.prototype, "loaderBackground", 2);
974
+ __decorateClass([
975
+ (0, import_decorators.property)()
976
+ ], LuzmoDashboard.prototype, "loaderFontColor", 2);
977
+ __decorateClass([
978
+ (0, import_decorators.property)()
979
+ ], LuzmoDashboard.prototype, "loaderSpinnerColor", 2);
980
+ __decorateClass([
981
+ (0, import_decorators.property)()
982
+ ], LuzmoDashboard.prototype, "loaderSpinnerBackground", 2);
983
+ __decorateClass([
984
+ (0, import_decorators.property)()
985
+ ], LuzmoDashboard.prototype, "appServer", 2);
986
+ __decorateClass([
987
+ (0, import_decorators.property)()
988
+ ], LuzmoDashboard.prototype, "timezoneId", 2);
989
+ __decorateClass([
990
+ (0, import_decorators.property)()
991
+ ], LuzmoDashboard.prototype, "apiHost", 2);
992
+ __decorateClass([
993
+ (0, import_decorators.property)({ type: Object })
994
+ ], LuzmoDashboard.prototype, "itemDimensions", 2);
995
+ __decorateClass([
996
+ (0, import_decorators.property)({
997
+ converter: {
998
+ fromAttribute: (value) => value === "true",
999
+ toAttribute: String
1000
+ }
1001
+ })
1002
+ ], LuzmoDashboard.prototype, "experimental", 2);
1003
+ __decorateClass([
1004
+ (0, import_decorators.property)({ attribute: false })
1005
+ ], LuzmoDashboard.prototype, "_containerId", 2);
1006
+ __decorateClass([
1007
+ (0, import_decorators.property)({ attribute: false })
1008
+ ], LuzmoDashboard.prototype, "_iframeId", 2);
1009
+ __decorateClass([
1010
+ (0, import_decorators.property)({ attribute: false })
1011
+ ], LuzmoDashboard.prototype, "params", 2);
1012
+ __decorateClass([
1013
+ (0, import_decorators.property)({ attribute: false })
1014
+ ], LuzmoDashboard.prototype, "_iframeUrl", 2);
1015
+ __decorateClass([
1016
+ (0, import_decorators.property)({ attribute: false })
1017
+ ], LuzmoDashboard.prototype, "iframeLoaded", 2);
1018
+ __decorateClass([
1019
+ (0, import_decorators.property)({ attribute: false })
1020
+ ], LuzmoDashboard.prototype, "promises", 2);
1021
+ __decorateClass([
1022
+ (0, import_decorators.property)({ attribute: false })
1023
+ ], LuzmoDashboard.prototype, "iframeStyle", 2);
1024
+ __decorateClass([
1025
+ (0, import_decorators.property)({ attribute: false })
1026
+ ], LuzmoDashboard.prototype, "_containerStyle", 2);
1027
+ __decorateClass([
1028
+ (0, import_decorators.property)({ attribute: false })
1029
+ ], LuzmoDashboard.prototype, "_loaderStyle", 2);
1030
+ __decorateClass([
1031
+ (0, import_decorators.property)({ attribute: false })
1032
+ ], LuzmoDashboard.prototype, "_lcStyle", 2);
1033
+ __decorateClass([
1034
+ (0, import_decorators.property)({ attribute: false })
1035
+ ], LuzmoDashboard.prototype, "_loadingCircleStyle", 2);
1036
+ __decorateClass([
1037
+ (0, import_decorators.property)({ attribute: false })
1038
+ ], LuzmoDashboard.prototype, "_containerLoaderStyle", 2);
1039
+ __decorateClass([
1040
+ (0, import_decorators.property)({ attribute: false })
1041
+ ], LuzmoDashboard.prototype, "_loaderMsg", 2);
1042
+ __decorateClass([
1043
+ (0, import_decorators.property)({ attribute: false })
1044
+ ], LuzmoDashboard.prototype, "containerWidth", 2);
1045
+ __decorateClass([
1046
+ (0, import_decorators.property)({ attribute: false })
1047
+ ], LuzmoDashboard.prototype, "dimensions", 2);
1048
+ __decorateClass([
1049
+ (0, import_decorators.property)({ attribute: false })
1050
+ ], LuzmoDashboard.prototype, "currentScreenMode", 2);
1051
+ __decorateClass([
1052
+ (0, import_decorators.property)({ attribute: false })
1053
+ ], LuzmoDashboard.prototype, "_itemEmbedding", 2);
1054
+ __decorateClass([
1055
+ (0, import_decorators.property)({ attribute: false })
1056
+ ], LuzmoDashboard.prototype, "browserError", 2);
1057
+ __decorateClass([
1058
+ (0, import_decorators.property)({ attribute: false })
1059
+ ], LuzmoDashboard.prototype, "browserErrorMsg", 2);
1060
+ __decorateClass([
1061
+ (0, import_decorators.property)({ attribute: false })
1062
+ ], LuzmoDashboard.prototype, "dashboardError", 2);
1063
+ __decorateClass([
1064
+ (0, import_decorators.property)({ attribute: false })
1065
+ ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1066
+ __decorateClass([
1067
+ (0, import_decorators.property)()
1068
+ ], LuzmoDashboard.prototype, "libVersion", 2);
1069
+ __decorateClass([
1070
+ (0, import_decorators.state)()
1071
+ ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
1072
+ __decorateClass([
1073
+ (0, import_decorators.state)()
1074
+ ], LuzmoDashboard.prototype, "dashboardReference", 2);
1075
+ __decorateClass([
1076
+ (0, import_decorators.state)()
1077
+ ], LuzmoDashboard.prototype, "currentAuthKey", 2);
1078
+ __decorateClass([
1079
+ (0, import_decorators.state)()
1080
+ ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1081
+ __decorateClass([
1082
+ (0, import_decorators.state)()
1083
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
1084
+
1085
+ // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
1086
+ var LuzmoEmbedDashboard = class extends LuzmoDashboard {
1087
+ };
1088
+ if (!customElements.get("luzmo-embed-dashboard")) {
1089
+ customElements.define("luzmo-embed-dashboard", LuzmoEmbedDashboard);
1090
+ }
1091
+
1092
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1093
+ var import_decorators2 = require("lit/decorators.js");
1094
+ var import_lit3 = require("lit");
1095
+ var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
1096
+ var dashboardContentsVersion = "0.1.92";
1097
+ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1098
+ constructor() {
1099
+ super(...arguments);
1100
+ this.appServer = "https://app.luzmo.com";
1101
+ this.apiHost = "https://api.luzmo.com";
1102
+ this.slots = [];
1103
+ this.version = version + "-wc-luzmo";
1104
+ this.dashboardContentsVersion = dashboardContentsVersion;
1105
+ this.libVersion = version + "-wc-luzmo";
1106
+ this.postInitCallQueue = [];
1107
+ }
1108
+ static {
1109
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1110
+ this.styles = import_lit3.css`
1111
+ :host {
1112
+ display: block;
1113
+ width: 100%;
1114
+ height: 100%;
1115
+ }
1116
+
1117
+ luzmo-embed-viz-item {
1118
+ width: 100%;
1119
+ height: 1000%;
1120
+ display: block;
1121
+ }
1122
+ `;
1123
+ }
1124
+ createRenderRoot() {
1125
+ if (!this.style.display) {
1126
+ this.style.display = "block";
1127
+ }
1128
+ if (!this.style.height) {
1129
+ this.style.height = "100%";
1130
+ }
1131
+ if (!this.style.width) {
1132
+ this.style.width = "100%";
1133
+ }
1134
+ return this;
1135
+ }
1136
+ canInitializeVizItem() {
1137
+ return !!(this.type || this.dashboardId && this.itemId);
1138
+ }
1139
+ getFilters() {
1140
+ return this.chartElement.getFilters();
1141
+ }
1142
+ export() {
1143
+ return this.chartElement.export();
1144
+ }
1145
+ getData() {
1146
+ return this.chartElement.getData();
1147
+ }
1148
+ refreshData() {
1149
+ return this.chartElement.refreshData();
1150
+ }
1151
+ setSelectedData(selectedDataInput) {
1152
+ return this.chartElement.setSelectedData(void 0, selectedDataInput);
1153
+ }
1154
+ setAuthorization(key, token) {
1155
+ return this.chartElement.setAuthorization(key, token);
1156
+ }
1157
+ attributeChangedCallback(name, _old, value) {
1158
+ super.attributeChangedCallback(name, _old, value);
1159
+ if (name === "selecteddata") {
1160
+ if (this.chartElement) {
1161
+ this.setSelectedData(JSON.parse(value ?? "{}"));
1162
+ } else {
1163
+ this.postInitCallQueue.push([this.setSelectedData, [JSON.parse(value ?? "{}")]]);
1164
+ }
1165
+ }
1166
+ }
1167
+ async firstUpdated(_changedProperties) {
1168
+ super.firstUpdated(_changedProperties);
1169
+ if (this.canInitializeVizItem()) {
1170
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1171
+ this.createAndAppendElement();
1172
+ }
1173
+ }
1174
+ createAndAppendElement() {
1175
+ if (!this.chartElement) {
1176
+ this.chartElement = document.createElement("chart-component");
1177
+ this.chartElement.setAttribute("embedding-mode", "chart");
1178
+ this.chartElement.style.height = "100%";
1179
+ this.chartElement.style.width = "100%";
1180
+ this.chartElement.style.display = "block";
1181
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1182
+ this.chartElement.addEventListener("rendered", (payload) => {
1183
+ if (this.postInitCallQueue?.length > 0) {
1184
+ for (const functionToCall of this.postInitCallQueue) {
1185
+ functionToCall[0].bind(this)(...functionToCall[1]);
1186
+ }
1187
+ } else {
1188
+ if (this.selectedData) {
1189
+ this.setSelectedData(this.selectedData);
1190
+ }
1191
+ }
1192
+ this.dispatchEvent(new CustomEvent("rendered", payload));
1193
+ });
1194
+ this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1195
+ this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1196
+ this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1197
+ this.updateVizItemProperties();
1198
+ this.renderRoot.append(this.chartElement);
1199
+ }
1200
+ }
1201
+ updateVizItemProperties() {
1202
+ if (this.chartElement) {
1203
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1204
+ const value = this[key];
1205
+ if (value) {
1206
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1207
+ this.chartElement.setAttribute(
1208
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1209
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1210
+ );
1211
+ }
1212
+ }
1213
+ }
1214
+ }
1215
+ async updated(changedProperties) {
1216
+ if (this.chartElement) {
1217
+ for (const [propertyName] of changedProperties.entries()) {
1218
+ const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1219
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1220
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1221
+ }
1222
+ } else {
1223
+ if (this.canInitializeVizItem()) {
1224
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1225
+ this.createAndAppendElement();
1226
+ }
1227
+ }
1228
+ }
1229
+ render() {
1230
+ return import_lit3.html` `;
1231
+ }
1232
+ };
1233
+ __decorateClass([
1234
+ (0, import_decorators2.property)()
1235
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
1236
+ __decorateClass([
1237
+ (0, import_decorators2.property)()
1238
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1239
+ __decorateClass([
1240
+ (0, import_decorators2.property)({ type: Array })
1241
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
1242
+ __decorateClass([
1243
+ (0, import_decorators2.property)({ type: Object })
1244
+ ], LuzmoBaseVizItem.prototype, "options", 2);
1245
+ __decorateClass([
1246
+ (0, import_decorators2.property)()
1247
+ ], LuzmoBaseVizItem.prototype, "type", 2);
1248
+ __decorateClass([
1249
+ (0, import_decorators2.property)()
1250
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
1251
+ __decorateClass([
1252
+ (0, import_decorators2.property)()
1253
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
1254
+ __decorateClass([
1255
+ (0, import_decorators2.property)()
1256
+ ], LuzmoBaseVizItem.prototype, "version", 2);
1257
+ __decorateClass([
1258
+ (0, import_decorators2.property)()
1259
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
1260
+ __decorateClass([
1261
+ (0, import_decorators2.property)({
1262
+ converter: (value) => {
1263
+ try {
1264
+ return JSON.parse(value);
1265
+ } catch {
1266
+ return value;
1267
+ }
1268
+ }
1269
+ })
1270
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1271
+ __decorateClass([
1272
+ (0, import_decorators2.property)({ type: Array })
1273
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
1274
+ __decorateClass([
1275
+ (0, import_decorators2.property)()
1276
+ ], LuzmoBaseVizItem.prototype, "dashboardId", 2);
1277
+ __decorateClass([
1278
+ (0, import_decorators2.property)()
1279
+ ], LuzmoBaseVizItem.prototype, "itemId", 2);
1280
+ __decorateClass([
1281
+ (0, import_decorators2.property)({ type: Object })
1282
+ ], LuzmoBaseVizItem.prototype, "selectedData", 2);
1283
+ __decorateClass([
1284
+ (0, import_decorators2.property)()
1285
+ ], LuzmoBaseVizItem.prototype, "dashboardContentsVersion", 2);
1286
+ __decorateClass([
1287
+ (0, import_decorators2.property)()
1288
+ ], LuzmoBaseVizItem.prototype, "libVersion", 2);
1289
+
1290
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
1291
+ var LuzmoEmbedVizItem = class extends LuzmoBaseVizItem {
1292
+ };
1293
+ if (!customElements.get("luzmo-embed-viz-item")) {
1294
+ customElements.define("luzmo-embed-viz-item", LuzmoEmbedVizItem);
1295
+ }
1296
+
1297
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-chat.ts
1298
+ var import_decorators3 = require("lit/decorators.js");
1299
+ var import_lit4 = require("lit");
1300
+ var SharedLib4 = __toESM(require("@luzmo/shared-embed"), 1);
1301
+ var inputMap = {
1302
+ aiEndpoint: "ai-endpoint",
1303
+ appServer: "app-server",
1304
+ apiHost: "api-host",
1305
+ options: "options",
1306
+ initialSuggestionsDatasetId: "initialSuggestionsDatasetId",
1307
+ authKey: "auth-key",
1308
+ authToken: "auth-token",
1309
+ version: "version",
1310
+ libVersion: "lib-version",
1311
+ aydHost: "ayd-host"
1312
+ };
1313
+ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
1314
+ constructor() {
1315
+ super(...arguments);
1316
+ this.appServer = "https://app.luzmo.com";
1317
+ this.apiHost = "https://api.luzmo.com";
1318
+ this.version = version + "-wc-luzmo";
1319
+ this.libVersion = version + "-wc-luzmo";
1320
+ this.remoteEntryServer = "http://localhost:4202/";
1321
+ this.aydHost = "https://ayd.luzmo.com/";
1322
+ }
1323
+ static {
1324
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1325
+ this.styles = import_lit4.css`
1326
+ :host {
1327
+ display: block;
1328
+ width: 100%;
1329
+ height: 100%;
1330
+ }
1331
+ `;
1332
+ }
1333
+ createRenderRoot() {
1334
+ return this;
1335
+ }
1336
+ async firstUpdated(_changedProperties) {
1337
+ super.firstUpdated(_changedProperties);
1338
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1339
+ this.createAndAppendElement();
1340
+ }
1341
+ createAndAppendElement() {
1342
+ if (!this.chartElement) {
1343
+ this.chartElement = document.createElement("luzmo-iq-chat-component");
1344
+ this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1345
+ this.updateVizItemProperties();
1346
+ this.renderRoot.append(this.chartElement);
1347
+ }
1348
+ }
1349
+ updateVizItemProperties() {
1350
+ if (this.chartElement) {
1351
+ for (const key in inputMap) {
1352
+ const value = this[key];
1353
+ if (value) {
1354
+ const attributeValue = ["appServer", "apiHost", "aydHost"].includes(key) ? SharedLib4.removeTrailingSlash(value) : value;
1355
+ this.chartElement.setAttribute(
1356
+ inputMap[key],
1357
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1358
+ );
1359
+ }
1360
+ }
1361
+ }
1362
+ }
1363
+ async updated(changedProperties) {
1364
+ if (this.chartElement) {
1365
+ for (const [propertyName] of changedProperties.entries()) {
1366
+ const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1367
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1368
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1369
+ }
1370
+ } else {
1371
+ await SharedLib4.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1372
+ this.createAndAppendElement();
1373
+ }
1374
+ }
1375
+ render() {
1376
+ return import_lit4.html``;
1377
+ }
1378
+ connectedCallback() {
1379
+ super.connectedCallback();
1380
+ const embedChat = document.querySelector("luzmo-iq-embed-chat");
1381
+ if (!embedChat) {
1382
+ return;
1383
+ }
1384
+ const observer = new MutationObserver(() => {
1385
+ const customChatWidgetContentSlot = embedChat.querySelector('*[slot="custom-chat-widget-content"]');
1386
+ if (!customChatWidgetContentSlot) {
1387
+ return;
1388
+ }
1389
+ const chatElement = embedChat.querySelector("luzmo-iq-chat-component");
1390
+ if (chatElement) {
1391
+ chatElement.append(customChatWidgetContentSlot);
1392
+ observer.disconnect();
1393
+ }
1394
+ });
1395
+ observer.observe(embedChat, { childList: true, subtree: true });
1396
+ }
1397
+ };
1398
+ __decorateClass([
1399
+ (0, import_decorators3.property)()
1400
+ ], LuzmoIQEmbedChatComponent.prototype, "appServer", 2);
1401
+ __decorateClass([
1402
+ (0, import_decorators3.property)()
1403
+ ], LuzmoIQEmbedChatComponent.prototype, "apiHost", 2);
1404
+ __decorateClass([
1405
+ (0, import_decorators3.property)({ type: Object })
1406
+ ], LuzmoIQEmbedChatComponent.prototype, "options", 2);
1407
+ __decorateClass([
1408
+ (0, import_decorators3.property)({ type: String })
1409
+ ], LuzmoIQEmbedChatComponent.prototype, "initialSuggestionsDatasetId", 2);
1410
+ __decorateClass([
1411
+ (0, import_decorators3.property)()
1412
+ ], LuzmoIQEmbedChatComponent.prototype, "aiEndpoint", 2);
1413
+ __decorateClass([
1414
+ (0, import_decorators3.property)()
1415
+ ], LuzmoIQEmbedChatComponent.prototype, "authKey", 2);
1416
+ __decorateClass([
1417
+ (0, import_decorators3.property)()
1418
+ ], LuzmoIQEmbedChatComponent.prototype, "authToken", 2);
1419
+ __decorateClass([
1420
+ (0, import_decorators3.property)()
1421
+ ], LuzmoIQEmbedChatComponent.prototype, "version", 2);
1422
+ __decorateClass([
1423
+ (0, import_decorators3.property)()
1424
+ ], LuzmoIQEmbedChatComponent.prototype, "libVersion", 2);
1425
+ __decorateClass([
1426
+ (0, import_decorators3.property)()
1427
+ ], LuzmoIQEmbedChatComponent.prototype, "remoteEntryServer", 2);
1428
+ __decorateClass([
1429
+ (0, import_decorators3.property)()
1430
+ ], LuzmoIQEmbedChatComponent.prototype, "aydHost", 2);
1431
+ if (!customElements.get("luzmo-iq-embed-chat")) {
1432
+ customElements.define("luzmo-iq-embed-chat", LuzmoIQEmbedChatComponent);
1433
+ }
1434
+
1435
+ // libs/embed-libs/embed/src/lib/luzmo-iq-components/luzmo-iq-answer.ts
1436
+ var import_decorators4 = require("lit/decorators.js");
1437
+ var import_lit5 = require("lit");
1438
+ var SharedLib5 = __toESM(require("@luzmo/shared-embed"), 1);
1439
+ var inputMap2 = {
1440
+ aiEndPoint: "ai-end-point",
1441
+ appServer: "app-server",
1442
+ apiHost: "api-host",
1443
+ options: "options",
1444
+ authKey: "auth-key",
1445
+ authToken: "auth-token",
1446
+ version: "version",
1447
+ libVersion: "lib-version",
1448
+ messages: "messages"
1449
+ };
1450
+ var LuzmoIQEmbedAnswerComponent = class extends import_lit5.LitElement {
1451
+ constructor() {
1452
+ super(...arguments);
1453
+ this.appServer = "https://app.luzmo.com";
1454
+ this.apiHost = "https://api.luzmo.com";
1455
+ this.version = version + "-wc-luzmo";
1456
+ this.libVersion = version + "-wc-luzmo";
1457
+ this.remoteEntryServer = "http://localhost:4202";
1458
+ }
1459
+ static {
1460
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1461
+ this.styles = import_lit5.css`
1462
+ :host {
1463
+ display: block;
1464
+ width: 100%;
1465
+ height: 100%;
1466
+ }
1467
+ `;
1468
+ }
1469
+ createRenderRoot() {
1470
+ return this;
1471
+ }
1472
+ async firstUpdated(_changedProperties) {
1473
+ super.firstUpdated(_changedProperties);
1474
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1475
+ this.createAndAppendElement();
1476
+ }
1477
+ createAndAppendElement() {
1478
+ if (!this.chartElement) {
1479
+ this.chartElement = document.createElement("luzmo-iq-answer-component");
1480
+ this.chartElement.addEventListener("addQuestion", (payload) => this.dispatchEvent(new CustomEvent("addQuestion", payload)));
1481
+ this.chartElement.addEventListener("addAnswer", (payload) => this.dispatchEvent(new CustomEvent("addAnswer", payload)));
1482
+ this.updateVizItemProperties();
1483
+ this.renderRoot.append(this.chartElement);
1484
+ }
1485
+ }
1486
+ updateVizItemProperties() {
1487
+ if (this.chartElement) {
1488
+ for (const key in inputMap2) {
1489
+ const value = this[key];
1490
+ if (value) {
1491
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib5.removeTrailingSlash(value) : value;
1492
+ this.chartElement.setAttribute(
1493
+ inputMap2[key],
1494
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1495
+ );
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1500
+ async updated(changedProperties) {
1501
+ if (this.chartElement) {
1502
+ for (const [propertyName] of changedProperties.entries()) {
1503
+ const mappedAttributeName = inputMap2[propertyName] ?? propertyName;
1504
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1505
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1506
+ }
1507
+ } else {
1508
+ await SharedLib5.loadLibrary(this.appServer.startsWith("http://localhost") ? this.remoteEntryServer : this.appServer, "Component");
1509
+ this.createAndAppendElement();
1510
+ }
1511
+ }
1512
+ render() {
1513
+ return import_lit5.html` `;
1514
+ }
1515
+ };
1516
+ __decorateClass([
1517
+ (0, import_decorators4.property)()
1518
+ ], LuzmoIQEmbedAnswerComponent.prototype, "appServer", 2);
1519
+ __decorateClass([
1520
+ (0, import_decorators4.property)()
1521
+ ], LuzmoIQEmbedAnswerComponent.prototype, "apiHost", 2);
1522
+ __decorateClass([
1523
+ (0, import_decorators4.property)({ type: Object })
1524
+ ], LuzmoIQEmbedAnswerComponent.prototype, "options", 2);
1525
+ __decorateClass([
1526
+ (0, import_decorators4.property)()
1527
+ ], LuzmoIQEmbedAnswerComponent.prototype, "aiEndPoint", 2);
1528
+ __decorateClass([
1529
+ (0, import_decorators4.property)()
1530
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authKey", 2);
1531
+ __decorateClass([
1532
+ (0, import_decorators4.property)()
1533
+ ], LuzmoIQEmbedAnswerComponent.prototype, "authToken", 2);
1534
+ __decorateClass([
1535
+ (0, import_decorators4.property)()
1536
+ ], LuzmoIQEmbedAnswerComponent.prototype, "messages", 2);
1537
+ __decorateClass([
1538
+ (0, import_decorators4.property)()
1539
+ ], LuzmoIQEmbedAnswerComponent.prototype, "version", 2);
1540
+ __decorateClass([
1541
+ (0, import_decorators4.property)()
1542
+ ], LuzmoIQEmbedAnswerComponent.prototype, "libVersion", 2);
1543
+ __decorateClass([
1544
+ (0, import_decorators4.property)()
1545
+ ], LuzmoIQEmbedAnswerComponent.prototype, "remoteEntryServer", 2);
1546
+ if (!customElements.get("luzmo-iq-embed-answer")) {
1547
+ customElements.define("luzmo-iq-embed-answer", LuzmoIQEmbedAnswerComponent);
1548
+ }
1549
+
1550
+ // libs/embed-libs/embed/src/lib/helper/json-schema-utils.ts
1551
+ var cachedSchemas = {};
1552
+ function addJSONSchemas(schemas) {
1553
+ if (schemas.some((schema) => !schema.$id)) {
1554
+ throw new Error("To add schemas they all must have an $id property.");
1555
+ }
1556
+ schemas.forEach((schema) => {
1557
+ cachedSchemas[schema.$id] = schema;
1558
+ });
1559
+ }
1560
+ function getCachedJSONSchema(schemaUrl) {
1561
+ return cachedSchemas[schemaUrl];
1562
+ }
1563
+ function getCachedJSONSchemas() {
1564
+ return cachedSchemas;
1565
+ }
1566
+ function getJSONSchemaUrl(schemaName) {
1567
+ return `https://developer.luzmo.com/assets/json-schemas/${dashboardContentsVersion}/${schemaName}.schema.json`;
1568
+ }
1569
+ async function fetchJSONSchema(schemaName) {
1570
+ const schemaUrl = getJSONSchemaUrl(schemaName);
1571
+ if (getCachedJSONSchema(schemaUrl)) {
1572
+ return getCachedJSONSchema(schemaUrl);
1573
+ }
1574
+ try {
1575
+ const response = await fetch(schemaUrl, { credentials: "omit" });
1576
+ if (!response.ok) {
1577
+ throw new Error(`Failed to fetch schema ${schemaUrl}, response status: ${response.status}`);
1578
+ }
1579
+ const schema = await response.json();
1580
+ addJSONSchemas([schema]);
1581
+ return schema;
1582
+ } catch (error) {
1583
+ console.error(error);
1584
+ }
1585
+ }
1586
+ var luzmoRefParserResolver = {
1587
+ order: 101,
1588
+ // 101 would make it run after the file resolver, but before the HTTP resolver
1589
+ canRead: (file) => {
1590
+ const isLuzmoUrl = file.url.startsWith("https://developer.luzmo.com");
1591
+ if (isLuzmoUrl) {
1592
+ return !!getCachedJSONSchema(file.url);
1593
+ }
1594
+ return false;
1595
+ },
1596
+ read: (file, callback) => {
1597
+ callback(null, getCachedJSONSchema(file.url));
1598
+ }
1599
+ };
1600
+ var luzmoRefParserOptions = {
1601
+ mutateInputSchema: false,
1602
+ resolve: {
1603
+ luzmo: luzmoRefParserResolver,
1604
+ external: true
1605
+ }
1606
+ };
1607
+ // Annotate the CommonJS export names for ESM import in node:
1608
+ 0 && (module.exports = {
1609
+ LuzmoEmbedDashboard,
1610
+ LuzmoEmbedVizItem,
1611
+ LuzmoIQEmbedAnswerComponent,
1612
+ LuzmoIQEmbedChatComponent,
1613
+ addJSONSchemas,
1614
+ fetchJSONSchema,
1615
+ getCachedJSONSchema,
1616
+ getCachedJSONSchemas,
1617
+ getJSONSchemaUrl,
1618
+ luzmoRefParserOptions,
1619
+ selectedDataUtils
1620
+ });