@luzmo/embed 6.2.1 → 6.2.2

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