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